Introduction à Python — Cours Python

Telechargé par jemesuser userjames
16/03/2022 12:44
Introduction à Python — Cours Python
https://courspython.com/introduction-python.html
1/5
/
%
print()
range()
len()
input()
for i in [0, 1, 2]:
print("valeur :", i)
print("Fin")
16/03/2022 12:44
Introduction à Python — Cours Python
https://courspython.com/introduction-python.html
2/5
valeur : 0
valeur : 1
valeur : 2
Fin
>>>
In [1]:
In [1]: 3 * 4
Out[1]: 12
In [2]: 5 + 2
Out[2]: 7
>>> 4 + 5
>>> 3 - 7 # les espaces sont optionnels
>>> 5 + 2 * 3 # la priorité des opérations mathématiques est-elle respectée ?
>>> (6 + 3) * 2
**
>>> 5**2
/
/
from __future__ import division
>>> 7 / 2
3.5
//
>>> 7 // 2
3
%
%
16/03/2022 12:44
Introduction à Python — Cours Python
https://courspython.com/introduction-python.html
3/5
>>> 7 % 2
1
>>> 6 % 2
0
>>> a = 2
>>> a
2
>>> b = a + 3
>>> b
5
a = 2
a 2
a a a = 2
2 a
print()
print()
>>> print("bonjour")
bonjour
>>> a = 5
>>> print(a)
5
>>> a = 5
>>> print("a vaut", a)
a vaut 5
print "a vaut", a
print("a vaut", a)
print "a vaut", a,
print("a vaut", a, end=" ")
from __future__ import print_function
range()
range()
>>> range(10)
range(0, 10)
list()
>>> list(range(10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list(range(5, 10))
[5, 6, 7, 8, 9]
>>> list(range(0, 10, 3))
[0, 3, 6, 9]
>>> list(range(-10, -100, -30))
[-10, -40, -70]
16/03/2022 12:44
Introduction à Python — Cours Python
https://courspython.com/introduction-python.html
4/5
>>> a = list(range(1,10,2))
>>> a
[1, 3, 5, 7, 9]
>>> a[0]
1
>>> a[2]
5
len()
len()
>>> a = list(range(7,10))
>>> a
[7, 8, 9]
>>> len(a)
3
input()
x = int(input("Donnez un entier : "))
input() int()
n = 3
print("Je vais vous demander", n, "nombres")
for i in range(n):
x = int(input("Donnez un nombre : "))
if x > 0:
print(x, "est positif")
else:
print(x, "est négatif ou nul")
print("Fin")
for
for i in range(n):
bloc d'instructions
if
if x > 0:
print(x, "est positif")
else:
print(x, "est négatif ou nul")
if for
16/03/2022 12:44
Introduction à Python — Cours Python
https://courspython.com/introduction-python.html
5/5
if for
# Ceci est un commentaire
a = 2 # Ceci est un commentaire
1 / 5 100%

Introduction à Python — Cours Python

Telechargé par jemesuser userjames
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !