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
If we assume the modern view of existential import, why is the following syllogism invalid? No computer is made of clay. All com
Papessa [141]

Answer:

<u>because the conclusion is not in agreement with the two premises.</u>

Explanation:

<em>Remember</em>, the term<u> syllogism</u> refers to the form of reasoning that draws its conclusion based on the stated premises. In other words, a conclusion is reached if it satisfies <em>all or part </em>of the premises.

In this case, the statement "No computer is made of clay" and  "All computers are electronic devices" should be inferred to mean, <em><u>No </u></em><em>electronic devices are made of clay" </em>not<em> </em><em>"Some electronic devices are not made of clay," </em>since the two premises neither suggest that electronic devices are made from clay.

5 0
3 years ago
What type of volcano is Dukono
ValentinkaMS [17]
Dukono is an active volcano located in the northern part of Halmahera island, Indonesia. It has a broad profile and is capped by compound craters.
8 0
3 years ago
Unit testing:_________. A. provides the final certification that the system is ready to be used in a production setting. B. incl
NARA [144]

Answer:

Option (C) is the correct option to the following question.

Explanation:

The following option is correct because the unit testing is the process of testing a single unit of software at a time, which means the testing of each and every program separately.

In simple words, Unit testing a process of testing in which the developer executes the single method or a function, statements or loop in the program of the software to checking is it working fine or not.

7 0
3 years ago
Name two different ways you can bring up the my computer folder
sweet [91]

The My Computer folder is a multipurpose tool and is a gateway to all the data stored in the computer. This folder sits at the top of your laptop or PC. It can be found on your computer’s desktop, on the start menu and within the windows explorer. <u>Clicking or double clicking on these options will bring up the My Computer folder. </u>

<u>Another easier way of doing this is to hold down the windows + E combination keyboard keys.</u>

7 0
3 years ago
Read 2 more answers
Which of the following is the fastest growing input technique​
Natali [406]
We need more information for this one, please.
8 0
3 years ago
Other questions:
  • Electronic files created on a computer using programs such as word software are considered to be
    15·1 answer
  • 10 points (sorry it won’t let me do more points)
    10·1 answer
  • Betrand Meyer developed the ______ programming language which is not type-safe because it violates the law of contravariance.
    9·1 answer
  • A digital designer might do computer animation or video games true or false
    13·2 answers
  • When troubleshooting firewalls, you should never attempt to repeat the problem because you could do more damage. T/F
    6·1 answer
  • In order to get a comprehensive evaluation of the computer programmers he managed, Justin organized a(n) __________, where he as
    11·1 answer
  • Write an expression to compute the quartic root of x. the quartic root of a number is the square root of its square root. exampl
    11·1 answer
  • What are the most commonly found items in the trash according to the Municipal Solid Waste report?
    12·2 answers
  • CLICK ME IF U DARE hehehe
    10·2 answers
  • What complications are imposed if one tries to implement a dynamic list using a traditional one-dimensional array
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!