Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

we have to finish the #TODO part, no use of break, continue, enumerate word. no complex code, simple enough. with steps if possible, thanks! from_future__

image text in transcribed

image text in transcribed

image text in transcribed

we have to finish the #TODO part, no use of break, continue, enumerate word. no complex code, simple enough. with steps if possible, thanks!

from_future__ import annotations from typing import TYPE_CHECKING, List, Tuple, Optional if TYPE_CHECKING: from survey import Answer, survey, Question def sort_students(1st: List[Student], attribute: str) -> List[Student); Return a shallow copy of sorted by =Precondition sur is a attribute name for the Student class >>> S1 = Student 1, "Misha) >>> s2 - Student(2, 'Diane') >>> s3 = Student(3, 'Mario') >>> sort_students([s1, s3, s2], 'id') == [s1, s2, S3] True >>> sort_students([s1, s2, S3], 'name') -- [S2, S3, si] True return sorted (1st, key-lambda s: getattr(s, attribute) class Student: *** A Student who can be enrolled in a university course, ass Public Attributes was id: the id of the student name: the name of the student === Representation Invariants esa name is not the empty string *** id: int name: str def __init_(self, id_: int, name: str) -> None : *** Initialize a student with name and id sids" # TODO: complete the body of this method def_str_(self) -> str: "*" Return the name of this student # TODO: complete the body of this method def has_answer(self, question: Question) -> bool: Return True iff this student has an answer for a question with the same id as None: Record this student's answer . # TODO: complete the body of this method def get_answer(self, question: Question) -> Optional Answer): Return this student's answer to the question . Return None if this student does not have an answer question> # TODO: complete the body of this method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

Prepare and properly label figures and tables for written reports.

Answered: 1 week ago