Computer Science, asked by evanwalters, 10 months ago

Python Program

Ask the user for 2 numbers, calculate the total (add), calculate the difference between the 1st and the 2nd (subtract), calculate the product (multiply), calculate the division of 1st ÷ 2nd, calculate the floor division (whole number when divided) and lastly calculate the modulo (remainder when divided)

Answers

Answered by sauravkumarcha61
3

num1 = int(input("Enter First Number: "))

num2 = int(input("Enter Second Number: "))

print("Enter which operation would you like to perform?")

ch = input("Enter any of these char for specific operation +,-,*,/: ")

result = 0

if ch == '+':

result = num1 + num2

elif ch == '-':

result = num1 - num2

elif ch == '*':

result = num1 * num2

elif ch == '/':

result = num1 / num2

else:

print("Input character is not recognized!")

print(num1, ch , num2, ":", result)

Output 1: Addition

Enter First Number: 100

Enter Second Number: 5

Enter which operation would you like to perform?

Enter any of these char for specific operation +,-,*,/: +

100 + 5 : 105

Output 2: Division

Enter First Number: 20

Enter Second Number: 5

Enter which operation would you like to perform?

Enter any of these char for specific operation +,-,*,/: /

20 / 5 : 4.0

Output 3: Subtraction

Enter First Number: 8

Enter Second Number: 7

Enter which operation would you like to perform?

Enter any of these char for specific operation +,-,*,/: -

8 - 7 : 1

Output 4: Multiplication

Enter First Number: 6

Enter Second Number: 8

Enter which operation would you like to perform?

Enter any of these char for specific operation +,-,*,/: *

6 * 8 : 48

Similar questions