Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- import math
- import operator
- # dictionary containing all users points
- users = {
- }
- # WR's
- wr_hundo = 7059
- wr_any = 3581
- wr_norba = 3856
- wr_cheat = 3554
- wr_nodog = 4282
- wr_trotless = 489
- # Prompts, Data Collection
- while True:
- # Resets to points to default (0)
- points = {
- "hundo": 0,
- "any": 0,
- "norba": 0,
- "cheat": 0,
- "nodog": 0,
- "trotless": 0,
- }
- #Username
- name = input('Enter Username: ')
- # function for collecting user info about a given category
- def time(cat,wr,weight):
- while True:
- a = input('Does ' + name + ' have a BK '+cat+' PB? (Y/N) ').lower()
- if a == 'y':
- string = input('What is ' + name + '\'s BK '+cat+' time? (HH:MM:SS) ')
- try:
- date_time = datetime.datetime.strptime(string, "%H:%M:%S")
- timedelta = date_time - datetime.datetime(1900, 1, 1)
- sec = timedelta.total_seconds()
- points[cat] = math.ceil(max(weight*(((wr*1.5 - sec)**2)/(wr*0.5)**2),0))
- break
- except ValueError:
- print('Please use the format: HH:MM:SS')
- continue
- elif a == 'n':
- break
- else:
- print('Please enter either "Y" or "N".')
- continue
- # calls previous function for each category; # represents weight
- time("hundo",wr_hundo,600)
- time("any",wr_any,300)
- time("norba",wr_norba,200)
- time("cheat",wr_cheat,100)
- time("nodog",wr_nodog,100)
- time("trotless",wr_trotless,100)
- # totals user's points, prints data, & adds key/value to 'users' dictionary
- pts_total = sum(points.values())
- print(name,'\'s Points: ')
- for key, value in points.items():
- print(f"{key}: {value}, ", end="")
- print("")
- print('Total: ',pts_total)
- users[name]=pts_total
- # prompt to add more users
- while True:
- x = input('Would you like to enter another username? (Y/N) ').lower()
- if x=='y' or x=='n':
- break
- else:
- print('Please enter either "Y" or "N".')
- continue
- if x=='n':
- break
- # sorts users based on points and prints
- sorted_users = sorted(users.items(), key=operator.itemgetter(1),reverse=True)
- print(*sorted_users, sep='\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement