python basis of a day17 jobs

3. map # treated string list, the list of all become sb, for example alex_sb 
name = [ 'Alex', 'wupeiqi', 'yuanhao', 'Nezha']
# DEF FUNC (Item):
# return Item + '_ SB'
# RET = Map (FUNC, name) #RET iterators
# for I in RET:
# Print (I)
# Print (List (RET))

# RET = Map (the lambda Item: Item + '_ SB' , name)
# Print (list (RET))

# 4. a digital filter function processing list, the list will filter out all of the even numbered
# NUM = [1,3,5,6,7,8]
# DEF FUNC (X ):
#% 2 == 0 X IF:
# return True
# RET = filter (FUNC, NUM) #RET iterators
# Print (List (RET))
#
# RET = filter (the lambda X: X% 2 == 0, NUM)
# RET = filter (the lambda X: IF True X False the else% 2 == 0, NUM)
# Print (List (RET))

# 5. the free to write more than one line in the file 20
# Run the program, first read the contents of memory, with a list of storage.
# Receiving user input page, page 5, the output only when the contents of the page

# with Open ( 'File', encoding = 'UTF-. 8') AS F:
# f.readlines L = ()
# The page_num = int (INPUT ( "Please enter the page: '))
# pages, divmod MOD = (len (L),. 5) # find how many pages there are no remaining rows
# if mod: # if the number of remaining rows, the number of pages plus a
# pages + = 1 # a total number of page
# if page_num> pages or page_num < = 0: # of pages input by the user or less than the total number 0
# Print ( 'mistyped')
# == pages elif the page_num and mod = 0:! # If the page is the last page of the user input, and before there remaining rows
# for I in Range (MOD):
# Print (L [(. 1-the page_num). 5 * + I] .strip ()) # output only on the remaining lines of the page
# the else:
# for I in Range (5):
# Print (L [(. 1-the page_num) * 5 + I] .strip ()) # 5 output line

# 6. the following, each small dictionary name corresponding to the name of the stock, shares corresponding to the number of shares, price corresponds to the price of the stock
# portfolio = [
# {'name': 'IBM', 'shares': 100, 'price': 91.1},
# {'name': 'AAPL', 'shares': 50, 'price': 543.22},
# {'name': 'FB', 'shares': 200, 'price': 21.09},
# {'name': 'HPQ', 'shares': 35, 'price': 31.75},
# {'name': 'YHOO', 'shares': 45, 'price': 16.35},
# {'name': 'ACME', 'shares': 75, 'price': 115.65}
# ]

# 6.1.计算购买每支股票的总价
# ret = map(lambda dic : {dic['name']:round(dic['shares']*dic['price'],2)},portfolio)
# print(list(ret))

# 6.2.Filtered with filter out, the unit price is greater than the stock 100 which # Print (List (RET))# RET = filter (the lambda DIC : DIC [ '. price']> 100, Portfolio)# Print (List (RET))
# RET = filter (the lambda DIC: True IF DIC [ '. Price']> 100 the else False, Portfolio)




# Big week job
# this week written all blog address, url page is accurate to at least three, is not limited
# big job: py readme (job description, the way you can write something that you want to communicate and guide members ) flow chart
#

Guess you like

Origin www.cnblogs.com/wang-tan/p/11082297.html