Program of the Day #3

Write a program to help a user calculate percentages. The program should take two arguments: a number and a percentage. The program prints a sentence (formatted as in the example below) giving the percentage of the number. The number and percent may be floating-point values or integers, but your program may throw an error if the user enters something that’s not a number. A sample run of the program might look like this; your output must be formatted exactly like mine to pass the tests:

>>> %Run P03_percent.py 900 50.0
50.0 percent of 900.0 is 450.0
>>> 

Other Practice Problems

  1. Write a program that prompts the user for three numbers in a row, then prints the sum of all three numbers. The program should work if the user enters decimal numbers, but can throw an error if the user enters something that isn’t a number. An example run of the program might look like this, where the numbers after each prompt are typed by the user:

    Enter the first number: 4
    Enter the second number: 2.4
    Enter the third number: 8.6
    Your numbers total 15.0
  2. Modify your program from #1 to print the full equation for the sum; for example, the last line of the example above would read

    4.0+2.4+8.6=15.0

    The catch: you have to print the equation without spaces between the numbers.