Starting Out with Python (3rd Edition)
3rd Edition
ISBN: 9780133582734
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 (3rd 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
Find and correct the error(s) in each of the following segments of code: The following code should output the e...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
The order of operations dictates that the division operator works before the addition operator does.
Starting out with Visual C# (4th Edition)
Even if you do not write an equals method for a class, java provides one. Describe the behavior of the equal s ...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
What is a high-level programming language? What is a source program?
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Distinguish among data definition commands, data manipulation commands, and data control commands.
Modern Database Management (12th Edition)
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_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_forward6arrow_forward
- When you call a method, you must include the ____________ required by the method.arrow_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
- To 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_forwardclassname.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_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
- Part 2. fill Method Define a method in simpy named fill. Its purpose is to fill a simpy's values with a specific number of repeating values. The fill method will have two parameters following self: 1. The float value you are filling the values list in with. 2. The int number of values to fill in. The fill method is procedure-like in that it returns None and mutates the object the method is called on. After calling fill, the length of the Simpy object's values should be equal to the second argument given to fill. For example, consider the following usage and expected printed output, given inline, below: twos = Simpy([]) twos.fill(2.0, 3) print("Actual: ", twos, Expected: Simpy([2.0, 2.0, 2.0])") twos.fill(2.0, 5) print("Actual: ", twos, " - Expected: Simpy([2.0, 2.0, 2.0, 2.0, 2.0])") mixed = Simpy([]) mixed.fill(3.0, 3) - Expected: Simpy([3.0, 3.0, 3.0])") print("Actual: ", mixed, mixed.fill(2.0, 2) print("Actual: ", mixed, Expected: Simpy ([2.0, 2.0])") Pythonarrow_forwardImplement all the classes using Java programming language from the given UML Class diagram. Note: This problem requires you to submit just two classes: Customer.java, Invoice.java. Do NOT include "public static void main()" method inside all of these classes. Graders will be testing your classes, using the unit-testing framework JUnit 4. Customer - ID:int -name:String -discount:int Discount rate in percent +Customer(ID:int,name:String, discount:int) +getID():int +getName ():String +getDiscount():int +setDiscount(discount:int):void +toString():String "name (ID)" The Customer class models, a customer design as shown in the class diagram. Write the codes for the Customer class and a test driver to test all the public methods. Invoice - ID:intarrow_forwardWhen the _ _init_ _ method executes, what does the self parameter reference?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