renamed files and exercise 1.2

This commit is contained in:
Tutur33
2023-11-28 22:39:24 +01:00
parent f39c57c778
commit 24dbf6099f
26 changed files with 19 additions and 6 deletions
@@ -0,0 +1,3 @@
for i in range(1,11):
for y in range(1,11):
print(i, "x", y, "=", i*y)
@@ -0,0 +1,5 @@
a = int(input("Nombre de notes ? "))
note = 0
for i in range(a):
note += float(input("-->"))
print(f"Moyenne : {note/a}")
@@ -0,0 +1,8 @@
a = input("Entrer la chaîne : ")
b = 0
for i in range(len(a)):
if a[i] == "Z" or a[i] == "z":
b += 1
print(f"Résultat : {b}")
@@ -0,0 +1,2 @@
a = input("Entrer la chaîne : ")
print("Résultat : ",a.count("z") + a.count("Z"))
@@ -0,0 +1,5 @@
import time
while True:
print("Heure courante", time.strftime("%H:%M:%S"))
time.sleep(1)
@@ -0,0 +1,16 @@
import random
nombre = random.randint(1,100)
coup = 0
a = None
print("Le jeu consiste à deviner un nombre entre 1 et 100 :")
while a != nombre:
coup += 1
a = int(input("--> "))
if a < nombre:
print("trop petit !")
elif a > nombre:
print("trop grand !")
else:
print(f"Gagné en {coup} coups !")
@@ -0,0 +1,16 @@
msg = input("Message à coder ? ")
res = ""
alph = 'abcdefghijklmnopqrstuvwxyz'
for i in msg:
if i == ' ' or i =="'":
res += i
else:
p = alph.find(i)
t = p + 3
if t > 25:
t = t - 26
res += alph[t]
print(res)
@@ -0,0 +1,16 @@
msg = input("Message à coder ? ")
res = ""
alph = 'abcdefghijklmnopqrstuvwxyz'
for i in msg:
if i == ' ' or i =="'":
res += i
else:
p = alph.find(i)
t = p - 3
if t < 0:
t = 26 + t
res += alph[t]
print(res)
@@ -0,0 +1,7 @@
u = int(input("Valeur initiale ?"))
jusque = int(input("Jusqu'à quel rang ?"))
print(0, u)
for i in range(1,jusque+1):
u = u/2 + 1/u
print(i, u)
@@ -0,0 +1,8 @@
from math import sqrt
res = 0
for i in range(1,1001):
res = 1+res/i
print(i, res)
print(1 + sqrt(5)/2)
@@ -0,0 +1,12 @@
nbr = int(input("Nombre ? "))
pre = True
for i in range(2,11):
if i != nbr:
if nbr % i == 0:
pre = False
if pre:
print("nombre premier !")
else:
print("nombre non premier !")
@@ -0,0 +1,8 @@
nbr = int(input("Nombre ? "))
nbr_pre = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
while nbr != 0:
for i in nbr_pre:
if nbr % i == 0:
nbr = nbr/i
print(i)