0% found this document useful (0 votes)
1 views1 page

Ex Files in Python

The document outlines a series of tasks to be performed using a file named numbers.txt containing a list of integers. Tasks include calculating the total, finding the largest and smallest numbers, computing the average, counting numbers above the average, writing results to a new file, and counting even and odd numbers. Each task requires reading from the input file and performing specific calculations or outputs.

Uploaded by

bonolomncube344
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Ex Files in Python

The document outlines a series of tasks to be performed using a file named numbers.txt containing a list of integers. Tasks include calculating the total, finding the largest and smallest numbers, computing the average, counting numbers above the average, writing results to a new file, and counting even and odd numbers. Each task requires reading from the input file and performing specific calculations or outputs.

Uploaded by

bonolomncube344
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ex Files in Python

[Link] contains the following numbers. Use this file for all
questions
14
8
23
5
17
42
9
31
6
19

1. Calculate the total: Read all the numbers from [Link] and print their sum.
2. Find the largest and smallest: Read the numbers and print both the maximum
and minimum values in the file.
3. Compute the average: Read the numbers and print the average (mean),
rounded to 2 decimal places.
4. Count numbers above the average: Read the numbers, calculate the average,
then count and print how many numbers are strictly above it. Also print those
numbers on one line.
5. Read [Link], then write a new file called [Link] that contains: the total,
the average (2 decimal places), the highest number, the lowest number, each
on its own labelled line.

6. Count even and odd numbers: Read [Link] and print how many numbers
are even and how many are odd.

You might also like