Python Program to Print the Sum and Product of All Numbers Input By User

In this example, we will write a simple program to take input from the user until he/she exits from the application and calculate the sum and product of all the numbers he/she entered. To better understand this example, make sure you have knowledge of the following tutorials:-

Python Program to Print the Sum and Product of All Numbers Input By User

The output of the above program is:-

Enter number: 5
Press q to exit / or Enter to continue:
Enter number: 7
Press q to exit / or Enter to continue:
Enter number: 3
Press q to exit / or Enter to continue: q
Sum = 15, Product = 105
Here while statement iterates indefinitely unless the user presses the q button. The sum and product are stored in two variables. The resulting display is done using the format operator. You can find more information about formatting output here, Python Input and Output.
SHARE Python Program to Print the Sum and Product of All Numbers Input By User

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Share