函数定义和简单调用
公司新来部分新员工,定义函数并循环打印欢迎新员工的消息
employees = {"Chris": "NOC", "David": "PJM", "Brain": "SA", "John": "UX"} def introduce_employee(employee, post): print("Welcome our new colleague " + username + ", his post is " + job + " !") for key, value in employees.items(): username = key job = value introduce_employee(username, job)
输出
Welcome our new colleague Chris, his post is NOC ! Welcome our new colleague David, his post is PJM ! Welcome our new colleague Brain, his post is SA ! Welcome our new colleague John, his post is UX !