Python First Experience

Source: Internet
Author: User

2017 the last day, in the QC Inculcation, I finally wrote (back) six questions, the basic syntax of Python has a general understanding.

1, A+b+c

Just to practice the input, Line=input (). Split () into the list, split open to assign to A,b,c, don't forget to turn int

2. The problem of removing surplus

As with the previous question, there is a% redundancy and a simple if condition selection.

3. Judging prime numbers

There is an import imported into the math package, and a DEF definition function, M.SQRT (x) is the root of x, with a for to traverse, range () left closed right, and if statement ellipsis (true is executed).

4. Matrix flipping

This problem is the most difficult, in order to talk about this problem, QC back to me a two-dimensional array demonstration, moved ing~

Expand Mat by Line=[[]]*m, expand by column, enter data, then swap mat[j][i], Mat[j][n-1-i]=mat[j][n -1-i],mat[j][i], the same can be up and down. The output is a traversal.

5. Duplicate elements in the migration group

The use of Set element non-repeatability

6, the length of the last letter

Output list the length of the second element with print (line[-1].__len__ ())

Finally thanks to QC, you are the best and most powerful father in the world ~

Python First Experience

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.