+ 3
Python : I need advices
Hi guys, I finally started coding in python. As usual, I begin coding easy apps. Here I coded the display of a pyramid using a random number between 5 and 11. I would appreciate if any of you could explain me what are my gaps and what I can do better before going further into python. Any advice including my app or general python skills are welcome. Thank you and have a good day, Sam https://code.sololearn.com/ca1pn99K2L73/?ref=app
6 ответов
+ 4
Hi sam,
When i started coding i started with python and loved it. You can write it pretty simple and it gave me a good understanding of how a programming language works. As far as i can see your code looks fine. I would recommend you to try to split up the code among different functions. That way you can start practicing oop.
Have fun!
+ 2
One little thing:
You are using 'chr' as an identifier, but it is the name of a built-in function!
You can temporarily overwrite functions like that (by 'del chr' you can 'liberate' the built-in whenever you want to), but you would probably at least want to know when you're doing this.
https://docs.python.org/3/library/functions.html
+ 2
I can't say much about you by the program, you only used the Python components from the first and the second module of SoloLearn's Python tutorial and used some importing from the third module. The most important is that the program does what it was supposed to do.
I thought that OOP is one of the hardest parts of SoloLearn's Python tutorial, if you think, that the third module is pretty clear you could go straight to the OOP, but I don't mean you should skip the modules 4, 5 and 6.
In Python, 2 useful things SoloLearn never mentioned in it's tutorial are the functions: help() and dir()
help() might offer you information from almost anything in Python such as modules, syntax and keywords.
Doesn't require the print function.
dir() gives a list of all the built-in functions and variables.
If you put for example a string in it's arguments:
dir("hello123") it will return a list of all the string methods.
After importing a module, putting the module name as dir argument returns all the module's funcs & vars.
+ 1
HonFu Indeed I didn't have a look to those built-in functions already, thank you to have noticed it, I'll keep care by now :)
0
Willem Roos Yes Willem thank you, I just started so I didn't go through functions and classes already.
Python interests me alot because I've had a quick look to "lambdas".
Thank you for your answer and I'll go through OOP asap ;)
0
Seb TheS Thanks alot, I'll go through OOP asap then and keep care of what you talked about :) it seems very useful