PYTHON PROGRAMMING ONLY. Please provide explanation as well. Thank you. Write a while loop that lets a user enter a number less than 10. If the number inputted exceeds 10, print an error and ask for the number again, in which a user may enter the same or a different number. When the user inputs a valid number, the number should be incremented by 5, and the result assigned to a variable named sum. This loop should continue to iterate as long as the sum totals less than 50. When sum exceeds 30, it should print "Almost there..." until it reaches or exceeds 50. Once it does, print out "your final sum is (replace with final sum)". For example, if the sum is currently 45 and the user inputs 4, the program will not enter the loop again since the new sum will be 54 and should then print "your final sum is 45".

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question
PYTHON PROGRAMMING ONLY. Please provide explanation as well. Thank you.
Write a while loop that lets a user enter a number less than 10. If the number inputted exceeds 10,
print an error and ask for the number again, in which a user may enter the same or a different
number. When the user inputs a valid number, the number should be incremented by 5, and the result
assigned to a variable named sum. This loop should continue to iterate as long as the sum totals less
than 50. When sum exceeds 30, it should print "Almost there..." until it reaches or exceeds 50. Once it
does, print out "your final sum is (replace with final sum)". For example, if the sum is currently 45 and
the user inputs 4, the program will not enter the loop again since the new sum will be 54 and should
then print "your final sum is 45".
Transcribed Image Text:PYTHON PROGRAMMING ONLY. Please provide explanation as well. Thank you. Write a while loop that lets a user enter a number less than 10. If the number inputted exceeds 10, print an error and ask for the number again, in which a user may enter the same or a different number. When the user inputs a valid number, the number should be incremented by 5, and the result assigned to a variable named sum. This loop should continue to iterate as long as the sum totals less than 50. When sum exceeds 30, it should print "Almost there..." until it reaches or exceeds 50. Once it does, print out "your final sum is (replace with final sum)". For example, if the sum is currently 45 and the user inputs 4, the program will not enter the loop again since the new sum will be 54 and should then print "your final sum is 45".
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr