Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 11, Problem 4TF
Only the _ _init_ _method can be overridden.
Expert Solution & Answer
Learn your wayIncludes step-by-step video
schedule03:14
Students have asked these similar questions
What type must self be for the __str__ method?
class User:def __init__(self, first_name, last_name, user_id, last_login, password):self.first_name = first_nameself.last_name = last_nameself.user_id = user_idself.last_login = last_loginself.password = passworddef describe_user(self):print(f"Accessing user {self.user_id}:")print(f"{self.first_name} {self.last_name} last logged in on {self.last_login}")def greet_user(self):print(f"Welcome to the jungle {self.first_name} {self.last_name}, you gonna die")def new_login(self, month, day, year):if month < 1 or month > 12:print("That is not a valid month")returnif day < 1 or day > 31:print("That is not a valid day")returnif year < 0:print("That is not a valid year")returnmonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]month_name = months[month-1]self.last_login = f"{month_name} {day}, {year}"
Hard-Code:
# hard-coded callsjim =…
class User:def __init__(self, first_name, last_name, user_id, last_login, password):self.first_name = first_nameself.last_name = last_nameself.user_id = user_idself.last_login = last_loginself.password = passworddef describe_user(self):print(f"Accessing user {self.user_id}:")print(f"{self.first_name} {self.last_name} last logged in on {self.last_login}")def greet_user(self):print(f"Welcome to the jungle {self.first_name} {self.last_name}, you gonna die")
Hard-code
# hard-coded calls
jim = User(first_name='Jim',last_name='Bob',user_id=1000,last_login='June 12, 1998',password='password123')jim.describe_user()jim.greet_user()joe = User('Joe','Bob',1001,'July 4, 2001','babygirl')joe.greet_user()joe.describe_user()joe.new_login(2, 3, 2025)joe.describe_user()joe.new_login(15, 3, 2025)joe.new_login(2, 35, 2025)joe.new_login(2, 3, -55)
Chapter 11 Solutions
Starting Out with Python (4th Edition)
Ch. 11.1 - In this section, we discussed superclasses and...Ch. 11.1 - Prob. 2CPCh. 11.1 - What does a subclass inherit from its superclass?Ch. 11.1 - Look at the following code, which is the first...Ch. 11.2 - Look at the following class definitions: class...Ch. 11 - In an inheritance relationship, the ___________ is...Ch. 11 - In an inheritance relationship, the _________ is...Ch. 11 - Suppose a program uses two classes: Airplane and...Ch. 11 - This characteristic of object-oriented programming...Ch. 11 - Prob. 5MC
Ch. 11 - Polymorphism allows you to write methods in a...Ch. 11 - It is not possible to call a superclasss _ _init_...Ch. 11 - A subclass can have a method with the same name as...Ch. 11 - Only the _ _init_ _method can be overridden.Ch. 11 - You cannot use the isinstance function to...Ch. 11 - What does a subclass inherit from its superclass?Ch. 11 - Look at the following class definition. What is...Ch. 11 - Prob. 3SACh. 11 - Write the first line of the definition for a...Ch. 11 - Look at the following class definitions: class...Ch. 11 - Look at the following class definition: class...Ch. 11 - Employee and ProductionWorker Classes Write an...Ch. 11 - ShiftSupervisor Class In a particular factory, a...Ch. 11 - Person and Customer Classes The Person and...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Write a program segment that defines a file stream object named employees. The file should be opened for both i...
Starting Out with C++ from Control Structures to Objects (9th Edition)
If the Vole executes an instruction every microsecond (a millionth of a second), how long does it take to compl...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
For the circuit shown, use the node-voltage method to find v1, v2, and i1.
How much power is delivered to the c...
Electric Circuits. (11th Edition)
Distinguish among data definition commands, data manipulation commands, and data control commands.
Modern Database Management
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In java languagearrow_forwardMatch the C-function on the left to the Intel assemble function on the right. W: cmpl $4 movl %edi , %edi jmp .L4(,%rdi,8) %edi .L3: movl $17, %eax ret .15: movl $3, %eax int A ( int x , int y) { int a ; if ( x == 0 ) else i f ( x == 1 ) a = 3 ; else i f ( x == 2 ) a = 2 0 ; else i f ( x == 3 ) a = 2 ; else i f ( x == 4 ) a = 1 ; ret .L6: a = 17; movl $20, %eax ret .L7: movl $2, %eax ret else a = 0; .L8: return a ; movl $1, %eax .L2: ret . section .rodata . L4: .quad .L3 .quad .L5 .quad .L6 .quad .L7 .quad .L8 X: testl %edi, %edi je cmpl je cmpl je стр1 je cmpl .L16 $1, %edi .L17 $2, %edi .L18 $3, %edi int B (int x, int y) { int a; switch (x) { .L19 $4, %edi %al movzbl %al, %eax case 0: a = 17; break; sete break; case 1: a = 3; case 2: a = 20; break; case 3: a = 2; break; case 4: a = 1; a = 0; } return a; ret .L16: break; movl $17, %eax ret .L17: movl $3, %eax } ret .L18: movl $20, %eax ret .L19: movl ret $2, %eaxarrow_forwardclass Book: book_belongs_to = 'Schulich School of Engineering' def _init_(self, pages = e, title = 'Unknown', author = 'Unknown', isbn self.pages = pages e): %3D self.title = title self.author = author self.isbn = isbn Book (255, 'Black Beauty', 'Anna Sewell', 9780001840423) Book (208, 'The Chrysalids', 'John Wyndham', 9780140013085) book1 = book2 = Book.book_belongs_to 'Emily Marasco' %3D book3 = Book ()arrow_forward
- 6arrow_forwardUse java languagearrow_forwardclass Polynomial: class TermNode:def __init__(self, coefficient: int, exponent: int) -> None:"""Initialize this node to represent a polynomial term with thegiven coefficient and exponent. Raise ValueError if the coefficent is 0 or if the exponentis negative."""if coefficient == 0:raise ValueError("TermNode: zero coefficient")if exponent < 0:raise ValueError("TermNode: negative exponent") self.coeff = coefficientself.exp = exponentself.next = None def __init__(self, coefficient: int = None, exponent: int = 0) -> None:"""Initialize this Polynomial with a single term constructed from thecoefficient and exponent. If one argument is given, the term is a constant coefficient(the exponent is 0).If no arguments are given, the Polynomial has no terms. # Polynomial with no terms:>>> p = Polynomial()>>> print(p._head)None>>> print(p._tail)None # Polynomial with one term (a constant):>>> p = Polynomial(12)>>> p._head.coeff12>>>…arrow_forward
- find and fix all the errors so the code can run #ifndef Student.h#define Student.h class CStudent{private:char Student_name[50];int Student_id;char Student_email_username[10];char Student_major[10];float Student_grades[5];float Student_score;char Student_email_password[10]; public:CStudent(); char *get_Student_name();int get_student_id();char *get_Student_email_username();char *get_Student_major();float *get_Student_grades();float get_Student_score();char *get_Student_email_password(); //set methodsvoid set_Student_name(char *name);void set_student_id(int id);void set_Student_email_username(char *username);void set_Student_major(char *major);void set_Student_grades(float *grades);void set_Student_score(float score);void set_Student_email_password(char *password); }; #endif #include "Student.h"#include <cstddef>…arrow_forwardJAVA ONLYPlease create a code that checks if 'user' favourite game is in the top 3 games. if the game is in the top 3 then it should say: "common favourite game" if else then "uncommon favourite game"code: TOP_3_GAMES = {'', 'CALL OF DUTY', 'LEAGUE OF LEGENDS', 'VALORANT'}arrow_forwardTo write an application that uses recursion to solve a problem. Details: Create a class called Power that computes the value of base exponent. The class should have one recursive method: • public static int power(int base, int exponent) – Which computes the value of base exponent using recursion, returning the result. The recursion step should use the following relationship base exponent = base x base exponent - 1 and the termination condition should occur when exponent is equal to 1, because base 1 = base NOTE: For the power method, assume the exponent parameter value is always greater than 0. Create a second class called PowerTest that contains the main method, and tests the Power.power method. The test class does not need to ask for input from the user of the class, nor does it need to do any additional error checking. Upload both source files to Blackboard. Note: Ensure that your program is properly formatted and it follows all Java naming conventions.arrow_forward
- classname.py -> using "sys.argv" ● Create a program called classname.py. The program should define a class called person that has one method called hello, and one attribute called name, which represents the name of the person. ● The hello method should print the following string to the screen: ‘My name is ____ and I am a _____’ where: ○ The first blank should be the name attribute ○ The second blank should be the name of the class ○ The above blanks should NOT be manually printed (ex. print(‘My name is Greg and I am a person’)) ● After defining the class, there are three things you must do: 1. Instantiate an object of the class 2. Run the hello method of the instantiated object a. (e.g., Greg.hello()) 3. For grading purposes, you must also print the name of the class so I can be sure you’ve created a class a. (The expected output is )arrow_forwardWritten in Python It should have an init method that takes two values and uses them to initialize the data members. It should have a get_age method. Docstrings for modules, functions, classes, and methodsarrow_forwardclass Book: book_belongs_to = 'Schulich School of Engineering' def _init_(self, pages = 0, title = 'Unknown', author = 'Unknown', isbn = self.pages = pages self.title = title e): self.author = author self.isbn = isbn book1 = Book(255, 'Black Beauty', 'Anna Sewell', 9780001840423) book2 = Book(208, 'The Chrysalids', 'John Wyndham', 9780140013085) Book.book_belongs_to = 'Emily Marasco' book3 = Book()arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY