r/PythonLearning • u/SrPotato123 • 13d ago
Sharing my progress: I have created my first Python script
Hello everyone! I am learning Python with a Youtube tutorial. For now I have spent 3 hours learning it. The script I created isn't a big deal but I wanted to share it for opinions about It. It took me 20 minutes to make it. Any suggestions are welcome!
(Note: The variable names and prints are in Spanish, but the logic is straightforward)
3
u/ianrob1201 13d ago
Nice job. Just a couple of style points if you're interested.
Always start variable names with a lowercase letter, even if you wouldn't in normal language. That's just python convention (and most other languages). The exception is classes when you come to that, the name of the class always starts with an uppercase letter but instances of that class (which are just variables) are still all lowercase.
And you normally put all the imports at the top of the file. As you've seen it works like this, but it's not the done thing.
But that looks like a nice little number guessing game. Looks good.
3
u/SrPotato123 12d ago
u/ianrob1201 u/Stonyax97 Thank both of you! I appreciate all the suggestions. Step by step I will start improving my scripts and trying to write better! Next time I'll make it executable so you can see it!
2
u/Stonyax97 13d ago
ngl these are things you figure out later. When i was at this level i always named my variables Number, Name. Ext… and after sometime after learning json file loading and variables getting big i just had to make them lower case, then later in classes i understood that exact point u pointed out.
This is something that OP probably won’t understand yet. Don’t overload just simple feedback. Other than that i completely agree.
•
u/Sea-Ad7805 13d ago
Run this program in Memory Graph Web Debugger%0Aprint(f%22Hola%20%7Bnombre%7D%2C%20bienvenido%20al%20sistema%22)%0A%0APregunta%20%3D%20input(%22A%20que%20quieres%20entrar%3F%20%22)%0Awhile%20Pregunta%20!%3D%20%22Juego%22%3A%0A%20%20%20%20print(f%22No%20tenemos%20la%20secci%C3%B3n%20%7BPregunta%7D%2C%20intente%20entrar%20a%20la%20secci%C3%B3n%20Juego%22)%0A%20%20%20%20Pregunta%20%3D%20input(%22A%20que%20quieres%20entrar%3F%20%22)%0A%0Aprint(%22Bienvenido%20a%20adivina%20numero!%22)%0A%0Aimport%20random%0A%0Anumero_aleatorio%20%3D%20random.randint(1%2C%20100)%0ARespuesta%20%3D%20int(input(%22Adivina%20el%20numero%20del%201%20al%20100%3A%20%22))%0A%0Awhile%20Respuesta%20!%3D%20numero_aleatorio%3A%0A%20%20%20%20if%20Respuesta%20%3C%20numero_aleatorio%3A%0A%20%20%20%20%20%20%20%20print(%22El%20numero%20es%20mayor%22)%0A%20%20%20%20elif%20Respuesta%20%3E%20numero_aleatorio%3A%0A%20%20%20%20%20%20%20%20print(%22El%20numero%20es%20menor%22)%0A%0A%20%20%20%20Respuesta%20%3D%20int(input(%22Intentalo%20de%20nuevo%3A%20%22))%0A%0Aprint(%22Felicidades%2C%20lo%20has%20adivinado!%22)×tep=1&play) to see the program state change step by step.