Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions ch_1_lesson_adam_hutchings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
list_1111 = [
'Edgewater, Maryland',2003,True,['CHS District Bethesda MS Event sponsored by Bechtel', #Just tons of lists until line 23
'CHS District Owings Mills MD Event sponsored by Leidos','FIRST Chesapeake District Championship'],
['Bethesda, Maryland','Owings Mills, Maryland','Fairfax, Virginia'],
['Autonomous Award sponsored by Ford',"District Chairman's Award",'Team Spirit Award sponsored by FCA Foundation']]

list_1678 = [
'Davis, California',2005,True,
['Central Valley Regional','Sacramento Regional','Aerospace Valley Regional','Carver Division','Einstein Field',
'RCC Qianjiang International Robotics Invitational'],['Fresno, California','Davis, California','Lancaster, California',
'Houston, Texas','Hangzhou, China'],["Regional Chairman's Award",'Regional Winners',"FIRST Dean's List Finalist Award",
'Industrial Design Award sponsored by General Motors','Excellence in Engineering Award sponsored by Delphi',
'Championship Subdivision Winner','Entrepeneurship Award sponsored by Kleiner Perkins Caufield and Byers']]

list_2222 = [
'Tacoma, Washington',2007,False,"Pacific Northwest Regional",'Portland, Oregon','No awards. Boo-hoo...']

list_3333 = [
'Julesburg, Colorado',2010,False,"Colorado Regional",'Denver, Colorado','Judges Award']

list_5555 = [
'Warren, Michigan',2015,True,['FIM District Center Line Event','FIM District Marysville Event'],
['Center Line, Michigan','Marysville, Michigan'],"District Event Winner"]

valid_input_1 = False #Whether a valid input has been submitted for a team
valid_input_2 = False #Whether a valid input has been submitted for a statistic

statistics_dictionary = {'location':0, 'rookie_year':1, 'competed':2, 'competition_names':3,
'competition_locations':4, 'season_awards':5}


while valid_input_1 == False: #Until a valid input has been submitted for a team
team_selection = str(input("What team would you like to view statistics about? ")) #Which team do you want?
if team_selection == '1111' or '1678' or '2222' or '3333' or '5555': #Breaking the loop for a valid input
valid_input_1 = True
if team_selection == '1111':
team_selection = list_1111
if team_selection == '1678':
team_selection = list_1678
if team_selection == '2222':
team_selection = list_2222
if team_selection == '3333':
team_selection = list_3333
if team_selection == '5555':
team_selection = list_5555

while valid_input_2 == False: #Until a valid input has been submitted for a statistic
statistic_wanted = input("Which statistic would you like to find out? ") #Which statistic do you want?
if statistic_wanted == 'location' or 'rookie_year' or 'competed' or 'competition_names' or 'competition_locations' or 'season_awards': #Breaking the loop for a valid input
valid_input_2 = True #Breako el infinito el loopo

print(team_selection[statistics_dictionary[statistic_wanted]]) #Print the list selected, and the element of said list
52 changes: 52 additions & 0 deletions ch_1_lesson_adam_hutchings_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
list_1111 = [
'Edgewater, Maryland',2003,True,['CHS District Bethesda MS Event sponsored by Bechtel', #Just tons of lists until line 23
'CHS District Owings Mills MD Event sponsored by Leidos','FIRST Chesapeake District Championship'],
['Bethesda, Maryland','Owings Mills, Maryland','Fairfax, Virginia'],
['Autonomous Award sponsored by Ford',"District Chairman's Award",'Team Spirit Award sponsored by FCA Foundation']]

list_1678 = [
'Davis, California',2005,True,
['Central Valley Regional','Sacramento Regional','Aerospace Valley Regional','Carver Division','Einstein Field',
'RCC Qianjiang International Robotics Invitational'],['Fresno, California','Davis, California','Lancaster, California',
'Houston, Texas','Hangzhou, China'],["Regional Chairman's Award",'Regional Winners',"FIRST Dean's List Finalist Award",
'Industrial Design Award sponsored by General Motors','Excellence in Engineering Award sponsored by Delphi',
'Championship Subdivision Winner','Entrepeneurship Award sponsored by Kleiner Perkins Caufield and Byers']]

list_2222 = [
'Tacoma, Washington',2007,False,"Pacific Northwest Regional",'Portland, Oregon','No awards. Boo-hoo...']

list_3333 = [
'Julesburg, Colorado',2010,False,"Colorado Regional",'Denver, Colorado','Judges Award']

list_5555 = [
'Warren, Michigan',2015,True,['FIM District Center Line Event','FIM District Marysville Event'],
['Center Line, Michigan','Marysville, Michigan'],"District Event Winner"]

valid_input_1 = False #Whether a valid input has been submitted for a team
valid_input_2 = False #Whether a valid input has been submitted for a statistic

statistics_dictionary = {'location':0, 'rookie_year':1, 'competed':2, 'competition_names':3,
'competition_locations':4, 'season_awards':5}


while valid_input_1 == False: #Until a valid input has been submitted for a team
team_selection = str(input("What team would you like to view statistics about? ")) #Which team do you want?
if team_selection == '1111' or '1678' or '2222' or '3333' or '5555': #Breaking the loop for a valid input
valid_input_1 = True
if team_selection == '1111':
team_selection = list_1111
if team_selection == '1678':
team_selection = list_1678
if team_selection == '2222':
team_selection = list_2222
if team_selection == '3333':
team_selection = list_3333
if team_selection == '5555':
team_selection = list_5555

while valid_input_2 == False: #Until a valid input has been submitted for a statistic
statistic_wanted = input("Which statistic would you like to find out? ") #Which statistic do you want?
if statistic_wanted == 'location' or 'rookie_year' or 'competed' or 'competition_names' or 'competition_locations' or 'season_awards': #Breaking the loop for a valid input
valid_input_2 = True #Breako el infinito el loopo

print(team_selection[statistics_dictionary[statistic_wanted]]) #Print the list selected, and the element of said list
232 changes: 232 additions & 0 deletions ch_2_assign_adam_hutchings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
master_dictionary = {} #Setting up the master el dictionario
input_list = ['menu', 'view', 'remove', 'search', 'modify']
statistic_list = ['tm', 'n', 'pl', 'w', 'l', 'cv', 'dt']
#Translating user inputs into functions

def remove_function():
while True: #Idiotproofing code
removal = input("Which team would you like to remove? This action cannot be undone!")
if ("statistics" + removal) in master_dictionary:
master_dictionary[removal] = {}
break
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'menu' to go back to the main menu, 'view' to view more,
'remove' to remove more, 'search' to search the teams, or 'modify' to modify the information.""")
if menu_selection in input_list:
if menu_selection == 'menu':
valid_input_5 = True
menu_function()
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()

def view_function():
valid_input_6 = False #This, and all other such "shells", is safeproofing so the code doesn't die if the user enters an invalid input.
while valid_input_6 == False:
viewing_selection = input("Which team's statistics would you like to view? ")
if "statistics" + str(viewing_selection) in master_dictionary:
valid_input_6 = True
valid_input_7 = False
while valid_input_7 == False:
statistic_selection = input("""Which statistic would you like to view? Please type one of
tm (team number), n (name), pl (programming language), w or l (width or a length for your robot),
cv (whether or not your robot has a camera vision system),or dt (the number of drivetrain motors on your robot). """)
if statistic_selection in statistic_list and master_dictionary["statistics" + viewing_selection][statistic_selection] != '':
print (master_dictionary["statistics" + viewing_selection][statistic_selection])
valid_input_7 = True
elif master_dictionary["statistics" + viewing_selection][statistic_selection] == '':
print("That hasn't been added yet. Try something else.")
valid_input_7 = True
else:
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'menu' to go back to the main menu, 'view' to view more,
'remove' to remove data, 'search' to search the teams, or 'modify' to modify the information.""")
if menu_selection == 'menu':
valid_input_5 = True
menu_function()
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()

def search_teams(): #Searching teams
valid_input_4 = False
while valid_input_4 == False:
team_search = input("What team would you like to search for?")
if team_search.isdigit() == True: #If the search is all digits
valid_input_4 = True
for search in master_dictionary: #Checking every master_dict key to see if it's equal to the search
if search == ("statistics" + team_search):
print("A match has been found!")
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'menu' to go back to the main menu, 'view' to view more,
'remove' to remove data, 'search' to search the teams again, or 'modify' to modify the information.""")
if menu_selection in input_list:
if menu_selection == 'menu':
valid_input_5 = True
menu_function()
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()
else:
print("A match has not been found.")
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'menu' to go back to the main menu, 'view' to view more,
'remove' to remove data, 'search' to search the teams again, or 'modify' to modify the information.""")
if menu_selection in input_list:
if menu_selection == 'menu':
valid_input_5 = True
menu_function()
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()

def add_team(): #How to add a new team
print("You are adding a new file. The first step is to name your team.")
valid_team_name = False
while valid_team_name == False:
team_name = input("What would you like your team to be named? Make sure it's all numbers! ") #Getting a name for the team
if team_name.isdigit() == True: #Checking if a team name is all digits
valid_team_name = True #Breaking the infinite loop
master_dictionary["statistics" + str(team_name)] = {} #Making a dictionary entry for the team
for yeet in statistic_list:
master_dictionary["statistics" + str(team_name)][yeet] = ''
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'menu' to go back to the main menu, 'view' to view more,
'remove' to remove data, 'search' to search the teams, or 'modify' to modify the information again.""")
if menu_selection in input_list:
if menu_selection == 'menu':
valid_input_5 = True
menu_function()
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()

def add_statistic(): #How to add a statistic for a team
team_name = '' #Setting variables empty
datapoint = ''
team_name_validity = False
while team_name_validity == False:
team_name = input("Please select a team whose information you would like to modify.") #Finding the team
if ("statistics" + str(team_name)) in master_dictionary:
team_name_validity = True
statistic_validity = False
while statistic_validity == False:
statistic_added = input("""You may add a team number (tm), a name (n), a programming language (pl),
a width or a length for your robot (w or l), whether or not your robot has a camera vision system (cv),
and the number of drivetrain motors on your robot (dt). Which one of these options would you like
to edit? Enter your options as the parenthetical after the option you have selected. """) #Note the shorthands like 'pl' here.
if statistic_added in statistic_list:
statistic_validity = True
for statistic_name in statistic_list: #For all possible statistic names
if statistic_added == statistic_name: #If the statistic selected has been found:
datapoint = (input("What would you like to set this team's " + statistic_added + "?")) #What data the user wants to add.
master_dictionary["statistics" + str(team_name)][statistic_added] = datapoint
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'menu' to go back to the main menu, 'view' to view more,
'remove' to remove data, 'search' to search the teams, or 'modify' to modify the information again.""")
if menu_selection in input_list:
if menu_selection == 'menu':
valid_input_5 = True
menu_function()
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()

def modification_function(): #Modifying data in this program.
valid_input_3 = False
while valid_input_3 == False:
adding_teams = input("Would you like to add a new team or a new statistic? Please type 'team' or 'statistic'. ") #Whether new team files are still being created
if adding_teams == 'team': #Getting other functions to run
add_team()
valid_input_3 = True
if adding_teams == 'statistic' and master_dictionary != {}: #Checking if there are any teams for statistics to be added to
add_statistic()
valid_input_3 = True

def menu_function():
if master_dictionary == {}:
valid_input = False
while valid_input == False:
first_input = input("You don't seem to have any data. Enter 'yes' to add some. ")
if first_input == 'yes':
modification_function()
valid_input = True
else: #If information has already been saved.
valid_input_5 = False
while valid_input_5 == False:
menu_selection = input("""Type 'view' to view more,
'remove' to remove, 'search' to search the teams, or 'modify' to modify the information.""")
if menu_selection == 'view':
valid_input_5 = True
view_function()
if menu_selection == 'remove':
valid_input_5 = True
remove_function()
if menu_selection == 'search':
valid_input_5 = True
search_teams()
if menu_selection == 'modify':
valid_input_5 = True
modification_function()

menu_function()
Loading