-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignments-02.qmd
93 lines (67 loc) · 3.47 KB
/
assignments-02.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
title: "Module 2 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 01
**Due date: `r assignments %>% filter(assessment == "Module 2 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 3
**Due date: `r assignments %>% filter(assessment == "Module 2 Programming Problems") %>% pull(formatted_date)` at 9pm**
Write two python functions. The first function does the following:
1. Its name is `celsius_to_fahrenheit`.
2. It takes a float argument, `celsius`.
3. It calculates the Fahrenheit temperature based on the given celsius temperature. To do so multiply the Celsius temperature by 1.8 (or 9/5) and add 32.
4. It returns the Fahrenheit temperature with two decimals of precision.
The other function convert temperatures in degrees from Fahrenheit to Celsius.
1. Its name is `fahrenheit_to_celsius`.
2. It takes a float argument, `fahrenheit`.
3. It calculates the Celsius temperature based on the given Fahrenheit temperature. To do so subtract 32 from the Fahrenheit temperature and multiply the result by 5/9.
4. It returns the Celsius temperature with two decimals of precision.
Name the program `temperatures.py`. Make sure that gradescope gives you the points for passing the test cases.
Development test cases:
```{python}
#| echo: true
#| eval: false
print( celsius_to_fahrenheit(15) ) # 59.0
print( celsius_to_fahrenheit(25) ) # 77.0
print( celsius_to_fahrenheit(38) ) # 100.4
print( fahrenheit_to_celsius(100) ) # 37.78
print( fahrenheit_to_celsius(115) ) # 46.11
print( fahrenheit_to_celsius(75) ) # 23.89
```
You can also download the [ready-to-run script](test_scripts/test_temperatures.py) to test your solution.
## Programming Problem 4
**Due date: `r assignments %>% filter(assessment == "Module 2 Programming Problems") %>% pull(formatted_date)` at 9pm**
Write two python functions. The first function does the following:
1. Its name is `feet_to_inches`.
2. It takes a float argument, `feet`.
3. It converts the feet measurement to inches. As you might already know, an inch is 1/12th of a foot.
4. It returns the measure in inches as a rounded integer.
The second function does the following:
1. Its name is `feet_to_meters`.
2. It takes a float argument, `feet`.
3. It converts the feet measurement to meter (divide the feet measurement by 3.281)
4. It returns the measure in meters as an rounded to two decimal places.
Name the program `measures.py`. Make sure that gradescope gives you the points for passing the test cases.
Development test cases:
```{python}
#| echo: true
#| eval: false
print( feet_to_inches(1) ) # 12
print( feet_to_inches(2.5) ) # 30
print( feet_to_inches(5.4) ) # 65
print( feet_to_meters(1) ) # 0.3
print( feet_to_meters(5) ) # 1.52
print( feet_to_meters(20) ) # 6.1
```
You can also download the [script](test_scripts/test_measures.py) to test your solution.