Need help coding with Python (edited)

Ask questions about projects relating to: aerodynamics or hydrodynamics, astronomy, chemistry, electricity, electronics, physics, or engineering.

Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators

Post Reply
emeryt123
Posts: 2
Joined: Tue Sep 08, 2026 10:33 am
Occupation: Student

Need help coding with Python (edited)

Post by emeryt123 »

Hello,
I am working on a science fair project on how long it takes for a computer program/code to decipher a password from one of the project ideas here. The first step is to download Python, however, when I do that, I can see the file, but not the other file to where I can actually build my code. How can I do this?

-Emery
(Edit: Turns out I cannot run Python on my school computer, so I am using W3Schools instead... hopefully that works🤞)

Moderator note: Science Buddies project link: https://www.sciencebuddies.org/science- ... -be-hacked
ameyab19
Student Expert
Posts: 10
Joined: Tue Feb 24, 2026 6:07 pm
Occupation: Student

Re: Need help coding with Python (edited)

Post by ameyab19 »

Hi,

Sounds like a great idea to use W3Schools to work around the Python issue. Since WS3Schols is web-based, you could also try saving your code on a separate document before closing the tab so you don't lose your progress.

Good luck on your project!

- AB
emeryt123
Posts: 2
Joined: Tue Sep 08, 2026 10:33 am
Occupation: Student

Re: Need help coding with Python (edited)

Post by emeryt123 »

Thanks for the advice. Unfortunately, I have had to move once again, this time to OneComplier.
I actually got my code down this time, but the current issue is that I can only do so many digits for my code to guess before it says "CPU time limit exceeded", which I know is from the actual website not being able to compute all the data.

Any advice for being able to guess more complex codes?
Here is the current code. (I don't know how to paste a screenshot.)

import itertools
import string
import time


target = ""

charset = string.ascii_letters + string.digits + string.punctuation

print(f"Testing target password: '{target}'")
print("Starting search...")

start_time = time.perf_counter()

attempts = 0
found = False

target_length = len(target)
for combination in itertools.product(charset, repeat=target_length):
attempts += 1
guess = "".join(combination)

if guess == target:
found = True
print("Password found!")
break

end_time = time.perf_counter()
elapsed_seconds = end_time - start_time

if found:
print(f"\nPassword: '{guess}'")
print(f"Total attempts: {attempts:,}")
print(f"Elapsed Time: {elapsed_seconds:.6f} seconds")
print("Try another?")
Post Reply

Return to “Grades 6-8: Physical Science”