Comments in python
Useful commands
Python Variables
There are also list, tuples and dictionaries. To see what are the types of the variables we are working with:
Guidelines: - Use descriptive names. - Be consistent. - Keep length in check. You can't use spaces not dots (.) when defining names Values
Mathematical operations
There also exist a library called to make other kind of mathematical operationsWe can use this with numbers and booleans |
String methods
Conditions
Functions
When using functions you can use the command you want for the result, but is better using return instead of print because you can assign the result to a variable |
Booleans
Conditionals
The form of arrange is important, while you are under a condition you have to write inside it While Loops:
In this kind of loops, while the condition is still true, it continues happening. Helping in While Loops:
Both of them are useful to avoid infinite loops For Loops
A for loop is a control flow statement for specifying iteration, which allows code to be executed repeatedly. Library random
For using the library you have to import it:
Then, for using it, you need to say that you are going to look for the function in the library. If you want to avoid it you can import just one function from the library. Helping in For Loops:
These commands continue and break are useful to avoid infinite loops |
Cheatography
https://cheatography.com
Python Basics Cheat Sheet (DRAFT) by MacaSalva
Beginners guide for Python
This is a draft cheat sheet. It is a work in progress and is not finished yet.