Professional Documents
Culture Documents
1 Python Essentials
1.1 Session N°1
27/01/2024
hello students
[1]: print("Hello All")
Hello All
Hello All,
Let's learn python
Hello World
Hello All,
Let's learn python
[10]: x = 10
print(x)
x
10
[10]: 10
[8]: x = 10.5
print(x)
1
x
10.5
[8]: 10.5
[19]: x=1
print(type(x))
type(x)
<class 'int'>
[19]: int
[21]: x=11.65
print(type(x))
type(x)
<class 'float'>
[21]: float
[25]: x="s"
print(type(x))
type(x)
<class 'str'>
[25]: str
[27]: x="same"
print(type(x))
type(x)
<class 'str'>
[27]: str
[29]: x="1"
print(type(x))
type(x)
<class 'str'>
[29]: str
[32]: x=True
print(type(x))
2
type(x)
<class 'bool'>
[32]: bool
[34]: x=False
print(type(x))
type(x)
<class 'bool'>
[34]: bool
[37]: 'youssef'
[14]: 24
[41]: 1250.544454
[21]: str(2.5)
[21]: '2.5'
3
[63]: # This is a print function
print("hello") # This is a print function
print("hello1")
# This is a print function print("hello2")
# This is a print function
# print("hello3")
#This is a print functionThis is a print functionThis is a print functionThis␣
↪is a print functionThis is a print functionThis is
"""print
lsolfqf
qsfqdf
gsdqgdaq
qghfshgq"""
print("hello1")
hello
hello1
hello1
Input In [65]
2myvar="a"
^
SyntaxError: invalid syntax
[33]: 1.2
[33]: 1.2
4
1.2 Session N°2
03/02/2024
[23]: True
[23]: True
[25]: False
[25]: False
[26]: 1 < 2
[26]: True
[28]: 1 > 2
[28]: False
[34]: 1 <= 2
[34]: True
[37]: 1 >= 2
[37]: False
[39]: 1 == 2
[39]: False
[41]: 2 == 2
[41]: True
[43]: 1 != 2
[43]: True
[49]: 1 != 1
[49]: False
[50]: False
5
[51]: "hello" == "hello"
[51]: True
[57]: x = 10
if x > 10: # Si
print("X > 10")
elif x==5: # Sinon Si
print("X == 5")
else: # Sinon
print("X < 10")
X < 10
[64]: age = 25
if age < 18:
print("Mineur")
else:
if age < 65:
print("Adulte")
else:
print("Senior Citizen")
Adulte
[66]: age = 25
if age < 18:
print("Mineur")
elif age < 65:
print("Adulte")
else:
print("Senior Citizen")
Adulte
[68]: False
[70]: True
[72]: False
6
[74]: age =25
age < 5
[74]: False
[76]: True
[80]: False
[82]: True
[83]: True
[84]: True
[86]: False
[88]: a = True
b= False
if a and b:
print("Both a and b are true")
else:
print("at least a or b are true")
[90]: False
[92]: True
7
[93]: x = 10
y = 3
[95]: x+y
[95]: 13
[96]: x-y
[96]: 7
[98]: x/y
[98]: 3.3333333333333335
[100]: x//y
[100]: 3
[101]: x*y
[101]: 30
[102]: x**y
[102]: 1000
[105]: 10%2
[105]: 0
[109]: 2.0
[111]: result/=2
result
[111]: 0.5
[112]: result+=1
result
[112]: 1.5
8
[120]: result/=2 # result = result/2
result*=4 # result = result * 4
[122]: print(1)
print(2)
print(3)
print(4)
1
2
3
4
Hello
Hello
Hello
Hello
Hello
Hello
[130]: count = 1
while count <=5:
print(count)
count+=1
1
2
3
4
5
[ ]: