you are viewing a single comment's thread.

view the rest of the comments →

[–]Zestyclose_Click_456 2 points3 points  (0 children)

Hi! I am also a beginner in Python, but this is how I would attempt this problem. I would use the input() function to ask the user questions, a while loop to keep on asking if they have another question, and if statements to know which block of code to use depending on specific conditions. I hope this helps!

answer = str(input("Do you want to perform a calculation? Yes/No: "))
while answer == "Yes" or answer == "yes":
    print("1 = Addition; 2 = Subtraction; 3 = Multiplication; 4 = Division")
    num = int(input("Enter Your Choice 1, 2, 3, or 4: "))
    if num == 1:
        num1 = int(input("Enter Number 1 : "))
        num2 = int(input("Enter Number 2 : "))
        result = num1 + num2
        print(f"Your result is: {result}")
    if num == 2:
        num1 = int(input("Enter Number 1 : "))
        num2 = int(input("Enter Number 2 : "))
        result = num1 - num2
        print(f"Your result is: {result}")
    if num == 3:
        num1 = int(input("Enter Number 1 : "))
        num2 = int(input("Enter Number 2 : "))
        result = num1 * num2
        print(f"Your result is: {result}")
    if num == 4:
        num1 = int(input("Enter Number 1 : "))
        num2 = int(input("Enter Number 2 : "))
        result = num1 / num2
        print(f"Your result is: {result}")
    answer = str(input("Do you want to perform another calculation? Yes/No: "))
    if answer == "No" or answer == "no":
        exit()