generated from jhudsl/OTTR_Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
03-writing_code_activity.Rmd
46 lines (27 loc) · 1.2 KB
/
03-writing_code_activity.Rmd
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
```{r, include = FALSE}
ottrpal::set_knitr_image_path()
```
# Writing Code: Hands-On Exercise
Now it’s your turn to try!
## Code
Here's the code you need for question #2.
```
def calculate_average(numbers):
total = 0
for number in numbers:
total += number
average = total / len(numbers)
return average
numbers = [1, 2, 3, 4, "5"]
average = calculate_average(numbers)
print("The average of the numbers is:", average)
```
## Questions
1. Write a prompt to create a function that replaces all instances of the string "three" with the number 3, then create a prompt that allows you to modify the function so that "three", "Three", and "THREE" are all replaced with the number 3.
1. Write a query that helps you debug the code snippet from above.
1. Create a query that explains how to retrieve data from an online database. Don't forget to find out what the source of the code is.
1. Write a prompt to plan out a program that creates and plays a game of Rock, Paper, Scissors. You should create a multi-step plan as well as figure out what your first coding task should be.
1. Create a prompt that identifies the best coding language for the above game.
```{r}
devtools::session_info()
```