DEV Community

Nimal Anand
Nimal Anand

Posted on

#python1(task)

i=5
while i>=1:
print(i, end=" ")
i=i-1
output is 5 4 3 2 1
here we have used variable 1 which carries the value 5 and it runs inside the loop to print the value i,then it gets decrement by 1 and then enters into loop and print the present i .it repeats the same till i value gets value 1. we use end="" to display the value in linear manner.

i=10
while i>=1:
print(i, end=" ")
i=i-2
here in the same operation we have used decrement value by 2 and have printed the i value and have also used the same end .

i=15
while i>=1:
print(i, end=" ")
i=i-3
i=25
while i>=1:
print(i, end=" ")
i=i-5

Top comments (1)

Collapse
 
gunalan22082002 profile image
Guna Ramesh • Edited

Awesome brother your explanation is very good and grammer also well!