This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# year <- saisir une année | |
# input ... | |
bonrep = False | |
while bonrep == False: | |
year = input("Date ? >") | |
try: | |
yearnew=int(year)+10 | |
print(yearnew) | |
bonrep= True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
a = 14/0 | |
print(a) | |
except Exception as error: | |
# ou : except ZeroDivisionError as error : | |
# print("Division par 0 !") | |
print("Aïe :" + str(error)) | |
# ou : print(error) | |
print("fini !") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def lancerUnDe(n): | |
d = random.randint(1,n) | |
return d | |
def lancerDeDes(nbDes,nbFaces): | |
listeDesDes = [] | |
for i in range(nbDes): | |
d = lancerUnDe(nbFaces) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dict = {1:'I', 4:'IV', 5:'V', 9:'IX', 10:'X', 40:'XL', 50:'L', 90:'XC', 100:'C', 400:'CD', 500:'D', 900:'CM', 1000:'M'} | |
def arabe(n): | |
res = "" | |
for k, v in reversed(sorted(dict.items())): | |
while n >= k: | |
n -= k | |
res += v | |
return res | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
owmapik = "7f9054c4edb12a97316c2da4d6fed6c9" | |
owm_baseurl = "http://api.openweathermap.org/data/2.5/weather?appid=7f9054c4edb12a97316c2da4d6fed6c9&units=metric" | |
def get_weather(c): | |
lat = c["ltt"] | |
long = c["lng"] | |
own_url = owm_baseurl + "&lat=" + lat + "&lon=" + long | |
own_data = requests.get(own_url).json() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bibliotheque pour executer des requetes web : | |
import requests | |
''' | |
fichier de configuration (config.py) enregistré à côté de ce fichier. il contient l'API etc. | |
Plus pratique pour se refiler du code... mais tout le monde doit utiliser la même convention | |
| |
apikey='' | |
lang='fr' | |
name='Thomas HOCEDEZ' | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int Shambhala; // le nom du bouton poussoir augmentant la luminosité | |
int Irkalla; // le nom du bouton poussoir diminuant la luminosité | |
int Chrysopee; // le nom de la led | |
byte niveau = 0; // la variable "niveau" de 0 à 255 octets | |
void setup() | |
{ | |
Shambhala = 4; // le pin du premier bouton poussoir | |
Irkalla = 2; // le pin du second bouton poussoir | |
Chrysopee = 5; // le pin de la led | |
pinMode(Shambhala, INPUT); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# exo 5 fonction qui affiche toutes les dates d'une année (jj MMM AAAA) ex : 14 JUL 2020 | |
import os | |
def bissextile(annee): | |
bissextile = False | |
if (annee % 400 == 0) or (annee % 4 ==0 and not annee % 100 ==0): | |
bissextile = True | |
return bissextile | |
def nb_jour(annee): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# exo 4 fonction pour définir le maximum entre 3 chiffres | |
x = int(input("Entrez le premier nombre : ")) | |
y = int(input("Entrez le deuxième nombre : ")) | |
z = int(input("Entrez le troisième nombre : ")) | |
def max(x,y,z): | |
if x>y and z: | |
return(x) | |
if y>x and z: | |
return(y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# exo 3 fonction de calcul de l'aire d'un cercle | |
rayon = int(input("Entrez le rayon du cercle : ")) | |
from math import* | |
def aire(rayon): | |
A=pi*rayon**2 | |
return(A) | |
print("L'aire du cercle vaut : ", aire(rayon)) |
NewerOlder