python function operation

Function definition # 
# for code reuse
# DEF print_verse ():
# # function body
# print ( 'hoe Wo day when afternoon')
#
# print_verse ()
# print_verse ()
# print_verse ()

# DEF print_verse (verse_name):
# # # function body
# # if verse_name == 'Nostalgia':
## Print ( 'Moonlight')
# # elif verse_name == 'Saying Good':
## Print ( 'I go gently ... ')
# #
# # print_verse (' CAMBRIDGE ')

# return value
# DEF calc_exchange_rate (AMT, Source, target):
# IF Source ==' BGN 'and target ==' USD ':
# = Result AMT / 6.7516
# # Print (Result)
# return Result
#
# = R & lt calc_exchange_rate (100,'CNY','USD')
Print # (R & lt) 14.811303987203035


# Tips
# DEF calc_exchange_rate (AMT, Source, target = 'USD'):
# IF Source == 'BGN' and target == 'USD':
# = Result AMT / 6.7516
# elif Source = = 'BGN' and target == 'EUR':
# = Result AMT / 7.7512
# return Result
#
# = R & lt calc_exchange_rate (100, 'BGN', 'EUR')
# Print (R & lt)

# parameter passing sequence
# def calc ( A, B, C):
# return (A + B) * C
#
# L = [1,5,20]
# 120 #
# Print (Calc (L *))

# dictionary parameter passing
# def health_check (name, age ):
# Print ( 'good health', name, Age)
# param = { 'name': 'John Doe', 'age': '28 '}
# # Good health and Joe Smith 28
# health_check (** param)

The return value comprising a plurality of data #
# DEF get_detil_info ():
# DIC1 = {
# 'Employee': [
# { 'name': 'John Doe', 'the salary': 8000},
# { 'name': 'John Doe ',' the salary ': 2000},
#],
#' Device ': [
# {' ID ':' 234 342 ',' title ': 234},
# {' ID ':' 243 234 ',' title ': 20.04324 million },
#]
#}
# return DIC1
# Print (get_detil_info ());

Guess you like

Origin www.cnblogs.com/ericblog1992/p/11275617.html