read.cash Log in
@MyHero

Program 101: Choosing Arithmetic Operations using Python This program display the result based on the user's choice operation. It will not automatically print the results of all four operations. * The program using if, elif and else statement. Code: # Choosing Arithmetic Operation using Python num1 = int(input("Enter First Number: ")) num2 = int(input("Enter Second Number: ")) opr = input("Choose which operation would you like to perform? (+,-,*,/): ") if opr == '+': print("\nAddition: " +str(num1)+ " + " +str(num2)+ " = " +str(num1+num2)) elif opr == '-': print("\nSubtraction: " +str(num1)+ " - " +str(num2)+ " = " +str(num1-num2)) elif opr == '*': print("\nMultiplication: " +str(num1)+ " * " +str(num2)+ " = " +str(num1*num2)) elif opr == '/': print("\nDivision: " +str(num1)+ " / " +str(num2)+ " = " +str(num1/num2)) else: print("\nInvalid Operator") Running Program: https://onlinegdb.com/JWdPMzFr_

3 comments

Log in to join in Reading is open to everyone. Replying needs an account.