print("Goodby World")
Goodby World
= 11 #Without type specification
x int = 11 #With type specification y:
print(x)
print(y)
11
11
str = "WaveG"
nev: print(nev)
print(f"First character is: {nev[1]}")
print(f"Reversed: {nev[::-1]}")
WaveG
First character is: a
Reversed: GevaW
print(f"There are {y} monkeys")
There are 11 monkeys
not
and not !
or
and not |
and
and not &
True
, as False
)
type()
Is
returns True if both variables are the same
object= True
a = False
b print(a and b)
print(a or b)
print(a and b)
print(a is b)
= 1
x += 12
x print(x)
False
True
False
False
13
This is the part where the most controversial thing come in python. The indentation There aren't any curly brackets. The only thing that says wich line is in the cycle is the indentation, wich is 4 space long
for i in range(12):
print(i)
0
1
2
3
4
5
6
7
8
9
10
11
list = [1, 2, 3, 4, 5] #It's like an array we will se it later
for number in list:
print(number)
1
2
3
4
5
list = [] #It's like an array we will se it later
for number in list:
print(number)
else:
print("empty list")
empty list
= 1
i while i < 11:
print(i)
+= 1 i
1
2
3
4
5
6
7
8
9
10
list = [1, 2, 3, 4]
for number in list: #Interating through the list
print(number)
print(list)
print(list[1]) #2nd element of the list
print(list[-1]) #last element of the list
print(list[1:-1]) #2nd to last element of the list
1
2
3
4
[1, 2, 3, 4]
2
4
[2, 3]
def square1(num):
return num**2
def square(num: int) -> int:
return num**2
print(square1(2))
print(square(4))
4
16
= square
func 6) func(
36