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
laiz [17]
3 years ago
14

How does object-oriented programming work in Python?

Computers and Technology
1 answer:
Serggg [28]3 years ago
3 0
So basically you have a class, and within that class you have methods and instance variables; very much like how object oriented programming works in other languages. However, the main difference is that the class constructor in Python is defined right within the class object and is denoted by the method name, "__init__" and requires a parameter of "self". 
Ex:
class Py:
    def __init__(self):
          <em>constructor code...
</em>The __init__ method is what is called first when an object of the class is instantiated. The way you instantiate an object is by the following:
<em />object_name = Py()

If you wanted to make your class more useful, you could add more parameters to your __init__ constructor, so when an object is created you can pass arguments to that object:
class Py:
    def __init__(self, name, age):
         self.name = name
         self.age = age
         print "Your name is %s and you are %d years old" % (name, age)
def main():
     Bob = Py("Bob", 23)
if __name__ == "__main__":
     main()

This code would give you: Your name is Bob and you are 23 years old
You might be interested in
​which type of cryptography provides the most security?
Doss [256]

Answer B: Asymmetric cryptography, because the receiver has its own decryption key and cannot create encrypted messages, because he doesn't have the encryption key.

About the other answers:

A: Private keys are always involved, there has to be some secret to do encryption, so this answer doesn't say very much.

C: Digital signatures can be used to verify/prove some data comes from some person (the signer) in an unaltered way. It is not about encryption, so is not about the security of your message. You use it in combination with encryption.

D: Like A, this doesn't say very much. Shared secret keys (symmetric keys) can be used for encryption, but they are less secure since the keys have to exist in more than one place (sender and receiver).



4 0
3 years ago
Cell division is called:
Blizzard [7]

Answer:

Mitosis

Explanation:

6 0
3 years ago
Spelling and grammar checking options can be controlled at the word options dialog box. To display this dialog box, begin by cli
Cerrena [4.2K]
By clicking the file tab
8 0
4 years ago
According to the text, there are always _________ keys from a letter name to its next occurrence up or down the keyboard.
Anna007 [38]

Answer:

8 (eight)

Explanation:

A piano keyboard is a musical instrument, with tabs of white and black keys that makes sound ranging from a low pitch to a high pitch sound. Its keys a labelled from A to G and occur several times on the keyboard.

If a letter "C" is pressed on the keyboard, a count of eight keys gives another occurrence of "C" again, whether it is counted upwards or downwards , but it gives a slightly higher pitch than the former "C".

6 0
4 years ago
What protocol does a web browser normally use? at which osi layer does this protocol work?
Nookie1986 [14]
The answer is HTTP and it works over the application layer. The hypertext transfer protocol or as called as HTTP is an application protocol for distributed, collaborative and hypermedia information systems in which this is the foundation of the data communication for the world wide web or as called as www. 
6 0
3 years ago
Other questions:
  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
    15·1 answer
  • How has social media and the workplace affected you?
    6·1 answer
  • reading is important blank areas of life A in very few B in many C only in academic D only in career​
    10·1 answer
  • Digital art is created by using __?
    5·1 answer
  • An algorithm is defined as a well-ordered collection of unambiguous and effectively computable operations that when executed pro
    10·1 answer
  • An option button is<br>​
    14·2 answers
  • ¿Qué herramienta web es google drive?
    12·2 answers
  • PowerPoint SAM Capstone Project 1 can PLEASE someone do it for me I have some directions like steps and you just have to do it i
    10·2 answers
  • Who is considered as the father of computer science​
    8·2 answers
  • When viewing an e-book section of an assignment in launchpad, you can return to your main course page at any time by clicking th
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!