# Function to get marks from user
def get_marks():
marks = []
num_students = int(input("Enter the number of students: "))
for i in range(num_students):
mark = int(input(f"Enter the mark for student {i+1}: "))
marks.append(mark)
return marks
# Function to calculate mean
def calculate_mean(marks):
return sum(marks) / len(marks)
# Function to calculate median
def calculate_median(marks):
marks.sort()
n = len(marks)
mid = n // 2
if n % 2 == 0: # even number of elements
median = (marks[mid - 1] + marks[mid]) / 2
else: # odd number of elements
median = marks[mid]
return median
# Function to calculate mode
def calculate_mode(marks):
frequency = {}
for mark in marks:
if mark in frequency:
frequency[mark] += 1
else:
frequency[mark] = 1
max_count = max(frequency.values())
modes = [key for key, value in frequency.items() if value == max_count]
if len(modes) == len(frequency):
return "No unique mode found"
else:
return modes
# Main program
def main():
marks = get_marks()
mean = calculate_mean(marks)
median = calculate_median(marks)
mode = calculate_mode(marks)
print("\nMarks: ", marks)
print(f"Mean: {mean}")
print(f"Median: {median}")
print(f"Mode: {mode}")
# Run the main function
if __name__ == "__main__":
main()