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
3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate a
Tju [1.3M]

Answer:

year = int(input("Enter a year: "))

if (year % 4) == 0:

  if (year % 100) == 0:

      if (year % 400) == 0:

          print(str(year) + " - leap year")

      else:

          print(str(year) +" - not a leap year")

  else:

      print(str(year) + " - leap year")

else:

  print(str(year) + "- not a leap year")

Explanation:

*The code is in Python.

Ask the user to enter a year

Check if the <u>year mod 4</u> is 0 or not. If it is not 0, then the year is not a leap year. If it is 0 and if the <u>year mod 100</u> is not 0, then the year is a leap year. If the <u>year mod 100</u> is 0, also check if the <u>year mod 400</u> is 0 or not. If it is 0, then the year is a leap year. Otherwise, the year is not a leap year.

8 0
3 years ago
Read 2 more answers
Paula needs to ensure that an animation she has created is repeated. Which option should she use to achieve this?
SCORPION-xisa [38]

Answer:

1.

Explanation:

The option Paula can choose to ensure that the animation she has created in her presentation repeats is the transition. She can find the option of transition from the Transitions tab.

After selecting the Transitions tab, choose the effect you want to create in your presentations. You can also choose the sound of transition, or either you want to create on one slide or all slides, etc.

Therefore, option 1 is correct.

5 0
3 years ago
Kiko loves to surf the internet and check on different websites. One day he received an email from unknown source. When he opens
Angelina_Jolie [31]

He experienced phishing

Phishing is a method of trying to gather personal information using deceptive e-mails and websites.

Here are some measures to avoid phishing. You can pick up the one you liked the most

  • Always check the spelling of the URLs in email links before you click or enter sensitive information
  • Watch out for URL redirects, where you're subtly sent to a different website with identical design
  • If you receive an email from a source you know but it seems suspicious, contact that source with a new email, rather than just hitting reply.
  • Don't post personal data, like your birthday, vacation plans, or your address or phone number, publicly on social media
5 0
3 years ago
The more _____ a thumb drive has, the more storage capability it will provide. Hertz, bytes or pixels. The more _____ a micropro
beks73 [17]

Answer:

a) bytes

b) hertz

c) 1) hertz  and 2) bytes

Explanation:

A byte is the basic unit of information and data stored in a computer storage.  Hence, the storage capability of a drive will be measured in Bytes. On the other hand speed of processor is measured in terms of number of cycles made per second i.e hertz. Hence, the higher the value of hertz the higher is the speed of the computer.

5 0
3 years ago
Does anyone know how to move the search bar
jekas [21]

Answer:

I know how to on a phone, it's not the same on a computer. I wish I could help, I have the same problem sometimes :(

Explanation:

8 0
3 years ago
Other questions:
  • You are boating on a lake. the weather turns bad. what should all passengers do first?
    14·2 answers
  • 125 • 12² what is the answer?<br>- 124​
    6·1 answer
  • Computer input is the process of translating physical signals (light, sound, movement) into which of the following?
    8·2 answers
  • What is an example of CT SO?
    9·1 answer
  • To use the AutoCalculate area, select the range of cells containing the numbers for a calculation you want to verify and then pr
    6·1 answer
  • Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can_______ the appropriate
    5·1 answer
  • Tell me the errors please
    14·1 answer
  • A major retailer wants to enhance their customer experience and reduce losses
    9·1 answer
  • assume there are K sorted lists, each of n/k elements. We want to merge them into a single sorted list of n elements. Give an op
    7·1 answer
  • Suppose you made an error while creating your document. You used the word b. Find and Replace dialog box "SDAM" instead of "SIMA
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!