python msp_Python 练习实例71
參考方法:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
class Student:
name = ""
age = 0
score = [None] * 4
def input(self):
self.name = raw_input("Input name, please: ")
self.age = int(raw_input("Input age, please: "))
for i in range(len(self.score)):
self.score[i] = int(raw_input("Input %d score, please: " % (i + 1)))
def output(self):
print 'Output name: %s' % self.name
print 'Output age: %d' % self.age
for i in range(len(self.score)):
print 'Output %d score: %d' % ((i + 1), self.score[i])
if __name__ == "__main__":
N = 5
studentArray = [Student()] * N
for i in range(len(studentArray)):
studentArray[i].input()
for i in range(len(studentArray)):
studentArray[i].output()
Kirito
Kirito
msp***bo@outlook.com3年前 (2017-08-01)
總結
以上是生活随笔為你收集整理的python msp_Python 练习实例71的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 乐播投屏怎么把声音投到电视上
- 下一篇: cf王者魅影怎么获得 2022CFPL