Python 30th days-class, python 30th days

Source: Internet
Author: User

Python 30th days-class, python 30th days
Programming Paradigm

Programming is the process in which programmers use code consisting of specific syntaxes, data structures, and algorithms to tell computers how to execute tasks, A program is a set of commands compiled by programmers to get the results of a task. There are many different ways to implement a task, summarize the features of these different programming methods, that is, the programming paradigm. Different programming paradigms essentially represent different ideas for solving problems for various types of tasks. Most languages only support one programming paradigm, and of course some languages support multiple programming Paradigms at the same time. The two most important programming paradigms are process-oriented and object-oriented programming.

 

Object-Oriented Programming: OOP object oriented programing

You can use 'class' and 'object' to create models to describe the real world.

The opposite core:

Class: A class is the abstraction, blueprint, and prototype of an object with the same attributes. in the class, all attributes of these objects are defined (variables (data )) common method.

Object: an object is an instance after a class is instantiated. A class must be instantiated before it can be called in a program. A class can instantiate multiple objects, each object can have different attributes.

ENCAPSULATION:

Assign values to data in the class. Internal calls are transparent to external users. This makes the Class A container, which contains class data and methods.

Inheritance:

A class can be derived from a subclass. The attributes defined in this parent class are automatically inherited by the subclass.

Polymorphism:

Polymorphism is an important feature of object-oriented. An interface and multiple implementations refer to different subclasses in a base class, each subclass inherits the same method name and implements different methods of the parent class!

1 def dog (name, gj): # define dog 2 data = {3 'name': name, 4 'gj ': gj 5 6} 7 return data 8 def pop (name, gj, lev, hp, mp): # defined by 9 data = {10 'name': name, 11 'gj': gj, 12 'lev': hp, 13 'hp ': hp, 14 'mp': mp15} 16 return data17 18 def bark (d ): 19 print ("dog % s: Wang" % d ['name']) 20 21 def walk (p): 22 print ('person % s: speaker '% p ['name']) 23 24 dog1 = dog ('dash', '000000') 25 print (dog1)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.