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
Simora [160]
2 years ago
11

In python please.

Computers and Technology
1 answer:
Aloiza [94]2 years ago
3 0

Answer:

class Book:
   def __init__(self, book_title, book_author, book_publisher):

       self.__book_title = book_title

       self.__book_author = book_author

       self.__book_publisher = book_publisher

Explanation:

Python kind of haves private data attributes, although technically they don't.

Take for example the following code:

"

class A:

   def __init__(self):

       self.__privateAttribute = 0

x = A()

print(x.__privateAttribute)

"

all this really does is rename the variable name, and if you run the following code:

print(dir(x))

it will print the attributes of "x" which include "_A__privateAttribute" which is the attribute that was initialized.

Anyways getting that out of the way, you need to now about the __init__ method, which runs each time you initialize a new instance of the class. It's a way of setting up some necessary values that will be used in the objects methods (the functions inside the class)

So, because we simply cannot know what the book_title, book_author, and book_publisher are (since they vary book to book...), we take them as arguments using the __init__ method, and then initialize their values in their.

"

class Book:
   def __init__(self, book_title, book_author, book_publisher):

       self.__book_title = book_title

       self.__book_author = book_author

       self.__book_publisher = book_publisher

"

I just realized I completely forgot to even mention what the "self" variable stands for. Whenever you initialize a variable, or call a method from an instance of the class, the first argument passed will be the instance of the class. Take for example the following class

"

class A:

   def __init__(self, b):
       self.b = b

   def printB(self):
       print(self.b)

def printB(self):

   print(self.b)

c = A(3)

d = A(4)

c.printB()

printB(c)

d.printB()

printB(d)

"

The two lines

c.printB() and printB(c) are the same exact thing, the only difference is when you call c.printB(), you automatically pass the "c" as the first argument, and the same thing for d.printD(), it's implicitly passed whenever you call a method from an instance of the class.

You might be interested in
What is the unemployment rate if the GDP gap is 13.5%?<br><br> A. 6.25%<br> B. 6.75%<br> C. 6.7%
Kamila [148]
I think it can be like 6.25%
6 0
4 years ago
To construct a battery with a current of 6 A, you would connect six 1 A cells
Eva8 [605]

in series i believe

6 0
3 years ago
a _____ is a telecommunications network that connects users and their computers in a geographical area that spans a campus or a
Pachacha [2.7K]

Answer:

(WAN) a wide area network

5 0
3 years ago
Be able to list a technology-based company and discuss whether it enjoys sustainable competitive advantage based on the resource
aev [14]

Answer:

idk good luck finding one

5 0
3 years ago
A company has a main office and 12 branch offices. The users and computers are within a single domain. All servers are Windows S
LenaWriter [7]

Answer:

The answer to this question can be given as:

To access the server, the administrator must Configure L2TP with IPsec and MS-CHAPv2.

Explanation:

In this question, the user doesn't access the server by the User name and password. The User wants to access the server by the computer-level authentication. To access the server successfully user must Configure L2TP with IPsec and MS-CHAPv2. where L2TP with IPsec stands for Layer 2 Tunneling Protocol or it is also known as Virtual private network. It is a communications protocol that allows us to move data from one network to another in the encrypted form that is used by the IPsec. MS-CHAPv2 stands for Microsoft Challenge-Handshake Authentication Protocol that is developed by Microsoft. In computing, the CHAP provides the authentication to the user or network host entity. For example, this entity may be an internet service provider. And v2 stands for security.

So to access the server successfully, the administrator must Configure L2TP with IPsec and MS-CHAPv2.

8 0
3 years ago
Other questions:
  • Scientific models can be used for a variety of different purposes. Which of the following statements about scientific models is
    7·2 answers
  • What is the most effective way to demonstrate being prepared for an interview?
    8·2 answers
  • _______is the equal distribution of visual weight on either side of an imaginary axis through the center of a design. A building
    6·2 answers
  • Which of the following SNSs has been associated with art work display?
    14·2 answers
  • What was the first message ever sent in morse code?
    13·1 answer
  • Which of the following is the easiest way for visitors to learn about a business while visiting a website?
    13·1 answer
  • Can we update App Store in any apple device. (because my device is kinda old and if want to download the recent apps it aint sho
    10·1 answer
  • Can someone explain to me the process of inserting fonts into pdf, please? Also, related to this topic, metadata about a font th
    12·1 answer
  • Function of Ribbon in Access 2010​
    7·1 answer
  • I NEED INFORMATION ON THE WALT DISNEY VS. FADEN CASE ASAP<br> WILL GIVE BRAINLIEST
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!