Python学习:函数
1.函数参数分形参和实参,形参在定义是使用,实参在条用时使用;
2.实参有位置实参、关键字实参、可选实参、任意数量实参;
3.函数可以存储在模块中,模块是一个独立的文件。
# employee moudle
def input_employee():
"""Obtain employee information through user input"""
employee = {
'name':'', 'age': 0, 'sex': 'male',
'position': '', 'score': 0
}
while True:
for key in employee.keys():
employee[key] = input("Please give the empolyee's " + key + ": ")
if employee[key] == '':
break
if key == 'age' or key == 'score':
employee[key] = int(employee[key])
end_of_input = input("Do you want to continue? (Y/n) ")
if end_of_input.lower() != 'y':
break
return employee
def employee_informat