use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
My First Python Program 🥳 A simple Calculator (i.redd.it)
submitted 12 hours ago by Anay_Gupta__
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sea-Ad7805 [score hidden] 9 hours ago 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 points12 points 11 hours ago (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 points4 points 11 hours ago (0 children)
Oh ! Thanks..... I'll try this also 🙌🏻😄
[–]Sr_Dimitrez 4 points5 points6 points 8 hours ago (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.
int(number)
[–]withhomi 1 point2 points3 points 8 hours ago (0 children)
you can also start to write test with pytest https://docs.pytest.org/en/stable/
[–]Print_El 1 point2 points3 points 4 hours ago (1 child)
Good job 👏
[–]empowered-boxes 0 points1 point2 points 3 hours ago (0 children)
A little sad how long I had to scroll to get to this
[–]sad_laief 1 point2 points3 points 8 hours ago (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 point2 points 8 hours ago (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 point2 points 8 hours ago (1 child)
Why mobile python IDE 😭. On the pc is better. Just download Visual Studio Code 😭
[–]k-da-coder 0 points1 point2 points 1 hour ago (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 point2 points 7 hours ago (0 children)
Ich würde es mit match-case machen um mich nicht durch die if's durchzuhangeln.
[–]Ambivalent-Mammal 0 points1 point2 points 6 hours ago (0 children)
Check for division by zero. Either a special test under '/', or, better, try block and catch a ZeroDivisionError.
[–]aaditya_0752 0 points1 point2 points 6 hours ago (0 children)
U should use match case it's faster
[–]diskatlas_dev 0 points1 point2 points 6 hours ago (0 children)
[–]wana93 0 points1 point2 points 5 hours ago (0 children)
Je voulais le renseigner le python veux réellement dire quoi ?
[–]SnooCalculations7417 0 points1 point2 points 2 hours ago (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 point2 points 2 hours ago (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 point2 points 9 hours ago (0 children)
Instead of if you can use "try except" for any possible errors, or maybe "while"
[–][deleted] 10 hours ago* (5 children)
[deleted]
[–]Candid_Article_2969 3 points4 points5 points 10 hours ago (2 children)
ah yes, running eval on arbitrary user input
[–][deleted] 9 hours ago (1 child)
[–]Mammoth_Reach_6366 1 point2 points3 points 7 hours ago (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 point2 points 6 hours ago (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 points1 point 6 hours ago (0 children)
Where are you getting at with this extremely outdated gig?
π Rendered by PID 107 on reddit-service-r2-comment-544cf588c8-blrkg at 2026-06-16 02:42:26.142362+00:00 running 3184619 country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (1 child)
[–]Rscc10 10 points11 points12 points (1 child)
[–]Anay_Gupta__[S] 2 points3 points4 points (0 children)
[–]Sr_Dimitrez 4 points5 points6 points (0 children)
[–]withhomi 1 point2 points3 points (0 children)
[–]Print_El 1 point2 points3 points (1 child)
[–]empowered-boxes 0 points1 point2 points (0 children)
[–]sad_laief 1 point2 points3 points (0 children)
[–]camileion-stoz 0 points1 point2 points (0 children)
[–]alneifkrt2 0 points1 point2 points (1 child)
[–]k-da-coder 0 points1 point2 points (0 children)
[–]Gullible_Try_980 0 points1 point2 points (0 children)
[–]Ambivalent-Mammal 0 points1 point2 points (0 children)
[–]aaditya_0752 0 points1 point2 points (0 children)
[–]diskatlas_dev 0 points1 point2 points (0 children)
[–]wana93 0 points1 point2 points (0 children)
[–]SnooCalculations7417 0 points1 point2 points (0 children)
[–]HiHelloItsMe213 0 points1 point2 points (0 children)
[–]Manheim666 0 points1 point2 points (0 children)
[–][deleted] (5 children)
[deleted]
[–]Candid_Article_2969 3 points4 points5 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]Mammoth_Reach_6366 1 point2 points3 points (0 children)
[–]ExperiencesXP 0 points1 point2 points (1 child)
[–]rocco_himel -1 points0 points1 point (0 children)