Day5-python Study notes (eight) built-in functions

Source: Internet
Author: User

 #函数即变量 
# len type print input str

# Print (All ([1, 2, 3, 4]) # to determine whether the values inside an iterated object are true
# print (Any ([0, 1, 2, 3, 4]) # To determine if the value inside the iterated object has a true
# print (Bin (100)) # decimal to binary
# ejz = Bin (+)
# print (Ejz.replace (' 0b ')
# Print (Chr (65)) # printable number corresponding ASCII
# print (Ord (' A ')) # Print the ASCII code corresponding to the string
# print (dir (1)) # Print the callable method of the incoming object
# print (eval (' [] ') # executes Python code and can only perform simple, defined data types and Operations
# code = ' def func (a):p ' # '
# Print (eval (code))
# code = ' Def A ():p rint (' AA ') '
# Print (EXEC code) # Execute Python codes
#zip
# Print (Filter (lambda x:x > 5, [12, 3, 12, 2, 1, 2, 35]) # The following iteration object Filters
# print (Map (lambda x:x > 5, [1, 2, 3, 4, 5, 6])

ids= [1,2,3,4,7,8,0,-1]
names=[' Little black ', ' small white ', based on the previous method ', ' Little Yellow ', ' little Green ']
names1=[' small black ', ' small white ', ' small yellow ', ' little Green ']

# for id,name,s in Zip (ids,names,names1):
# print (id,name,s)
Print (sorted (' 0123450 ')) #升序
Print (sorted (ids,reverse=true)) #降序
Round (1.987123,5) # Keep a few decimals

# def func (a):
# If a%2==0:
# return a
# Else:
# return ' odd '
# nums = [x for x in range (11)]
# Print (nums)
# res = map (func,nums)
# Print (list (res))
# #循环调用函数, and then put the result of each function processing into a list and return


def func (a):
If a%2==0:
Return True
Else
Return False
Nums = [x for x in range (11)]
# Print (nums)
res = filter (func,nums)
Print (list (res))
#filter is also for you to loop the call function, filter only save the result returned as true


function is variable
# def say (name):
# Print (name)
#
# YBQ = say
# YBQ (' original Treasure green ')

def add ():
Print (' Add Item ')
Def view ():
Print (' View Products ')
def delete ():
Print (' Delete item ')

Choice = input (' Please enter select 1, 2, 3, '). Strip ()

Menu = {
' 1 ': Add,
' 2 ': view,
' 3 ':d elete
}
If choice in menu:
Menu[choice] () #适合用于函数没有参数, or the parameter is the same.
Else
Print (' input error ')







Day5-python Study notes (eight) built-in functions

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.