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
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...
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...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
convert this code to accept int value instead of float values using python. Make sure to...
convert this code to accept int value instead of float values using python. Make sure to follow the same code. do not change the steps and make sure to point to what code you replaced. make sure to have 2 files Method:----------------------- #define a python user difined method def get_float_val (prompt): is_num = False str_val = input (prompt) #prming read for our while #while is_num == False: (ignore this but it works) old school while not is_num: try: value =...
PYTHON Ask the user for a value N (0 ≤ N < 10) Create a 2-D...
PYTHON Ask the user for a value N (0 ≤ N < 10) Create a 2-D list in an N X N structure with integers 1-(N*N) Print the list created Reverse the list such that (1) each list in the 2D list is reversed and (2) the order of each list in the outer list is reversed (see example) Print the reversed list Example Execution What size 2D list would you like to create? N> 3 The original list is:...
1. What will the following python code display? num = list(range(5)) print(num) 2. Answer the following...
1. What will the following python code display? num = list(range(5)) print(num) 2. Answer the following questions using the list below. You can record your answers in the essay textbox. data = [5,3,7] A. Write code to replace the value in the 0 position with the number 8. B. Add the value 10 to the end of the list. C. Insert the value 22 after position 1 in the list. D. Remove the value at position 2. E. Sort the...
Please answer this using def (functions) in python 3 with a single print statement under #main....
Please answer this using def (functions) in python 3 with a single print statement under #main. Is this possible to do in one print as output? User specifies the number of books ordered, and if the order is online, or not. You can collect the second input by asking the user to enter 1 for online, and 0 for offline. You can assume that the user will enter 1 or 0 as directed. Unit price for a book is 15$....
So, i have this code in python that i'm running. The input file is named input2.txt...
So, i have this code in python that i'm running. The input file is named input2.txt and looks like 1.8 4.5 1.1 2.1 9.8 7.6 11.32 3.2 0.5 6.5 The output2.txt is what i'm trying to achieve but when the code runs is comes up blank The output doc is created and the code doesn't error out. it should look like this Sample Program Output 70 - 510, [semester] [year] NAME: [put your name here] PROGRAMMING ASSIGN MENT #2 Enter...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT