Starting Out with Python (3rd Edition)
3rd Edition
ISBN: 9780133582734
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 10, Problem 8MC
Program Description Answer
The method that gets automatically called when an object is created is “__int__” method.
Hence, the correct answer is option “A”.
Expert Solution & Answer
Learn your wayIncludes step-by-step video
schedule02:05
Students have asked these similar questions
This function is used to check whether an object is an instance of a specific class or a subclass of that class. a. isinstance b. isobject c. isreference d. _ _str_ _
Fill-in-the-Blank
A constructor is automatically called when an object is _________.
A. Car Class
Create a Python Program where you write a class
named Car that has the following data attributes:
• _ _year_model (for the car's year model)
• __make (for the make of the car)
• _ _speed (for the car's current speed)
The Car class should have an _init_ method that
accepts the car's year model and make as arguments.
These values should be assigned to the object's
_year_model and
make data attributes. It should
also assign 0 to the __speed data attribute.
The class should also have the following methods:
accelerate()
The accelerate method should add 5 to the speed data
attribute each time it is called.
brake()
The brake method should subtract 5 from the speed
data attribute each time it is called.
• get_speed()
The get_speed method should return the current speed.
Next, design a program that creates a Car object then
calls the accelerate method five times. After each call
to the accelerate method, get the current speed of the
car and display it. Then call the brake method…
Chapter 10 Solutions
Starting Out with Python (3rd Edition)
Ch. 10.2 - You hear someone make the following comment: "A...Ch. 10.2 - In this chapter, we use the metaphor of a cookie...Ch. 10.2 - What is the purpose of the _ _init_ _ method? When...Ch. 10.2 - Prob. 8CPCh. 10.2 - In a Python class, how do you hide an attribute...Ch. 10.2 - What is the purpose of the _ _str_ _ method?Ch. 10.2 - Prob. 11CPCh. 10.3 - What is an instance attribute?Ch. 10.3 - Prob. 13CPCh. 10.3 - What is an accessor method? What is a mutator...
Ch. 10.4 - What is an object?Ch. 10.4 - Prob. 2CPCh. 10.4 - Why is an object's internal data usually hidden...Ch. 10.4 - What are public methods? What are private methods?Ch. 10.4 - Prob. 15CPCh. 10.4 - Prob. 16CPCh. 10.4 - When designing an object-oriented application, who...Ch. 10.4 - How do you identify the potential classes in a...Ch. 10.4 - What are a classs responsibilities?Ch. 10.4 - What two question should you ask to determine a...Ch. 10.4 - Will all of a class's action always be directly...Ch. 10 - The _______ programming practice is centered on...Ch. 10 - The ___________ programming practice is centered...Ch. 10 - A(n) _____ is a component of a class that...Ch. 10 - Prob. 4MCCh. 10 - By doing this, you can hide a classs attribute...Ch. 10 - Prob. 6MCCh. 10 - A(n) ________ method stores a value in a data...Ch. 10 - Prob. 8MCCh. 10 - If a class has a method named _ _str_ _ , which of...Ch. 10 - A set of standard diagrams for graphically...Ch. 10 - In one approach to identifying the classes in a...Ch. 10 - Prob. 12MCCh. 10 - The practice of procedural programming is centered...Ch. 10 - Object reusability has been a factor in the...Ch. 10 - It is a common practice in object-oriented...Ch. 10 - Prob. 4TFCh. 10 - Starting an attribute name with two underscores...Ch. 10 - You cannot directly call the _ _ str _ _ method.Ch. 10 - One way to find the classes needed for an...Ch. 10 - Prob. 1SACh. 10 - Why should an object's data attributes be hidden...Ch. 10 - What is the difference between a class and an...Ch. 10 - The following statement calls an object's method....Ch. 10 - Prob. 5SACh. 10 - In a Python class, how do you hide an attribute...Ch. 10 - Prob. 7SACh. 10 - Suppose my_car is the name of a variable that...Ch. 10 - Prob. 2AWCh. 10 - Look at the following description of a problem...Ch. 10 - Pet Class The Pet class Write a class named Pet,...Ch. 10 - Car Class Write a class named Car that has the...Ch. 10 - Personal Information Class Design a class that...Ch. 10 - Employee Class Write a class named Employee that...Ch. 10 - RetailItem Class Write a class named RetailItem...Ch. 10 - Employee Management System This exercise assumes...Ch. 10 - Cash Register This exercise assumes you have...Ch. 10 - Trivia Game In this programming exercise, you will...
Knowledge Booster
Similar questions
- In Python: Write a class named Pet, which should have the following data attributes: _ _name (for the name of a pet) _ _animal_type (for the type of animal that a pet is. Example values are 'Dog','Cat', and 'Bird') _ _age (for the pets age) The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods: set_nameThis method assigns a value to the _ _name field set_animal_typeThis method assigns a value to the _ _animal_type field set_ageThis method assignsa value to the _ _age field get_nameThis method assignsa value to the _ _name field get_animal_typeThis method assignsa value to the _ _animal_type field get_ageThis method assignsa value to the _ _age field Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type and age of his or her pet. This data should be stored as the objects attributes. Use the objects accessor methods to retrieve the pets…arrow_forwardPlease do it fast Copy constructor definition requires __________________ i) Object to be passed by value ii) Object not to be passed to it iii) Object to be passed by reference iv) Object to be passed with each data member valuearrow_forwardclass Student(object): """Represents a student.""" def __init__(self, name, number): """All scores are initially 0.""" self._name = name self._scores = [] for count in range(number): self._scores.append(0) def getName(self): """Returns the student's name.""" return self._name def setScore(self, i, score): """Resets the ith score, counting from 1.""" self._scores[i - 1] = score def getScore(self, i): """Returns the ith score, counting from 1.""" return self._scores[i - 1] def getAverage(self): """Returns the average score.""" return sum(self._scores) / len(self._scores) def getHighScore(self): """Returns the highest score.""" return max(self._scores) def __str__(self): """Returns the string representation of the student.""" return "Name: " + self._name + "\nScores: " + \ " ".join(map(str, self._scores))arrow_forward
- Question 3 Encapsulation is supported by ___________arrow_forwardComputer Science Write the code to define a class called student. The student class should contain a data attribute called name and another attribute called gpa. Write the Student class to include an initializer method __init__ and a __str__ method. Create two different objects of the student class and call print on each object to display the output in the __str__method.arrow_forwardWritre in Python Code Please Create class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: item description, units in inventory, and price. Once you have written the class, write a program that creates three RetailItem objects and stores the following data in them: Description Units in Inventory Price Item#1 Jacket 12 59.95 Item#2 Designer Jeans 40 34.95 Item#3 Shirt 20 24.95 Create CashRegister class that can be used with the RetailItem class. The CashRegister class should be able to internally keep a list of RetailItem objects. The class should have the following methods: • A method named purchase_item that accepts a RetailItem object as an argument. Each time the purchase_item method is called, the RetailItem object that is passed as an argument should be added to the list. • A method named get_total that returns the total price of all the RetailItem…arrow_forward
- 2. The MyInteger Class Problem Description: Design a class named MyInteger. The class contains: n [] [] A private int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A get method that returns the int value. Methods isEven () and isOdd () that return true if the value is even or odd respectively. Static methods isEven (int) and isOdd (int) that return true if the specified value is even or odd respectively. Static methods isEven (MyInteger) and isOdd (MyInteger) that return true if the specified value is even or odd respectively. Methods equals (int) and equals (MyInteger) that return true if the value in the object is equal to the specified value. Implement the class. Write a client program that tests all methods in the class.arrow_forwardCould you please help me with this chapter 6 number 15 Programming challenge from Starting out with Java Gaddis 7th edition book. Thank youarrow_forwardIn java languagearrow_forward
- Using pythonarrow_forwardBook Donation App Create a book-app directory. The app can be used to manage book donations and track donors and books. The catalog is implemented using the following classes: 1. The app should have donors-repo.js to maintain the list of donors and allow adding, updating, and deleting donors. The donor object has donorID, firstName, lastName, and email properties. This module should implement the following functions: • getDonor(donorId): returns a donor by id. • addDonor(donor): adds a donor to the list of donors; donorID should be autoassigned a random number. • updateDonor(donor): updates the donor having the matching donorID. • deleteDonor(donorID): delete the donor with donorID from the list of donors, only if they are not associated with any books. 2. The app should have books-repo.js to maintain the list of donated books and allow adding, updating, and deleting books. The book object has bookID, title, authors, and donorID properties. • donorID references the book’s donor. This…arrow_forwardUse java languagearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage