Commit 9b3bd08f authored by Swicech's avatar Swicech
Browse files

upload assignment 9

parent bf008f16
%% Cell type:markdown id: tags:
# Admission limits
**Learning goals:**
* Read from files
* Dictionaries
**Starting Out with Python:**
* Chapt. 6: Files and Exceptions
* Chapt. 9.1 Dictionaries
In this assignment are we going to read a file with admission limits from Samordna Opptak (Admission office).
The files is in a CSV-format (Comma Separated Values), wich means that each line is a list of fields separated by a comma. Text fields are enclosed by quotation marks (").
* The first field is the name of the study
* The second field is the admission limit (either a number or "Alle" (means everyone in norwegian) if everyone got in)
For example the line **"NTNU 194459 Antikkens kultur","Alle"** says that everyone that applied got in at the Dragvoll-study "Antikkens kultur" at NTNU.
Each function in the following tasks use data from the file **poenggrenser_2011.csv** as input. Because of this is it very practical to save the content in a variable, so you don't have to read the file again every time.
%% Cell type:markdown id: tags:
### a)
%% Cell type:markdown id: tags:
Read from the file `poenggrenser_2011.csv` and save the content in a varable.
***Write your code below.***
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
### b)
%% Cell type:markdown id: tags:
Write a function that calculates how many studies accepted all the applicants.
***Remember that you can use the varable you defined in task a) as long as you have run the code snippet first!***
*Exampel run:*
```python
Amount of studies where everyone was accepted: 590
```
***Write your code in the codeblock below.***
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
### b)
%% Cell type:markdown id: tags:
Write a function that finds an average admission limit for NTNU. Don't use the studies that accepted everyone in your calculation.
*Exampel run:*
```python
Average admission limit for NTNU was: 46.29
```
***Write your code in the codeblock below.***
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
#### Hint
%% Cell type:markdown id: tags:
To check if the study was at NTNU can you get the four first letters at each line. if you have a string study kan you do this by writing: study[1:5]
%% Cell type:markdown id: tags:
### c)
%% Cell type:markdown id: tags:
Write a function that finds the lowest admission limit (that did NOT take in all the applicants).
*Example run:*
```python
The study with the lowest admission limit was: AHO 189343 Industridesign
```
***Write your code in the box below.***
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
### d)
%% Cell type:markdown id: tags:
Create a dictionary with the study-place as a key and a list of dictionaries as value. This list of dictionaries should have the name of the study as key and the corresponding admission limit as value. If a study has the name "Fysikk og Matematikk" do you only need to use the first word "Fysikk".
**Example print-out:**
```python
ATH [{'Kristendom': ' Alle'}, {'Interkulturell': ' Alle'}, {'Musikk': ' Alle'}, {'Teologi': ' Alle'}, {'Kristendom': ' Alle'}, {'Psykologi': ' Alle'}, {'Musikk': ' Alle'}, {'Interkulturell': ' Alle'}, {'Psykologi': ' Alle'}, {'Praktisk': ' Alle'}]
AHO [{'Arkitekt': '12.3'}, {'Industridesign': '11.7'}]
BDH [{'Sykepleierutdanning': '45.5'}]
MF [{'Kristendom/RLE': ' Alle'}, {'Samfunnsfag': ' Alle'}, {'Interkulturell': ' Alle'}, {'Teologi': ' Alle'}, {'Religion': ' Alle'}, {'Ungdom': ' Alle'}, {'Lektor-': ' Alle'}, {'Teologi': ' Alle'}]
DHS [{'Sykepleierutdanning': '48.3'}, {'Vernepleierutdanning': '41.8'}, {'Sosialt': '49.1'}, {'Sosialt': '42.4'}, {'Ergoterapeututdanning': '32.6'}]
DMMH [{'Førskolelærerutdanning': '36.3'}, {'Førskolelærer': '39.1'}, {'Førskolelærer': '44'}, {'Førskolelærer': '46.2'}, {'Førskolelærer': ' Alle'}]
.
.
.
UIT [{'Ingeniør': ' Alle'}, {'Ingeniør': ' Alle'}, {'Ingeniør': ' Alle'}, {'Ingeniør': ' Alle'}, {'Sykepleierutdanning': '43.8'}, {'Lærerutdanning': ' Alle'}, {'Lærerutdanning': ' Alle'}, {'Førskolelærerutdanning': ' Alle'}, ....
```
***Write your code below.***
%% Cell type:code id: tags:
``` python
```