-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignments-10.qmd
69 lines (48 loc) · 2.51 KB
/
assignments-10.qmd
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
---
title: "Module 10 Assignments"
---
```{r}
#| echo: false
#| message: false
#| warning: false
library(tidyverse)
library(readxl)
assignments <- read_excel("assessment_schedule.xlsx") %>%
mutate(formatted_date = format(due_date, "%A, %B %d, %Y"))
```
# Short Project 08
**Due date: `r assignments %>% filter(assessment == "Module 10 Programming Problems") %>% pull(formatted_date)` at 9pm**
Short Programming projects are submitted during our weekly 45-minute in-person lab sessions. Each lab sessions is guided by two TAs. The instructions for the short project will be available only during the lab sessions. To schedule your lab session go to the weekly lab session spreadsheet in [Short Project Dates and Instructions](short-projects.html).
# Programming Problems
Programming Problems should be submitted to [gradescope](https://www.gradescope.com/courses/934148).
## Programming Problem 19
**Due date: `r assignments %>% filter(assessment == "Module 10 Programming Problems") %>% pull(formatted_date)` at 9pm**
Write a Python function that does the following:
1. Its name is `zip_lists`
2. It takes three arguments: `list_1`, `list_2`, `list_3` -- all of the same length
3. It iterates over all three lists (remember, they have the same length, so you can use the same index for all of them) appending to a new list of tuples of three elements
4. It returns the list of tuples
Test cases:
```{python}
#| echo: true
#| eval: false
print( zip_lists([1, 2], ["a", "b"], [1.0, 2.0]) ) # [(1, "a", 1.0), (2, "b", 2.0)]
print( zip_lists([], [], []) ) # []
```
Name the program `create_tuples.py`. Make sure that gradescope gives you the points for passing the test case.
## Programming Problem 20
**Due date: `r assignments %>% filter(assessment == "Module 10 Programming Problems") %>% pull(formatted_date)` at 9pm**
Write a Python function that does the following:
1. Its name is `all_mappings`
2. It takes a single `dictionary` as an argument, which maps strings to lists of integers
3. It returns a list of 2-value tuples, where the first value of the tuples is a key from D, and the second value is an element from its associated list value
Test cases:
```{python}
#| echo: true
#| eval: false
print( all_mappings({"a": [7, 3, 1]}) ) # [("a", 7), ("a", 3), ("a", 1)]
print( all_mappings({"a": [8], "b": [2]}) ) # [("a", 8), ("b", 2)]
print( all_mappings({"a": [], "b": [2]}) ) # [("b", 2)]
print( all_mappings({}) ) # []
```
Name the program `mappings.py`. Make sure that gradescope gives you the points for passing the test case.