---
# System prepended metadata

title: Week 6 - Dictionaries

---

# Week 6 - Dictionaries

## Team

Team name: Group 1
Date: 2/4/2021

Members: Stephen van Rumpt, Lucas Lalande, Hlib Hryshko

| Role                                                                                                                                                                          | Name |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
| **Facilitator** keeps track of time, assigns tasks and makes sure all the group members are heard and that decisions are agreed upon.                                             |      |
| **Spokesperson** communicates group’s questions and problems to the teacher and talks to other teams; presents the group’s findings.                                              |      |
| **Reflector** observes and assesses the interactions and performance among team members. Provides positive feedback and intervenes with suggestions to improve groups’ processes. |      |
| **Recorder** guides consensus building in the group by recording answers to questions. Collects important information and data.                                                   |      |

## Activities

### Activity 1: count letters in a string

...

### Activity 2: recognizing languages

...

### Activity 3: Find out: dictionaries around us

- Retail Store Database, In every database of a retail company (ex. Nike) there will be an existing database which contains all kinds of information, may it be if the item is in stock or if the item has enough stock of a specific size.

- Lottery, Every lottery has people writing down their personal information so when the hosts draw the winner they can easily find the person who won. Furthermore, there is always some sort of code or number on a ticket that can be traced.

- Stock history, Every company in the stock market has a database which records the prices of said stock throughout the day. This is a way to keep track of how your company is doing.

- Websites (with memberships), Everything with memberships require a password (and a username) to access whatever is offered. To do this, the user must first enter their credentials into a terminal. When the user inputs the information, the terminal enters the database to see if there are any matches; If there are none, then the user is denied access.

- Security Companies, Whenever there is a sign of trespassing on some terrain that said company is responsible for, the alarm system will log the event which is occuring at that moment. This is useful for many things (ex. tracking down criminals).


### Activity 4: Find out: dictionaries in other languages

- **C++ : Map**
- **Python : Dictionary**
-Definition
``` python =
thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
```
-Adding
``` python =
thisdict["color"] = "red"
print(thisdict)
```
-Remove
``` python =
thisdict.pop("model")
print(thisdict)
```
-Check
``` python =
if "model" in thisdict:
  print("Yes, 'model' is one of the keys in the thisdict dictionary")
```
-Retrieve
``` python =
x = thisdict.keys()
print(x)
```
- **C# : Dictionary**

-Definition
``` csharp =
var cities = new Dictionary<string, string>(){
	{"UK", "London, Manchester, Birmingham"},
	{"USA", "Chicago, New York, Washington"},
	{"India", "Mumbai, New Delhi, Pune"}
};
```
-Add
``` csharp =
IDictionary<int, string> numberNames = new Dictionary<int, string>();
numberNames.Add(1,"One"); 
numberNames.Add(2,"Two");
numberNames.Add(3,"Three");

foreach(KeyValuePair<int, string> kvp in numberNames)
    Console.WriteLine("Key: {0}, Value: {1}", kvp.Key, kvp.Value);
			
foreach(var kvp in cities)
    Console.WriteLine("Key: {0}, Value: {1}", kvp.Key, kvp.Value);
```
-Remove
``` csharp =
cities.Remove("UK");
```
-Check
``` csharp =
if(cities.ContainsKey("France")){
    cities["France"] = "Paris";
}
```
-Retrieve
``` csharp =
for (int i = 0; i < cities.Count; i++)
{
    Console.WriteLine("Key: {0}, Value: {1}", 
    cities.ElementAt(i).Key, 
    cities.ElementAt(i).Value);
}
```

- **Scala : Map**
- **Ruby : Hashes**

### Activity 5: ensureCapacity function

...

### Activity 6: insertAt function

...

### Activity 7: increment function

And that's how you insert code blocks:

```c=

double *number = malloc(sizeof(double));


```

### Activity 8: function strtok

...

### Activity 9: how many words

...

## Look back

### What we've learnt

Fill in...

### What were the surprises

Fill in...

### What problems we've encountered

Fill in...

### What was or still is unclear

Fill in...

### How did the group perform?

How was the collaboration? What were the reasons for hick-ups? What worked well? What can be improved next time?



