1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OlgaM077 [116]
2 years ago
14

Course Aggregation Many times, departments are only interested with how students have done in courses relative to a specific maj

or when considering applicants for admission purposes.
For this problem you are given a dictionary where the keys are strings representing student ids and the values are dictionaries where the keys represent a course code and the value represents a grade. Your task is to write a function that given a dictionary of the described format and a prefix for course codes, return a dictionary where each key is a student id and the corresponding value is the average grade of the student only in courses that start with the given prefix.
def course_grader (student_to_grades, course_prefix): ({str, {str, float}}) -> {str, float} I: a dictionary containing the grades of students (as described above) and a course code prefix P: compute and store the average grade of all students only for courses that start with the given course prefix 0: a dictionary of student ids to average grades as described in the Processing step pass
Computers and Technology
1 answer:
nadezda [96]2 years ago
8 0

Answer:

def course_grader(student_to_grades, course_prefix):

   student_grades = dict()

   for key, value in student_to_grades.items():

       grade_score = 0

       for course,grade in value.items():  

           if course_prefix == course:  

               grade_score += grade

                student_grades[key] = grade_score / len(value.keys())

   return student_grades

Explanation:

The course_grader function is a python program that accepts two arguments, the student dictionary and the course prefix. The function returns a dictionary of the student id as the key and the average grade of the student as the value.

You might be interested in
This is for C++: Using a nested for loop output the following pattern to the screen:
olga55 [171]

Answer:

Following are the code to the given question:

#include <iostream>//header file

using namespace std;

int main()//main method

{

int r=26,x,y;//defining integer variable  

char c;//defining a character variable

for(x= 1; y<= r; x++)//using for loop for count value

{

for(y= 1; y<= x; y++)//using for loop to convert value in triangle  

{

c=(char)(y+64);//convert value into character  

cout << c;//print character value

}

cout << "\n";//use print method for line break

}

return 0;

}

Output:

Please find the attachment file.

Explanation:

In this code, three integer variable "x,y, and r", and one character variable "c" is declared, that is used in the nested for loop,  in the first for loop it counts the character value and in the next for loop, it converts the value into a triangle and uses the char variable to print its character value.

3 0
2 years ago
In this scenario, two friends are eating dinner at a restaurant. The bill comes in the amount of 47.28 dollars. The friends deci
pickupchik [31]

Answer:

The java program for the given scenario is as follows.

import java.util.*;

import java.lang.*;

public class Main

{

   //variables for bill and tip declared and initialized

   static double bill=47.28, tip=0.15;

   //variables for total bill and share declared

   static double total, share1;

public static void main(String[] args) {

    double total_tip= (bill*tip);

    //total bill computed

    total = bill + total_tip;

    //share of each friend computed

    share1 = total/2;

    System.out.printf("Each person needs to pay: $%.2f", share1);  

}

}

Explanation:

1. The variables to hold the bill and tip percent are declared as double and initialized with the given values.

static double bill=47.28, tip=0.15;

2. The variables to hold the values of total bill amount and total tip are declared as double.

3. All the variables are declared outside main() and at class level, hence declared as static.

4. Inside main(), the values of total tip, total bill and share of each person are computed as shown.

double total_tip= (bill*tip);

total = bill + total_tip;

share1 = total/2;

5. The share of each person is displayed to the user. The value is displayed with only two decimal places which is assured by %.2f format modifier. The number of decimal places required can be changed by changing the number, i.e. 2. This format is used with printf() and not with println() method.

System.out.printf("Each person needs to pay: $%.2f", share1);  

6. The program is not designed to take any user input.

7. The program can be tested for any value of bill and tip percent.

8. The whole code is put inside a class since java is a purely object-oriented language.

9. Only variables can be declared outside method, the logic is put inside a method in a purely object-oriented language.

10. As shown, the logic is put inside the main() method and only variables are declared outside the method.

11. Due to simplicity, the program consists of only one class.

12. The output is attached.

5 0
3 years ago
Read 2 more answers
Write a function with this prototype:
sp2606 [1]

Answer:

Following are the code to this question:

#include <iostream> //defining header file  

using namespace std;

void numbers(ostream &outs, const string& prefix, unsigned int levels); // method declaration

void numbers(ostream &outs, const string& prefix, unsigned int levels) //defining method number

{

string s; //defining string variable

if(levels == 0) //defining condition statement that check levels value is equal to 0

{

outs << prefix << endl;  //use value

}

else //define else part

{

for(char c = '1'; c <= '9'; c++) //define loop that calls numbers method

{

s = prefix + c + '.'; // holding value in s variable  

numbers(outs, s, levels-1); //call method numbers

}

}

}

int main() //defining main method

{

numbers(cout, "THERBLIG", 2); //call method numbers method that accepts value

return 0;

}

Output:

please find the attachment.

Explanation:

Program description:

  • In the given program, a method number is declared, that accepts three arguments in its parameter that are "outs, prefix, levels", and all the variable uses the address operator to hold its value.
  • Inside the method a conditional statement is used in which string variable s and a conditional statement is used, in if the block it checks level variable value is equal to 0. if it is false it will go to else block that uses the loop to call method.
  • In the main method we call the number method and pass the value in its parameter.  

5 0
3 years ago
My ar goal is 16.3 what percent am i at if i have 3 points??
Mazyrski [523]

24 percent so far so keep working at that goal

5 0
3 years ago
The exception of MS Access 2007 and above files is _ and older version are _ files ​
ohaa [14]

Answer:

Never heard of that kind of software, but I think it's an old file.

4 0
2 years ago
Other questions:
  • WHAT DOES THE WORD MONOCHROME MEAN?
    11·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Which of the following conditions will maximize the amount of interest you earn
    5·1 answer
  • True or false
    10·1 answer
  • Assuming dataFile is an ofstream object associated with a disk file named payroll.dat, which of the following statements would w
    9·1 answer
  • In Java, Create a two part program. The first takes a user inputted number and lists the factors. The second, lists all the prim
    12·1 answer
  • Help101111 avatar can we be friend's please? My name is Keegan. what is yours?
    12·1 answer
  • How do you mark the brainiest?
    8·2 answers
  • After a Hacker has selects her target, performed reconnaissance on the potential target's network, and probed active Internet Ad
    13·1 answer
  • True or false. The send e-mail feature, listed under tools, will allow you to send an e-mail to your instructor and to fellow st
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!