
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:Programming Demo 3: Dog Class
Write the program below to familiarize with the conventional syntax and formatting of Object-Oriented
Programming in Python.
1. Let us create a class Dog with the script below. Save this script as dogs.py. Take note of the
indentions, colons, and number of parenthesis used to avoid errors on our program.
12345678
3
9
10
11
12
class Dog:
definit_(self, name, breed, age):
self.name = name
self.breed breed
=
self.age = age
def sit(self):
print (self.name.title() + is now sitting.")
123456
def roll(self):
"
print (self.name.title() + rolled over!")
def bark(self, times):
print (self.name, 'says woof', times, times.')
2. Identify the user-defined attributes/parameters on our class Dog.
"
3. Identify the user-defined methods or actions that can be acted out on our class Dog.
4. Create a new Python script and name it as sub_dogs.py. Make sure this script is saved on the same
folder with dogs.py. Write the codes below then run it.
from dogs import Dog
dog1= Dog("bantay", "aspin',4)
print (dog1.name)
print (dog1. breed)
print (dog1.age)

Transcribed Image Text:5. Determine the purpose of line 1 on our code. What will happen if we commented or delete the first
line before running the code.
6. Try replacing the values: "bantay" to "milo", 'aspin' to 'labrador', 4 to 13. What will be the outputs?
8
9
print('The name of my dog is + dog1.name.title() + ".")
print('She is an {0}. She is {1} years old.'
.format (dog1.breed.title(), str (dog1.age)))
10
11
7. Explain the outputs of line 8 to line 10.
dog1.sit()
dog1.roll()
dog1.bark()
12
13
14
15
8. Identify the outputs of line 12 to line 14. Try inserting an integer value inside the bark() function.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- How would you read the expression x.y () (C++ code)? As: Select one: a. method of object x cross out b. member y of object x cross out c. None of the provided answers. cross out d. member y of structure x cross out e. method y of object pointed by x cross outarrow_forwardPlease give me the answer with proper explanationarrow_forwardMatch the concept/term with the correa statement that describes or defines thne concept/term. used to do an action in your program OOP uses an interpreter instead of a compiler mport a tool to store data and can change its method value used when something needs to be brought into your program from another file list/array a programming model centered around objects primitive type variable considered strong y-typed" int double, boolean ava a data structure pythonarrow_forward
- Create pseudocode, flowchart and python code for the Patient Charges program. Thisfinal project requires multiple files (modules, drivers, and your main).Design a class named Patient that has fields for the following data:● First name, middle name, last name● Address, city, state, and ZIP code● Phone number● Name and phone number of emergency contactThe Patient class should have a constructor that accepts an argument for each field. ThePatient class should also have accessor and mutator methods for each field.Next, write a class named Procedure that represents a medical procedure that has beenperformed on a patient. The Procedure class should have fields for the following data:● Name of the procedure● Date of the procedure● Name of the practitioner who performed the procedure● Charges for the procedureThe Procedure class should have a constructor that accepts an argument for each field.The Procedure class should also have accessor and mutator methods for each field.Next, design a…arrow_forwardIn Python IDLE: How would I write code for the two problems in the attached image?arrow_forwardPython, do not import any modulearrow_forward
- Code in c++ there is a description of the demand for Joe's Automotive Shop. Based on this, the manager can delete and query the service quote at any time. When querying, you can use "customer name" or "date of service quote" as a keyword, and list Get all service quotes that matches your keywords. Please implement an object-based program according to the above requirements, and create an instruction document to explain how to use your program. If there are special functions, please describe them in detail. Joe’s Automotive Shop services foreign cars, and specializes in servicing cars made by Mercedes, Porsche, and BMW. When a customer brings a car to the shop, the manager gets the customer’s name, address, and telephone number. The manager then determines the make, model, and year of the car, and gives the customer a service quote. The service quote shows the estimated parts charges, estimated labor charges, sales tax, and total estimated chargesarrow_forwardNEED HELP PYTHON ONLY PLZZarrow_forwardRefer to the following interface: Provide two examples (screenshots) that in many ways could improve the above or similar interface using the principles of direct manipulation. Explain the relevant improvements as well. (Examples might have different object, labels and organization)arrow_forward
- Select all the statements that are true about Python's unittest module and Django's test framework: a. Django's test framework builds on Python's unittest module b. Django's TestCase class is a sub-class of unittest.TestCase c. A collection of unit tests is called a "test suite" d. Unit tests are run using the same database that the programmer uses for the development server e. HTML assert methods (such as assertHTMLEqual) are already part of Python's unittest.TestCasearrow_forwardThe Object data type (and those related to it like Function and Date) is the only JavaScript data type that has methods. True or False (Include valid reason)arrow_forwardProblem 1 consists of multiple parts. You should finish one part and ensure that it works before moving to the next part. You will need to refactor (rewrite parts of) your code as you move between parts. Only your final program will be graded. Part 1 The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers (you will need to look up how to do this). The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again.>again." and let the student try the same question repeatedly until the student finally gets it right. A separate method should be…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY