TP Python

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

TP 1 :

name = (input('your name :'))

height = int(input('your height :'))

weight = int(input('your wheight :'))

def function(name,height,weight):

bmi = weight / height ** 2

print("bmi :")

print(bmi)

if bmi < 25:

print(name + " is not overweight")

else:

print(name + " is overweight")

TP 2 :
name = (input('your name :'))

age = int(input('your name :'))

def function(name, age):

if age > 60:

print(name + " is an old person ")

elif age < 15:

print(name + ' is a child')

else:

print(name + "is an adult")


TP 3 :
a = int(input("entre votre age"))

if a == 1:

print('la personne a', a ,'an')

else:

print('la personne a', a ,'ans')

TP 4 :
a = float(input("entre la valeur de a "))

b = float(input("entre la valeur de b "))

c = float(input("entre la valeur de c"))

delta = b**2 - 4*a*c

if delta > 0:

x1 = (-b - delta ** 0.5) / (2 * a)

x2 = (-b + delta ** 0.5) / (2 * a)

print("Les solutions : x1 = ", x1, " x2 = ", x2)

else:

if delta == 0:

x = -b / (2. * a)

print("La solution est x = ", x)

else:

print("L'équation n'a pas de solution")


TP 5 :
a = int(input("write the first number"))

b = int(input("write the second number"))

if a * b < 0:

print("negative number")

elif a * b > 0:

print("positive number")

else:

print("zero")

TP 6 :
s = int(input('the water temperature is :'))

if s > 100:

print(" gas")

elif 0 < s <= 100:

print(" liquid")

else:

print(" solid ice")

You might also like