ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

python基础练习题库实验7

2026/8/7 12:51:44 拓冰建站 浏览量
python基础练习题库实验7

文章目录

  • 题目1
    • 代码
    • 实验结果
  • 题目2
    • 代码
    • 实验结果
  • 题目3
    • 代码
    • 实验结果
  • 题目总结


题目1

编写代码创建一个名为Staff的类和方法__init__,以按顺序初始化以下实例属性:
-staff_number
-first_name
-last_name
-email

代码

class Staff:def __init__(self, staff_number, first_name, last_name, email):self.staff_number = staff_numberself.first_name = first_nameself.last_name = last_nameself.email = email

实验结果

在这里插入图片描述

题目2

With the class called Staff you defined.
Your task is to write code to create 3 Staff objects with the following details:

staffObj1: 100001, John, Lee, jl123@gmail.com
staffObj2: 100002, Mary, Zheng, maryz@gmail.com
staffObj3: 100003, Cindy, Wilson, cw456@hotmail.com

代码

class Staff:def