I am new to python and was trying to write something like this below (code A) so it does eactly like code B. I want to make use of user input of mathematical operators as do_what
variable. How can we write this code (A) in python so it would work like code B?
code A
num1 = input("Enter a number: ")
num2 = input("Enter another number: ")
do_what = input("Enter a calculation symbol for calculation you want to perform: ")
result = float(num1) do_what float(num2)
print("result is: " + str(result))
code B
num1 = input("Enter a number: ")
num2 = input("Enter another number: ")
result = int(num1) + int(num2)
print("result is: " + str(result))