Welcome to Westonci.ca, your go-to destination for finding answers to all your questions. Join our expert community today! Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
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 hope this was helpful. Please come back whenever you need more information or answers to your queries. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.