Sharing the code of my simple (for kids 😏) first program.
I just wrote it and im trying to find better ways to improve the code and to minimize the code lines.
🤝
I just wrote it and im trying to find better ways to improve the code and to minimize the code lines.
Code
def choice():
global a
global b
global r
try:
a = int(input("Give first number "))
b = int(input("Give second number "))
action = input("choose + , - , * , / ")
if action == "+":
addition()
elif action == "-":
substraction()
elif action == "*":
multi()
elif action == "/":
division()
except ValueError:
print ("Give ONLY Number")
choice()
def substraction():
r = (a - b)
print (r)
def addition():
r = (a + b)
print (r)
def multi():
r = (a * b)
print (r)
def division():
r = (a / b)
print (r)
while True:
choice()🤝

