tableau python code example
Example 1: python table
# There's an error on the second code, so i fixed it
from tabulate import tabulate
from math import sqrt
def mysqrt(a):
for x in range(1, int(1 / 2 * a)):
while True:
y = (x + a / x) / 2
if y == x:
break
x = y
return x
results = [(x, mysqrt(x), sqrt(x)) for x in range(10, 20)]
print(tabulate(results, headers=["num", "mysqrt", "sqrt"]))
Example 2: python tableau
l=10*[0]
print(l)
for i in range(len(l)):
l[i]=10*[0]
print(l)
l[0][0]=1
print(l)
l[0][1]=2
print(l)
Example 3: python tableau
>>> liste = list(range(1, 21))# créer la liste des entiers de 1 à 20 inclus
>>> print([i for i in liste if i % 3 == 0])# afficher les éléments de 'liste' qui sont multiples de 3
[3, 6, 9, 12, 15, 18]
Example 4: python tableau
l = [[0 for i in range(10)] for i in range(10)]