organisations.txt:
Melbourne:www.melbourne.edu.au 199.45.12.3; 1245
Famagusta:www.famagusta.com 145.78.35.6; 499
Athens:www.athens.org.gr 178.55.12.2; 6789
Istanbul:www.istanbul.com.tr 145.44.32.7; 2980
I want to calculate mean, minimum & maximum of the numbers in the second column...what fuction/method should I use? Tried finding on net but nothing relevant was available.
Code:
if operation == 2:
with open('pass.txt') as f:
credentials = dict([x.strip().split(':') for x in f.readlines()]) # Created a dictionary with username:password items
username_input = input('Please Enter username: ')
if username_input not in credentials: # Check if username is in the credentials dictionary
sys.exit('Incorrect incorrect username, terminating... \n')
password_input = input('Please Enter Password: ')
if password_input != credentials[username_input]: # Check if the password entered matches the password in the dictionary
sys.exit('Incorrect Password, terminating... \n')
print ('User is logged in!\n')
#with open("organisation.txt") as f:
with open('organisation.txt') as f:
#organisations = dict([x.strip().split(':') for x in f.readlines()])
lines = f.readlines()
numbers = [int(line.split(";")[-1].strip()) for line in lines if line.strip()]
maxval = str(max(numbers))
minval = str(min(numbers))
print('maximum value:'+maxval)
print('maximum value:'+minval)