python 程序耗时记录_Python学校的学生身高记录程序
python 程序耗時記錄
A team of 5 people is assigned with a task to record the heights of students in a school and they have decided to make a python program using class to record all the student's height.
由5人組成的小組負責記錄學校中學生的身高,他們決定使用課堂制作python程序來記錄所有學生的身高。
In the below program, we try to use class in python to build a Student Height Record program for a school. The Record will contain the student’s name along with its height. This article aims to develop an understanding of the usage of class in the student height record system.
在下面的程序中,我們嘗試使用python中的class來為學校構建Student Height Record程序 。 記錄將包含學生的姓名及其身高。 本文旨在加深對學生身高記錄系統中班級用法的理解。
Program:
程序:
# definig a class student, # which contain name and height of the studentclass Student(object):def __init__(self, name, height):self.name = nameself.height = heightdef getheight(self):return self.heightdef __str__(self):return self.name + ' : ' + str(self.getheight())# Defining a function for building a Menu # which generates list of Food def HeightRecord(rec, name, height):rec.append(Student(name, height))return recRecord = [] x = 'y' while x == 'y':name = input('Enter the name of the student: ')height = input('Enter the height recorded: ')Record = HeightRecord(Record, name, height)x = input('another student? y/n ')n = 1 for el in Record:print(n,'. ', el)n = n + 1Output
輸出量
Enter the name of the student: Prerana Jain Enter the height recorded: 165 another student? y/n y Enter the name of the student: Monika Sharma Enter the height recorded: 167 another student? y/n y Enter the name of the student: Shivang Yadav Enter the height recorded: 170 another student? y/n y Enter the name of the student: Radib Kar Enter the height recorded: 169 another student? y/n n 1 . Prerana Jain : 165 2 . Monika Sharma : 167 3 . Shivang Yadav : 170 4 . Radib Kar : 169翻譯自: https://www.includehelp.com/python/student-height-record-program-for-a-school.aspx
python 程序耗時記錄
總結
以上是生活随笔為你收集整理的python 程序耗时记录_Python学校的学生身高记录程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用Netty撸一个心跳机制和断线重连!
- 下一篇: c ++查找字符串_C ++朋友功能|