  Hi,please I need to use Python for the following:Use for loop to do the following:1) print the numbers 0 to 9 2) print first 10 odd numbers 3) print the numbers 20 down to 10 4) print even numbers from 20 down to 10 5) print even numbers from 20 down to 10 separated by ','

Question

Hi,please I need to use Python for the following:

Use for loop to do the following:

1) print the numbers 0 to 9

2) print first 10 odd numbers

3) print the numbers 20 down to 10

4) print even numbers from 20 down to 10

5) print even numbers from 20 down to 10 separated by ','

Step 1

Program instructions:

• Use range() in for loop to print the numbers.
• Function range() has here arguments range(start, stop, step).
• Use end in print() to print the numbers separated by “,”.
Step 2

Program:

#print the numbers 0 to 9

for i in range(10):

print(i)

# print first 10 odd numbers

for i in range(1,20,2):

print(i)

# print the numbers 20 down to 10

for i in range(20,9,-1):

print(i)

# print even numbers from 20 down to 10

for i in range(20,9,-1):

if i%2==0:

print(i)

#  print even numbers from 20 down to 10 separated by ','

for i in range(20,9,-1):

if i%2==0:

print(i,end=",")

Step 3

Sample Output 1:

...

Want to see the full answer?

See Solution

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Python 