Question

Answer must be submitted in a python file (.py at the end of the file) You...

Answer must be submitted in a python file (.py at the end of the file)

You will ask three questions (1-3 below). Based on the answer from question 3, you will determine to add, subtract, divide or multiply question 1 and 2.

  1. Enter value one?
  2. Enter value two?
  3. What operation would you like to perform? 1 to add, 2 to subtract, 3 to divide and 4 to multiply.
  4. Print the result

Make sure to cover all four scenarios from question 3.

Homework Answers

Answer #1
n1 = float(input("Enter value one? "))
n2 = float(input("Enter value two? "))
choice = int(input("What operation would you like to perform? 1 to add, 2 to subtract, 3 to divide and 4 to multiply: "))

if choice == 1:
    print(n1 + n2)
elif choice == 2:
    print(n1 - n2)
elif choice == 3:
    print(n1 / n2)
elif choice == 4:
    print(n1 * n2)
else:
    print("Invalid choice!")

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
Python Practice Sample: Question 1. Math Write a program that runs these steps three times: ...
Python Practice Sample: Question 1. Math Write a program that runs these steps three times:  Ask the user to enter a non-zero number (can be positive or negative).  Find the cube of the number and subtracts 100.0 from the cube.  Calculate the square root of the result above. If the result is negative, multiply the result by -1 so it is positive before calculating the square root.  Print the result with two decimal places.
Write a phython program to display a menu with the following options: (1) add, (2) subtract,...
Write a phython program to display a menu with the following options: (1) add, (2) subtract, (3) multiply, (4) divide (5) mod, and (6) do nothing. If the user enters something else (except 1-6), the program should display an error message. Otherwise, it should ask the user for two numbers, perform the calculation, and display the result.
ON PYTHON Exercise 1. For each of the relational/logical expressions listed in exercise1.py determine whether the...
ON PYTHON Exercise 1. For each of the relational/logical expressions listed in exercise1.py determine whether the expression evaluates to True or False. Place a comment after each expression with the truth value and submit the updated exercise1.py file to the dropbox. For example, x = 10 y = 11 x < y # True  insert a comment after the expression x = 10 y = 11 a = 12.5 b = -5.2 x < y # True x <...
This python program must have 9 functions: •main() Controls the flow of the program (calls the...
This python program must have 9 functions: •main() Controls the flow of the program (calls the other modules) •userInput() Asks the user to enter two numbers •add() Accepts two numbers, returns the sum •subtract() Accepts two numbers, returns the difference of the first number minus the second number •multiply() Accepts two numbers, returns the product •divide() Accepts two numbers, returns the quotient of the first number divided by the second number •modulo() Accepts two numbers, returns the modulo of the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the console calculator is created which perform multiply,divide,sub and add, operation and it accept all type of data (divide by 0 case as well ).Now the main motive is to create the library project from the console calculator project .Than we have to create a unit test project which test the functionality of added library.Make test like Test 1. multiply two positive number,Test 2. Add...
For this assignment you will implement a simple calculator or interpreter that reads arithmetic expressions from...
For this assignment you will implement a simple calculator or interpreter that reads arithmetic expressions from a file. Specifically, you will implement the following function: /* * Reads one arithmetic "expression" at a time from a file stream, computes, then * returns the result. If there are additional expressions in the file, they are * read and computed by successive calls to “calculator”. * * “Expressions” are groups of operations (add, subtract, multiply, divide). Your * calculator will read and...
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
Python Regular Expressions problem: How do you get string data from file of say rows of...
Python Regular Expressions problem: How do you get string data from file of say rows of IP address and city location values obtained from re.finditer patterns to appear in the same dictionary? for example: text file has 100.200.10.255 New York City 10. 16. 25.254 Los Angeles segment of code includes for item in re.finditer(the_two_patterns, text_file, re.MULTILINE): print (item.groupdict()) result is below that I am getting {‘IP’: ‘100.200.10.255’, ‘city’: None} {‘IP’: None, ‘city’: ‘New York City’} {‘IP’: ‘10.16.25.254’, ‘city’: None} {IP’:...
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file....
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file. Both files must be in the same directory to compile. Display all dollar amounts using the DecimalFormat class. Create an account Ask the user for the type of account, the bank account number, the amount that they will deposit to start the account. Set interest earned to 0. Print the account information using an implicit or explicit call to toString Update an account Use...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT