Design and development of python-object-oriented programming

Source: Internet
Author: User

Programming Paradigm

1, the different types of tasks, the use of different ways to solve the problem.

2. There are two kinds of programming paradigm

1. Process-oriented programming

2. Object-Oriented Programming

process-oriented programmingWhat is process-oriented programming?

Process-Steps to solve the problem

To solve a big problem

1, first to split the big problem into a number of small problems or sub-processes.

2. Then the sub-process is split into small problems or sub-processes

3, until the small problem can be solved in a small step in the range.

What are the pros and cons?

Advantages: The complexity of the problem flow, programming difficult.

Cons: Poor scalability

Write code:

Write a simple user registration program

#1 Write a user registration program#process-Oriented programming methods:#1. User Input account password#2. User input Legality detection#3. Write to Input library#Note:#Advanced : How do I change the email registration function when I need to increase it? ImportJSONdefInteractive ():#Step 1user = input ('>>'). Strip () PSW= Input ('>>'). Strip ()return {        'name': User,'pwd': PSW}defCheck (User_info):#Step 2Is_value =TrueifLen (user_info['name']) ==0:Print('user name cannot be empty') Is_value=FalseifLen (user_info['pwd']) < 6:        Print('password cannot be less than 6 bits') Is_value=Falsereturn {        'Is_value': Is_value,'User_info': User_info}defRegister (Check_info):#Step 3    ifcheck_info['Is_value']: with open ('json.db','W', encoding='Utf-8') as F:json.dump (check_info['User_info'], F)defMain (): User_info= Interactive ()#Step 1Check_info = Check (user_info)#Step 2Register (Check_info)#Step 3if __name__=='__main__': Main ()
View Code

Increase input Email Registration

#1 Write a user registration program#process-Oriented programming methods:#1. User Input account password#2. User input Legality detection#3. Write to Input library#Note:#Advanced : How do I change the email registration function when I need to increase it? ImportJson,redefInteractive ():#Step 1user = input ('>>'). Strip () PSW= Input ('>>'). Strip () email=input ('>>'). Strip ()return {        'name': User,'pwd': PSW,'Email': Email}defCheck (User_info):#Step 2Is_value =TrueifLen (user_info['name']) ==0:Print('user name cannot be empty') Is_value=FalseifLen (user_info['pwd']) < 6:        Print('password cannot be less than 6 bits') Is_value=Falseif  notRe.search (R'@.*?\.com$', user_info['Email']):        Print('Bad mailbox Format') Is_value=Falsereturn {        'Is_value': Is_value,'User_info': User_info}defRegister (Check_info):#Step 3    ifcheck_info['Is_value']: with open ('json.db','W', encoding='Utf-8') as F:json.dump (check_info['User_info'], F)defMain (): User_info= Interactive ()#Step 1Check_info = Check (user_info)#Step 2Register (Check_info)#Step 3if __name__=='__main__': Main ()
View Code

Application scenarios?

Once the feature is implemented, few changes are made to the scene. Scenarios such as automatic deployment scripts.

Object-oriented programming what is object-oriented programming?

What are the pros and cons?

Application scenarios?

Design and development of python-object-oriented programming

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.