This file contains 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
def convert_ip_to_list(ip): | |
""" | |
entrée : ip (string) | |
sortie : liste d'entiers | |
""" | |
# à vous | |
def test_convert_ip_to_list(): | |
assert convert_ip_to_list('192.168.0.1') == [192, 168, 0, 1] | |
This file contains 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
def sousreseau(IPA, IPB, masque): | |
""" | |
IPA : "192.168.0.1" string contenant une IP | |
IPB : "192.168.0.5" string contenant une IP | |
masque : 24 entier du masque en notation CIDR | |
renvoie un booléen si IPA et IPB sont dans | |
le même sous-réseau | |
""" | |
l_ipa = IPA.split('.') |
This file contains 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
class Pile: | |
def __init__(self): | |
self.data = [] | |
def est_vide(self): | |
return len(self.data) == 0 | |
def empile(self,x): | |
self.data.append(x) |
This file contains 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
from microbit import * | |
from random import randint | |
a = randint(0,4) | |
b = randint(0,4) | |
chrono = running_time() | |
display.set_pixel(a,b,9) |
This file contains 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
from microbit import * | |
display.clear() | |
while True: | |
if button_a.was_pressed(): | |
display.show(Image.SAD) | |
if button_b.was_pressed(): | |
display.show(Image.HAPPY) |
This file contains 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
# code réalisé par Léo Capes TNSI | |
import pygame, sys | |
import time | |
from pygame.locals import * | |
from random import randint | |
clock = pygame.time.Clock() | |
FPS = 30 |
This file contains 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
def fibo_imperatif(n): | |
a = 0 | |
b = 1 | |
for k in range(n-1): | |
t = b | |
b = a + b | |
a = t | |
return b |
This file contains 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
def fibo(n): | |
if n == 0 : | |
return 0 | |
elif n == 1 : | |
return 1 | |
else : | |
return fibo(n-1) + fibo(n-2) |
This file contains 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
def factorielle_imp(n): | |
p = 1 | |
for k in range(1,n+1): | |
p = p * k | |
return p | |
def factorielle_rec(n): | |
if n == 1 : | |
return 1 | |
else : |
This file contains 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
#------------- Question 1 | |
class Point : | |
def __init__(self,x,y): | |
self.x = x | |
self.y = y | |
def distance(self) : | |
return (self.x**2+self.y**2)**0.5 | |
A = Point(3,5) |
NewerOlder