Question

(Printing Series) Write a program that displays numbers for a given number, n to 1 using...

(Printing Series) Write a program that displays numbers for a given number, n to 1 using for statement.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program to display numbers for a given number n to 1 using for statement in python;

a = int(input("Enter the value of a: "))#To ask the user to enter value and to store the value
if (a<=1): #the entered value must be greater than 1
   print ("a should be greater than 1")
   exit()
print ("value of a: ",a)#to print the entered value a
for i in range(a,0,-1): #loop starts from entered value and ends upto 1
   print (i) #to print the values upto 1

In the below program the given input a value is 5

In the above program incase if the given input value a is 1 then it prints this output.

Add a comment
Know the answer?
Add Answer to:
(Printing Series) Write a program that displays numbers for a given number, n to 1 using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT