175k views
15 votes
Use a for loop to output all multiples of 10 , starting at 10 and going to and including 1000?

This is python
Pls help!!

User Weirdpanda
by
3.2k points

2 Answers

13 votes

Final answer:

To print multiples of 10 from 10 to 1000 in Python, use a for loop with the range function starting at 10, ending at 1001 (to include 1000), and increment by 10 at each step. Each iteration will print the loop variable, which will be the next multiple of 10.

Step-by-step explanation:

To output all multiples of 10 starting at 10 and ending at 1000 using a for loop in Python, you can use the following code snippet:

for i in range(10, 1001, 10):
print(i)

This code makes use of the range() function in Python. The range() function is called with three arguments: the starting value (10), the end value (1001), and the step value (10). The end value is set to 1001 because the range goes up to, but does not include the end value. This means that 1000 will be the last multiple of 10 that's printed by the loop. Each iteration prints the current value of i, which is a multiple of 10, starting at 10 and increasing by 10 on each loop until it reaches 1000.

User Fragment
by
3.3k points
6 votes

Answer:

def main():

for i in range(10,1010,10):

print(str(i))

main()

Step-by-step explanation:

def main(): # Creates main function

for i in range(10,1010,10): # is an iteration that starts at 10, ends at 1010 and skips 10 numbers per iteration

print(str(i)) # Outputs each multiple of 10

main() # Calls the main function

Hope this helps :)

User Teddy K
by
3.2k points