Académique Documents
Professionnel Documents
Culture Documents
import math
i = -90
while i <= 90:
if i == 0:
print("\033[91m sin(0)/0 est indéfinie !!!!\033[0m")
else:
print("sin(",i,")/",i,"=",math.sin(math.radians(i)) / i)
i = i + 10
#Exercice 5
import os
try:
x = int(input("premier nombre :"))
y = int(input("deuxième nombre:"))
except ValueError:
print("saisie invalide ")
#Exercice 6
import os
try:
x = int(input("nombre :"))
except ValueError:
print("Saisie invalide")
i=0
for i in range(x+1, x + 6):
print(i)
nombre :1
2
3
4
5
6
#Exercice 7
import os
try:
x = int(input("le nombre d'heures travaillées :"))
y = int(input("montant par heure :"))
except ValueError:
print("Saisie invalide")
if x <= 39:
print("Pas d'heures supplémentaires.")
else:
if x in range(39,45):
print("prime =", (x-40)* 0.5 * y )
else:
if x in range(44,50):
print("prime =", (x-45)* 0.75 * y )
else:
if x >49:
print("prime =", (x-49)* y )
i = 0
r = 1
if x == 0:
print("Le factoriel de 0 est 1")
else:
for i in range(1, x + 1):
r *= i
r = 1
while x >0:
r*=x
x-=1
#Exercice 10
liste = ["qwerty", "azerty", "python", "td-1-python"]
liste2 = []
for i in liste:
longueur = len(i)
msg = i + " est de longueur " + str(longueur)
liste2.append(msg)
print(liste2)
['qwerty est de longueur 6', 'azerty est de longueur 6', 'python est
de longueur 6', 'td-1-python est de longueur 11']