FOR PYTHON Write a python program that uses a while loop to

FOR PYTHON:

Write a python program that uses a while loop to display the integers from 0 to 200 in increments of 25, all on one line separated by a single space. Then use a for loop and the range operator to display the same integers in descending order. See example output.

Example Output
0 25 50 75 100 125 150 175 200
200 175 150 125 100 75 50 25 0

Solution

count = 0
i = 0
while i <= 200:
print i,
i = i + 25
count = count + 1
print \"\"
for i in range(200, -1, -25):
print i,

Output:

sh-4.3$ python main.py                                                                                                                                                                                                                                                   

0 25 50 75 100 125 150 175 200                                                                                                                                                                                                                                           

200 175 150 125 100 75 50 25 0

FOR PYTHON: Write a python program that uses a while loop to display the integers from 0 to 200 in increments of 25, all on one line separated by a single space

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site