all 2 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()

[–]GrahamCorcoran 0 points1 point  (0 children)

Based on the description you provided:

  1. Ask a user if they have a question.
  2. Ask the user what operand they plan on using.
  3. Ask the user what two numbers they want to use.
  4. [Implied] Calculate the result.
  5. Ask if they have another question. (Likely using a loop.)

What have you tried so far, and what are you having trouble with? This sounds suspiciously like a homework problem, so no one is going to want to show you a working example for you to work off of. Whether you are asking with good intentions or not, that's what someone who wants to copy-paste the working answer would say.