Create a python code of this output
Choices:
a. Calculator
b. Odd or Even
c. Positive or Negative Number
Enter your choice: c
Enter a number: -6
-6 is a negative number.
SOLUTION CODE
print("\nChoices")
print("\na. Calculator")
print("b. Odd or Even")
print("c. positive or Negative")
choice = input("\nEnter your choice: ")
if choice == "a":
print("\n1. Multiplication")
print("2. Division")
my_cal_choice = int(input("Enter the operation to perform: "))
if my_cal_choice == 1:
first_number = int(input("Enter the first number: "))
second_number = int(input("Enter the second number: "))
print("The product of "+str(first_number+ " and "+str(second_number)+" = "+str(first_number*second_number)))
elif my_cal_choice == 2:
first_number = int(input("Enter the first number: "))
second_number = int(input("Enter the second number: "))
print("The quotient of "+str(first_number+ " and "+str(second_number)+" = "+str(first_number/second_number)))
else:
print("Inavlid option please try again")
if choice=="b":
number = int(input("\nEnter a number: "))
if number % 2 == 0:
print(str(number)+" is an even number")
else:
print(str(number) + " is an odd number")
elif(choice == "c"):
number = int(input("\nEnter a number: "))
if number == 0:
print("The number you have entered is a zero")
elif number > 0:
print(str(number) + " is a positive number")
else:
print(str(number) + " is a negative number")
else:
print("Invalid choice, please try again")
Comments
Leave a comment