How operation and maintenance personnel learn Python Programming

Programmer Pike 2022-06-23 17:41:27 阅读数:840

operationmaintenancepersonnellearnpython

Never write code , To be able to write code to solve problems independently . This question is very important ! Blind learning of so-called projects , Finally, I still can't write my own code to solve the problem . First of all, we solved the problem of writing code independently , Then through the project to strengthen training .

O & M must understand development , especially python Development , We have reached a consensus , Do not understand the operation and maintenance of development , The road will get narrower and narrower .

The difficulties encountered in some o & M are : Some don't even understand books ; Some books can be read , Simple code written by others can also be understood , But I can't write code to solve problems .

The author believes that learning programming is more than learning grammar , Need to learn algorithms ( Computational Thinking 、 Solutions to problems 、 Programming ideas ).

What is Computational Thinking :

 Computational Thinking (Computational Thinking) The concept is a natural product of the development of computer science .
 It was Carnegie who first clearly used this concept · Zhou Yizhen of Mellon University (Jeannette M. Wing) professor . For novices, Xiaobai wants to learn more easily Python Basics ,Python Reptiles ,web Development 、 big data , Data analysis , Artificial intelligence and other technologies , Here to share the system teaching resources , Take off my lieutenant ( Tongying ): 2763 177 065 【 course / Tools / Method / Solve the problem 】
 Computational thinking is to use the basic concepts of computer science to solve problems 、 Designing systems and understanding human behavior ;
 The most fundamental content of Computational Thinking , That is, its essence is abstraction and Automation .

Programming ideas , In fact, it is the concrete embodiment of computational thinking , Use grammar to express solutions to problems 、 Algorithm .

Let's talk about how to learn python

1、 Buy a good book , Recommend 《python Programming core 》, One book is enough .

2、 While reading , You need to tap the code , Every code in the book needs to be typed , In the process of knocking , To encounter problems . Problems encountered , Find a solution to , To improve .

3、 We also need to do proper exercises to strengthen our study .

4、python There are many programming paradigms , Process oriented , object-oriented , Functional programming, etc . It is suggested to start with process oriented learning .

Some friends aim high , Even the basic logical expression is not clear , Circulation and judgment are not clear , Just want to learn django.

Question 1 :

Output the following styles 1,2,3,4,5,6,7,8,9,10

Many beginners , Will write the following code ,

 for i in range(1, 11): print str(i) + ",",

The output is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,

I don't know how to output the last comma . Tell you , I know when I read if Judgment statement , But the practical application is not good .

Analyze this style 1,2,3,4,5,6,7,8,9,10 The last one has no comma , There is a comma in front of it , This is obviously a judgment . For novices, Xiaobai wants to learn more easily Python Basics ,Python Reptiles ,web Development 、 big data , Data analysis , Artificial intelligence and other technologies .

So the code is written like this :

 n = 10 for i in range(1, n+1): if i < n: print str(i) + ",", else: print str(i) Question two :

Counting cycle , I believe most of the toy codes in the book can be understood .

The following question , Beginners do not necessarily think of using counting loops to solve this problem .

Code 1 :

A couple M Text file for , It needs to be every 100 Lines are written to the new file .

Don't underestimate the counting cycle , This problem can be solved by counting loops and judging statements .

coding:utf-8
with open('dist_1.txt','r') as f1 ,open('dist_new.txt','w') as f2: i = 0 for line in f1: i += 1 if i % 100 == 0: f2.write(line)

Code 2 :

A log text file has 2000 That's ok , I want to extract 100 Row to 200 That's ok , How do you do it? ?

You can try the following methods .

Don't look down on while Count cycle , In fact, it can be used to do many things .

 #coding:utf-8 i = 0 file1 = open("test.txt","r") file2 = open("out.txt","w") while True: line = file1.readline() i += 1 if 100<=i and i<=200: file2.write(line) if i >200 : break if not line: break file1.close() file2.close() 5、 Function abstraction 、 We need to master how to resolve big problems into small ones , Every little problem is solved by a function , The big problem will be solved by integration .

6、 Object oriented class abstraction , A class is the blueprint of an object composed of attributes and methods . Be able to model with object-oriented ideas .

summary : Is there a programming idea , It is the key to whether you can write code yourself . Master some common simple algorithms : Exhaustive method , Dichotomy , recursive algorithm , A recursive algorithm , Backtracking algorithm and so on ;

The most important thing is problem-solving training , Have ideas , Be able to solve problems independently , To be invincible in the workplace !

版权声明:本文为[Programmer Pike]所创,转载请带上原文链接,感谢。 https://pythonmana.com/2022/01/202201061849383286.html