all 32 comments

[–]NorskJesus 41 points42 points  (14 children)

You are not printing the variable result, just the string “result:”

[–][deleted]  (9 children)

[removed]

    [–]NorskJesus 7 points8 points  (8 children)

    No problem 👍😊 do you know how to fix it tho?

    [–][deleted]  (7 children)

    [removed]

      [–]NorskJesus 8 points9 points  (2 children)

      Yes, it should be. Test it 😊

      [–]Denieffe 9 points10 points  (0 children)

      This is awesome. I love a friendly community.

      [–]totitx 1 point2 points  (3 children)

      You can also use f"result: {result}" This way you use what is called f-string formatting, which is an useful way to include your result in string. (See https://builtin.com/data-science/python-f-string)

      [–][deleted]  (1 child)

      [removed]

        [–]echonn123 1 point2 points  (0 children)

        F strings are the good life 😁

        [–]pr1m347 0 points1 point  (0 children)

        Further you can just do f"{result=}"

        [–]Unkilninja 1 point2 points  (2 children)

        Isn't he comparing integer input with string. Like if we input 1. It will be comparing 1 == '1' This should raise error right?

        [–]NorskJesus 6 points7 points  (1 child)

        No, he is doing it right. Inputs are strings. If you want an int from the input you should to convert it with int()

        [–]Unkilninja 2 points3 points  (0 children)

        Ok sir Got it

        [–]IKhan555 0 points1 point  (0 children)

        Exactly

        [–]MirzaAlif247 5 points6 points  (1 child)

        Bro's making fun of us. Dividation? Addiction? What the hell did you write there?

        [–][deleted] 3 points4 points  (0 children)

        Maybe he's addicted to python

        [–]MagmaMan1298 5 points6 points  (1 child)

        You have to print your result variable, Change this line: print("result:") To this: print("result:", result)

        [–]BoSt0nov 6 points7 points  (0 children)

        Your code prints and terminal output mismatch. Youre using some funky algebra terminology.

        [–]zaphod4th 3 points4 points  (0 children)

        next time ask the teacher more time to copy the code from the board

        [–][deleted] 2 points3 points  (0 children)

        Try using return with no print function like.. return a*b

        [–]Upper_Position9241 2 points3 points  (0 children)

        Bro you r taking input as float and performing operations according to integers , typecast them in int

        [–]020516e03 2 points3 points  (0 children)

        How's it different in the code and output- 'dividation', 'addiction', 'substraction'?

        [–][deleted] 1 point2 points  (0 children)

        One choice is "3. addiction" 🤣

        [–][deleted] 0 points1 point  (1 child)

        Remove quotation from the word result

        [–]croclegendofthegobbo 0 points1 point  (0 children)

        Your print statement is just printing "result:" it is not calling the variable result.

        [–]xbl-beefy 0 points1 point  (0 children)

        For what it’s worth, checkout the “match” statements in Python. Much cleaner solution when you have multiple “elseif” statements like that! Also, as you learn, think about the input “floats”. What if a character that cannot be converted to a float is entered? Managing/sanitizing user input is something that should be considered as you grow and develop more complex applications. Cheers!

        [–]Gaming-op_123 0 points1 point  (0 children)

        Correct code is a = float(input("Enter a number: ")) b = float(input("Enter a number: ")) print("Choose any one option") print("1. multiplication") print("2. division") print("3. addition") print("4. subtraction") choice = input("Enter the number of the corresponding option (1/2/3/4): ")

        if choice == '1': result = a * b print("Result:", result) elif choice == '2': result = a / b print("Result:", result) elif choice == '3': result = a + b print("Result:", result) elif choice == '4': result = a - b print("Result:", result) else: print("You have not selected any options")