-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignments-12.qmd
69 lines (48 loc) · 2.31 KB
/
assignments-12.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 12 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 10
**Due date: `r assignments %>% filter(assessment == "Module 12 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 23
**Due date: `r assignments %>% filter(assessment == "Module 12 Programming Problems") %>% pull(formatted_date)` at 9pm**
Write a Python function that does the following:
1. Its name is `differences`
2. It takes two sets as arguments: `set_1` and `set_2`
3. It calculates and returns the number of elements that are different (not in common) between the two parameter sets
4. It returns an integer with the number of different elements
Test cases:
```{python}
#| echo: true
#| eval: false
print( differences({1, 2, 3}, {2, 3, 4, 5}) ) # 3
print( differences({'john', 'mark', 'paul'}, {'john', 'mark'}) ) # 1
```
Name the program `differences.py`. Make sure that gradescope gives you the points for passing the test case.
## Programming Problem 24
**Due date: `r assignments %>% filter(assessment == "Module 12 Programming Problems") %>% pull(formatted_date)` at 9pm**
Write a Python function that does the following:
1. Its name is `has_duplicate`
2. It takes a single list as argument
3. It returns `True` if the list contains any duplicate values, `False` if all values are unique
Test cases:
```{python}
#| echo: true
#| eval: false
print( has_duplicate([]) ) # False
print( has_duplicate([1, 2, 3, 1]) ) # True
print( has_duplicate([1, "a", "b", 4, 5]) ) # False
print( has_duplicate([1, "a", "a", 2, 3, 4]) ) # True
```
Name the program `detect_duplicates.py`. Make sure that gradescope gives you the points for passing the test case.