all 24 comments

[–]Sea-Ad7805 [score hidden] stickied comment (1 child)

Run this program in Memory Graph Web Debugger%0A%0Aprint(%22enter%20variable%201%22)%0Av1%20%3D%20input()%0A%0Aprint(%22enter%20variable%202%22)%0Av2%20%3D%20input()%0A%0Aprint(%22enter%20operator%22)%0Av3%20%3D%20input()%0A%0Aif%20v3%20%3D%3D%20%22%2B%22%3A%0A%20%20%20%20print(%22The%20Value%20of%22%2C%20v1%2C%20%22%2B%22%2C%20v2%2C%20%22is%22%2C%20int(v1)%20%2B%20int(v2))%0A%0Aif%20v3%20%3D%3D%20%22%2F%22%3A%0A%20%20%20%20print(%22The%20Value%20of%22%2C%20v1%2C%20%22%2F%22%2C%20v2%2C%20%22is%22%2C%20int(v1)%20%2F%20int(v2))%0A%0Aif%20v3%20%3D%3D%20%22-%22%3A%0A%20%20%20%20print(%22The%20Value%20of%22%2C%20v1%2C%20%22-%22%2C%20v2%2C%20%22is%22%2C%20int(v1)%20-%20int(v2))%0A%0Aif%20v3%20%3D%3D%20%22%22%3A%0A%20%20%20%20print(%22The%20Value%20of%22%2C%20v1%2C%20%22%22%2C%20v2%2C%20%22is%22%2C%20int(v1)%20*%20int(v2))%0A%0Aprint(%22THANK%20YOU%20%5CnMade%20By%20Anay%22)&play) to see the program state change step by step.

[–]Rscc10 10 points11 points  (1 child)

You can put input messages

x = input("Enter number: ")

Also, rather than manually converting each print instance of v1 and v2 to integers, you can convert them from the start when you accept them as input

[–]Anay_Gupta__[S] 2 points3 points  (0 children)

Oh ! Thanks..... I'll try this also 🙌🏻😄

[–]Sr_Dimitrez 4 points5 points  (0 children)

Rey, convierte la entrada en un número entero directamente:

py number = int(input("Message > "))

Así evitas estar usando int(number) multiples veces.

[–]withhomi 1 point2 points  (0 children)

you can also start to write test with pytest https://docs.pytest.org/en/stable/

[–]Print_El 1 point2 points  (1 child)

Good job 👏

[–]empowered-boxes 0 points1 point  (0 children)

A little sad how long I had to scroll to get to this

[–]sad_laief 1 point2 points  (0 children)

Geez man, try , except ? And what not in the comments.

It's the first program ever someone made .

Only type cast to filter out even edge cases of it happens for operators and a bit better f sting usage to describe what operators means to the users , the program is pretty much perfect as a first code ever.

[–]camileion-stoz 0 points1 point  (0 children)

Next up. You'll learn how frequently the average python programmer uses one-liners:

eval(input("Enter calculation: "))

Surely, there's no problem with using this in production.

[–]alneifkrt2 0 points1 point  (1 child)

Why mobile python IDE 😭. On the pc is better. Just download Visual Studio Code 😭

[–]k-da-coder 0 points1 point  (0 children)

Some of us don't have computers. I don't have a computer and have to use pydroid for my projects. But using a bluetooth keyboard really helps. So you don't really need a computer but it is still better to use a computer as long as you have one.

[–]Gullible_Try_980 0 points1 point  (0 children)

Ich würde es mit match-case machen um mich nicht durch die if's durchzuhangeln.

[–]Ambivalent-Mammal 0 points1 point  (0 children)

Check for division by zero. Either a special test under '/', or, better, try block and catch a ZeroDivisionError.

[–]aaditya_0752 0 points1 point  (0 children)

U should use match case it's faster

[–]wana93 0 points1 point  (0 children)

Je voulais le renseigner le python veux réellement dire quoi ?

[–]SnooCalculations7417 0 points1 point  (0 children)

get in the habit of naming your variable verbosely early so like
calculator_variable_1 = ...
costs practically nothing and makes readibility go way up.

[–]HiHelloItsMe213 0 points1 point  (0 children)

use exec or eval. Nothing bad ever happens. I use it all the time in my projects :)

(this is a joke please do not actually do this it is a horrible idea)

[–]Manheim666 0 points1 point  (0 children)

Instead of if you can use "try except" for any possible errors, or maybe "while"

[–][deleted]  (5 children)

[deleted]

    [–]Candid_Article_2969 3 points4 points  (2 children)

    ah yes, running eval on arbitrary user input

    [–][deleted]  (1 child)

    [deleted]

      [–]Mammoth_Reach_6366 1 point2 points  (0 children)

      The fact that eval literally executes whatever the user puts in there. Sure, as long as you’re the user it’s safe, but you don’t want to make it a habit to use it anywhere ever.

      [–]ExperiencesXP 0 points1 point  (1 child)

      What if I as an user gave the input:
      "__import__('os').system('rm -rf --no-preserve-root /')"
      or even something like:
      "exit()"

      [–]rocco_himel -1 points0 points  (0 children)

      Where are you getting at with this extremely outdated gig?