Cheatography
https://cheatography.com
Interacting with the userprint a message | print("Hello, World!") | asking the user for a string | print("What is your name? ") |
Definitions:
strings – assigning a value to a variable
Options in PythonX = 3
If X == 3:
print("x is 3")
Number = 80
If Number >= 50:
print("Close")
Elif Number < 50:
print("Far")
Else:
print ("too far") |
| | Textsingle quoted | 'example' | double quoted | "example" | multi-line | ' ' ' Hello, | concatenating strings (adding strings together) | 'Hello' + 'World' | converting strings to integers | int('467') |
Definitions:
integers – positive or whole numbers with no decimal point
Variablescreating a variable | name = "Lisa" | using a variable | print("My name is ") + name |
Definitions:
variable – can be used to store data like integers, decimals, and characters.
Maths in Pythonaddition and subtraction | 2 + 2 - 3 | multiplication and division | 10*5/5 | Powers (e.g. x to the power of y) | 3**5 | Converting integers to strings | str(511) |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment