-2

This is the code that I have.

#Ask for how many students will be putting for grades.
students= input ('How many students that you have: ')
print (students)

#Create a list of the students and ask for the grades.
grades = []

students_grades =[]
while students_grades != 'stop':

    students_grades = input("Enter the students grades you have, or enter 'stop' when you done: ")


    if students_grades != 'stop':
        grades.append(students_grades)
print(grades)

Could I ask you that how do we find the mean and median for the list that I got from this? please help me! Thank you !

Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96
Harry N
  • 11
  • 1
    Happy Coding. SO is about fixing _your_ Code - not implementing your homework. Please go over [how to ask](https://stackoverflow.com/help/how-to-ask) and [on-topic](https://stackoverflow.com/help/on-topic) again and if you a specific questions, provide your code as [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). If you encounter errors, copy and paste the error message verbatim ( word for word) into your question. Thank you. – Patrick Artner Oct 29 '18 at 21:02
  • Searching this forum for existing questions is a good way to get stuff done, read about mean in lists here: https://stackoverflow.com/questions/24101524/finding-median-of-list-in-python – Patrick Artner Oct 29 '18 at 21:03

1 Answers1

-1

This seems like a homework question and you should just google "how to" but given that you have created a new question, I am going to provide a simple answer.

Use numpy.

You have a list called grades.

Do this:

import numpy as np

grades = np.array(grades)

print(np.mean(grades))
print(np.median(grades))
seralouk
  • 30,938
  • 9
  • 118
  • 133