From 9c202c2b539fae0339922ff250b01e07ba7a4029 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 11 Sep 2019 19:53:41 -0700 Subject: [PATCH 01/20] Add ch_1_lesson_Claire_Hays.py to repository. --- ch_1_lesson_Claire_Hays.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 ch_1_lesson_Claire_Hays.py diff --git a/ch_1_lesson_Claire_Hays.py b/ch_1_lesson_Claire_Hays.py new file mode 100644 index 0000000..4648e70 --- /dev/null +++ b/ch_1_lesson_Claire_Hays.py @@ -0,0 +1 @@ +print("Hello, World!") \ No newline at end of file From b17e7c010ef71ed9528aeb14d0013cde819de0da Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Thu, 12 Sep 2019 20:44:56 -0700 Subject: [PATCH 02/20] Add ch_1_assign_Claire_Hays.py to repository --- ch_1_assign_Claire_Hays.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ch_1_assign_Claire_Hays.py diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py new file mode 100644 index 0000000..4d13eac --- /dev/null +++ b/ch_1_assign_Claire_Hays.py @@ -0,0 +1,36 @@ +teams = { +'1678': {'location': 'Davis, CA, USA', 'rookie year': 2005, +'2019 compete': True , +'names of 2019 competitions': ['Central Valley Regional', 'Sacramento Regional', 'Aerospace Valley Regional', 'Carver Division', 'Einstein Field', 'RCC', 'Chezy Champs'] +, 'location of 2019 competitions': ['Fresno, CA, USA', 'Davis, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'Hangzhou, Zhejian, China', 'San Jose, CA, USA'] +, '2019 awards': ['Regional Chairmans', 'Regional Winner', 'Regional Winner', 'Regional Winner', 'Division Winner'] +}, +'1323': {'location': 'Madera, CA, USA', 'rookie year': 2004, +'2019 compete': True , +'names of 2019 competitions': ['Central Valley Regional', 'Sacramento Regional', 'Newton Division', 'Einstein Field'] +, 'location of 2019 competitions': ['Fresno, CA, USA', 'Davis, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA'] +, '2019 awards': ['Regional Winner', 'Regional Winner', 'Division Winner', 'Houston Champs Winner'] +}, +'254': {'location': 'San Jose, CA, USA', 'rookie year': 1999, +'2019 compete': True , +'names of 2019 competitions': ['San Francisco Regional', 'Silicon Valley Regional', 'Turing Division', 'Einstein Field', 'Chezy Champs'] +, 'location of 2019 competitions': ['San Francisco, CA, USA', 'San Jose, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'San Jose, CA, USA'] +, '2019 awards': ['Regional Winner', 'Regional Winner', 'Division Winner'] +}, +'3132': {'location': 'Sydney, New South Wales, Australia', +'rookie year': 2010, +'2019 compete': True , +'names of 2019 competitions': ['Southern Cross Regional', 'South Pacific Regional', 'Carver Division', 'Einstein Field'] +, 'location of 2019 competitions': ['Sydney Olympic Park, NSW, Australia', 'Sydney Olympic Park, NSW, Australia', 'Houston, TX, USA', 'Houston, TX, USA'] +, '2019 awards': ['Regional Finalist','Division Winner'] +}, +'3476:' {'location': 'Irvine, CA, USA', 'rookie year': 2011, +'2019 compete': True , +'names of 2019 competitions': ['Los Angeles Regional', 'Aerospace Valley Regional', 'Hopper Division', 'Battleship Blast', 'Chezy Champs', 'Beach Blitz'] +, 'location of 2019 competitions': ['Los Angeles, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'San Pedro, CA, USA', 'San Jose, CA, USA', 'Huntington Beach, CA, USA'] +, '2019 awards': ['Regional Chairmans', 'Regional Winner', 'Regional Winner', 'Regional Winner', 'Division Winner'] +} +} +team_num = input("Team number: ") +attribute = input("Attribute: ") +print(teams[team_num][attribute]) From 29449db74b3ad972fe0e64f1f859642c9cbaca8a Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Sun, 15 Sep 2019 22:31:21 -0700 Subject: [PATCH 03/20] Add ch_1_assign_Claire_Hays.py to repostory. --- ch_1_assign_Claire_Hays.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index 4d13eac..f309fb2 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -1,36 +1,48 @@ -teams = { -'1678': {'location': 'Davis, CA, USA', 'rookie year': 2005, +teams = { +'1678': { +'location': 'Davis, CA, USA', +'rookie year': 2005, '2019 compete': True , 'names of 2019 competitions': ['Central Valley Regional', 'Sacramento Regional', 'Aerospace Valley Regional', 'Carver Division', 'Einstein Field', 'RCC', 'Chezy Champs'] , 'location of 2019 competitions': ['Fresno, CA, USA', 'Davis, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'Hangzhou, Zhejian, China', 'San Jose, CA, USA'] -, '2019 awards': ['Regional Chairmans', 'Regional Winner', 'Regional Winner', 'Regional Winner', 'Division Winner'] +, '2019 awards': ['Regional Chairmans', 'Regional Winner', 'Regional Winner', 'FIRST Deans List Finalist Award', 'Industrial Design Award', 'Regional Winner', 'Excellence in Engineering Award', 'Division Winner', 'Entrepreneurship Award'] }, -'1323': {'location': 'Madera, CA, USA', 'rookie year': 2004, + +'1323': { +'location': 'Madera, CA, USA', +'rookie year': 2004, '2019 compete': True , 'names of 2019 competitions': ['Central Valley Regional', 'Sacramento Regional', 'Newton Division', 'Einstein Field'] , 'location of 2019 competitions': ['Fresno, CA, USA', 'Davis, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA'] -, '2019 awards': ['Regional Winner', 'Regional Winner', 'Division Winner', 'Houston Champs Winner'] +, '2019 awards': ['Regional Winner', 'Autonomous Award', 'Regional Winner', 'Quality Award', 'Division Winner', 'Industrial Design Award', 'Houston Champs Winner'] }, -'254': {'location': 'San Jose, CA, USA', 'rookie year': 1999, + +'254': { +'location': 'San Jose, CA, USA', +'rookie year': 1999, '2019 compete': True , 'names of 2019 competitions': ['San Francisco Regional', 'Silicon Valley Regional', 'Turing Division', 'Einstein Field', 'Chezy Champs'] , 'location of 2019 competitions': ['San Francisco, CA, USA', 'San Jose, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'San Jose, CA, USA'] -, '2019 awards': ['Regional Winner', 'Regional Winner', 'Division Winner'] +, '2019 awards': ['Regional Winner', 'Innovation in Control Award', 'Regional Winner', 'Excellence in Engineering Award', 'Division Winner', 'Industrial Design Award', 'Houston Champs Finalist'] }, -'3132': {'location': 'Sydney, New South Wales, Australia', + +'3132': { +'location': 'Sydney, New South Wales, Australia', 'rookie year': 2010, '2019 compete': True , 'names of 2019 competitions': ['Southern Cross Regional', 'South Pacific Regional', 'Carver Division', 'Einstein Field'] , 'location of 2019 competitions': ['Sydney Olympic Park, NSW, Australia', 'Sydney Olympic Park, NSW, Australia', 'Houston, TX, USA', 'Houston, TX, USA'] -, '2019 awards': ['Regional Finalist','Division Winner'] +, '2019 awards': ['Woodie Flowers Finalist Award', 'Gracious Professionalism Award', 'Regional Engineering Inspiration Award', 'Safety Award','Division Winner'] }, -'3476:' {'location': 'Irvine, CA, USA', 'rookie year': 2011, +'3476:' { +'location': 'Irvine, CA, USA', +'rookie year': 2011, '2019 compete': True , 'names of 2019 competitions': ['Los Angeles Regional', 'Aerospace Valley Regional', 'Hopper Division', 'Battleship Blast', 'Chezy Champs', 'Beach Blitz'] -, 'location of 2019 competitions': ['Los Angeles, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'San Pedro, CA, USA', 'San Jose, CA, USA', 'Huntington Beach, CA, USA'] -, '2019 awards': ['Regional Chairmans', 'Regional Winner', 'Regional Winner', 'Regional Winner', 'Division Winner'] +, 'location of 2019 competitions': ['Los Angeles, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'San Pedro, CA, USA', 'San Jose, CA, USA', 'Huntington Beach, CA, USA'] +, '2019 awards': ['Gracious Professionalism Award', 'Autonomous Award', 'Regional Winner', 'Quality Award'] } } team_num = input("Team number: ") attribute = input("Attribute: ") -print(teams[team_num][attribute]) +print(teams[team_num][attribute]) #prints value for key corresponding to attribute within the value for key corresponding to team number From 16cadd6d20bfb465c87fc374ecb6e39a52d6dd53 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Sun, 15 Sep 2019 22:44:35 -0700 Subject: [PATCH 04/20] Add ch_1_assign_Claire_Hays.py to repository. --- ch_1_assign_Claire_Hays.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index f309fb2..6b01f77 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -45,4 +45,4 @@ } team_num = input("Team number: ") attribute = input("Attribute: ") -print(teams[team_num][attribute]) #prints value for key corresponding to attribute within the value for key corresponding to team number +print(teams[team_num][attribute]) \ No newline at end of file From 863f119d2b738416eb79d864778d71132533e418 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 18 Sep 2019 19:30:01 -0700 Subject: [PATCH 05/20] Format ch_1_assign_Claire_Hays.py. --- ch_1_assign_Claire_Hays.py | 169 ++++++++++++++++++++++++++++--------- 1 file changed, 129 insertions(+), 40 deletions(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index 6b01f77..5cb4d15 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -1,47 +1,136 @@ teams = { -'1678': { -'location': 'Davis, CA, USA', -'rookie year': 2005, -'2019 compete': True , -'names of 2019 competitions': ['Central Valley Regional', 'Sacramento Regional', 'Aerospace Valley Regional', 'Carver Division', 'Einstein Field', 'RCC', 'Chezy Champs'] -, 'location of 2019 competitions': ['Fresno, CA, USA', 'Davis, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'Hangzhou, Zhejian, China', 'San Jose, CA, USA'] -, '2019 awards': ['Regional Chairmans', 'Regional Winner', 'Regional Winner', 'FIRST Deans List Finalist Award', 'Industrial Design Award', 'Regional Winner', 'Excellence in Engineering Award', 'Division Winner', 'Entrepreneurship Award'] -}, + '1678': { + 'location': 'Davis, CA, USA', + 'rookie year': 2005, + '2019 compete': True , + 'names of 2019 competitions': [ + 'Central Valley Regional', + 'Sacramento Regional', + 'Aerospace Valley Regional', + 'Carver Division', + 'Einstein Field', + 'RCC', + 'Chezy Champs' + ], + 'location of 2019 competitions': [ + 'Fresno, CA, USA', + 'Davis, CA, USA', + 'Lancaster, CA, USA', + 'Houston, TX, USA', + 'Houston, TX, USA', + 'Hangzhou, Zhejian, China', + 'San Jose, CA, USA' + ], + '2019 awards': [ + 'Regional Chairmans', + 'Regional Winner', + 'Regional Winner', + 'FIRST Deans List Finalist Award', + 'Industrial Design Award', + 'Regional Winner', + 'Excellence in Engineering Award', + 'Division Winner', + 'Entrepreneurship Award' + ] + }, -'1323': { -'location': 'Madera, CA, USA', -'rookie year': 2004, -'2019 compete': True , -'names of 2019 competitions': ['Central Valley Regional', 'Sacramento Regional', 'Newton Division', 'Einstein Field'] -, 'location of 2019 competitions': ['Fresno, CA, USA', 'Davis, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA'] -, '2019 awards': ['Regional Winner', 'Autonomous Award', 'Regional Winner', 'Quality Award', 'Division Winner', 'Industrial Design Award', 'Houston Champs Winner'] -}, + '1323': { + 'location': 'Madera, CA, USA', + 'rookie year': 2004, + '2019 compete': True , + 'names of 2019 competitions': [ + 'Central Valley Regional', + 'Sacramento Regional', + 'Newton Division', + 'Einstein Field' + ], + 'location of 2019 competitions': [ + 'Fresno, CA, USA', + 'Davis, CA, USA', + 'Houston, TX, USA', + 'Houston, TX, USA' + ], + '2019 awards': [ + 'Regional Winner', + 'Autonomous Award', + 'Regional Winner', + 'Quality Award', + 'Division Winner', + 'Industrial Design Award', + 'Houston Champs Winner' + ] + }, -'254': { -'location': 'San Jose, CA, USA', -'rookie year': 1999, -'2019 compete': True , -'names of 2019 competitions': ['San Francisco Regional', 'Silicon Valley Regional', 'Turing Division', 'Einstein Field', 'Chezy Champs'] -, 'location of 2019 competitions': ['San Francisco, CA, USA', 'San Jose, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA', 'San Jose, CA, USA'] -, '2019 awards': ['Regional Winner', 'Innovation in Control Award', 'Regional Winner', 'Excellence in Engineering Award', 'Division Winner', 'Industrial Design Award', 'Houston Champs Finalist'] -}, + '254': { + 'location': 'San Jose, CA, USA', + 'rookie year': 1999, + '2019 compete': True , + 'names of 2019 competitions': [ + 'San Francisco Regional', + 'Silicon Valley Regional', + 'Turing Division', + 'Einstein Field', + 'Chezy Champs'] + , 'location of 2019 competitions': [ + 'San Francisco, CA, USA', + 'San Jose, CA, USA', + 'Houston, TX, USA', + 'Houston, TX, USA', + 'San Jose, CA, USA'], + '2019 awards': [ + 'Regional Winner', + 'Innovation in Control Award', + 'Regional Winner', + 'Excellence in Engineering Award', + 'Division Winner', + 'Industrial Design Award', + 'Houston Champs Finalist'] + }, -'3132': { -'location': 'Sydney, New South Wales, Australia', -'rookie year': 2010, -'2019 compete': True , -'names of 2019 competitions': ['Southern Cross Regional', 'South Pacific Regional', 'Carver Division', 'Einstein Field'] -, 'location of 2019 competitions': ['Sydney Olympic Park, NSW, Australia', 'Sydney Olympic Park, NSW, Australia', 'Houston, TX, USA', 'Houston, TX, USA'] -, '2019 awards': ['Woodie Flowers Finalist Award', 'Gracious Professionalism Award', 'Regional Engineering Inspiration Award', 'Safety Award','Division Winner'] -}, -'3476:' { -'location': 'Irvine, CA, USA', -'rookie year': 2011, -'2019 compete': True , -'names of 2019 competitions': ['Los Angeles Regional', 'Aerospace Valley Regional', 'Hopper Division', 'Battleship Blast', 'Chezy Champs', 'Beach Blitz'] -, 'location of 2019 competitions': ['Los Angeles, CA, USA', 'Lancaster, CA, USA', 'Houston, TX, USA', 'San Pedro, CA, USA', 'San Jose, CA, USA', 'Huntington Beach, CA, USA'] -, '2019 awards': ['Gracious Professionalism Award', 'Autonomous Award', 'Regional Winner', 'Quality Award'] -} + '3132': { + 'location': 'Sydney, New South Wales, Australia', + 'rookie year': 2010, + '2019 compete': True , + 'names of 2019 competitions': [ + 'Southern Cross Regional', + 'South Pacific Regional', + 'Carver Division', + 'Einstein Field'], + 'location of 2019 competitions': [ + 'Sydney Olympic Park, NSW, Australia', + 'Sydney Olympic Park, NSW, Australia', + 'Houston, TX, USA', + 'Houston, TX, USA'], + '2019 awards': [ + 'Woodie Flowers Finalist Award', + 'Gracious Professionalism Award', + 'Regional Engineering Inspiration Award', + 'Safety Award','Division Winner'] + }, + '3476:' { + 'location': 'Irvine, CA, USA', + 'rookie year': 2011, + '2019 compete': True , + 'names of 2019 competitions': [ + 'Los Angeles Regional', + 'Aerospace Valley Regional', + 'Hopper Division', + 'Battleship Blast', + 'Chezy Champs', + 'Beach Blitz'], + 'location of 2019 competitions': [ + 'Los Angeles, CA, USA', + 'Lancaster, CA, USA', + 'Houston, TX, USA', + 'San Pedro, CA, USA', + 'San Jose, CA, USA', + 'Huntington Beach, CA, USA'], + '2019 awards': [ + 'Gracious Professionalism Award', + 'Autonomous Award', + 'Regional Winner', + 'Quality Award'] + } } team_num = input("Team number: ") attribute = input("Attribute: ") From a5dc73a3c6d00e0ba19be33efbf1a97419f5e3d1 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 18 Sep 2019 19:34:48 -0700 Subject: [PATCH 06/20] Format ch_1_assign_Claire_Hays.py. --- ch_1_assign_Claire_Hays.py | 39 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index 5cb4d15..e8128eb 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -43,13 +43,13 @@ 'Sacramento Regional', 'Newton Division', 'Einstein Field' - ], + ], 'location of 2019 competitions': [ 'Fresno, CA, USA', 'Davis, CA, USA', 'Houston, TX, USA', 'Houston, TX, USA' - ], + ], '2019 awards': [ 'Regional Winner', 'Autonomous Award', @@ -57,8 +57,7 @@ 'Quality Award', 'Division Winner', 'Industrial Design Award', - 'Houston Champs Winner' - ] + 'Houston Champs Winner'] }, '254': { @@ -70,21 +69,21 @@ 'Silicon Valley Regional', 'Turing Division', 'Einstein Field', - 'Chezy Champs'] - , 'location of 2019 competitions': [ - 'San Francisco, CA, USA', - 'San Jose, CA, USA', - 'Houston, TX, USA', - 'Houston, TX, USA', - 'San Jose, CA, USA'], - '2019 awards': [ - 'Regional Winner', - 'Innovation in Control Award', - 'Regional Winner', - 'Excellence in Engineering Award', - 'Division Winner', - 'Industrial Design Award', - 'Houston Champs Finalist'] + 'Chezy Champs'], + 'location of 2019 competitions': [ + 'San Francisco, CA, USA', + 'San Jose, CA, USA', + 'Houston, TX, USA', + 'Houston, TX, USA', + 'San Jose, CA, USA'], + '2019 awards': [ + 'Regional Winner', + 'Innovation in Control Award', + 'Regional Winner', + 'Excellence in Engineering Award', + 'Division Winner', + 'Industrial Design Award', + 'Houston Champs Finalist'] }, '3132': { @@ -96,7 +95,7 @@ 'South Pacific Regional', 'Carver Division', 'Einstein Field'], - 'location of 2019 competitions': [ + 'location of 2019 competitions': [ 'Sydney Olympic Park, NSW, Australia', 'Sydney Olympic Park, NSW, Australia', 'Houston, TX, USA', From 02282c3eb0bbc92fe8a6fd4c9f79e2a6b11bd158 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 18 Sep 2019 20:09:19 -0700 Subject: [PATCH 07/20] Format ch_1_assign_Claire_Hays.py. --- ch_1_assign_Claire_Hays.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index e8128eb..3f938d7 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -1,5 +1,5 @@ teams = { - '1678': { + '1678':{ 'location': 'Davis, CA, USA', 'rookie year': 2005, '2019 compete': True , @@ -106,7 +106,7 @@ 'Regional Engineering Inspiration Award', 'Safety Award','Division Winner'] }, - '3476:' { + '3476':{ 'location': 'Irvine, CA, USA', 'rookie year': 2011, '2019 compete': True , From 16997142075736f95121ca9f96e27f19ed126f35 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 25 Sep 2019 20:06:18 -0700 Subject: [PATCH 08/20] Add ch_2_assign_Claire_Hays.py to repository. --- ch_2_assign_Claire_Hays.py | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 ch_2_assign_Claire_Hays.py diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py new file mode 100644 index 0000000..8707ec6 --- /dev/null +++ b/ch_2_assign_Claire_Hays.py @@ -0,0 +1,95 @@ +teams = {} +while True: + command = input("""Enter the command (add a team, remove a team, search for a team, list all teams, + view team's information, modify team's information, view all teams and information, or quit): """) + + + if command == "add a team": + team_num = int(input("What is the team number? ")) + team_name = input("What is the team name? ") + team_prog_lang = input("What is the team's programming language? ") + robot_width = float(input("What is the robot's width? ")) + robot_length = float(input("What is the robot's length? ")) + robot_vision = input("Does the robot have camera vision? ") + if robot_vision == "yes" or "Yes" or "YES": + robot_vision = True + elif robot_vision == "no" or "No" or "NO": + robot_vision == False + robot_motors = int(input("How many drivetrain motors does the robot have? ")) + attributes = {"Name": team_name, "Programming Language": team_prog_lang, + "Width": robot_width, "Length": robot_length, "Camera Vision": robot_vision, + "Drivetrain Motors": robot_motors} + new_team = {team_num: attributes} + teams.update(new_team) + + + if command == "remove a team": + remove_team_num = int(input("What team number would you like to remove? ")) + teams.pop(remove_team_num) + print("Team number successfully removed. To view new team list, type 'list all teams'") + + + if command == "search for a team": + team_search = int(input("What team number would you like to search for? ")) + print(teams.get(team_search)) + + + if command == "list all teams": + print(teams.keys()) + + + if command == "view team's information": + view_team_num = int(input("What team's information would you like to view? ")) + print(teams.get(view_team_num)) + + + if command == "modify team's information": + print("If attribute hasn't changed, type none") + chng_team_num = int(input("What team number's information would you like to change? ")) + new_team_name = input("What is the new team name? ") + + if new_team_name == "none": + new_team_name = teams[chng_team_num]["Name"] + new_team_prog_lang = input("What is the team's new programming language? ") + + if new_team_prog_lang == "none": + new_team_prog_lang = teams[chng_team_num]["Programming Language"] + new_robot_width = input("What is the robot's new width? ") + + if new_robot_width == "none": + new_robot_width = teams[chng_team_num]["Width"] + else: + new_robot_width = float(new_robot_width) + new_robot_length = input("What is the robot's new length? ") + + if new_robot_length == "none": + new_robot_length = teams[chng_team_num]["Length"] + else: + new_robot_length = float(new_robot_length) + new_robot_vision = input("Does the new robot have camera vision? ") + + if new_robot_vision == "none": + new_robot_vision = teams[chng_team_num]["Camera Vision"] + elif new_robot_vision == "yes" or "Yes" or "YES": + new_robot_vision = True + elif new_robot_vision == "no" or "No" or "NO": + new_robot_vision == False + new_robot_motors = input("How many drivetrain motors does the new robot have? ") + + if new_robot_motors == "none": + new_robot_motors = teams[chng_team_num]["Drivetrain Motors"] + else: + new_robot_motors = int(new_robot_motors) + new_attributes = {"Name": new_team_name, "Programming Language": new_team_prog_lang, + "Width": new_robot_width, "Length": new_robot_length, "Camera Vision": new_robot_vision, + "Drivetrain Motors": new_robot_motors} + teams[chng_team_num] = new_attributes + + + if command == "view all teams and information": + print(teams) + + + if command == "quit": + break + From 67e0d21e1d23782b323fadcb3d5af5b7a90f07ef Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 25 Sep 2019 20:40:11 -0700 Subject: [PATCH 09/20] Add ch_2_assign_Claire_Hays.py to repository. --- ch_2_assign_Claire_Hays.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py index 8707ec6..1d175e0 100644 --- a/ch_2_assign_Claire_Hays.py +++ b/ch_2_assign_Claire_Hays.py @@ -11,15 +11,15 @@ robot_width = float(input("What is the robot's width? ")) robot_length = float(input("What is the robot's length? ")) robot_vision = input("Does the robot have camera vision? ") - if robot_vision == "yes" or "Yes" or "YES": + if robot_vision.lower() == "yes": robot_vision = True - elif robot_vision == "no" or "No" or "NO": + elif robot_vision.lower() == "no": robot_vision == False robot_motors = int(input("How many drivetrain motors does the robot have? ")) attributes = {"Name": team_name, "Programming Language": team_prog_lang, "Width": robot_width, "Length": robot_length, "Camera Vision": robot_vision, "Drivetrain Motors": robot_motors} - new_team = {team_num: attributes} + new_team = {team_num: attributes} teams.update(new_team) @@ -40,7 +40,9 @@ if command == "view team's information": view_team_num = int(input("What team's information would you like to view? ")) - print(teams.get(view_team_num)) + view_team_attribute = str(input("""What attribute would you like to view (Name, + Programming Language, Width, Length, Camera Vision, Drivetrain Motors? """)) + print(teams[view_team_num][view_team_attribute]) if command == "modify team's information": @@ -70,9 +72,9 @@ if new_robot_vision == "none": new_robot_vision = teams[chng_team_num]["Camera Vision"] - elif new_robot_vision == "yes" or "Yes" or "YES": + elif new_robot_vision.lower() == "yes": new_robot_vision = True - elif new_robot_vision == "no" or "No" or "NO": + elif new_robot_vision.lower() == "no": new_robot_vision == False new_robot_motors = input("How many drivetrain motors does the new robot have? ") From e72b56fcccc7cbd6a2bf3f65f3cd49d19323a3b6 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Thu, 26 Sep 2019 20:45:52 -0700 Subject: [PATCH 10/20] Add ch_1_assign_Claire_Hays.py to repository. --- ch_1_assign_Claire_Hays.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index 3f938d7..548052b 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -1,5 +1,5 @@ teams = { - '1678':{ + 1678:{ 'location': 'Davis, CA, USA', 'rookie year': 2005, '2019 compete': True , @@ -34,7 +34,7 @@ ] }, - '1323': { + 1323: { 'location': 'Madera, CA, USA', 'rookie year': 2004, '2019 compete': True , @@ -60,7 +60,7 @@ 'Houston Champs Winner'] }, - '254': { + 254: { 'location': 'San Jose, CA, USA', 'rookie year': 1999, '2019 compete': True , @@ -86,7 +86,7 @@ 'Houston Champs Finalist'] }, - '3132': { + 3132: { 'location': 'Sydney, New South Wales, Australia', 'rookie year': 2010, '2019 compete': True , @@ -106,7 +106,7 @@ 'Regional Engineering Inspiration Award', 'Safety Award','Division Winner'] }, - '3476':{ + 3476:{ 'location': 'Irvine, CA, USA', 'rookie year': 2011, '2019 compete': True , @@ -131,6 +131,6 @@ 'Quality Award'] } } -team_num = input("Team number: ") +team_num = int(input("Team number: ")) attribute = input("Attribute: ") print(teams[team_num][attribute]) \ No newline at end of file From 75fd510e68e865f621dd1314cc133ff243125dfb Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 2 Oct 2019 16:32:53 -0700 Subject: [PATCH 11/20] Change names and locations of competitions to one dictionary. --- ch_1_assign_Claire_Hays.py | 102 +++++++++++++------------------------ 1 file changed, 35 insertions(+), 67 deletions(-) diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py index 548052b..5584f88 100644 --- a/ch_1_assign_Claire_Hays.py +++ b/ch_1_assign_Claire_Hays.py @@ -3,24 +3,15 @@ 'location': 'Davis, CA, USA', 'rookie year': 2005, '2019 compete': True , - 'names of 2019 competitions': [ - 'Central Valley Regional', - 'Sacramento Regional', - 'Aerospace Valley Regional', - 'Carver Division', - 'Einstein Field', - 'RCC', - 'Chezy Champs' - ], - 'location of 2019 competitions': [ - 'Fresno, CA, USA', - 'Davis, CA, USA', - 'Lancaster, CA, USA', - 'Houston, TX, USA', - 'Houston, TX, USA', - 'Hangzhou, Zhejian, China', - 'San Jose, CA, USA' - ], + 'names and locations of 2019 competitions': { + 'Central Valley Regional': 'Fresno, CA, USA', + 'Sacramento Regional': 'Davis, CA, USA', + 'Aerospace Valley Regional': 'Lancaster, CA, USA', + 'Carver Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA', + 'RCC': 'Hangzhou, Zhejian, China', + 'Chezy Champs': 'San Jose, CA, USA' + }, '2019 awards': [ 'Regional Chairmans', 'Regional Winner', @@ -38,18 +29,12 @@ 'location': 'Madera, CA, USA', 'rookie year': 2004, '2019 compete': True , - 'names of 2019 competitions': [ - 'Central Valley Regional', - 'Sacramento Regional', - 'Newton Division', - 'Einstein Field' - ], - 'location of 2019 competitions': [ - 'Fresno, CA, USA', - 'Davis, CA, USA', - 'Houston, TX, USA', - 'Houston, TX, USA' - ], + 'names and locations of 2019 competitions': { + 'Central Valley Regional': 'Fresno, CA, USA', + 'Sacramento Regional': 'Davis, CA, USA', + 'Newton Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA' + }, '2019 awards': [ 'Regional Winner', 'Autonomous Award', @@ -64,18 +49,12 @@ 'location': 'San Jose, CA, USA', 'rookie year': 1999, '2019 compete': True , - 'names of 2019 competitions': [ - 'San Francisco Regional', - 'Silicon Valley Regional', - 'Turing Division', - 'Einstein Field', - 'Chezy Champs'], - 'location of 2019 competitions': [ - 'San Francisco, CA, USA', - 'San Jose, CA, USA', - 'Houston, TX, USA', - 'Houston, TX, USA', - 'San Jose, CA, USA'], + 'names and locations of 2019 competitions': { + 'San Francisco Regional': 'San Francisco, CA, USA', + 'Silicon Valley Regional': 'San Jose, CA, USA', + 'Turing Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA', + 'Chezy Champs': 'San Jose, CA, USA'}, '2019 awards': [ 'Regional Winner', 'Innovation in Control Award', @@ -90,41 +69,30 @@ 'location': 'Sydney, New South Wales, Australia', 'rookie year': 2010, '2019 compete': True , - 'names of 2019 competitions': [ - 'Southern Cross Regional', - 'South Pacific Regional', - 'Carver Division', - 'Einstein Field'], - 'location of 2019 competitions': [ - 'Sydney Olympic Park, NSW, Australia', - 'Sydney Olympic Park, NSW, Australia', - 'Houston, TX, USA', - 'Houston, TX, USA'], + 'names and locations of 2019 competitions': { + 'Southern Cross Regional': 'Sydney Olympic Park, NSW, Australia', + 'South Pacific Regional': 'Sydney Olympic Park, NSW, Australia', + 'Carver Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA'}, '2019 awards': [ 'Woodie Flowers Finalist Award', 'Gracious Professionalism Award', 'Regional Engineering Inspiration Award', 'Safety Award','Division Winner'] }, + 3476:{ 'location': 'Irvine, CA, USA', 'rookie year': 2011, '2019 compete': True , - 'names of 2019 competitions': [ - 'Los Angeles Regional', - 'Aerospace Valley Regional', - 'Hopper Division', - 'Battleship Blast', - 'Chezy Champs', - 'Beach Blitz'], - 'location of 2019 competitions': [ - 'Los Angeles, CA, USA', - 'Lancaster, CA, USA', - 'Houston, TX, USA', - 'San Pedro, CA, USA', - 'San Jose, CA, USA', - 'Huntington Beach, CA, USA'], - '2019 awards': [ + 'names and locations of 2019 competitions': { + 'Los Angeles Regional': 'Los Angeles, CA, USA', + 'Aerospace Valley Regional': 'Lancaster, CA, USA', + 'Hopper Division': 'Houston, TX, USA', + 'Battleship Blast': 'San Pedro, CA, USA', + 'Chezy Champs': 'San Jose, CA, USA', + 'Beach Blitz': 'Huntington Beach, CA, USA'}, + '2019 awards': [ 'Gracious Professionalism Award', 'Autonomous Award', 'Regional Winner', From 8d41af45febdc0e6c922fdbeb2a87da3b183a199 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 2 Oct 2019 16:47:26 -0700 Subject: [PATCH 12/20] Add feature for searching by team name. --- ch_2_assign_Claire_Hays.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py index 1d175e0..22f7521 100644 --- a/ch_2_assign_Claire_Hays.py +++ b/ch_2_assign_Claire_Hays.py @@ -1,7 +1,7 @@ teams = {} while True: command = input("""Enter the command (add a team, remove a team, search for a team, list all teams, - view team's information, modify team's information, view all teams and information, or quit): """) +view team's information, modify team's information, view all teams and information, or quit): """) if command == "add a team": @@ -30,8 +30,18 @@ if command == "search for a team": - team_search = int(input("What team number would you like to search for? ")) - print(teams.get(team_search)) + team_search = input("What team would you like to search for? ") + if team_search.isnumeric() == True: + print(teams.get(int(team_search))) + else: + names = [] + for team_num, team_attributes in teams.items(): + names.append(team_attributes["Name"]) + if team_search in names: + print("The team you searched for was found in the database.") + else: + print("The team you searched for was not in the database.") + if command == "list all teams": From f0c0235f5a6a4c9e08c146e429cba731dfdd2774 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 2 Oct 2019 20:48:44 -0700 Subject: [PATCH 13/20] Made a system so that non-integers won't break the program. --- ch_2_assign_Claire_Hays.py | 230 +++++++++++++++++++++++++++++-------- 1 file changed, 184 insertions(+), 46 deletions(-) diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py index 22f7521..d1e5ae6 100644 --- a/ch_2_assign_Claire_Hays.py +++ b/ch_2_assign_Claire_Hays.py @@ -5,17 +5,82 @@ if command == "add a team": - team_num = int(input("What is the team number? ")) + check = False + while check == False: + team_num = input("What is the team number? ") + if team_num == 'quit': + check = True + elif team_num.isdigit(): + team_num = int(team_num) + check = True + else: + print("Please type your team number as an integer") + if team_num == 'quit': + continue + team_name = input("What is the team name? ") + if team_name == 'quit': + continue + team_prog_lang = input("What is the team's programming language? ") - robot_width = float(input("What is the robot's width? ")) - robot_length = float(input("What is the robot's length? ")) - robot_vision = input("Does the robot have camera vision? ") - if robot_vision.lower() == "yes": - robot_vision = True - elif robot_vision.lower() == "no": - robot_vision == False - robot_motors = int(input("How many drivetrain motors does the robot have? ")) + if team_prog_lang == 'quit': + continue + + check = False + while check == False: + robot_width = input("What is the robot's width? ") + if robot_width == 'quit': + check = True + elif robot_width.isnumeric(): + robot_width = float(robot_width) + check = True + else: + print("Please type your robot width as an float") + if robot_width == 'quit': + continue + + check = False + while check == False: + robot_length = input("What is the robot's length? ") + if robot_length == 'quit': + check = True + elif robot_length.isnumeric(): + robot_length = float(robot_length) + check = True + else: + print("Please type your robot length as an float") + if robot_length == 'quit': + continue + + check = False + while check == False: + robot_vision = input("Does the robot have camera vision? ") + if robot_vision == 'quit': + check = True + elif robot_vision.lower() == "yes": + robot_vision = True + check = True + elif robot_vision.lower() == "no": + robot_vision == False + check = True + else: + print("Please type either yes or no") + if robot_vision == 'quit': + continue + + check = False + while check == False: + robot_motors = input("How many drivetrain motors does the robot have? ") + if robot_motors == 'quit': + check = True + elif robot_motors.isdigit(): + robot_motors = int(robot_motors) + check = True + else: + print("Please type the number of motors as an integer") + if robot_motors == 'quit': + continue + attributes = {"Name": team_name, "Programming Language": team_prog_lang, "Width": robot_width, "Length": robot_length, "Camera Vision": robot_vision, "Drivetrain Motors": robot_motors} @@ -23,15 +88,21 @@ teams.update(new_team) - if command == "remove a team": - remove_team_num = int(input("What team number would you like to remove? ")) + elif command == "remove a team": + remove_team_num = input("What team number would you like to remove? ") + if remove_team_num == 'quit': + continue + else: + remove_team_num = int(remove_team_num) teams.pop(remove_team_num) print("Team number successfully removed. To view new team list, type 'list all teams'") - if command == "search for a team": + elif command == "search for a team": team_search = input("What team would you like to search for? ") - if team_search.isnumeric() == True: + if team_search == 'quit': + continue + elif team_search.isnumeric() == True: print(teams.get(int(team_search))) else: names = [] @@ -49,59 +120,126 @@ if command == "view team's information": - view_team_num = int(input("What team's information would you like to view? ")) + view_team_num = input("What team's information would you like to view? ") + if view_team_num == 'quit': + continue + else: + view_team_num = int(view_team_num) view_team_attribute = str(input("""What attribute would you like to view (Name, - Programming Language, Width, Length, Camera Vision, Drivetrain Motors? """)) - print(teams[view_team_num][view_team_attribute]) + Programming Language, Width, Length, Camera Vision, Drivetrain Motors? """)) + if view_team_attribute == 'quit': + continue + else: + print(teams[view_team_num][view_team_attribute]) if command == "modify team's information": print("If attribute hasn't changed, type none") - chng_team_num = int(input("What team number's information would you like to change? ")) + + check = False + while check == False: + chng_team_num = input("What team number's information would you like to change? ") + if chng_team_num == 'quit': + check = True + elif chng_team_num.isdigit(): + chng_team_num = int(chng_team_num) + check = True + else: + print("Please type your team number as an integer") + if chng_team_num == 'quit': + continue + new_team_name = input("What is the new team name? ") + if new_team_name == 'quit': + continue + elif new_team_name == "none": + new_team_name = teams[chng_team_num]["Name"] - if new_team_name == "none": - new_team_name = teams[chng_team_num]["Name"] new_team_prog_lang = input("What is the team's new programming language? ") - - if new_team_prog_lang == "none": + if new_team_prog_lang == 'quit': + continue + elif new_team_prog_lang == "none": new_team_prog_lang = teams[chng_team_num]["Programming Language"] - new_robot_width = input("What is the robot's new width? ") - - if new_robot_width == "none": - new_robot_width = teams[chng_team_num]["Width"] - else: - new_robot_width = float(new_robot_width) - new_robot_length = input("What is the robot's new length? ") - if new_robot_length == "none": - new_robot_length = teams[chng_team_num]["Length"] - else: - new_robot_length = float(new_robot_length) - new_robot_vision = input("Does the new robot have camera vision? ") + check = False + while check == False: + new_robot_width = input("What is the robot's new width? ") + if new_robot_width == 'quit': + check = True + elif new_robot_width == 'none': + new_robot_width = teams[chng_team_num]["Width"] + check = True + elif new_robot_width.isnumeric(): + new_robot_width = float(new_robot_width) + check = True + else: + print("Please type your robot width as an float") + if new_robot_width == 'quit': + continue - if new_robot_vision == "none": - new_robot_vision = teams[chng_team_num]["Camera Vision"] - elif new_robot_vision.lower() == "yes": - new_robot_vision = True - elif new_robot_vision.lower() == "no": - new_robot_vision == False - new_robot_motors = input("How many drivetrain motors does the new robot have? ") + check = False + while check == False: + new_robot_length = input("What is the robot's new length? ") + if robot_length == 'quit': + check = True + elif new_robot_length == "none": + new_robot_length = teams[chng_team_num]["Length"] + check = True + elif robot_length.isnumeric(): + new_robot_length = float(new_robot_length) + check = True + else: + print("Please type your robot length as an float") + if new_robot_length == 'quit': + continue + + + check = False + while check == False: + new_robot_vision = input("Does the new robot have camera vision? ") + if new_robot_vision == 'quit': + check = True + elif new_robot_vision == "none": + new_robot_vision = teams[chng_team_num]["Camera Vision"] + check = True + elif new_robot_vision.lower() == "yes": + new_robot_vision = True + check = True + elif new_robot_vision.lower() == "no": + new_robot_vision == False + check = True + else: + print("Please type either yes or no") + if new_robot_vision == 'quit': + continue - if new_robot_motors == "none": - new_robot_motors = teams[chng_team_num]["Drivetrain Motors"] - else: - new_robot_motors = int(new_robot_motors) + + check = False + while check == False: + new_robot_motors = input("How many drivetrain motors does the new robot have? ") + if new_robot_motors == 'quit': + check = True + elif new_robot_motors == "none": + new_robot_motors = teams[chng_team_num]["Drivetrain Motors"] + check = True + elif new_robot_motors.isdigit(): + new_robot_motors = int(new_robot_motors) + check = True + else: + print("Please type the number of motors as an integer") + if new_robot_motors == 'quit': + continue + new_attributes = {"Name": new_team_name, "Programming Language": new_team_prog_lang, "Width": new_robot_width, "Length": new_robot_length, "Camera Vision": new_robot_vision, "Drivetrain Motors": new_robot_motors} teams[chng_team_num] = new_attributes - if command == "view all teams and information": + elif command == "view all teams and information": print(teams) - if command == "quit": + elif command == "quit": break From cceee3444ad1c2fdcb1c5dfbe41294a4c33223b8 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 16 Oct 2019 18:47:26 -0700 Subject: [PATCH 14/20] Add ch_3_assign_Claire_Hays.py to repository. --- ch_3_assign_Claire_Hays.py | 230 +++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 ch_3_assign_Claire_Hays.py diff --git a/ch_3_assign_Claire_Hays.py b/ch_3_assign_Claire_Hays.py new file mode 100644 index 0000000..c4fa0ac --- /dev/null +++ b/ch_3_assign_Claire_Hays.py @@ -0,0 +1,230 @@ +teams = {} +while True: + command = input("""Enter the command (add a team, remove a team, search for a team, list all teams, +view team's information, modify team's information, view all teams and information, or quit): """) + def check_if_int(a): + while True: + if a == 'quit': + return None + elif a.isdigit() == True: + a = int(a) + return a + else: + a = input("Please type attribute as an integer: ") + def check_if_bool(b): + while True: + if b == 'quit': + return None + elif b.lower() == 'yes': + b = True + return b + elif b.lower() == 'no': + b = False + return b + else: + b = input("Please type either 'yes' or 'no': ") + def check_if_quit(c): + if c == 'quit': + return True + + if command.lower() == "add a team": + team_num = input("What is the team number? ") + team_num = check_if_int(team_num) + if team_num is None: # User entered 'quit' + break + + location = input("What is the location of the team? ") + if check_if_quit(location) == True: + break + + rookie_year = input("What was the team's rookie year? ") + rookie_year = check_if_int(rookie_year) + if rookie_year is None: # User entered 'quit' + break + + + compete_2019 = input("Did the team compete in 2019? ") + if check_if_quit(compete_2019) == True: + break + compete_2019 = check_if_bool(compete_2019) + if compete_2019 is None: # User entered 'quit' + break + + num_of_comp = input("How many competitions did the team compete in during the 2019 season? ") + if check_if_quit == True: + break + num_of_comp = check_if_int(num_of_comp) + if num_of_comp is None: # User entered 'quit' + break + competitions = {} + while num_of_comp > 0: + comp_name = input("What is the name of the competition? ") + if check_if_quit(comp_name) == True: + break + else: + comp_loc = input("What is the location of the competition? ") + comp = {comp_name: comp_loc} + competitions.update(comp) + num_of_comp -= 1 + + num_of_awards = input("How many awards did the team earn during the 2019 season? ") + if check_if_quit(num_of_awards) == True: + break + num_of_awards = check_if_int(num_of_awards) + if num_of_awards is None: # User entered 'quit' + break + awards = [] + while num_of_awards > 0: + award = input("What is the name of the award? ") + if check_if_quit(award) == True: + break + awards.append(award) + num_of_awards -= 1 + + attributes = {'location': location, + 'rookie year': rookie_year, + '2019 compete': compete_2019, + 'names and locations of 2019 competitions': competitions, + '2019 awards': awards} + new_team = {team_num: attributes} + teams.update(new_team) + + + elif command == "remove a team": + remove_team_num = input("What team number would you like to remove? ") + if check_if_quit(remove_team_num) == True: + break + remove_team_num = check_if_int(remove_team_num) + if remove_team_num is None: # User entered 'quit' + break + teams.pop(remove_team_num) + print("Team number successfully removed. To view new team list, type 'list all teams'") + + + elif command == "search for a team": + team_search = input("What team would you like to search for? ") + if check_if_quit(team_search) == True: + break + team_search = check_if_int(team_search) + if team_search is None: # User entered 'quit' + break + print(teams.get(team_search)) + + + elif command == "list all teams": + print(teams.keys()) + + + elif command == "view team's information": + view_team_num = input("What team's information would you like to view? ") + if check_if_quit(view_team_num) == True: + break + view_team_num = check_if_int(view_team_num) + if view_team_num is None: # User entered 'quit' + break + view_team_attribute = str(input("""What attribute would you like to view (location, rookie year, 2019 compete, +names and locations of 2019 competitions, or 2019 awards)? """)) + if check_if_quit(view_team_attribute) == True: + break + print(teams[view_team_num][view_team_attribute]) + + + elif command == "modify team's information": + chng_team_num = input("What team number's information would you like to change? ") + if check_if_quit(chng_team_num) == True: + break + chng_team_num = check_if_int(chng_team_num) + if chng_team_num is None: # User entered 'quit' + break + chng_attribute = input("""What attribute would you like to change (location, rookie year, 2019 compete, +names and locations of 2019 competitions, or 2019 awards)? """) + if check_if_quit(chng_attribute) == True: + break + + if chng_attribute == 'location': + new_location = input("What is the location of the team? ") + if check_if_quit(new_location) == True: + break + new_rookie_year = teams[chng_team_num]['rookie year'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == 'rookie year': + new_rookie_year = input("What was the team's rookie year? ") + new_rookie_year = check_if_int(new_rookie_year) + if new_rookie_year is None: # User entered 'quit' + break + new_location = teams[chng_team_num]['location'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == '2019 compete': + new_compete_2019 = input("Did the team compete in 2019? ") + if check_if_quit(new_compete_2019) == True: + break + new_compete_2019 = check_if_bool(new_compete_2019) + if new_compete_2019 is None: # User entered 'quit' + break + new_location = teams[chng_team_num]['location'] + new_rookie_year = teams[chng_team_num]['rookie year'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == 'names and locations of 2019 competitions': + new_num_of_comp = input("How many competitions did the team compete in during the 2019 season? ") + if check_if_quit(new_num_of_comp) == True: + break + new_num_of_comp = check_if_int(new_num_of_comp) + if new_num_of_comp is None: # User entered 'quit' + break + new_competitions = {} + while new_num_of_comp > 0: + new_comp_name = input("What is the name of the competition? ") + if check_if_quit(new_comp_name) == True: + break + else: + new_comp_loc = input("What is the location of the competition? ") + new_comp = {new_comp_name: new_comp_loc} + new_competitions.update(new_comp) + new_num_of_comp -= 1 + new_location = teams[chng_team_num]['location'] + new_rookie_year = teams[chng_team_num]['rookie year'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == '2019 awards': + new_num_of_awards = input("How many awards did the team earn during the 2019 season? ") + if check_if_quit(new_num_of_awards) == True: + break + new_num_of_awards = check_if_int(new_num_of_awards) + if new_num_of_awards is None: # User entered 'quit' + break + new_awards = [] + while new_num_of_awards > 0: + new_award = input("What is the name of the award? ") + if check_if_quit(new_award) == True: + break + new_awards.append(new_award) + new_num_of_awards -= 1 + new_location = teams[chng_team_num]['location'] + new_rookie_year = teams[chng_team_num]['rookie year'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + + new_attributes = {'location': new_location, + 'rookie year': new_rookie_year, + '2019 compete': new_compete_2019, + 'names and locations of 2019 competitions': new_competitions, + '2019 awards': new_awards} + teams[chng_team_num] = new_attributes + + elif command == "view all teams and information": + print(teams) + + elif command == "quit": + break + + + From e51a79b4ed45aa9b289b8568e76a8483c9ded8ba Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 23 Oct 2019 20:40:39 -0700 Subject: [PATCH 15/20] Add ch_4_assign_Claire_Hays.py to repository --- ch_4_assign_Claire_Hays.py | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 ch_4_assign_Claire_Hays.py diff --git a/ch_4_assign_Claire_Hays.py b/ch_4_assign_Claire_Hays.py new file mode 100644 index 0000000..76683ef --- /dev/null +++ b/ch_4_assign_Claire_Hays.py @@ -0,0 +1,90 @@ +import math +class Point: + def __init__ (self, x, y): + self.x = x + self.y = y + def dist(self): + return math.sqrt(self.x**2 + self.y**2) + +class Point3D(Point): + def __init__ (self, x, y, z): + super().__init__ (x, y) + self.z = z + def dist(self): + return math.sqrt((super().dist())**2 + self.z**2) + +class Determine(Point3D): + def __init__(self, x2D, y2D, x, y, z): + super().__init__ (x, y, z) + self.x2D = x2D + self.y2D = y2D + def compare_tot_dist(self): + if super().dist() > Point(self.x2D, self.y2D).dist(): + return "3D point is farther from the origin." + else: + return "2D point is farther from origin." + + +check = False +while check == False: + x = input("What is the x coordinate of the 2D point? ") + if x.isdigit(): + x = int(x) + check = True + else: + print("Please type value as an integer. ") + +check = False +while check == False: + y = input("What is the y coordinate of the 2D point? ") + if y.isdigit(): + y = int(y) + check = True + else: + print("Please type value as an integer. ") + +point_2D = Point(x, y) +dist_2D = point_2D.dist() +print(dist_2D) + +check = False +while check == False: + x3D = input("What is the x coordinate of the 3D point? ") + if x3D.isdigit(): + x3D = int(x3D) + check = True + else: + print("Please type value as an integer. ") + +check = False +while check == False: + y3D = input("What is the y coordinate of the 3D point? ") + if y3D.isdigit(): + y3D = int(y3D) + check = True + else: + print("Please type value as an integer. ") + +check = False +while check == False: + z = input("What is the z coordinate of the 3D point? ") + if z.isdigit(): + z = int(z) + check = True + else: + print("Please type value as an integer. ") + +point_3D = Point3D(x3D, y3D, z) +dist_3D = point_3D.dist() +print(dist_3D) + +compare = Determine(x, y, x3D, y3D, z) +dist_tot_compare = compare.compare_tot_dist() +print(dist_tot_compare) + + + + + + + From f98b97ffb849d042c51b4b3e899db5b5ba3f58a1 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 30 Oct 2019 19:12:30 -0700 Subject: [PATCH 16/20] Repair discrepancy in search and mistake in quit. --- ch_2_assign_Claire_Hays.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py index d1e5ae6..a5c327b 100644 --- a/ch_2_assign_Claire_Hays.py +++ b/ch_2_assign_Claire_Hays.py @@ -103,7 +103,11 @@ if team_search == 'quit': continue elif team_search.isnumeric() == True: - print(teams.get(int(team_search))) + team_get = teams.get(int(team_search)) + if team_get == None: + print("The team you searched for was not found in the database. ") + else: + print("The team you searched for was found in the database. ") else: names = [] for team_num, team_attributes in teams.items(): @@ -180,12 +184,12 @@ check = False while check == False: new_robot_length = input("What is the robot's new length? ") - if robot_length == 'quit': + if new_robot_length == 'quit': check = True elif new_robot_length == "none": new_robot_length = teams[chng_team_num]["Length"] check = True - elif robot_length.isnumeric(): + elif new_robot_length.isnumeric(): new_robot_length = float(new_robot_length) check = True else: From b4abdccee736334db46a26484ef387e02fe9fa82 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 6 Nov 2019 19:08:18 -0800 Subject: [PATCH 17/20] Make user input validation function. modified: ch_4_assign_Claire_Hays.py --- ch_4_assign_Claire_Hays.py | 66 +++++++++++++------------------------- 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/ch_4_assign_Claire_Hays.py b/ch_4_assign_Claire_Hays.py index 76683ef..9961f18 100644 --- a/ch_4_assign_Claire_Hays.py +++ b/ch_4_assign_Claire_Hays.py @@ -23,56 +23,36 @@ def compare_tot_dist(self): return "3D point is farther from the origin." else: return "2D point is farther from origin." +def check_if_int(a): + while True: + if a == 'quit': + return None + elif a.isdigit() == True: + a = int(a) + return a + else: + a = input("Please type value as an integer: ") -check = False -while check == False: - x = input("What is the x coordinate of the 2D point? ") - if x.isdigit(): - x = int(x) - check = True - else: - print("Please type value as an integer. ") - -check = False -while check == False: - y = input("What is the y coordinate of the 2D point? ") - if y.isdigit(): - y = int(y) - check = True - else: - print("Please type value as an integer. ") +x = input("What is the x coordinate of the 2D point? ") +x = check_if_int(x) + +y = input("What is the y coordinate of the 2D point? ") +y = check_if_int(y) point_2D = Point(x, y) dist_2D = point_2D.dist() print(dist_2D) -check = False -while check == False: - x3D = input("What is the x coordinate of the 3D point? ") - if x3D.isdigit(): - x3D = int(x3D) - check = True - else: - print("Please type value as an integer. ") - -check = False -while check == False: - y3D = input("What is the y coordinate of the 3D point? ") - if y3D.isdigit(): - y3D = int(y3D) - check = True - else: - print("Please type value as an integer. ") - -check = False -while check == False: - z = input("What is the z coordinate of the 3D point? ") - if z.isdigit(): - z = int(z) - check = True - else: - print("Please type value as an integer. ") + +x3D = input("What is the x coordinate of the 3D point? ") +x3D = check_if_int(x3D) + +y3D = input("What is the y coordinate of the 3D point? ") +y3D = check_if_int(y3D) + +z = input("What is the z coordinate of the 3D point? ") +z = check_if_int(z) point_3D = Point3D(x3D, y3D, z) dist_3D = point_3D.dist() From 22c2cb5c9970a3c449e47fb85c462f441f928bcd Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 6 Nov 2019 19:35:07 -0800 Subject: [PATCH 18/20] Fix bug with points being equidistant. --- ch_4_assign_Claire_Hays.py | 40 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/ch_4_assign_Claire_Hays.py b/ch_4_assign_Claire_Hays.py index 9961f18..721f5f3 100644 --- a/ch_4_assign_Claire_Hays.py +++ b/ch_4_assign_Claire_Hays.py @@ -1,28 +1,30 @@ import math class Point: - def __init__ (self, x, y): - self.x = x - self.y = y - def dist(self): - return math.sqrt(self.x**2 + self.y**2) + def __init__ (self, x, y): + self.x = x + self.y = y + def dist(self): + return math.sqrt(self.x**2 + self.y**2) class Point3D(Point): - def __init__ (self, x, y, z): - super().__init__ (x, y) - self.z = z - def dist(self): - return math.sqrt((super().dist())**2 + self.z**2) + def __init__ (self, x, y, z): + super().__init__ (x, y) + self.z = z + def dist(self): + return math.sqrt((super().dist())**2 + self.z**2) class Determine(Point3D): - def __init__(self, x2D, y2D, x, y, z): - super().__init__ (x, y, z) - self.x2D = x2D - self.y2D = y2D - def compare_tot_dist(self): - if super().dist() > Point(self.x2D, self.y2D).dist(): - return "3D point is farther from the origin." - else: - return "2D point is farther from origin." + def __init__(self, x2D, y2D, x, y, z): + super().__init__ (x, y, z) + self.x2D = x2D + self.y2D = y2D + def compare_tot_dist(self): + if super().dist() > Point(self.x2D, self.y2D).dist(): + return "3D point is farther from the origin." + elif super().dist() == Point(self.x2D, self.y2D).dist(): + return "Points are equidistant from origin." + else: + return "2D point is farther from origin." def check_if_int(a): while True: if a == 'quit': From 1a226ded42256c95d7541457688f1e92a88966ef Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Wed, 6 Nov 2019 20:09:01 -0800 Subject: [PATCH 19/20] Fix error in validations. --- ch_2_assign_Claire_Hays.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py index a5c327b..8322f5d 100644 --- a/ch_2_assign_Claire_Hays.py +++ b/ch_2_assign_Claire_Hays.py @@ -89,17 +89,33 @@ elif command == "remove a team": - remove_team_num = input("What team number would you like to remove? ") + check = False + while check == False: + remove_team_num = input("What team number would you like to remove? ") + if remove_team_num == 'quit': + check = True + elif remove_team_num.isnumeric(): + remove_team_num = float(remove_team_num) + check = True + else: + print("Please type your team number as a n integer") if remove_team_num == 'quit': continue - else: - remove_team_num = int(remove_team_num) teams.pop(remove_team_num) print("Team number successfully removed. To view new team list, type 'list all teams'") elif command == "search for a team": - team_search = input("What team would you like to search for? ") + check = False + while check == False: + team_search = input("What team would you like to search for? ") + if team_search == 'quit': + check = True + elif team_search.isnumeric(): + team_search = float(team_search) + check = True + else: + print("Please type your team number as a n integer") if team_search == 'quit': continue elif team_search.isnumeric() == True: @@ -124,11 +140,18 @@ if command == "view team's information": - view_team_num = input("What team's information would you like to view? ") + check = False + while check == False: + view_team_num = input("What team's information would you like to view? ") + if view_team_num == 'quit': + check = True + elif view_team_num.isnumeric(): + view_team_num = float(view_team_num) + check = True + else: + print("Please type your team number as a n integer") if view_team_num == 'quit': continue - else: - view_team_num = int(view_team_num) view_team_attribute = str(input("""What attribute would you like to view (Name, Programming Language, Width, Length, Camera Vision, Drivetrain Motors? """)) if view_team_attribute == 'quit': From b43e4c810a45e5ad6a903228f6e18d09eff7fb44 Mon Sep 17 00:00:00 2001 From: ClaireHays Date: Thu, 7 Nov 2019 17:00:34 -0800 Subject: [PATCH 20/20] Repair bug in search. --- ch_2_assign_Claire_Hays.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py index 8322f5d..87112f7 100644 --- a/ch_2_assign_Claire_Hays.py +++ b/ch_2_assign_Claire_Hays.py @@ -94,8 +94,8 @@ remove_team_num = input("What team number would you like to remove? ") if remove_team_num == 'quit': check = True - elif remove_team_num.isnumeric(): - remove_team_num = float(remove_team_num) + elif remove_team_num.isdigit(): + remove_team_num = int(remove_team_num) check = True else: print("Please type your team number as a n integer") @@ -106,19 +106,10 @@ elif command == "search for a team": - check = False - while check == False: - team_search = input("What team would you like to search for? ") - if team_search == 'quit': - check = True - elif team_search.isnumeric(): - team_search = float(team_search) - check = True - else: - print("Please type your team number as a n integer") + team_search = str(input("What team would you like to search for? ")) if team_search == 'quit': continue - elif team_search.isnumeric() == True: + elif team_search.isdigit() == True: team_get = teams.get(int(team_search)) if team_get == None: print("The team you searched for was not found in the database. ") @@ -145,8 +136,8 @@ view_team_num = input("What team's information would you like to view? ") if view_team_num == 'quit': check = True - elif view_team_num.isnumeric(): - view_team_num = float(view_team_num) + elif view_team_num.isdigit(): + view_team_num = int(view_team_num) check = True else: print("Please type your team number as a n integer")