Answer to Question #341215 in Python for Bunny

Question #341215

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.



1
Expert's answer
2022-05-15T16:59:40-0400
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  : ')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS