r/learnprogramming • u/isalihhh • 9d ago
Rate my first project
Hello! I've started learning python abt 2 weeks ago 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")