JOBSEEKER?

A university's Office of Admission keeps track of student majors. Each student can have a single major. Below is an example of how their system stores students, majors, and how it manipulates them:

students = [("Allen Anderson", "Computer Science"),
            ("Edgar Einstein", "Engineering"),
            ("Farrah Finn", "Fine Arts")]
     
def add_new_student(students, name, major):
    students.append((name, major))

def update_student(students, index, name, major):
    students[index] = (name, major)

def find_students_by_name(students, name):
    return [student for student in students if name in student[0]]

def get_all_majors(students):
    return [student[1] for student in students]

What can be concluded from the code snippet above?

(Select all acceptable answers.)

In the update_student function, the '(' and ')' parentheses can be removed without causing any errors.
Calling find_students_by_name(students, 'in') returns a list of 2 tuples.
The add_new_student function can be rewritten as seen below and still maintain identical functionality:
students[len(students)] = (name, major)
Calling get_all_majors(students) returns a list of 3 tuples.
The add_new_student function adds a new student in the last place in the list.
The name of the first student in the array can be set to the new_name variable, like students[0][0] = new_name
   

Tags
Python Lists Tuples New Public
Easy

3min

Would you like to see our other questions?

We have 1000+ premium hand-crafted questions for 50+ job skills and 20+ coding languages. We prefer questions with small samples of actual work over academic problems or brain teasers.

Visit our question library
Private Concierge

Send us an email with an explanation of your testing needs and a list of candidates. We will create an appropriate test, invite your candidates, review their results, and send you a detailed report.

Contact Private Concierge

On the TestDome Blog

Screening Applicants: The Good, the Bad and the Ugly

Since we’re all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they’ve been screening people for many years, so they must know how to do it right?

Not really. I was surprised to discover that many experts disagree with each other. Everybody praises their pet method and criticizes the others. Many of these methods look legitimate, but are based on...

Dashboard Start Trial Sign In Home Tour Tests Questions Pricing For Jobseekers