-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exam.py
69 lines (57 loc) · 947 Bytes
/
Exam.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
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 6 13:47:12 2023
@author: Lucie
"""
#%% Exercise 1
alpha = 0.9
sigma = 1/8
teta = 4
phi = 1
sample = 1
est = 4
dev = 0.5
Time = phi*est + teta*dev
i =0
while Time > 4 :
dif = sample - est
est = alpha*est + (1-alpha)*sample
dev = dev + sigma*(abs(dif)-dev)
Time = phi*est + teta*dev
i +=1
#%%Exercise 4.1
stack = []
stack.append(5)
stack.append(3)
print(stack)
stack.pop()
print(stack)
stack.append(2)
stack.append(8)
print(stack)
stack.pop()
stack.pop()
print(stack)
stack.append(9)
stack.append(1)
print(stack)
stack.pop()
print(stack)
stack.append(7)
stack.append(6)
print(stack)
stack.pop()
stack.pop()
print(stack)
stack.append(4)
print(stack)
stack.pop()
stack.pop()
print(stack)
#%% Exercise 4.3
S = [1,2,3,4,5]
T = []
for i in range(len(S)):
T.append(S[-1])
S.pop()
print(T)