1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
solmaris [256]
3 years ago
12

Write a calculator program that keeps track of a subtotal like real calculators do. Start by asking the user for an initial numb

er. Inside a loop, asks the user for a mathematical operation and a second number. Do the operation with the first number on the second number. Keep track of the result as a 'subtotal' to be used as the first number when going back to the top of the loop. When the user quits, print out the final result and quit the program. See output for an example for the behavior of the program. The operations should be at least
Computers and Technology
1 answer:
Taya2010 [7]3 years ago
8 0

Answer:

num1 = float(input("Enter the first number: "))

while True:

   print("Add, Subtract, Multiply, Divide, or Quit ?")

   choice = input("Your choice is: ")

   if choice == "Quit":

       break

   num2 = float(input("Enter the second number: "))

   if choice == "Add":

       num1 += + num2

       print("The subtotal is: " + str(num1))

   elif choice == "Subtract":

       num1 -= num2

       print("The subtotal is: " + str(num1))

   elif choice == "Multiply":

       num1 *= num2

       print("The subtotal is: " + str(num1))

   elif choice == "Divide":

       num1 /= num2

       print("The subtotal is: " + str(num1))

print("The final result is: " + str(num1))

Explanation:

Ask the user for the first number

Create a while loop that iterates until specified condition occurs inside the loop

Ask the user for the operation or quitting

If the user chooses quitting, stop the loop. Otherwise, get the second number, perform the operation and print the subtotal

When the loop is done, the user enters Quit, print the final value result

You might be interested in
The objects that you place on master pages are called _____.
Studentka2010 [4]
The answer to this is A.
3 0
3 years ago
IT professionals have a responsibility to educate employees about the risks of hot spots. Which of the following are risks assoc
kodGreya [7K]

Answer:

third partying and computer hackers.

Explanation:

7 0
3 years ago
A school at which you are likely to be accepted because you meet graduation requirements is called a:
zloy xaker [14]
The answer for Apex College and Career Prep 2 would be Probable College. 
7 0
3 years ago
Which slide elements must Claire use to enhance her presentation?
Alja [10]
She needs to use animations to enhance her presentation
8 0
2 years ago
Sheila is using a process of saving files to her desktop and then renaming them. She is
inessss [21]

Answer: D

Use the internet to search for a new app to rename the folder.​

Explanation:

Rename function is used to change the name of the file or directory i.e. from old_name to new_name without changing the content present in the file. This function takes name of the file as its argument. There are many alternatives to this in which Sheila can found out through the internet.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Write a C++ program that searches for anagrams in a dictionary. An anagram is a word obtained by scrambling the letters of some
    5·1 answer
  • Which component is the smallest unit in a spreadsheet?
    14·2 answers
  • Most programming languages provide loop statements that help users iteratively process code. In Coral you can write loops that h
    15·1 answer
  • In the software development life cycle, what is the role of participants in the planning phase? The participants’ role in the pl
    6·1 answer
  • When transporting data from real-time applications, such as streaming audio and video, which field in the ipv6 header can be use
    12·1 answer
  • Once artwork is inserted into a placeholder, it can be moved around on a slide. True False
    9·1 answer
  • Write a C program to calculate and display the coordinates of midpoint - M of a linesegment between two given points - say A and
    7·1 answer
  • Please help me. Adnan also wants to add a photograph of a bridge. It is on another PowerPoint presentation that is open in a dif
    11·1 answer
  • Desktop and personal computer are also known as​
    7·1 answer
  • a web server will utilize a directory protocol to enable users to authenticate with domain credentials. a certificate will be is
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!