Question

In: Computer Science

Using Python write a program that does the following in order: 1. Ask user to enter...

Using Python write a program that does the following in order:

1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out “Your account is overdrawn” and the “negative amount” 7. Round all print values to 1 decimal place Round your sum output to 2 decimal places

Solutions

Expert Solution

The Solution:

The Code:

name=input("Enter your Name: ")
print("Enter 5 numbers(amounts): ")
amount1=round(float(input("1: ")),1)
amount2=round(float(input("2: ")),1)
amount3=round(float(input("3: ")),1)
amount4=round(float(input("4: ")),1)
amount5=round(float(input("5: ")),1)
sum=round(amount1+amount2+amount3+amount4+amount5,2)
if sum>0:
print("Your Account Balance is: ",sum)
elif sum==0:
print("Your Account Balance is zero")
else:
print("Your Account is Overdrawn. Your Account Balance is: ",sum)

The Screenshots:

The Code:

The Output:


Related Solutions

Using Python Write a program that does the following in order: 1.     Asks the user to enter...
Using Python Write a program that does the following in order: 1.     Asks the user to enter a name 2.     Asks the user to enter a number “gross income” 3.     Asks the user to enter a number “state tax rate” 4.     Calculates the “Federal Tax”, “FICA tax” and “State tax” 5.     Calculates the “estimated tax” and round the value to 2 decimal places 6.     Prints values for “name”, “gross income” and “estimated tax” The program should contain three additional variables to store the Federal tax, FICA...
Write a program that does the following in order: 1. Ask user to enter a name...
Write a program that does the following in order: 1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out “Your account...
Write a program that does the following. It will ask the user to enter an integer...
Write a program that does the following. It will ask the user to enter an integer larger than 1, and the if entered integer is not larger than 1, it keeps prompting the user. After the user enters a valid integer, the program prints all the prime factors of the integer (including the repeated factors). For example, if the entered integer is 24, the program prints: 2 2 2 3 Run your program with the test cases where the entered...
Write a program that does the following in order: 1. Asks the user to enter a...
Write a program that does the following in order: 1. Asks the user to enter a name 2. Asks the user to enter a number “gross income” 3. Asks the user to enter a number “state tax rate” 4. Calculates the “Federal Tax”, “FICA tax” and “State tax” 5. Calculates the “estimated tax” and round the value to 2 decimal places 6. Prints values for “name”, “gross income” and “estimated tax” The program should contain three additional variables to store...
Write a python program that will ask the user to enter any number of days. The...
Write a python program that will ask the user to enter any number of days. The program reads the number of days from the user, and returns how many years, months, and days are there in the given number of days. Your program should prompt the user to: Enter the number of days : 1152 The user types number of days (1152 above, for example) and hit enter key. The program then will print: 3 years 1 months 27 days...
Write a python program that will ask the user to enter as many positive and negative...
Write a python program that will ask the user to enter as many positive and negative numbers and this process will only stop when the last number entered is -999. Use a while loop for this purpose. Your program should compute three sums; the sum of all numbers, sum of all positive numbers, and the sum of all negative numbers and display them. It should also display the count of all numbers, count of all positive numbers, and count of...
1. Write a Python program to: ask the user to enter two integers: int1 and int2....
1. Write a Python program to: ask the user to enter two integers: int1 and int2. The program uses the exponential operator to calculate and then print the result when int1 is raised to the int2 power. You also want to calculate the result when int1 is raised to the .5 power; however, you realize that it is not possible to take the square root of a negative number. If the value for int1 that is entered is a negative...
Write, save, and run a Python program Ask the user to enter a number of grams....
Write, save, and run a Python program Ask the user to enter a number of grams. Your program converts that to whole tones, then whole kilograms and whatever is left is in grams. It prints the entered grams , tones , kilograms and the remaining grams.      4 marks for i in range(0,10): print(i) 2    what is wrong in the above python code? display your explanation using print statement. mark 3    insert the following comments into your program of part...
Write a Python Program Continue to ask the user to enter a POSITIVE number until they...
Write a Python Program Continue to ask the user to enter a POSITIVE number until they type DONE to quit. The program should DOUBLE each of the digits in the number and display the original entry AND the SUM of the doubled digits. Hint: Use the // and % operators to accomplish this. Print the COUNT of entries that were invalid Examples: if the user enters 93218, the sum of the doubled digits is 18+6+4+2+16 = 46. User Entry Output...
Write a Python program to: ask the user to enter two integers: int1 and int2. The...
Write a Python program to: ask the user to enter two integers: int1 and int2. The program uses the exponential operator to calculate and then print the result when int1 is raised to the int2 power. You also want to calculate the result when int1 is raised to the .5 power; however, you realize that it is not possible to take the square root of a negative number. If the value for int1 that is entered is a negative number,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT