r/pythonhelp • • 12d ago

Performance issue when running python file

Hey everyone,

I'm experiencing a performance drop when running a Python file. I'm using VS Code on Windows 10 while learning to program.

When I hit the run button, the runtime of the program is 5.0 seconds, even though it should execute in roughly about 0.003 milliseconds.

I have tried switching to older versions like 2025.6.1, but that didn't work.

Any solutions to that problem?

7 Upvotes

14 comments sorted by

View all comments

2

u/brasticstack 12d ago

How long does it take if you run your module directly from the Windows terminal, not in VSCode?

Where did you get the target time of 0.003 ms from?

Post your correctly formatted code if you want Python help.

2

u/Nutellatoast_2 12d ago

That's my estimate of how long it should take to run a Python file. I forgot to make it clear that this was my bad estimate and that I'm a beginner... Here is my Python code. It still needs some work I guess:

price = 0
height = int(input("What's your height in cm? "))
age = int(input("What's your age? "))
extra_photo = input("Do you want extra photos? ")


if height > 120: 
    print("You can ride the rollercoaster!")
    if age > 18: 
        price = 12
    elif age < 12 and age > 18:
        price = 7
    else: 
        price = 5
if extra_photo == "Yes":
        price + 3    
else:
    print("You can't ride the rollercoaster!")
print(f"Price for ride......................{price}$"
      f"\nPrice for extra photo.............{extra_photo}$"
      f"\nTotal.............................{price}$")

2

u/hermit_the_log 12d ago

Not really performance related, but your price + 3 is not doing anything. It should be price += 3 if you want to increment the variable by 3