Python Courses
Python Courses
Python Courses
2- print(" /|")
print(" / |")
print(" / |")
print("/___|")
resultat un triangle
3-variables:
print("there was a boy called adel")
print("he was 85 years old")
print("he liked his name adel")
print("but wasn't happy about being 85")
lorsque tu as beaucoup de ligne c fatiguant de changer le nom,age,.. donc ndiro
character_name = "sidahmed" ex:
character_name = sid
print("there was a boy called " +character_name+ " sid")
print("he was 19 years old")
print("he liked his name " +character_name)
pour que les phrases ne seront pas coller on fait un espace hna:
"espace+ch.. ET MEME DANS CE CAS : ..name+ESPACE"espace...
-boolean hwese 3liha !
4- strings :
-print("code\nzilla") ki dir \n t3tik partie lwele f stere ou deuxieme partie fi
stere
-print("code\"zilla") resultat -> code"zilla
-print("code\tzilla") \t dirlk espace 4 FOIS entre les deux parties
-text = "SIdAhmed"
print(text.lower()) ymdlk text t3k minuscule
print(text.upper()) ymdlk text majuscule
print(text.islower())) y9olk wela text t3k raho minuscule wela non ou yjwebe b true
or false
print(text.isupper()) kifkif brk ychof wela raho majuscule
print(text.lower().islower()) hedi yrdlk text t3k minuscule oumb3D YCHOFLK WELA
RAHO MINUSCULE LA MEME CHOSE POUR (upper)
print(len(text)) hedi ychoflk text t3k ch7L fih mn lettre ex : CODEZILLA FIHA 9
print(text[0]) y3tilk ama lettre raho lwele ,f linformatique calcul ybda b 0 1
2 ....
print(text.index("lettre")) y3tik rang t33 HED LETTRE WELA LETTRE HEDI MTEXISTICHE
YKHROJLK ERREUR
print(text.replace("7eja","b 7eja"))
5- numbers :
print(10%3) resultat 1 psq % y3tik le reste
my_num = 5
print(str(my_num)+" my favorite number")
resultat: 5 my favorite number
my_num = -5
print(abs(my_num)) ymdna la valeur absolue t3 num
print(pow(3,2)) ymdlk 3^2 ou li hiya 9
print(min(3,5)) tmdlk la valeur minimale kima hna 3
print(max(3,5)) tmdlk 5
print(round(3.2)) tmdlk 3
print(round(3.7)) tmdlk 4
7- build calculator:
num1 = input("enter the first no: ")
num2 = input("enter the second no: ")
result = num1+num2
print(result) oumb3d dkhl les numbers z3ma lwele 10 ou deuxieme 5 YMDLK 105
WELA 7EBINA YMDNA LA SOMME NDIRO result = int(num1)+int(num2)
zid b int( mn9droche ndkhlo numero b virgule donc hna nkhdmo b float(num1)+....
9- listes
freinds = ["example", "sideh", "python", "leroy"]
print(freinds[2])
ymdlk python , wela drna z3ma print(freinds[-1]) ymdlk leroy chghol ybda mla fin
wela drna print(freinds[0:3]) ymdna klma lwela ou deuxieme ou troisieme mais
qaurtieme mydkhlhche
codezilla.sort()
print(codezilla)
yktblk wsh 3ndk 3LA 7SEB L'ALPHABET
wela 3ndk des numeros ytrblk msghir lkbire
list_news = codezilla
codezilla.append(1)
print(list_new)
print(codezilla)
resultat
['python', ....., '1'] ...1
['python.............]
BSA7 WELA DERNA
list_new = codezilla.copy() mtkhrojnche 1 FLWELA
11- tuples :
coordinates = (23, 45)
print(coordinates[1]) tkhrojlk 45 BRK
12-functions :
def say_hi():
print("hello user")
print("first")
say_hi()
print("second")
resultat: first
hello user
second
say_hi("mahmoud", "35")
def cube(num):
return(num*num*num)
print(cube(3)) resultat : 27
13- conditionals :
is_hungry = True
if is_hungry == true: n9dro ndiro if is_hungry:
print("go eat")
else:
print("do not eat")
is_hungry = True
wants_to_eat = True
if is_hungry or wants_to_eat:
print("go eat")
else:
print("do not eat")
is_hungry = true
wants_to_eat = True
if is_hungry and wants_to_eat:
print("go eat")
else:
print("do not eat")
is_hungry = True
wants_to_eat = False
if is_hungry and wants_to_eat:
print("go eat")
elif is_hungry and not wants_to_eat:
print("eat so u can survive")
elif not is_hungry and wants_to_eat:
print("do not eat u are not hungry")
else:
print("do not eat")
14- comparisons :
match_string("codezilla", "islam")
resultat : th strings do not match
15-calculator 2 :
num1 = float(input("please enter the first number"))
operator = input("please enter the operator")
num2 = float(input("please enter the second number"))
if operator == "+":
print(num1 + num2)
elif operator == "-":
print(num1 - num2)
elif operator == "/":
print(num1 / num2)
else:
print("wrong operator please try again")
16- dictionaires :
convert_math = {}
"jan": "january",
"feb": "febraury",
"mar":"march"
print(convert_math["mar"]) ou print(convert_month.get("mar"))
resultat : march
i=1
while i <= 10
print(i)
i += 1
else:
print("the condition is not true")
print("the loop has ended")
i = 1
while i <=10 :
i += 1
if i == 6:
continue
print(i)
resultat : ykhrjo men 2 HTA 11 APART 6
9LBNA PRINT(i) c pour ca khrjt lkhra
i = 1
while i <= 10:
i+= 1
print(i)
if i == 6:
break
print(i)
print("the loop has ended")
resultat: mn 2 HTA 5 PSQ HBSNA PROGRAMME