Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can i make it show +,-,*,/ instead of A,S,M,D

+3 votes
asked Sep 24, 2021 by Saiangsh Barua (150 points)
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 A= Addition, S= Subtraction, M= Multiplication, D= Division: ")

result = 0
if ch == 'A':
    operation = '+'
   result = num1 + num2
elif ch == 'S':
    operation = '-'
    result = num1 - num2
elif ch == 'M':
    operation = '*'
    result = num1 * num2
elif ch == 'D':
    operation = '/'
    result = num1 / num2
else:
     print("Input character is not recognized!")

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

2 Answers

0 votes
answered Sep 24, 2021 by Peter Minarik (84,720 points)
I don't see the problem here. Your last line will print the mathematical operator, not A/S/M/D.

What am I missing? What exactly are you looking for?
0 votes
answered Sep 25, 2021 by Manmohan Singh (140 points)

Instead of ASMD just put the operators between the single inverted commas and remove all the lines where you wrote operation ='.....'

For eg. : if ch =='+' 

               Result=num1+num2

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 operators for specific operation  + for Addition, - for Subtraction, * for Multiplication, / for Division: ")

result = 0
if op == '+':
   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)

commented Sep 25, 2021 by Peter Minarik (84,720 points)
Oh lol. Probably that's what OP meant.
This is just so trivial that I couldn't think the problem to be so simple.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...