Unable to get wanted output using for and range functions

2024/11/8 19:47:06

For my homework assignment, I am using the for loop and the range function. I have to create a loop that prints

Hello 0
Hello 1
Hello 3
Hello 6
Hello 10

The question says that the number corresponds to the accumulated summation over the successive indexes, but I am not really sure how to implement it into my code. I was thinking it was setting the range from 0 to 10 and trying to make a formula, but nothing has come yet. Any help would be appreciated. It has to be in a for i in range function and loop for this assignment.

for i in range(0,10,2):print("Hello",i)
Answer

may be this will be suitable :

i=0
step=1
while i<=10:print("Hello", i)i=i+stepstep=step+1
https://en.xdnf.cn/q/120581.html

Related Q&A

i want to add a new field to an existing module odoo11 but i dont know why it didnt work

product_template.xmlthe view to add the customizing field to the product module<?xml version="1.0" encoding="utf-8"?><odoo><data><record id="product_temp…

How to check with more RegEx for one address in python using re.findall()

How to check with more RegEx for one address in python using re.findall()Ex: I want to apply the below regex rules # need to get addresstxt = "hello user 44 West 22nd Street, New York, NY 12345 fr…

Finding all roots of an equation in Python

I have a function that I want to find its roots. I could write a program to figure out its roots but the point is, each time that I want to find the other root I should give it an initial value manuall…

defining matrix class in python

Define a class that abstracts the matrix that satisfies the following examples of practice

Why do round() and math.ceil() give different values for negative numbers in Python 3? [duplicate]

This question already has an answer here:What is the algorithmic difference between math.ceil() and round() when trailing decimal points are >= 0.5 in Python 3?(1 answer)Closed 6 years ago.Why do r…

getting the value from text file after the colon or before the colon in python

I only need the last number 25 so i can change it to int(). I have this text file:{"members": [{"name": "John", "location": "QC", "age": 25}…

How to remove the background of an object using OpenCV (Python) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 3 years ago.Improve…

How to move zeros to the end of a list [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

My program only appends one user input to list when main is looped

This is part of my code for a guessing game. I want to count the guesses of a player, and then append their name and number of guesses to a list that is later written or appended to file. As of now, it…

How to split a python dictionary for its values on matching a key

my_dict1 = {a:1, chk:{b:2, c:3}, e:{chk:{f:5, g:6}} }I would like to loop through the dict recursively and if the key is chk, split it. Expected output:{a:1, b:2, e:{f:5}} {a:1, c:3, e:{f:5}} {a:1, b:2…