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
PLEASE HELP ME! How should you behave in an online academic environment? Check all that apply. Keep messages brief Respect the c
Colt1911 [192]

Answer:

Maintain discipline

Ask questions

Try not to crack jokes

dress smartly

be friendly

dont underestimate anyone each person have their own unique skills

Explanation:

4 0
4 years ago
Read 2 more answers
Which letters appear in the home row on a keyboard?
ZanzabumX [31]
C) A, S, D, F, G, H, J, K, L

The home row of keys are the keys which are in the middle of the keyboard. F and J have little bumps on them, which signify that they are the home keys. The home row is also where your fingers are meant to return when not typing.

5 0
3 years ago
Read 2 more answers
What is the Slide Sorter View used for?
bonufazy [111]

Answer:

b. bc u can delete and add slides in ur presentation

3 0
3 years ago
Read 2 more answers
You are sending a very small amount of information that you need the listening program to respond to immediately. Which Transmis
Romashka-Z-Leto [24]

Answer:

Explanation:

hjggggggggggggg

8 0
3 years ago
Read 2 more answers
Tikenya was responsible for creating the PowerPoint presentation for the group project. When it was complete, she wanted to emai
Anna35 [415]

Answer:

They had to unzip or extract the zipped/ compressed presentation to see it.                          

Explanation:

  • Compressed file or a zip file contains a large file or more than one files that are packed or enclosed that large file or several files into a file or a folder.
  • The compressed file or folder takes less space than the actual large file or set of files.
  • Just as in this scenario the presentation file was larger than the size of what an email file should be. So Tikenya had to compress the file in order to email it to other members.
  • The other members can open the PowerPoint presentation by following any of the below mentioned methods:
  • In Windows to open a compressed file, right click on that file and select Extract All option.
  • File can also be seen by opening that file or folder and dragging that file or folder from the zipped folder to a new location. In Windows this will automatically extract the files.
  • This file can also be opened using a software like WinZip. Download WinZip. Then download the file which is sent in email and double click on that file which will open WinZip wizard dialogue box. Clicking that presentation file from the dialogue box will open another dialogue box confirming the opening of that file. By clicking on OK the presentation file will be opened and can be viewed now.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Write qbasic code for given pattern<br><br>NEPAL<br>. EPA<br>. P​
    12·1 answer
  • DSSS uses a chipping code to encode redundant data into the modulated signal. Which two of the following are examples of chippin
    12·1 answer
  • Which of the following is considered part of the process in the systems thinking example of a TPS?
    6·1 answer
  • What is the purpose of a diode in a cordless drill or power screwdriver?
    14·1 answer
  • Which quality is likely to ensure consistent career growth in the computer field?
    9·2 answers
  • Let f be the following function: int f(char *s, char *t){char *p1, *p2;for(p1 = s, p2 = t; *p1 != ‘\0’&amp;&amp; *p2 != ‘\0’; p1
    6·1 answer
  • Direct Mapped Cache. Memory is byte addressable. Fill in the missing fields based upon the properties of a direct-mapped cache.
    6·1 answer
  • There is a class called Roster whose constructor takes a List of tuples with the names of students and their grades in the class
    13·1 answer
  • What kind of electronic communication might commonly be affected by citizen journalism?
    9·1 answer
  • (Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!