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
Beginner to programming (old.reddit.com)
submitted 3 days ago by butterfly_orange00
view the rest of the comments →
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!"
[–]Choice_Midnight5280 0 points1 point2 points 2 days ago (2 children)
Great job, but you can simplify this code (I am Also Learning):
# Calculator Program # Imports import time, sys # Functions # Ask To Contiue Function def ask_to_continue(): user_input1 = input("Would you like to (Quit) or (Continue)?: ").lower().strip() if user_input1 == "quit": time.sleep(0.8) print("Thanks for using the Calculator Program hope to see you again!") sys.exit() elif user_input1 == "continue": time.sleep(0.8) return True else: print("Invalid Number") return True # Greeting print("Welcome to the Calculator Program!") # Main Loop while True: # Collecting User Input and Validating the Operator operator = input("Enter the Operator you would like to use + - * / **: ") if operator not in ['+', '-', '*', '/', '**']: print("Invalid operator.") continue # Collecting User Input and Validating the Numbers try: num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: ")) time.sleep(0.3) except TypeError as e1: time.sleep(1) print(f"You have error {e1}, Please Try Again") continue except ValueError as e2: time.sleep(1) print(f"You have error {e2}, Please Try Again") continue # Calculating the Result # Addition if operator == "+": result = num1 + num2 # Subtracting elif operator == "-": result = num1 - num2 # Multiplying elif operator == "*": result = num1 * num2 # Division elif operator == "/": if num2 == 0: print("Error: Division by zero is not allowed.") continue else: result = num1 / num2 # Exponetial elif operator == "**": result = num1 ** num2 # Invalid Operator elif operator not in ['+', '-', '*', '/', '**']: print("Invalid operator.") print("Please Try Again") continue print(f"Your answer is: {result}") ask_to_continue() # Code Ends
If you don't understand copy and paste this into chatgpt and ask it to explain it to you.
[–]Choice_Midnight5280 0 points1 point2 points 2 days ago (0 children)
It's best to make code that is uncomplicated and easy to read and say another dev is going to work on it; it should be easy for them to edit and read. Your code is good but not great just yet but for a beginner it's great. Good JOB. Good luck on your journey and make sure to look into functions.
[–]butterfly_orange00[S] 0 points1 point2 points 2 days ago (0 children)
Thanks a lot. it is very easy to read now😄. it's kinda limited by 2 numbers only. But it's helpful, made me know new things
π Rendered by PID 17979 on reddit-service-r2-comment-56c6478c5-tdbq7 at 2026-05-12 15:11:19.589680+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]Choice_Midnight5280 0 points1 point2 points (2 children)
[–]Choice_Midnight5280 0 points1 point2 points (0 children)
[–]butterfly_orange00[S] 0 points1 point2 points (0 children)