a = 5
type(a)
b = 110.2
type(b)
c = 'bonjour' #chaine de caracteres (string)
type(c)
d = [5,4,8,9] # liste (tableau)
type(d)
e = ( 5 == 4+1 ) # booleen
print(e)
type(e)
print(not e) # negation
print( (4 <= 5) or (4 > 7)) # ou
print( (4 <= 5) and (4 > 7)) # et
int convertit la saisie en un entier (sinon la saisie est une chaine).
age = int(input('Saisir votre âge : '))
if age < 18:
print('Tu es mineur')
else:
print('Vous êtes majeur')
k = 0
while k < 5:
print(k)
k = k+1
print('fin')
for i in range(5):
print(i)
L1 = [] # liste vide
L2 = [0]*4
L3 = [4, 500, 8, 10]
L4 = [[1,2,300,4] , [5,6,7,8]]
print(L1)
print(L2)
print(L3[1])
print(len(L3))
print(len(L4))
print(L4[0][2])
def f(x):
return x+10
f(7)
def g(a,b):
if a>b :
return a
else:
return b
g(4,7)
4 + 3*10
2**10 # puissance
5/3 # division
5//3 #division entiere (quotient de la division euclienne de 5 par 3)
5 % 3 #reste de la division euclidienne de 5 par 3
from math import sqrt #racine carree
sqrt(2)
from math import floor #partie entière
floor(2.35)