[Cheat sheet](https://perso.limsi.fr/pointal/_media/python:cours:mementopython3-english.pdf)
[Tutorial](https://www.tutorialspoint.com/python/)
# Basics
`print("Hello world ")`
## variables
### Strings
`name = "poli"` this is a string
`print(name[0])`
`print(name[0:2])`
### numbers
`age = 22` this is an integer
`price = 0.99` this is a float
`age += 1` this is the same as `age = age +1`
### list
`bands = ["rammstein", "sabaton", "amaranthe"]` this is a list
`bands.append("nightwish")`
## conditions:
```
band = "rammstein"
if band in bands:
print("Have it already")
else:
print("new band")
bands.append(band)
```
```
meal = 'pizza'
type = 'salami'
if meal == 'pizza' and type == 'salami':
print("eat")
elif meal == 'foul':
print("eat more")
else:
print("call ayham")
```
## Loops:
### for Loop
```
bands = ["rammstein", "sabaton", "amaranthe"]
for band in bands:
print(band)
```
### while loop
```
number = 0
while number <= 10:
print(number)
number += 1
```
## prime number example
```
def IsPrime(target):
listNumbers = range(2, target)
for number in listNumbers:
if (target%number) == 0:
print(str(target) + " is not a prime number")
return
print(str(target) + " is a prime number")
def AllPrimes(limit):
listNumbers = range(2, limit+1)
for number in listNumbers:
print(number)
IsPrime(number)
AllPrimes(10)
```