Python Exercises-builder expressions-filtering and operations

Source: Internet
Author: User

# Editor: Shanlong l = [2, 3, 4, 5, 6,7 for in#  get a new list L1, each element in the new list is the square of the value of each element in L /c6>printforif i > Max]#  filter out values greater than 40 in L1 and sum  print(sum (L1))

Above, there's nothing to say

#edited by: ShanlongShares = {    'IBM': 36.6,    'Lenovo': 27.3,    'Huawei': 40.3,    'Oldboy': 3.2,    'Ocean': 20.1}#question one: A list of stock names with a stock price greater than 30L = [i forIinchSharesifFloat (shares[i]) >30]Print(L)#question two: Find out the total price of all stocksL1 = [I forIinchshares.values ()]Print(SUM (L1))

The above, or special, nothing to say

#edited by: Shanlong#There are two lists of the names of the old boys who enrolled in the Linux and Python classes.Linux = ['Steel Bullets','Small Gecko','Little Tiger ratio','Alex','Wupeiqi','Yuanhao']python= ['Dragon','Steel Bullets','zhejiangF4','Little Tiger ratio']#question one: Get a list of students who sign up for both Linux and PythonL = [i forIinchLinuxifIinchPython]Print(L)#question two: Get a list of students who only sign up for Linux and not sign up for PythonL = [i forIinchLinuxifI not inchPython]Print(L)#question three: Get a list of students who only sign up for Python and not enroll in LinuxL = [i forIinchPythonifI not inchLinux]Print(l)

Above, there's still nothing to say

It's a wordless ending today, Battambang.

Python Exercises-builder expressions-filtering and operations

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.