fin cours 3

This commit is contained in:
pvalarcher 2022-10-26 18:22:20 +02:00
parent a261e7597e
commit 1b77a88561
8 changed files with 86 additions and 3 deletions

View File

@ -1,8 +1,8 @@
f = open ("books.csv", "r")
max = 0
f.readline()
for row in f:
ligne = row.split(",")
for t in f:
ligne = t.split(",")
if int(ligne[0]) > max:
max = int(ligne[0])
@ -18,3 +18,4 @@ f.write(enregistrement)
f.close()

8
python/3/annee.py Normal file
View File

@ -0,0 +1,8 @@
f = open("books.csv", "r")
annee = input("Quelle année : ")
for r in f:
l = r.split(",")
if l[3] == annee+"\n":
print(str(l[1]))
f.close()

View File

@ -3,5 +3,6 @@
1, A Brief History of Time, Stephen Hawking, 1988
2, The Great Gatsby , F. Scott Fitzgerald, 1922
3, The Man Who Mistook His Wife for a Hat, Oliver Sacks, 1985
4, Pride and Prejudice , Jane Austen , 1813
10, Pride and Prejudice , Jane Austen , 1813
5, Notre dame de Paris, Victor Hugo, 1834
11, Les 3 mousquetaires, Alexandre Dumas,2022

1 Book Author Year Released
3 1 A Brief History of Time Stephen Hawking 1988
4 2 The Great Gatsby F. Scott Fitzgerald 1922
5 3 The Man Who Mistook His Wife for a Hat Oliver Sacks 1985
6 4 10 Pride and Prejudice Jane Austen 1813
7 5 Notre dame de Paris Victor Hugo 1834
8 11 Les 3 mousquetaires Alexandre Dumas 2022

4
python/3/dessin.py Normal file
View File

@ -0,0 +1,4 @@
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('des nombres')
plt.show()

13
python/3/ex31.py Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
prenom = input("Entrer votre prénom: ")
## si la longueur de prenom < 5
## alors
if len(prenom) < 5:
nom = input("Entrer le nom de famille: ")
chaine = prenom + " " + nom ## concatenation avec un espace
print(chaine.upper())
## sinon
else:
print(prenom.lower())

17
python/3/exo32.py Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python3
## entrer un entier
## si il est entre 1 et 12
## alors
## afficher la table de multiplication
## sinon
## rien
n = int(input("Entrer un entier compris enter 1 et 12: "))
if n >= 1 and n <= 12: ## 1 ≤ n ≤ 12
for i in range(1, 11): ## [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
r = i * n
print(str(i) + " * " + str(n) + " = " + str(r)) ## i * n = r

13
python/3/exo33.py Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
n = int (input("rentrer un nombre: "))
coupdavant = n
while n < 5:
coupdavant = n
n = int (input("rentrer un nombre: "))
print("Dernière valeur : ", coupdavant)

26
python/3/exo34.py Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
n1 = int(input("Entrer un entier: "))
n2 = int(input("Entrer un entier: "))
somme = n1 + n2
reponse = input("voulez vous continuer: ")
while reponse == "oui":
n3 = int(input("Entrer un entier: "))
somme = somme + n3
reponse = input("voulez vous continuer: ")
print("La somme vaut ", somme)
## autre code
#n = int(input("Entrer un entier: "))
#somme = n
#reponse = "oui"
#while reponse == "oui":
# n = int(input("Entrer un entier: "))
# somme = somme + n
# reponse = input("voulez vous continuer: ")
#print("La somme vaut ", somme)