diff --git a/ch_1_assign_kathy_li.py b/ch_1_assign_kathy_li.py new file mode 100644 index 0000000..931fc94 --- /dev/null +++ b/ch_1_assign_kathy_li.py @@ -0,0 +1,110 @@ +#This is the dictionary that stores all the information about the teams. +teams_info = { + 1678: { + 'location': 'Davis, California, USA', + 'rookie year': 2005, + 'competed in 2019?': True, + '2019 competitions': [ + 'Central Valley Regional (Fresno, California, USA)', + 'Sacramento Regional (Davis, California, USA)', + 'Aerospace Valley (Lancaster, California, USA)', + 'Carver Division - Houston Championship (Houston, Texas, USA)', + 'Einstein Field - Houston Championship (Houston, Texas, USA)', + 'RCC Qianjiang International Robotics Invitational (Hangzhou, Zhejiang, China)', + 'Chezy Champs (San Jose, California, USA)', + ], + '2019 season awards': [ + 'Chairman\'s Award, Central Valley Regional', + 'Winner, 2019 Central Valley Regional', + 'FIRST Dean\'s List Finalist Award, Sacramento Regional (Katie Stachowicz)', + 'Industrial Design Award (sponsored by General Motors), Sacramento Regional', + 'Winner, 2019 Sacramento Regional', + 'Excellence in Engineering Award (sponsored by Delphi), Aerospace Valley Regional', + 'Winner, 2019 Aerospace Valley Regional', + 'Entrepreneurship Award (sponsored by Kleiner Perkins Caufield and Byers)', + 'Winner, 2019 Carver Division - Houston Championship', + ] + }, + 1868: { + 'location': 'Mountain View, California, USA', + 'rookie year': 2006, + 'competed in 2019?': True, + '2019 competitions': [ + 'Los Angeles North Regional (Valencia, California, USA)', + 'Silicon Valley Regional (San Jose, California, USA)', + 'Turing Division - Houston Championship (Houston, TX)', + 'Chezy Champs (San Jose, California, USA)', + ], + '2019 season awards': [ + 'Chairman\'s Award, Los Angeles North Regional', + 'Winner, 2019 Los Angeles North Regional', + 'Entrepreneurship Award (sponsored by Kleiner Perkins Caufield and Byers), Silicon Valley Regional', + ] + }, + 1323: { + 'location': 'Madera, California, USA', + 'rookie year': 2004, + 'competed in 2019?': True, + '2019 competitions': [ + 'Central Valley Regional (Fresno, California, USA)', + 'Sacramento Regional (Davis, California, USA)', + 'Newton Division - Houston Championship (Houston, Texas, USA)', + 'Einstein Field (Houston, Texas, USA)', + ], + '2019 season awards': [ + 'Autonomous Award (sponsored by Ford), Central Valley Regional', + 'Winner, 2019 Central Valley Regional', + 'Quality Award sponsored by Motorola Solutions Foundation', + 'Winner, 2019 Sacramento Regional', + 'Industrial Design Award (sponsored by General Motors), Houston Championship ' + 'Winner, 2019 Newton Division - Houston Championship', + 'Winner, 2019 Houston Championship', + ] + }, + 3132: { + 'location': 'Sydney, Australia', + 'rookie year': 2010, + 'competed in 2019?': True, + '2019 competitions': [ + 'Southern Cross Regional (Sydney, Australia)', + 'South Pacific Regional (Sydney, Australia)', + 'Carver Division - Houston Championship (Houston, Texas, USA)', + 'Einstein Field - Houston Championship (Houston, Texas, USA)', + 'Duel Down Under (Sydney, Australia)', + ], + '2019 season awards': [ + 'Woodie Flowers Finalist Award, Southern Cross Regional (Sarah Heimlich)', + 'Gracious Professionalism Award (sponsored by Johnson & Johnson), Southern Cross Regional', + 'Regional Engineering Inspiration Award, South Pacific Regional', + 'FIRST Dean\'s List Finalist Award, South Pacific Regional (Jaye Heimlich)', + 'Safety Award (sponsored by Underwriters Laboratories), South Pacific Regional', + 'Winner, 2019 Carver Division - Houston Championship', + ] + }, + 254: { + 'location': 'San Jose, California, USA', + 'rookie year': 1999, + 'competed in 2019?': True, + '2019 competitions': [ + 'San Francisco Regional (San Francisco, California, USA)', + 'Silicon Valley Regional (San Jose, California, USA)', + 'Turing Division - Houston Championship (Houston, Texas, USA)', + 'Einstein Field - Houston Championship (Houston, Texas, USA)', + 'Chezy Champs (San Jose, California, USA)' + ], + '2019 season awards': [ + 'Innovation in Control Award (sponsored by Rockwell Automation), San Francisco Regional', + 'Winner, 2019 San Francisco Regional', + 'Excellence in Engineering Award (sponsored by Delphi), Silicon Valley Regional', + 'Winner, 2019 Silicon Valley Regional', + 'Industrial Design Award (sponsored by General Motors), Turing Divions' + 'Winner, 2019 Turing Division - Houston Championship', + 'Championship Finalist, Einstein Field - Houston Championship', + + ] + }, +} +team_input = int(input('Choose an FRC team: 1678, 1868, 1323, 3132, or 254.\n')) +team_attribute = input('Enter an attribute: "Location", "Rookie Year", "Competed in 2019?", "2019 Competitions", and "2019 Season Awards".\n').lower() +#without .lower(), user input is case-sensitive. +print(teams_info[team_input][team_attribute]) \ No newline at end of file diff --git a/ch_1_lesson_{Kathy}_{Li}.py b/ch_1_lesson_{Kathy}_{Li}.py new file mode 100644 index 0000000..8c854ae --- /dev/null +++ b/ch_1_lesson_{Kathy}_{Li}.py @@ -0,0 +1 @@ +print('Hello, world!') \ No newline at end of file diff --git a/ch_2_assign_kathy_li.py b/ch_2_assign_kathy_li.py new file mode 100644 index 0000000..06d63db --- /dev/null +++ b/ch_2_assign_kathy_li.py @@ -0,0 +1,137 @@ +teams = {} +while True: + user_action = input("Welcome to the menu. Please select an action: add, remove, modify, view, search, or list. To quit, enter quit. \n") + + if user_action == "list": + print(teams) + continue + + elif user_action == "remove": + delete_team = int(input("Which team would you like to remove? Enter 0 to return to the menu. \n")) + if delete_team == 0: + continue + elif delete_team in teams.keys(): + teams.pop(delete_team) + print("Team " + str(delete_team) + " has been removed. ") + continue + else: + print("Team " + str(delete_team) + " has not been found. ") + continue + + elif user_action == "modify": + update_team = input("Which team would you like to modify? To return the to the menu, enter 0. \n") + if update_team.isnumeric(): + update_team = int(update_team) + if update_team == 0: + continue + elif update_team in teams.keys(): + update_variable = input("Which field would you like to modify: name, programming language, width, length, number of drivetrain motors, or camera vision? \n") + if update_variable not in teams[update_team].keys(): + print("There is no such field. ") + continue + change = input("Enter the new value. \n") + if update_variable in ["width", "length", "number of drivetrain motors"]: + if not change.isnumeric(): + print("Input is invalid. ") + continue + else: + teams[update_team][update_variable] = change + print("Successfully changed. ") + continue + elif update_variable == "camera vision": + if change != "True" and change != "False": + print("Please input True or False. ") + continue + else: + change = bool(change) + teams[update_team][update_variable] = change + print("Successfully changed. ") + continue + else: + teams[update_team][update_variable] = change + print("Successfully changed. ") + continue + else: + print("Team " + str(update_team) + " was not found. ") + continue + else: + print("Team " + str(update_team) + " was not found. ") + continue + + elif user_action == "add": + new_team = input("Enter the number of the team you want to add. To return to the menu, enter 0. \n") + if not new_team.isnumeric(): + print("Must be a number. ") + continue + elif new_team == "0": + continue + else: + new_team = int(new_team) + teams[new_team] = {} + teams[new_team]["name"] = input("What is the team's name? \n") + teams[new_team]["programming language"] = input("What programming language does the team use? \n") + width = input("What is the width of the team's robot? \n") + if not width.isnumeric(): + print("Width must be a number. ") + continue + else: + width = float(width) + teams[new_team]["width"] = width + length = input("What is the length of the team's robot? \n") + if not length.isnumeric(): + print("Length must be a number. ") + continue + else: + length = float(width) + teams[new_team]["length"] = length + camera_vision = input("Does the team have a camera vision system? Input True or False. \n") + if camera_vision != "True" and camera_vision != "False": + print("Please follow directions.") + continue + else: + camera_vision = bool(camera_vision) + teams[new_team]["camera vision"] = camera_vision + drivetrain_motors = input("How many drivetrain motors does the robot have? \n") + if not drivetrain_motors.isnumeric(): + print("Drivetrain motors must be a number. ") + continue + else: + teams[new_team]["number of drivetrain motors"] = drivetrain_motors + print("Team added. ") + continue + + elif user_action == "view": + view_input = input("Which team's information would you like to view? To return to the menu, press 0. \n") + if not view_input.isnumeric(): + print("Team must be a number. Returning to menu... ") + continue + + view_input = int(view_input) + + if view_input == 0: + continue + elif view_input in teams: + print(teams[view_input]) + continue + else: + print("Team " + str(view_input) + " has not been found. ") + continue + elif user_action == "search": + search_input = input("Which team would you like to search for? To return to the menu, enter 0. \n") + if search_input.isnumeric(): + search_input = int(search_input) + if search_input == 0: + continue + elif search_input in teams.keys(): + print(teams[search_input]) + else: + print("Team does not exist. ") + continue + else: + print("Invalid team. ") + continue + elif user_action == "quit": + break + else: + print("Invalid action.") + continue \ No newline at end of file diff --git a/ch_3_assign_kathy_li.py b/ch_3_assign_kathy_li.py new file mode 100644 index 0000000..75279e3 --- /dev/null +++ b/ch_3_assign_kathy_li.py @@ -0,0 +1,139 @@ +teams = {} + +def master_action(): + while True: + user_action = input("Welcome to the menu. Please select an action: add, remove, modify, view, search, or list. To quit, enter quit. \n") + if user_action == "list": + list_teams() + elif user_action == "remove": + remove_team() + elif user_action == "search": + search_team() + elif user_action == "add": + add_team() + elif user_action == "modify": + modify_team() + elif user_action == "view": + view_team() + elif user_action == "quit": + quit_program() + +def list_teams(): + print(teams) + +def remove_team(): + delete_team = input("Which team would you like to remove? \n") + if delete_team.isnumeric(): + if delete_team in teams.keys(): + teams.pop(delete_team) + print("Team " + str(delete_team) + " has been removed. ") + return + else: + print("Team " + str(delete_team) + " has not been found. ") + return + else: + print("Team must be a number.") + return + +def search_team(): + search_input = input("Which team would you like to search for? \n") + if search_input.isnumeric(): + if search_input in teams.keys(): + print(teams[search_input]) + else: + print("Team not found.") + else: + print("Team must be a number.") + +def add_team(): + new_team = input("Enter the number of the team you want to add. \n") + if new_team.isnumeric() == False: + print("Must be a number. ") + return + else: + new_team = int(new_team) + teams[new_team] = {} + teams[new_team]["name"] = input("What is the team's name? \n") + + teams[new_team]["location"] = input("Where is the team located? \n") + + rookie_year = input("What is the team's rookie year? \n") + if not rookie_year.isnumeric(): + print("Rookie year must be a number. ") + return + else: + rookie_year = int(rookie_year) + teams[new_team]["rookie year"] = rookie_year + + competed_in_2019 = input("Did they compete in 2019? Input True or False. \n") + if competed_in_2019 != "True" and competed_in_2019 != "False": + print("Please input True or False. ") + return + elif competed_in_2019 == "False": + competed_in_2019 = "" + competed_in_2019 = bool(competed_in_2019) + teams[new_team]["competed in 2019"] = competed_in_2019 + print("Team added.") + return + else: + competed_in_2019 = bool(competed_in_2019) + teams[new_team]["competed in 2019"] = competed_in_2019 + + teams[new_team]["2019 competitions"] = input("What were their 2019 competitions? \n") + teams[new_team]["2019 awards"] = input("What awards did they receive in 2019? \n") + print("Team added. ... ") + + +def view_team(): + view_input = input("Which team's information would you like to view? \n") + if not view_input.isnumeric(): + print("Team must be a number. ") + return + view_input = int(view_input) + if view_input in teams: + print(teams[view_input]) + else: + print("Team " + str(view_input) + " has not been found. ") + return + +def modify_team(): + update_team = input("Which team would you like to modify? To return the to the menu, enter 0. \n ") + if update_team.isnumeric(): + if update_team in teams.keys(): + update_variable = input("Which field would you like to modify: name, location, rookie year, compteted in 2019, 2019 competitions, or 2019 awards? \n") + if update_variable not in teams[update_team].keys(): + print("There is no such field. ") + return + + change = input("Enter the new value. \n") + if update_variable == "rookie year": + if not change.isnumeric(): + print("Input is invalid. ") + return + else: + teams[update_team][update_variable] = change + print("Successfully changed. ") + + elif update_variable == "competed in 2019": + if change != "True" and change != "False": + print("Please input True or False. ") + return + else: + change = bool(change) + teams[update_team][update_variable] = change + print("Successfully changed. ") + return + else: + teams[update_team][update_variable] = change + print("Successfully changed. ") + else: + print("Team " + str(update_team) + " was not found. ") + return + else: + print("Team must be a number.") + +def quit_program(): + ##break + print("Use Ctrl-C to exit the program.") + +master_action() \ No newline at end of file diff --git a/ch_4_assign_kathy_li.py b/ch_4_assign_kathy_li.py new file mode 100644 index 0000000..aea0a2f --- /dev/null +++ b/ch_4_assign_kathy_li.py @@ -0,0 +1,68 @@ +import math + +class Point: + def __init__ (self, x, y): + self.x = x + self.y = y + + def distance(self): + return math.sqrt(self.x**2 + self.y**2) + +class Point_3D(Point): + def __init__ (self, x, y, z): + super().__init__(x, y) + self.z = z + + def distance(self): + return math.sqrt(self.x**2 + self.y**2 + self.z**2) + +while True: + x = input("What is the x-value of your point? \n" ) + + if x.isnumeric(): + x = int(x) + else: + print("Invalid input.") + continue + + y = input("what is the y-value of your point? \n") + if y.isnumeric(): + y = int(y) + else: + print("Invalid input.") + continue + + point_a = Point(x, y) + print("The distance from the origin is " + str(point_a.distance())) + + x = input("What is the x-value of your point? \n" ) + if x.isnumeric(): + x = int(x) + else: + print("Invalid input.") + continue + + y = input("what is the y-value of your point? \n") + if y.isnumeric(): + y = int(y) + else: + print("Invalid input.") + continue + + z = input("What is the z-value of your point? \n") + if z.isnumeric(): + z = int(z) + else: + print("Invalid input.") + continue + point_b = Point_3D(x, y, z) + + print("The distance from the origin is " + str(point_b.distance())) + + if point_a.distance() > point_b.distance(): + print("The 2D point is further from the origin than the 3D point.") + elif point_b.distance() > point_a.distance(): + print("The 3D point is further from the origin than the 2D point.") + elif point_a.distance() == point_b.distance(): + print("The points are the same distance from the origin.") + break \ No newline at end of file