Linux Operations engineer face test fourth set

Source: Internet
Author: User

Python

1, suppose aaa=[1,1,1,3,5,2,6,1,7,3,45], how do you use Python to filter out the numbers repeated in the list?

>>>list (Set (AAA))


2, briefly describe the difference between list and tripe

List is dynamic, set up can be deleted elements, and tripe is static, can not delete elements, and tripe will automatically go heavy.


3. Briefly describe the difference between search () and match ()


4, how to generate a random number?

>>>import Random

>>>random.random ()

"comment" This will generate a floating-point number between 0~1.


5. Suppose aaa=["Messi", "Neymar", "Luis Suarez", "Pico", "Busquets", "Iniesta"],bbb=["Pico", "De Gea", "Ramos", "Iniesta", "Fa Fabregas", "Busquets", how to find the intersection and difference between the two lists?

Intersection: Ccc=[val for Val in AAA if Val in BBB]

Difference set: Ddd=[val for Val in AAA if Val not in BBB]

"Comment" DDD this difference is the AAA this list has but BBB does not have, if you want to show the BBB has and AAA not the elements, then switch Ddd=[val for Val in BBB if Val not in AAA]


6 . Reverse the string consisting of a word and an indefinite number of spaces, requiring the alphabetical order of the words to be the same. such as: "I love this game!"      Invert into "game! This Love I ".

>>> Import re

>>> AAA = "Ilove this game!"

>>> bbb= '. Join (Re.split (R ' (\s+) ', AAA) [::-1])

>>> Print (BBB)

"comment" This problem although a few words, but really difficult.




This article is from "Life is waiting for Gordo" blog, please make sure to keep this source http://chenx1242.blog.51cto.com/10430133/1742467

Linux Operations engineer face test fourth set

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.