r/CodingForBeginners • • 10d ago

My first project

Hello! I've started learning python abt 2 weeks ago ( I know my progress rate is slow)and till now, I just know the basics. I've created my very first project on my own (I only asked ChatGPT for project ideas but the rest was on me) and this is what I've done in abt an hour.

I'd like you guys to tell me how can I get better. I know many things are may be missing regarding calculations and operators.

print("===========================================")
print()
print()
print("     BASIC & ENGINEERING CALCULATOR   ")
print()
print()
print("===========================================")
calc_type = input("What type of calculator do you want to use?: Basic, Engineering ").capitalize().strip()
if calc_type =="Basic":
    operator = input("Enter the operator (+, -, *, /, ^):")
    num1 = float(input("Enter the first number:"))
    num2 = float(input("Enter the second number:"))
    if operator == '+':
        result = num1 + num2
        print(f"The result of adding {num1} and {num2} is: {round(result,2)}")
    elif operator == '-':
        result = num1 - num2
        print(f"The result of subtracting {num1} and {num2} is: {round(result,2)}")
    elif operator == '*':
        result = num1 * num2
        print(f"The result of multiplying {num1} by {num2} is: {round(result,2)}")
    elif operator == '/':
        result = num1 / num2
        print(f"The result of dividing {num1} by {num2} is: {round(result,2)}")
    elif operator == '^':
        result = num1 ** num2
        print(f"The result of raising {num1} to {num2} is: {round(result,2)}")
    else: 
        print("Enter a valid operator!")
elif calc_type == "Engineering":
    calculations=input("What do you want to calculate?: Force, Density, Speed ").capitalize().strip()
    if calculations == "Force":
        mass= float(input("Enter the mass value: "))
        acceleration= float(input("Enter the acceleration value: "))
        Force = mass * acceleration
        print(f"The Force is equal to {round(Force,2)} N.")
    elif calculations == "Density":
        mass= float(input("Enter the mass value: "))
        volume= float(input("Enter the volume value: "))
        Density = mass/volume
        print(f"The Density value is {round(Density,2)} kg/m^3 ")
    elif calculations == "Speed":
        distance = float(input("Enter the distance travelled: "))
        time = float(input("Enter the time in seconds:"))
        Speed = distance/time
        print(f"The Speed is {Speed} m/s")
    else: 
        print("Enter a valid calculation type!")
else:
    print("We only offer Basic & Engineering calculations")
3 Upvotes

12 comments sorted by

2

u/ThanOneRandomGuy 9d ago

Not bad. My first project was hello world

1

u/Better_Emotion_103 9d ago

Un truc sympa également si tu as déjà abordé cette notion: utiliser des fonctions.

F=F(m, a)
d=d(m, V)
V=V(D/t)

Tu convertis cela en code et tu peux ainsi les réutiliser et rendre le code plus lisible.

1

u/isalihhh 9d ago

Im considering that!

2

u/hungry_buddy_here 9d ago

great start from your side, now make more 

1

u/stepback269 9d ago

Not bad for 2 weeks. Just keep going no matter what your learn speed is.

You have no idea what "slow" is
I'm 70+ yrs old and much much slower than you
I've been on the slow climb up that steep Dunning-Kruger mountain for more than 1.5 years now.

My advice:
As a beginner, you need to consider yourself a baby and learn to crawl (learn the "fundamentals") before you can stand up and walk or sprint. So search for the Python "fundamentals" on Google and/or YouTube.

With that said:

(1) There are tons and tons of tutorial materials out there on the net including many good YouTube ones that are free. You should shop around rather than putting all your eggs in one basket.

(2) As a relative noob myself, I've been logging my personal learning journey and adding to it on an almost-daily basis at a blog page called "Links for Python Noobs" (--HERE--) Any of the top listed ones on that page should be good for you. And there are many add-ons at the tail end of the page. Personally, I cut my first Python teeth with Nana's Zero to Hero (==HERE==). Since then, I've moved on to watching short lessons with Indently and Tech with Tim. You should sample at least a few until you find a lecturer that suits your style.

(3) The main piece of advice is the 80/20 rule. Spend 80% of your time writing your own code (using your own fingers and your own creativity) as opposed to copying recipes and only 20% watching the lectures. Good luck.

1

u/Lucky_Cable_3145 9d ago

Good start!

I suggest you look at the CASE statement, it can make code with a lot of 'else if' easier to understand.

I also suggest you look at loops next (FOR, WHILE, etc). A good exercise might be to make the calculator keep running until the user decides to quit.

1

u/Ollidav 9d ago

Create una cuenta en GitHub y aprende a usarlo (no necesitas ser un experto. Pull, push, conmit, rebase y merge te valen) y lo compartes.

1

u/sai_8303 9d ago

a first project teaches a great deal when it stays small enough to finish uses only concepts already studied, and gets shared for feedback at the end .Bootdev could help provide that kind of structured early practice though any finished project builds reall skill

1

u/Dazzling_Music_2411 8d ago edited 8d ago

Trouble with these "basic calculators" is that they are so unrealistic. I'm not sure why they use them as training projects. A real calculator will never work like that - asking you what operation you want or what number, etc... you just press the key.

So I would say that a good next step is to make your basic calculator more realistic. You will have to record every single keypress and react to that. For instance, if '+' is pressed after a number, you know that the number has already been input. You will also have to reject inappropriate keystrokes, e.g. if you are inputting a number only the first '.' is considered a decimal point, subsequent use is ignored (until you get to the next number).

To handle these sort of events, read about Finite State Machines, which is the model you need. That would be a great first project!

1

u/Additional-Depth-977 3d ago

shipping your first working project is solid progress, don’t worry about the pace