The document contains instructions for a Python programming assignment, including the student's name and ID, deadline, and the task of writing a program to read numbers from a file, find the minimum, maximum, and mean for each line, and print the results. It provides an example input and output. The solution code reads the file, splits each line into a float list, calculates the requested stats, and prints them in the specified format.
The document contains instructions for a Python programming assignment, including the student's name and ID, deadline, and the task of writing a program to read numbers from a file, find the minimum, maximum, and mean for each line, and print the results. It provides an example input and output. The solution code reads the file, splits each line into a float list, calculates the requested stats, and prints them in the specified format.
The document contains instructions for a Python programming assignment, including the student's name and ID, deadline, and the task of writing a program to read numbers from a file, find the minimum, maximum, and mean for each line, and print the results. It provides an example input and output. The solution code reads the file, splits each line into a float list, calculates the requested stats, and prints them in the specified format.
a. Read the file “numbers.txt” (included in the email’s attachment), each line in the file containing the numbers separated by commas b. For each line in the file, print out the followings: i. The smallest and largest number ii. The mean of the numbers
Example: 1,8,9.2,-5 -> Min = 1, Max = 9, Mean = 3.55
Please paste the screenshots of your solution to this file and send the file to the email vuducly151092@gmail.com
with open('numbers.txt', 'r') as file:
for line in file: numbers = [float(num) for num in line.split(',')] smallest, largest = min(numbers), max(numbers) mean = sum(numbers) / len(numbers) print(f"Smallest: {smallest}, Largest: {largest}, Mean: {mean}")