欢迎大家加入京东淘宝捡垃圾群:698433653
可以自己试着跑,初学入门 函数的使用!
# #打印问候语
# def greet_user(username):
# """显示简单的问候语"""
# print("hello!")
# print("hello!"+username.title()+"!")#向参数传递信息
# greet_user('jesse')
# #传递实参
# def describe_pet(pet_name, animal_type='dog'):
# #def describe_pet(pet_name, animal_type):#亦可
# '''显示动物的信息'''
# print("\nI have a"+animal_type+".")
# print("My "+animal_type+"'s name is "+pet_name.title()+'.')
# # 等效的函数调用
# describe_pet('harry')
# describe_pet(animal_type='dog',pet_name='harry')#关键字实参
# describe_pet(animal_type='dog',pet_name='harry')#关键字实参
#返回值
# def describe_pet(pet_name, animal_type):
# '''返回整洁的值'''
# full_name = pet_name+' '+animal_type
# return full_name.title()#首字母大写
#
# mu = describe_pet('aaa','bbb')
# print(mu)
#让实参变成可选的
# def describe_pet(pet_name, animal_type,middle=''):
# '''返回整洁的值'''
# if middle:
#
# full_name = pet_name+' '+middle+' '+animal_type
# else:
# full_name = pet_name + ' ' + animal_type
# return full_name.title() # 首字母大写
#
# mu = describe_pet('aaa','bbb','ccc')
# print(mu)
# mu = describe_pet('ddd','eee')
# print(mu)
# #返回字典
# def bulid_person(f_name,l_name):
# person={'f':f_name,'l':l_name}
# return person
# mu = bulid_person('jj','kk')
# print(mu)
#传递列表
# def greet_user(names):
# '''向列表中的每位用户都发出简单的问候'''
# for name in names:#for循环 依次输出列表的数据
# msg = "Hello,"+name.title()+"!"
# print(msg)
# usernames = ['h','t','m']
# greet_user(usernames)
#在函数中修改列表
# un = ['a','b','c']
# co = []
# while un:
# cu =un.pop()
# print("Print model:"+cu)
# co.append(cu)
# print("\nThe following models have been printed:")
# for cos in co:
# print(cos)
#传递 任意 数量的实参
# def make_pizze(*top):
# print(top)
# make_pizze('pp')
# make_pizze('aa','bb','cc')
def make_pizze(*top):
for topp in top:
print(topp)
make_pizze('a','s','d')