forked from etrubbers/thonny-data_visualization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exemple.py
77 lines (56 loc) · 1.46 KB
/
exemple.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Les données intéressantes à observer sont initialisées à partir de la ligne 28
# Pour l'import, assurez vous de l'avoir installé.
# (dans Tools -> Manage packages..., recherchez numpy et installez le)
import numpy as np
class Node:
def __init__(self, data):
self.prev = None
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def insert(self, new_node):
if self.head:
last_node = self.head
while last_node.next != None:
last_node = last_node.next
new_node.prev = last_node
last_node.next = new_node
else: self.head = new_node
# Variables builtin simples
a = 42
b = "Hello world"
lst = []
lst.append(a)
lst.append(b)
dic = {}
dic[a] = b
dic[b] = a
dic["lst"] = lst
t = (a, b)
s = {a, b, t}
# Variable d'import simples
na = np.array(lst)
# Objets créés simples
node1 = Node(a)
node2 = Node(b)
node3 = Node(lst)
# Variables builtin complexes
lst_complex = []
lst_complex.append(a)
lst_complex.append(node1)
lst_complex.append(node2)
dic_complex = {}
dic_complex[a] = node1
dic_complex[b] = node2
dic_complex["lst"] = node3
t_complex = (node1, node2)
s_complex = {node1, node2, node3}
# Variable d'import complexe
na = np.array([node1, node2, node3])
# Objet créé complexe
linked_list = LinkedList()
linked_list.insert(node1)
linked_list.insert(node2)
linked_list.insert(node3)