[Python]《从入门到实践》第八章-函数

# -*- coding: utf-8 -*-
"""
Created on Wed Jul 25 17:51:29 2018

@author: yangzifeng_i
"""

#指定默认值
def describe_pet(pet_name,animal_type='dog'):
    print("\nI have a "+animal_type+".")
    print("\nMy "+animal_type+"'s name is "+pet_name+".")
describe_pet(pet_name='lily')
#返回值
def name(first_name,last_name):
    full_name=first_name+' '+last_name
    return full_name.title()
name("Li","Luo Ke")
##返回字典
def build_person(first_name,last_name):
    person={'first':first_name,'last':last_name}
    return person
build_person('jimi','hendrix')

#结合使用函数和while循环

猜你喜欢

转载自blog.csdn.net/TOMOCAT/article/details/81207867