Update data.csv
Browse files
data.csv
CHANGED
|
@@ -1,5 +1,39 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
input:,output:
|
| 2 |
+
Write a py script for a weighted average. It accepts an indefinite number of args.,"Sure! For this, we'll use `*args` to create indefinite arguments.
|
| 3 |
+
Then, we will multiply each item by its weight, while making sure to account for it in the mean.
|
| 4 |
+
Here is the code:
|
| 5 |
+
```python
|
| 6 |
+
import math
|
| 7 |
+
|
| 8 |
+
def weightedAverage(*args):
|
| 9 |
+
|
| 10 |
+
weighted_sum = 0
|
| 11 |
+
total_weight = 0
|
| 12 |
+
|
| 13 |
+
nums = []
|
| 14 |
+
for i in range(0, len(args), 2):
|
| 15 |
+
number = args[i]
|
| 16 |
+
weight = args[i+1]
|
| 17 |
+
weighted_sum += number * weight
|
| 18 |
+
total_weight += weight
|
| 19 |
+
|
| 20 |
+
return weighted_sum / total_weight
|
| 21 |
+
|
| 22 |
+
print(weightedAverage(2, 3, 1, 2, 5, 2))
|
| 23 |
+
```
|
| 24 |
+
Usage:
|
| 25 |
+
arg1: first number
|
| 26 |
+
arg2: weight of the first number
|
| 27 |
+
arg3: 2nd number
|
| 28 |
+
etc."
|
| 29 |
+
Write a script to solve 1+1,"```python
|
| 30 |
+
result = 1+1
|
| 31 |
+
```"
|
| 32 |
+
Write a py script to find the World Record in SMB1 Any%,"Sure! To do so, we can use the Sure! To do so, we can use the SRC API!
|
| 33 |
+
```python
|
| 34 |
+
import requests
|
| 35 |
+
from math import floor
|
| 36 |
+
|
| 37 |
+
game = 'smb1'
|
| 38 |
+
category = 'any'
|
| 39 |
+
url = f""https://www.speedrun.com/api/v1/leaderboards/{game}/category/{category}?top=1""
|