1. Creating a function: Let's follow the example we used in the week one coding lectures and create a function for calcu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. Creating a function: Let's follow the example we used in the week one coding lectures and create a function for calcu
1. Creating a function: Let's follow the example we used in the week one coding lectures and create a function for calculating a student's grade in a class. For three students, we have the the points earned on each assignment Exam 1 Exam 2 Final Quiz 1 Quiz 2 Quiz 3 HW 1 HW 2 HW 3 80 92 10 8 9 40 47 25 80 82 10 6 30 37 25 75 72 9 10 40 50 29 Student 190 Student 270 Student 3 70 10 where tests are out of 100 points, quizzes are out of 10 points, and the homeworks are out of 40,50,and 30 points, respectively. Furthermore, Exam 1 and Exam 2 are each worth 10% of the student's grade, the final is worth 35% of the student's grade, each quiz is worth 5%, and each homework is worth 10%. (a) Create a function that takes in a vector of assignment scores, • a vector containing the number of points each assignment was worth, and a vector containing the weights of each assignment. This function should return the student's weighted average. Recall, the formula for calculating a weighted average is 100 - Σwigi where g; is the ith grade and w, is the weight of 9₁. Both g; and w; should be percentages in decimal form. (b) Using your function, find the weighted average for each student and save the output as A1-A3.