Answer to Question #273918 in Python for Vales

Question #273918

create a python program

Choices:

a. Calculator

b. Odd or Even

c. Positive or Negative Number Enter your choice: a Enter first number: 10 Enter second number: 5 The sum of 10 and 5 is 15 The difference of 10 and 5 is 5 The product of 10 and 5 is 50 The quotient of 10 and 5 is 2


1
Expert's answer
2021-12-01T06:40:43-0500
ch=""
while ch!="e":
    print("a. Calculator")
    print("b. Odd or Even")
    print("c. Positive or Negative Number")
    print("e. Exit")
    ch=input()
    if ch.lower()=="a":
        number1=int(input("Enter first number: "))
        number2=int(input("Enter second number: "))
        sumResult=number1+number2
        differenceResult=number1-number2
        productResult=number1*number2
        quotientResult=number1/number2
        print(f"The sum of {number1} and {number2} is {sumResult}")
        print(f"The difference of {number1} and {number2} is {differenceResult}")
        print(f"The product of {number1} and {number2} is {productResult}")
        print(f"The quotient of {number1} and {number2} is {quotientResult}")
    elif ch.lower()=="b":
        number=int(input("Enter a number: "))
        if number%2==0:
            print("Number is Even")
        else:
            print("Number is Odd")
    elif ch.lower()=="c":
        number=int(input("Enter a number: "))
        if number>0:
            print("Number is Positive")
        else:
            print("Number is Negative")
    elif ch.lower()=="e":
        pass
    else:
        print("Wrong menu item")

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