If the college entrance Examination Python programming, these questions you will how many?

Source: Internet
Author: User

Python (pronunciation: English [? Pa?θ?n], beauty [? Pa?θɑ:n]), is an object-oriented, literal translation of computer programming language, but also a powerful general-purpose language, has nearly 20 years of development history, mature and stable. It contains a comprehensive set of standard libraries that are easy to understand and can easily accomplish many common tasks. Its syntax is very simple and clear, unlike most other programming languages, it uses indentation to define the statement.

Python supports imperative programming, object-oriented programming, functional programming, slice-oriented programming, generic programming, and many programming paradigms. Like scheme, Ruby, Perl, Tcl and other dynamic languages, Python has garbage collection and can automatically manage storage usage. It is often used as a scripting language to handle system administration tasks and network programming, but it is also well suited to perform high-level tasks. The Python virtual machine itself can run on almost all operating systems. Using tools such as Py2exe, PyPy, Pyinstaller, you can convert Python source code into a program that can run out of the Python interpreter.

College Entrance Examination Parting

Autumn is a year of college entrance examination, first of all let us bless the students who will enter the examination room, I hope they can be admitted to the ideal university, although for some people the university is just a place to knock (DA) Generation (xi), but still wish they can go to a good school, after all, fast speed point.

I believe we all know that Python was selected in Shandong Primary school textbooks, Zhejiang Province Information College Entrance examination, then if one day Python formally entered the college entrance examination, what will be the topic? How can you not make it?

So today, dare to give a question, please well paid answer-

Send sub-question


Life is short and _______.


Click on the space below to get an answer

I use Python

Basic questions

Brief answer

What do these two parameters mean: *args,**kwargs? Why should we use them? (An interview question)


Click on the space below to get an answer

Tip: Drag the text down to see the full answer

If we are not sure how many arguments to pass into the function, or if we want to pass parameters in the form of lists and tuples to the function, then use *args; if we do not know how many keyword parameters to pass into the function, or if we want to pass in the value of the dictionary as a keyword parameter, then we need **kwargs. The two identifiers of args and Kwargs are conventionally used, and you can certainly use *bob and **billy, but that is not quite right.

Practical Exercises

Project Assessment

How do I crawl the "Glory of Kings" skin image with Python? (Novice crawler case)


Here are the answers

First go to all Heroes list and you'll see

This page contains all of the heroes, avatars and hero names.

The Python learning route is divided into three main stages: basic-advanced-framework-project combat

Basic first Stage: understanding of basic python. Basic second stage face to object programming (emphasis on programming ability)

The third stage of the basic object-oriented "design idea"-encapsulation-inheritance. Basic Phase IV Python advanced topic.

The first stage of Advanced class: Linux Foundation. Second: Python Web tools. The third Python deployment tool.

The four relational database. Fifth Python web Framework Foundation principle.

Framework phase. Python Web development phase web.py. Base Second Django Foundation.

The Third Flask Foundation. The foundation of the four tornado,

Project Combat: Personal Blog System-development-Enterprise OA system = Network Disk System.

Single hero

Click on one of the hero's avatars, such as the first "thyme compliance", and go in as follows:

The 196.shtml characters in the URL are immutable, and only 196.shtml are changed. And 196 is the "thyme compliance" the hero of the corresponding figures, to climb the image should be entered into each hero skin images of the URL, and all the hero's URL is the key to each hero corresponding number. So how do we find these numbers?

Hero numbers

In the list of all heroes, open the browser's developer tool, refresh and find a JSON-formatted file:

At this point, you will see all the heroes corresponding numbers. The URL format for the JSON file can be found in the headers shown. Import it into Python, extract the numbers, and then simulate all the heroes ' URLs

The section code is as follows (Ubuntu (Linux) system):






#导入json文件 (with all the heroes ' names and Numbers)

Url= ' Http://pvp.qq.com/web201605/js/herolist.json ' #英雄的名字json

head={' user-agent ': ' Change to your own head '

html = requests.get (url,headers = head)

Html=requests.get (URL)

Html_json=html.json ()


Hero_name=list (Map (lambda x:x[' cname '],html_json)) #名字

Hero_number=list (Map (lambda x:x[' ename '],html_json)) #数字

Download image

Now you can go to all the heroes URLs and crawl the images under the URLs. Go to a Hero's URL, open the Developer tool, refresh under the network and find the hero's skin image (remember it's a big picture). :

Then view the URL of the image in headers. Will find the skin pictures are regular. We can simulate the image URL in this way: ' http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/' +str (v) + '/' +str (v) + '-bigskin-' + STR (u) + '. jpg ', where only str (v) and STR (u) are changed (STR () is a function in Python), str (v) is a hero corresponding number, str (u) is just the picture number, for example, the first image is 1, the second is 2, the third ... And a hero's skin should not be more than 12 (this value can be adjusted to 20, etc.). Then it's downloaded.

The downloaded code is as follows (some addresses are to be replaced by your own):

Swipe right to see the full code

Just execute the main function when you're done with the above code.

Crawl down the picture is like this, each folder inside is the hero corresponding to the picture, such as:

The above is to tidy up a few Python questions, do not know how you will do? If it doesn't matter for the moment-life is too short, I use python!

What can python do?

Web development and crawler are more suitable for the 0 foundation

Automated operation and maintenance development and automated testing are suitable for those who are already doing operations and testing

Big Data data analysis This aspect is very need professional professional of relatively strong

Scientific calculations are generally used by researchers

Machine learning and AI first degree requirements high next high number requirements high difficulty is very big

I have a public number, and I often share some of the stuff about Python technology. If you like my share, you can use the search "Python language learning" to follow

Welcome to join thousands of people to exchange questions and answers skirt: 588+090+942

If the college entrance Examination Python programming, these questions you will how many?

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.