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
velikii [3]
2 years ago
13

Create a funtion makeStudent(studentlist) where studentlist is your list of Student namedtuples The function should do the follo

wing: Take user input for each of the fields of the namedtuple Create a Student namedtuple using the input Add the Student to studentlist
Computers and Technology
1 answer:
seropon [69]2 years ago
4 0

Answer:

def makeStudent(student_list):

   name = input()

   major = input()

   year = int(input())

   hhh = int(input())

   gpa = float(input())

   newstu = Student(name,major,year,hhh,gpa)

   student_list.append(newstu)

def setGPA(student,val):

   student = student._replace(gpa= val)

   return student

def setMajor(student,val):

   student = student._replace(major = val)

   return student

def setYear(student,val):

   student = student._replace(year = val)

   return student

def averageGPA(student_list):

   sum = 0

   for i in range(len(student_list)):

       sum = sum + student_list[i].gpa

   avg = sum/len(student_list)

   return avg

def getTopStudentGPA(student_list):

   max = -1000

   for i in range(len(student_list)):

       if student_list[i].gpa > max:

           max = student_list[i].gpa

   return max

Student = namedtuple('Student', ['name', 'major', 'year', 'id', 'gpa'])

stu1 = Student('Kenneth', 'Computer Science', 6, 987654321, 3.8)

stu2 = Student('Maegan', 'Neuroscience', 4, 123456789, 3.4)

namedlist = []

print (namedlist)

namedlist.append(stu1)

namedlist.append(stu2)

print(namedlist)

makeStudent(namedlist)

makeStudent(namedlist)

makeStudent(namedlist)

print(namedlist)

print(namedlist[1])

print(namedlist[3])

Explanation:

  • Create a function to take in in the information of a new student.
  • Create functions for setting GPA, a major subject and year.
  • Calculate average GPA by dividing the total GPA of student with the length of student list.
  • Get top student by checking the student having a maximum GPA .
You might be interested in
This project involves writing a program that encodes and decodes messages. The program should prompt the user to select whether
Lilit [14]

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class EncodeDecodeMessage {

public static String encode(String str) {

String result = "";

char ch;

for(int i = 0; i < str.length(); ++i) {

ch = str.charAt(i);

if(Character.isLowerCase(ch)) {

result += (char)('a' + (25-ch+'a'));

} else if(Character.isUpperCase(ch)) {

result += (char)('A' + (25-ch+'A'));

} else {

result += ch;

}

}

return result;

}

public static String decode(String str) {

return encode(str); // since the scheme is same, we can use encode for decode

}

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print("1. Encode, 2. Decode. Enter your choice: ");

int choice = in.nextInt();

in.nextLine();

if(choice == 1) {

System.out.print("Enter sentence to encode: ");

String line = in.nextLine();

System.out.println("Encoded string is: " + encode(line));

} else if(choice == 2) {

System.out.print("Enter sentence to decode: ");

String line = in.nextLine();

System.out.println("Decoded string is: " + decode(line));

}

}

}

8 0
3 years ago
What problems do you see in the process of transacting business online
allsm [11]

Lack of Computer Expertise. ...

Difficulty Developing Relationships. ...

Privacy and Security Concerns. ...

Issues With Copyrights. ...

Limitations of Business Types.

4 0
2 years ago
In the bremmer article, the author states that _________ translates into greater risks.
blondinia [14]

Answer:

instability

Explanation:

3 0
1 year ago
What type of Microsoft Server serves as an email server?
Misha Larkins [42]
I have a feeling you're looking for Microsoft Outlook.
4 0
3 years ago
Read 2 more answers
How many generations of computer languages have there been since the middle of the 20th century?
evablogger [386]
4 generations hahahaha
3 0
2 years ago
Read 2 more answers
Other questions:
  • In the Remote Access Domain, if private data or confidential data is compromised remotely, you should set automatic blocking for
    5·1 answer
  • Hi I am Khine Mye and I want to ask you a question I don't know that is square root of 2 is 1.4 and how to get that 1.4 and plz
    8·1 answer
  • Within the Chart Design tab, which section is used to change the data of a previously created chart?
    12·1 answer
  • Over the past few years a very definite need has arisen in the electrical trades for:
    15·1 answer
  • T FROW PYCW GCYN TA T ODYHP WQROW TW<br><br> Someone decode pls
    14·1 answer
  • String[][] arr = {{"Hello,", "Hi,", "Hey,"}, {"it's", "it is", "it really is"}, {"nice", "great", "a pleasure"},
    11·1 answer
  • 10010 - 1011 binary subtraction​
    5·1 answer
  • 19 dollar fortnite gift card
    14·2 answers
  • Does anyone know 7.1.3: Firework karel?
    5·1 answer
  • Which of these words is used to begin a conditional statement?<br> when<br> input<br> if<br> until
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!