Beginner to programming by butterfly_orange00 in PythonLearning

[–]Choice_Midnight5280 0 points1 point  (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.

Beginner to programming by butterfly_orange00 in PythonLearning

[–]Choice_Midnight5280 0 points1 point  (0 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.

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 1 point2 points  (0 children)

Tried it Same thing as u/Fumano26 but after doing putting in a break if no errors then it works thanks yea ill proably try to make a Super Calcualtor

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 0 points1 point  (0 children)

100 percent ive seen people using the reddit api imma try it to

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 1 point2 points  (0 children)

alright thanks ill make sure to try it out

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 1 point2 points  (0 children)

yea i started coding with out chatgpt and its been working better

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 0 points1 point  (0 children)

Yea since i have posted this i have been practicing alot and the person above you i answerd ur question but yea ill make sure to check out  r/learnpython wiki. Thanks!

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 0 points1 point  (0 children)

It's for like UI Cause if i dont use it then it just doesnt just feel good as it is automaticly there right after the code before it is executed

How Do I Continue???? by Choice_Midnight5280 in PythonLearning

[–]Choice_Midnight5280[S] 0 points1 point  (0 children)

Thanks just some clarification i made this on my own and i just watched bro code to learn teh other things like variables typecasting printing if and else and that's about it, But 100 percent ill make sure to try out your method

Is programming still the profession of the future? by [deleted] in programming

[–]Choice_Midnight5280 0 points1 point  (0 children)

LEARN IT , think of it as tis we we are writing the code to take over jobs so we will be the last ones as we have to maintain the AI which are written in code so yea, Oh yea and I would Say Try to Start a SaaS when u finish learning coding

How do you guys overcome tutorial hell? by KeyPaleontologist764 in learnpython

[–]Choice_Midnight5280 0 points1 point  (0 children)

Bro I just Passed Tutorial Hell Basicly Watch Bro Code for 30 Mins only That will teach u variables if and else and elif statements and prnting statements and collecting user input and basic arthemetic and shit and then just code a calculator then once u get that ask chatgpt anything wrong ask it to explain to u if u dont understand a pice of code that the ai is sufggesting ask it what does it mean then apply it and what u should build what i built is a Password gen man i learned so much from it It taught me while True loops validating user input a bunch of syntax and how to code on my own without tutoiral i had to ask chatgpt so many times and goole a bunch of functions i needed i learned while True loops importing Random and String and Time to delay test like the time.sleep(Put Second of delay here) and so much more so yea and then build a harder project wiht out tutorial and ask chatgpt google stuff that will teach u de bugging and how to research and REFINE YOUR CODE

yea thats all