Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def second_part():
- for file_name in os.listdir():
- if file_name.startswith('NENE'):
- file_ptr = open(file_name)
- pass_to_mean = get_mean(file_ptr)
- # Reset file pointer to initial position
- file_ptr.seek(0)
- pass_to_highest = get_highest(file_ptr)
- # Reset file pointer to initial position
- file_ptr.seek(0)
- pass_to_lowest = get_lowest(file_ptr)
- # Reset file pointer to initial position
- file_ptr.seek(0)
- pass_to_length_warning = get_length(file_ptr)
- print('The name of the file is',file_name,'its highest value is',pass_to_highest,'its lowest value is',pass_to_lowest,'its mean is ',pass_to_mean,'and it is',pass_to_length_warning)
- def get_mean(my_file):
- my_list = []
- for my_line in my_file:
- my_line = my_line.strip()
- my_line = float(my_line)
- my_list.append(my_line)
- my_mean = sum(my_list)/len(my_list)
- return my_mean
- def get_highest(my_file):
- my_list = []
- for my_line in my_file:
- my_line = my_line.strip()
- my_line = float(my_line)
- my_list.append(my_line)
- my_highest = max(my_list)
- return my_highest
- def get_lowest(my_file):
- my_list = []
- for my_line in my_file:
- my_line = my_line.strip()
- my_line = float(my_line)
- my_list.append(my_line)
- my_lowest = min(my_list)
- return my_lowest
- def get_length(my_file):
- my_list = []
- for my_line in my_file:
- my_line = my_line.strip()
- my_line = float(my_line)
- my_list.append(my_line)
- length = len(my_list)
- x = 'This is not long enough'
- y = 'This is long enough'
- if length <= 300:
- return x
- elif length >= 300:
- return y
- second_part()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement