Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am having hard time figuring out how to write code for the def header. I started with @classmethod def header(cls, ).

Hello,

I am having hard time figuring out how to write code for the def header.

I started with

@classmethod

def header(cls, ). <- I am not sure if I need an argument here or not

return (f"{'ID':<10} {'Last Name':<16} .....{'Course':<42}") + '/n' + '========.....'

Here is my assignment instruction:

__str()__: - this method should output a formatted string such that printing multiple Student objects will line up. Example results for 3 objects (fields: id, lastName, firstName, gpa, courses)

__repr()__: - we will not directly use this method, but it should have an output similar to __str__. However, the column formatting is not necessary. You can use commas in between fields

header() signature:

def signature(): - this method returns a string that can be used as a header for the results of the __str__ method. - notice that this is a class method because there is no "self" parameter, so it will be called using Student.header().

- example result:

ID Last Name First Name GPA Courses

=======================================

Hint and tips:

  • For Student.header(), you can use a character to inject a new line between the header text and the bar of equal signs.

  • Speaking of equal sign bar... Dont forget you can create a string of consecutive characters using the * operator. Example: 'A'*10

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago