Skip to content

Commit 761f81c

Browse files
committed
Update Assignment_6.ipynb
1 parent 958bf26 commit 761f81c

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

Assignments/EN/Assignment_6.ipynb

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"\n",
1111
"# Practical Machine Learning for Natural Language Processing - 2023 SS \n",
1212
"\n",
13-
"### Assigment 2 - \"Classic\" Python \n",
13+
"### Assigment 2 - Generators and Classes \n",
1414
"\n",
15-
"This assigment is an adaptation for Python of the original exercise [\"Unix for Poets\"](https://www.cs.upc.edu/~padro/Unixforpoets.pdf)"
15+
"In this assigment we are going to play with generators and instances/classes - structures that retain state. "
1616
]
1717
},
1818
{
@@ -26,13 +26,15 @@
2626
"cell_type": "markdown",
2727
"metadata": {},
2828
"source": [
29-
"### 1. Generator Functions \n",
29+
"### 1. Alea Iacta Est \n",
3030
"\n",
31-
"(a) Using [generator functions](https://github.com/rsouza/Python_Course/blob/master/Notebooks/Python_Basic/03_Functions.ipynb), create an object that emulates an eight-sided die (1-8) that is biased, such that the probability of this generator function returning a certain value is proportional to the value itself (for example, the face \"6\" is 3 times more likely to come out than face \"2\"); \n",
31+
"(a) Using [generator functions](https://github.com/rsouza/Python_Course/blob/master/Notebooks/Python_Basic/03_Functions.ipynb), create an object that emulates an eight-sided dice (1-8) that is biased, such that the probability of this generator function returning a certain value is proportional to the value itself (i.e. the face \"6\" is 3 times more likely to come out than face \"2\"); \n",
3232
"\n",
33-
"(b) Using the plt.plot or plt.hist commands, graphically show the result of 10000 plots; \n",
33+
" <img src=\"https://cdn11.bigcommerce.com/s-70184/images/stencil/608x608/products/532/7428/d8-dice-blue__64321.1664335674.jpg\" alt=\"8-Dice\" style=\"width:250px;height:300px;\"> \n",
3434
"\n",
35-
"(c) Modify this generator function so that it terminates automatically when all possible values (1,2,3,4,5,6,7,8) have been returned at least once. In this case, it will return the total absolute time that has occurred since the first iteration. "
35+
"(b) Using [Matplotlib](https://matplotlib.org/) plt.plot or plt.hist commands, show graphically the result of 10000 casts of the die; \n",
36+
"\n",
37+
"(c) Modify this generator function so that it terminates automatically when all possible values (1,2,3,4,5,6,7,8) have been cast at least once. In this case, it will return the total absolute time that has elapsed since the first iteration. (hint: a function can have both **return** and **yield** commands) "
3638
]
3739
},
3840
{
@@ -63,47 +65,47 @@
6365
]
6466
},
6567
{
66-
"cell_type": "code",
67-
"execution_count": null,
68+
"cell_type": "markdown",
6869
"metadata": {},
69-
"outputs": [],
7070
"source": [
71-
"Questão 4 (3.0 pontos)\n",
71+
"### 2. A ticket to the first Class \n",
7272
"\n",
73-
"Crie uma classe chamada \"Elevador\" que recebe, ao instanciada, o número de andares do edifício e inicia no andar mais baixo.\n",
74-
"Crie métodos e propriedades para permitir que o elevador:\n",
75-
"\n",
76-
" Receba uma chamada (usuário aperta um botão em um andar);\n",
77-
" Receba um andar como destino (usuários apertam botões dentro do elevador);\n",
78-
" Informe em qual andar o elevador está;\n",
79-
" Informe a sequência de andares ainda por visitar;\n",
80-
" Informe a quantidade de vezes que parou em cada andar (passar pelo andar sem \"parar\" no andar não conta);\n",
81-
"\n",
82-
"Leve em consideração que cada deslocamento de andar demora 3 segundos.\n",
83-
"Simule o comportamento do elevador atendendo à dez usuários, que têm andar de origem, andar de destino e sequência de chegada (fora e dentro do elevador) definidos aleatóriamente.\n"
73+
"+ Create a Class called \"Elevator\". Each instance of this class receives as parameters the number of floors in the building and starts the elevator on the lowest floor. \n",
74+
"+ This Class should have methods and properties to allow the elevator to:\n",
75+
"<br></br>\n",
76+
" + Receive a call - user(s) press a button to go to specific floor(s); \n",
77+
" + Receive a floor as a destination - when users enter the elevator, each one may press a button to choose destination floor; \n",
78+
" + Store and inform which floor the elevator is at each moment(consider that trips for consecutive floors takes 5 seconds, and stopping takes 10 seconds); \n",
79+
" + Store and inform which users are in the elevator; \n",
80+
" + Store and inform the sequence of floors yet to be visited; \n",
81+
" + Store the number of times the elevator stopped in each floor (passing through the floor without \"stopping\" on the floor does not count); \n",
82+
" + Refuses commands to go to inexistent floors. \n",
83+
"<br></br>\n",
84+
"+ Simulate the behavior of the elevator serving ten users, each one calling from a random floor, and chosing a random destination floor. \n",
85+
"+ Graphically illustrate the current elevator position for the requested simulation. \n",
86+
"+ (BONUS) Create a smart building simulator, controlling calls made to n > 1 elevators and routing elevator properly. "
8487
]
8588
},
8689
{
8790
"cell_type": "code",
8891
"execution_count": null,
8992
"metadata": {},
9093
"outputs": [],
91-
"source": [
92-
"Questão bônus I (0.5 ponto)\n",
93-
"\n",
94-
"Ilustre graficamente as posições do elevador acima para a simulação pedida:\n"
95-
]
94+
"source": []
9695
},
9796
{
9897
"cell_type": "code",
9998
"execution_count": null,
10099
"metadata": {},
101100
"outputs": [],
102-
"source": [
103-
"Questão bônus II (0.5 ponto) \n",
104-
"\n",
105-
"Crie um simulador de prédio inteligente, controlando chamadas feitas para n > 1 elevadores: "
106-
]
101+
"source": []
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"metadata": {},
107+
"outputs": [],
108+
"source": []
107109
}
108110
],
109111
"metadata": {

0 commit comments

Comments
 (0)