Create a python program that adds, subtract, multiply and divide two numbers. Use conditional keywords, iteration keywords, import keywords, function and structure keywords, and returning keywords on your program. Watch the attached video on this activity for your basis and guidelines.
def add_nums(a, b):
return a + b
def sub_nums(a, b):
return a - b
def mul_nums(a, b):
return a * b
def div_nums(a, b):
if b != 0:
return a / b
else:
raise ValueError
a = input('first number : ')
while a:
b = input('second number : ')
a, b = int(a), int(b)
print(f'{a} + {b} = {add_nums(a, b)}')
print(f'{a} - {b} = {sub_nums(a, b)}')
print(f'{a} * {b} = {mul_nums(a, b)}')
print(f'{a} / {b} = {div_nums(a, b)}')
a = input('first number : ')
Comments
Leave a comment