定义个Student类: 属性:身份证号码、姓名、性别、年龄、籍贯、住址,学号; 方法:eat,sleep,print,study;
时间: 2023-12-22 11:23:42 浏览: 141
class Student:
def __init__(self, id_number, name, gender, age, hometown, address, student_id):
self.id_number = id_number
self.name = name
self.gender = gender
self.age = age
self.hometown = hometown
self.address = address
self.student_id = student_id
def eat(self):
print("{} is eating".format(self.name))
def sleep(self):
print("{} is sleeping".format(self.name))
def print_info(self):
print("Name: {}".format(self.name))
print("ID Number: {}".format(self.id_number))
print("Gender: {}".format(self.gender))
print("Age: {}".format(self.age))
print("Hometown: {}".format(self.hometown))
print("Address: {}".format(self.address))
print("Student ID: {}".format(self.student_id))
def study(self):
print("{} is studying".format(self.name))
阅读全文