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".
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
Step by step
Solved in 4 steps with 2 images