1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
k0ka [10]
2 years ago
11

Write a class definition line and a one line docstring for the class Dog. Write an __init__ method for the class Dog that gives

each dog its own name and breed. Test this on a successful creation of a Dog object. >>> import dog >>> sugar
Computers and Technology
1 answer:
Viefleur [7K]2 years ago
4 0
Python Code:

class Dog:
""" Dog class definition """

# data attribute species as part of the class Dog
species = "Canis familiaris"

def __init__(self, _name, _breed):
""" Constructor """
# Assigning values
self.name = _name
self.breed = _breed
self.tricks = []

def teach(self, trick):
""" add a passed string parameter to tricks """
# Adding to list
self.tricks.append(trick)
# Printing message
print(self.name + " knows " + trick)


def knows(self, chkStr):
""" check whether a passed string parameter is in the dog’s list of tricks """
# Checking in tricks list
if chkStr in self.tricks:
# Printing message
print("Yes, " + self.name + " knows " + chkStr)
else:
# Printing message
print("No, " + self.name + " doesn't know " + chkStr)
You might be interested in
Interest accumulated on the principle of a loan must also be paid. The accumulated interest is known as which of the following?
tangare [24]
I think B but idk lol
7 0
3 years ago
The /tmp directory is a temporary directory and will not exist on a system at all times. True or False?
jeka94

Answer:

False.

Explanation:

The /tmp directory is a directory that contains files that are required temporarily and also for temporary storage of data.The data inside the /tmp directory gets deleted when the system boots or shuts down.Since the directory exists permanently the content inside it is temporary.

So we can conclude that the answer is False.

5 0
3 years ago
Which of the following can potentially be changed when implementing an interface?
yan [13]

Answer:

c. You cannot change the name, return type, or parameters of a method defined by the interface.

Explanation:

When implementing an interface:

  • The return type of the implementing method should be same as the one defined in the interface.
  • The parameters of the implementing method should be the same as defined in the interface.
  • The name of the method should be the same as that defined in the interface.

So among the given options , option c is the most relevant as it captures all the above conditions.

6 0
3 years ago
Write only in C, not C++.
yawa3891 [41]

Answer:

#include <iostream>

using namespace std;

int main() {

  int k;

double d;

string s;

cin >> k >> d >> s;

cout << s << " " << d << " " << k << "\n" << k << " " << d << " " << s; }

                                                                   

Explanation:

k is int type variable that stores integer values.

d is double type variable that stores real number.

s is string type variable that stores word.

cin statement is used to take input from user. cin takes an integer, a real number and a word from user. The user first enters an integer value, then a real number and then a small word as input.

cout statement is used to display the output on the screen. cout displays the value of k, d and s which entered by user.

First the values of k, d and s are displayed in reverse order. This means the word is displayed first, then the real number and then the integer separated again by EXACTLY one space from each other. " " used to represent a single space.

Then next line \n is used to produce a new line.

So in the next line values of k, d and s are displayed in original order (the integer , the real, and the word), separated again by EXACTLY one space from each other.

The program along with the output is attached.

7 0
3 years ago
Write a python program to calculate the length of any string recursively​
Solnce55 [7]

Answer:

b

Explanation:

6 0
2 years ago
Other questions:
  • When numbers are changed in cells that are involved in formula is the formulas are automatically
    14·1 answer
  • Dr. Patterson’s office calls to give patient Sara Martin her test results from her most recent visit. Her husband answers the ph
    8·2 answers
  • Which online resource is usually not free?
    10·2 answers
  • Page UND
    8·1 answer
  • Which of the statements below are true about Digital Signatures?
    15·1 answer
  • A program called a ( n ) ____ translates instructions written in high-level languages into machine code.
    13·1 answer
  • 2. Who created the first photograph? How was this done?
    14·2 answers
  • REPORT THIS USER. HE'S SHOWING HIS YK WHAT TO EVERYONE INCLUDING ME. HIS ACCOUNT PROFILE IS IN THE PICTURE BELOW
    14·1 answer
  • . Imagine that you were programming without an IDE. What problems might you encounter?​
    12·1 answer
  • ________ has the ability to drag windows to the edges or corners of your screen and have them snap into place.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!