Discover new knowledge and insights with IDNLearn.com's extensive Q&A platform. Find the information you need quickly and easily with our comprehensive and accurate Q&A platform.
Sagot :
Answer:
You need “input(prompt)” and “sum(iterable)”
Explanation:
import numpy
class Students:
def __init__(self, students_size, marks_size):
self.students_size = students_size
self.marks_size = marks_size
def input_name(self):
return input("Name of the student:")
def input_marks(self):
for __ in range(self.marks_size):
yield int(input("Mark:"))
def input_students_data(self):
for __ in range(self.students_size):
name = self.input_name()
yield name, list(self.input_marks())
if __name__ == "__main__":
students = Students(students_size=3, marks_size=5)
name = numpy.empty([students.students_size], dtype="<U100")
# more space might be needed for long names
marks = numpy.empty([students.students_size, students.marks_size])
for i, (student_name, student_marks) in enumerate(
students.input_students_data()):
name[i] = student_name
marks[i] = student_marks
total = sum(student_marks)
print("total: {:g}, average: {:g}".format(total, float(total)/students.marks_size))
We are delighted to have you as part of our community. Keep asking, answering, and sharing your insights. Together, we can create a valuable knowledge resource. IDNLearn.com is committed to providing the best answers. Thank you for visiting, and see you next time for more solutions.