Devin Dahlberg

Python: Assignment Eleven

Objective:

Design a program that reads the attached file numbers.txt (Download the file to the directory where your Python Program will be executed)

The program should validate that the file exists

The program should store the numbers from the numbers.txt file in a list

From the data read from the file output and format appropriately the lowest (100) sales number

From the data read from the file output and format appropriately the highest (600) sales number

From the data read from the file output and format appropriately the average (250) of all the sales numbers

From the data read from the file output and format appropriately the Total (2000) of all the sales numbers

From the data read from the file output and format appropriately the one-of-a-kind or unique numbers (100, 125, 175, 200, 300, 600) in the file or the list

The program should also display all the numbers greater than 200 (300, 600)

import os

file_path = 'C:/Users/devin/Desktop/Fall 2023/Python/Python Final/numbers.txt'

if os.path.exists(file_path):
    print('Now uploading "numbers.txt"...')
    print('Checking for valid file...')
    print('Success! "numbers.txt" file was found!')
    print('Now formating file...')
    print(' ')
else:
    print('File not found')

    
myfile = open('numbers.txt', 'r')

num_input = 6

numbers_list = []
greater_list =[]

for line in myfile:
    numbers_list.append(int(line))

num_set = set(numbers_list)

def main():

    for index in range(num_input):
        lowest_number = min(numbers_list)
        highest_number = max(numbers_list)
        average_number = sum(numbers_list) / len(numbers_list)
        sum_number = sum(numbers_list)

    for num in numbers_list:
        if num > 200:
            greater_list.append(num)
     
            
    print(f'The Lowest number is: {lowest_number}')
    print(f'The Highest number is: {highest_number}')
    print(f'The Average number is: {average_number}')
    print(' ')
    
    print(f'The Total of all the numbers is: {sum_number}')
    print(f'The unique numbers in the file are: {num_set}')
    print(f'The Number(s) greater than 200 are: {greater_list}')

    
main()

numbers.txt content:

100

200

300

200

100

300

Final Exam - File Present