Cheatography
https://cheatography.com
Python CommentsExample 1 #This is a comment | Example 2 #This is a comment #written in #more than just one line | Example 3 """ This is a comment written in more than just one line """ |
Python Variables #code x = "How old are you ?" #x is of type str print(x) #output >>> How old are you ? #code x = 25 #x now is of type int print(x) #output >>> 25
|
Python Data TypesText Type: | str
| Numeric Types: | int, float, complex
| Sequence Types: | list, tuple, range
| Mapping Type: | dict
| Set Types: | set, frozenset
| Boolean Type: | bool
| Binary Types: | bytes, bytearray, memoryview
| Get the data type of a variable "var" | type(var)
|
| | Python Data Types ExamplesExample | Data Type | x = "Color"
| list
| x = 1
| int
| x = 1.2
| float
| x = 2j
| complex
| x = ["Blue","Red","Yellow"]
| list
| x = ("Blue","Red","Yellow")
| tuple
| x = range(8)
| range
| x={"Age":25,"Height":1.72}
| dict
| x = {"Pink","Red"}
| set
| x = frozenset({"Pink","Red"})
| frozenset
| x = True
| bool
| x = b"Color"
| bytes
| x = bytearray(8)
| bytearray
| x = memoryview(bytes(8))
| memoryview
| Get the data type of x : | x = "Color" print(type(x)) >>> str
|
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by Nouha_Thabet