Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON PROGRAM: using while loop Write a program that asks the user for a number n and prints the sum of the numbers 1 to
PYTHON PROGRAM: using while loop Write a program that asks the user for a number n and prints the sum of the numbers 1 to n. The program keeps asking for a number until the user enters 0.
ex:
enter an integer number (0 to end): 0 #stops here immediately
enter an integer number (0 to end): 1 1 = 1 #keeps asking for numer until user enters 0.
enter an integer number (0 to end): 5 1+2+3+4+5 = 15
enter an integer number (0 to end): 20 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20 = 210
enter an integer number (0 to end): 0
# while n!=0 perhaps?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started