From 56c01f6e4ae35a73652309e57d1a0990f2335192 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 11 Sep 2019 19:44:32 -0700 Subject: [PATCH 01/25] add hello world --- ch_1_lesson_Jackson_Anglin-Hill.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 ch_1_lesson_Jackson_Anglin-Hill.py diff --git a/ch_1_lesson_Jackson_Anglin-Hill.py b/ch_1_lesson_Jackson_Anglin-Hill.py new file mode 100644 index 0000000..8c854ae --- /dev/null +++ b/ch_1_lesson_Jackson_Anglin-Hill.py @@ -0,0 +1 @@ +print('Hello, world!') \ No newline at end of file From 5462d68a7bc6ae217106ffcb9e3e8a6a52f24fef Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Thu, 12 Sep 2019 20:46:36 -0700 Subject: [PATCH 02/25] Did homework/assignment 1 --- Homework_1.py | 6 +++++ ch_1_assign_Jackson_Anglin-Hill.py | 41 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Homework_1.py create mode 100644 ch_1_assign_Jackson_Anglin-Hill.py diff --git a/Homework_1.py b/Homework_1.py new file mode 100644 index 0000000..41dabe2 --- /dev/null +++ b/Homework_1.py @@ -0,0 +1,6 @@ +team = { + 1678: {"weight": 123, "color": "blue", "wheels": "green"} + 123: {"weight": 145, "color": "red", "wheels": "yellow"} + 9432: {"weight": 1678, "color": "green", "wheels": "blue"} +} +requested_team_number = input("Team Number: ") diff --git a/ch_1_assign_Jackson_Anglin-Hill.py b/ch_1_assign_Jackson_Anglin-Hill.py new file mode 100644 index 0000000..73f824f --- /dev/null +++ b/ch_1_assign_Jackson_Anglin-Hill.py @@ -0,0 +1,41 @@ +teams = { +'1': {'location' : 'Flanders, New Jersey, USA', +'rookie year' : 1999, +'competed in 2019 competitions': 'Yes', +'names of 2019 competitions': 'FIM District Center Line Event and FIM District Troy Event', +'location of 2019 competitions': 'Center Line, MI, USA and Troy, MI, USA', +'2019 season award': 'Imagery Award'}, + +'554': {'location' : 'Ft. Thomas, Kentucky, USA', +'rookie year' : '2001', +'competed in 2019 competitions': 'Yes', +'names of 2019 competitions': 'Miami Valley Regional', +'location of 2019 competitions': 'Dayton, OH 45435, USA', +'2019 season award': 'None'}, + +'253': {'location' : 'Millbrae, California, USA', +'rookie year': '1999', +'competed in 2019 competitions': 'Yes', +'names of 2019 competitions': 'San Francisco Regional, Monterey Bay Regional and Newton Division', +'location of 2019 competitions': 'San Francisco, CA, USA, Seaside, CA, USA and Houston, TX, USA', +'2019 season award': 'Team Spirit Award'}, + +'342': {'location' : 'North Charleston, South Carolina, USA', +'rookie year' : '2000', +'competed in 2019 competitions': 'Yes', +'names of 2019 competitions': 'Palmetto Regional and Rocket City Regional', +'location of 2019 competitions': 'Myrtle Beach, SC 29578, USA and Huntsville, AL 35801, USA', +'2019 season award': 'None'} , + +'16': {'location' : 'Mountain Home, Arkansas, USA', +'rookie year' : '1996', +'competed in 2019 competitions': 'Yes', +'names of 2019 competitions': 'Midwest Regional, Rocket City Regional and Darwin Division', +'location of 2019 competitions': 'Detroit, MI, USA and Huntsville, AL 35801, USA', +'2019 season award': 'Industrial Design Award, Regional Finalists and Excellence in Engineering Award' +} +} +print("You must enter options exactly as they are displayed. If they are entered incorrectly, you will not receive any information.") +team_number = input("Please enter team number. You can enter '1, 554, 253, 342, or 16': ") +team_attribute = input("Please enter team attribute. You can enter 'location, rookie year, competed in 2019 competitions, names of 2019 competitions, location of 2019 competitions, or 2019 season award': ") +print(teams[team_number][team_attribute]) \ No newline at end of file From fce6621ffd2eae418ba924d8f7b1a677b658710b Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 18 Sep 2019 18:59:17 -0700 Subject: [PATCH 03/25] Edit assignment --- ch_1_assign_Jackson_Anglin-Hill.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ch_1_assign_Jackson_Anglin-Hill.py b/ch_1_assign_Jackson_Anglin-Hill.py index 73f824f..77cb721 100644 --- a/ch_1_assign_Jackson_Anglin-Hill.py +++ b/ch_1_assign_Jackson_Anglin-Hill.py @@ -32,10 +32,9 @@ 'competed in 2019 competitions': 'Yes', 'names of 2019 competitions': 'Midwest Regional, Rocket City Regional and Darwin Division', 'location of 2019 competitions': 'Detroit, MI, USA and Huntsville, AL 35801, USA', -'2019 season award': 'Industrial Design Award, Regional Finalists and Excellence in Engineering Award' -} +'2019 season award': 'Industrial Design Award, Regional Finalists and Excellence in Engineering Award'} } print("You must enter options exactly as they are displayed. If they are entered incorrectly, you will not receive any information.") team_number = input("Please enter team number. You can enter '1, 554, 253, 342, or 16': ") team_attribute = input("Please enter team attribute. You can enter 'location, rookie year, competed in 2019 competitions, names of 2019 competitions, location of 2019 competitions, or 2019 season award': ") -print(teams[team_number][team_attribute]) \ No newline at end of file +print(teams[team_number][team_attribute]) \ No newline at end of file From 46cd23e57a6c05617660b7ee382f21abd8eb0aa2 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 25 Sep 2019 19:03:21 -0700 Subject: [PATCH 04/25] Edit assignment 1 again. --- ch_1_assign_Jackson_Anglin-Hill.py | 70 +++++++++++++++++------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/ch_1_assign_Jackson_Anglin-Hill.py b/ch_1_assign_Jackson_Anglin-Hill.py index 77cb721..ec7153e 100644 --- a/ch_1_assign_Jackson_Anglin-Hill.py +++ b/ch_1_assign_Jackson_Anglin-Hill.py @@ -1,38 +1,48 @@ teams = { -'1': {'location' : 'Flanders, New Jersey, USA', -'rookie year' : 1999, -'competed in 2019 competitions': 'Yes', -'names of 2019 competitions': 'FIM District Center Line Event and FIM District Troy Event', -'location of 2019 competitions': 'Center Line, MI, USA and Troy, MI, USA', -'2019 season award': 'Imagery Award'}, + '1': { + 'location' : 'Flanders, New Jersey, USA', + 'rookie year' : 1999, + 'competed in 2019 competitions': 'Yes', + 'names of 2019 competitions': 'FIM District Center Line Event and FIM District Troy Event', + 'location of 2019 competitions': 'Center Line, MI, USA and Troy, MI, USA', + '2019 season award': 'Imagery Award' + }, -'554': {'location' : 'Ft. Thomas, Kentucky, USA', -'rookie year' : '2001', -'competed in 2019 competitions': 'Yes', -'names of 2019 competitions': 'Miami Valley Regional', -'location of 2019 competitions': 'Dayton, OH 45435, USA', -'2019 season award': 'None'}, + '554': { + 'location' : 'Ft. Thomas, Kentucky, USA', + 'rookie year' : '2001', + 'competed in 2019 competitions': 'Yes', + 'names of 2019 competitions': 'Miami Valley Regional', + 'location of 2019 competitions': 'Dayton, OH 45435, USA', + '2019 season award': 'None' + }, -'253': {'location' : 'Millbrae, California, USA', -'rookie year': '1999', -'competed in 2019 competitions': 'Yes', -'names of 2019 competitions': 'San Francisco Regional, Monterey Bay Regional and Newton Division', -'location of 2019 competitions': 'San Francisco, CA, USA, Seaside, CA, USA and Houston, TX, USA', -'2019 season award': 'Team Spirit Award'}, + '253': { + 'location' : 'Millbrae, California, USA', + 'rookie year': '1999', + 'competed in 2019 competitions': 'Yes', + 'names of 2019 competitions': 'San Francisco Regional, Monterey Bay Regional and Newton Division', + 'location of 2019 competitions': 'San Francisco, CA, USA, Seaside, CA, USA and Houston, TX, USA', + '2019 season award': 'Team Spirit Award' + }, -'342': {'location' : 'North Charleston, South Carolina, USA', -'rookie year' : '2000', -'competed in 2019 competitions': 'Yes', -'names of 2019 competitions': 'Palmetto Regional and Rocket City Regional', -'location of 2019 competitions': 'Myrtle Beach, SC 29578, USA and Huntsville, AL 35801, USA', -'2019 season award': 'None'} , + '342': { + 'location' : 'North Charleston, South Carolina, USA', + 'rookie year' : '2000', + 'competed in 2019 competitions': 'Yes', + 'names of 2019 competitions': 'Palmetto Regional and Rocket City Regional', + 'location of 2019 competitions': 'Myrtle Beach, SC 29578, USA and Huntsville, AL 35801, USA', + '2019 season award': 'None' + }, -'16': {'location' : 'Mountain Home, Arkansas, USA', -'rookie year' : '1996', -'competed in 2019 competitions': 'Yes', -'names of 2019 competitions': 'Midwest Regional, Rocket City Regional and Darwin Division', -'location of 2019 competitions': 'Detroit, MI, USA and Huntsville, AL 35801, USA', -'2019 season award': 'Industrial Design Award, Regional Finalists and Excellence in Engineering Award'} + '16': { + 'location' : 'Mountain Home, Arkansas, USA', + 'rookie year' : '1996', + 'competed in 2019 competitions': 'Yes', + 'names of 2019 competitions': 'Midwest Regional, Rocket City Regional and Darwin Division', + 'location of 2019 competitions': 'Detroit, MI, USA and Huntsville, AL 35801, USA', + '2019 season award': 'Industrial Design Award, Regional Finalists and Excellence in Engineering Award' + } } print("You must enter options exactly as they are displayed. If they are entered incorrectly, you will not receive any information.") team_number = input("Please enter team number. You can enter '1, 554, 253, 342, or 16': ") From a9b5bd85b670832fe3e1c4d8f3d4e22fb311cfd9 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Thu, 26 Sep 2019 18:57:41 -0700 Subject: [PATCH 05/25] Edit Ch1 Assignment again --- ch_1_assign_Jackson_Anglin-Hill.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ch_1_assign_Jackson_Anglin-Hill.py b/ch_1_assign_Jackson_Anglin-Hill.py index ec7153e..41c9ad2 100644 --- a/ch_1_assign_Jackson_Anglin-Hill.py +++ b/ch_1_assign_Jackson_Anglin-Hill.py @@ -1,5 +1,5 @@ teams = { - '1': { + 1: { 'location' : 'Flanders, New Jersey, USA', 'rookie year' : 1999, 'competed in 2019 competitions': 'Yes', @@ -8,36 +8,36 @@ '2019 season award': 'Imagery Award' }, - '554': { + 554: { 'location' : 'Ft. Thomas, Kentucky, USA', - 'rookie year' : '2001', + 'rookie year' : 2001, 'competed in 2019 competitions': 'Yes', 'names of 2019 competitions': 'Miami Valley Regional', 'location of 2019 competitions': 'Dayton, OH 45435, USA', '2019 season award': 'None' }, - '253': { + 253: { 'location' : 'Millbrae, California, USA', - 'rookie year': '1999', + 'rookie year': 1999, 'competed in 2019 competitions': 'Yes', 'names of 2019 competitions': 'San Francisco Regional, Monterey Bay Regional and Newton Division', 'location of 2019 competitions': 'San Francisco, CA, USA, Seaside, CA, USA and Houston, TX, USA', '2019 season award': 'Team Spirit Award' }, - '342': { + 342: { 'location' : 'North Charleston, South Carolina, USA', - 'rookie year' : '2000', + 'rookie year' : 2000, 'competed in 2019 competitions': 'Yes', 'names of 2019 competitions': 'Palmetto Regional and Rocket City Regional', 'location of 2019 competitions': 'Myrtle Beach, SC 29578, USA and Huntsville, AL 35801, USA', '2019 season award': 'None' }, - '16': { + 16: { 'location' : 'Mountain Home, Arkansas, USA', - 'rookie year' : '1996', + 'rookie year' : 1996, 'competed in 2019 competitions': 'Yes', 'names of 2019 competitions': 'Midwest Regional, Rocket City Regional and Darwin Division', 'location of 2019 competitions': 'Detroit, MI, USA and Huntsville, AL 35801, USA', @@ -45,6 +45,6 @@ } } print("You must enter options exactly as they are displayed. If they are entered incorrectly, you will not receive any information.") -team_number = input("Please enter team number. You can enter '1, 554, 253, 342, or 16': ") +team_number = int(input("Please enter team number. You can enter '1, 554, 253, 342, or 16': ")) team_attribute = input("Please enter team attribute. You can enter 'location, rookie year, competed in 2019 competitions, names of 2019 competitions, location of 2019 competitions, or 2019 season award': ") print(teams[team_number][team_attribute]) \ No newline at end of file From 863c7ffa3b8ad970c82659c9bd766efa743d92f2 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 2 Oct 2019 20:01:05 -0700 Subject: [PATCH 06/25] Added Chapter 2 Assginment --- ch_2_assignment_Jackson_Anglin-Hill.py | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 ch_2_assignment_Jackson_Anglin-Hill.py diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py new file mode 100644 index 0000000..b432dd5 --- /dev/null +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -0,0 +1,80 @@ +on = True +#teams is a dictionary with teams numbers as the keys and their information as the definitions. +teams = {} +#team_names is a list containing the names of the teams. +team_names = [] +allowed_actions = [ + 'Add team', + 'Remove team', + 'View team information', + 'Modify team information', + 'Search for team', +] +while on: + print(teams.keys()) + print(allowed_actions) + request = input('What would you like to do? Please enter exactly as shown: ') + while request == 'Add team': + requested_team = input('Input team number: ') + requested_team_name = input('Input team name: ') + team_info = input('Enter team information: ') + teams[int(requested_team)] = team_info + team_names.append(requested_team_name) + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'Done' + + while request == 'Remove team': + print(teams.keys()) + print(team_names) + requested_team = int(input('Input team number: ')) + requested_team_name = str(input('Enter team name: ')) + if requested_team in teams: + teams.pop(requested_team) + team_names.remove(requested_team_name) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'Done' + + while request == 'View team information': + requested_team = int(input('Input team number: ')) + if requested_team in teams: + print(teams[requested_team]) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'Done' + + while request == 'Modify team information': + print(teams.keys()) + requested_team = int(input("What team's information would you like to edit? Enter the team number, not name: ")) + if requested_team in teams: + team_info = input(teams[requested_team] + 'Edit here. You will have to copy all the information shown above and make changes while typing, or untyped information will be lost: ') + teams.pop(requested_team) + teams[requested_team] = team_info + elif requested_team not in teams: + print('Team not found. Try another team or make sure you entered the team number correctly.') + uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'Done' + + while request == 'Search for team': + wanted_action = input("Would you like to search by team number or name? Enter 'number' or 'name': ") + if wanted_action == 'number': + requested_team = int(input("Which team would you like to confirm is in our database?: ")) + if requested_team in teams: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + else: + print('Team not found. Please search for another team.') + if wanted_action == 'name': + requested_team = input("Which team would you like to confirm is in our database?: ") + if requested_team in team_names: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + else: + print('Team not found. Please search for another team.') + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'Done' \ No newline at end of file From cf9bf06b1da0ca9efb3e5321382c853eb66aa934 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Thu, 3 Oct 2019 20:11:56 -0700 Subject: [PATCH 07/25] Edit assignment 2 --- ch_2_assignment_Jackson_Anglin-Hill.py | 81 +++++++++++++++++--------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index b432dd5..ee352e5 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -2,7 +2,6 @@ #teams is a dictionary with teams numbers as the keys and their information as the definitions. teams = {} #team_names is a list containing the names of the teams. -team_names = [] allowed_actions = [ 'Add team', 'Remove team', @@ -16,30 +15,40 @@ request = input('What would you like to do? Please enter exactly as shown: ') while request == 'Add team': requested_team = input('Input team number: ') - requested_team_name = input('Input team name: ') - team_info = input('Enter team information: ') - teams[int(requested_team)] = team_info - team_names.append(requested_team_name) + if requested_team in teams: + print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') + else: + name = input('What is the team name?: ') + program = input('What programming language do they use?: ') + width = input('What is the width of the robot?: ') + length = input('What is the length of the robot?: ') + camera = input('Do they have a camera system?: ') + drivetrain = input('How many drivetrain motors do they have?: ') + teams[requested_team] = {} + teams[requested_team]['Name'] = name + teams[requested_team]['Program'] = program + teams[requested_team]['Width'] = width + teams[requested_team]['Length'] = length + teams[requested_team]['Camera'] = camera + teams[requested_team]['Drivetrain#'] = drivetrain uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") +#Returns to main menu if uncontinue == 'No': request = 'Done' while request == 'Remove team': print(teams.keys()) - print(team_names) - requested_team = int(input('Input team number: ')) - requested_team_name = str(input('Enter team name: ')) + requested_team = input('Input team number: ') if requested_team in teams: teams.pop(requested_team) - team_names.remove(requested_team_name) else: print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' - + while request == 'View team information': - requested_team = int(input('Input team number: ')) + requested_team = input('Input team number: ') if requested_team in teams: print(teams[requested_team]) else: @@ -50,31 +59,45 @@ while request == 'Modify team information': print(teams.keys()) - requested_team = int(input("What team's information would you like to edit? Enter the team number, not name: ")) + requested_team = input("What team's information would you like to edit?: ") if requested_team in teams: - team_info = input(teams[requested_team] + 'Edit here. You will have to copy all the information shown above and make changes while typing, or untyped information will be lost: ') - teams.pop(requested_team) - teams[requested_team] = team_info + change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetrain#': ") + if change == 'Name': + name = input('What is the team name?: ') + teams[requested_team].pop('Name') + teams[requested_team]['Name'] = name + if change == 'Program': + program = input('What program is the team using?: ') + teams[requested_team].pop('Program') + teams[requested_team]['Program'] = program + if change == 'Width': + width = input('What width is the robot?: ') + teams[requested_team].pop('Width') + teams[requested_team]['Width'] = width + if change == 'Length': + length = input('What length is the robot?: ') + teams[requested_team].pop('Length') + teams[requested_team]['Length'] = length + if change == 'Camera': + camera = input('Does the robot have a camera system?: ') + teams[requested_team].pop('Camera') + teams[requested_team]['Camera'] = camera + if change == 'Drivetrain#': + drivetrain = input('How many drivetrains is the robot using?: ') + teams[requested_team].pop('Drivetrain#') + teams[requested_team]['Drivetrain#'] = drivetrain elif requested_team not in teams: - print('Team not found. Try another team or make sure you entered the team number correctly.') + print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' while request == 'Search for team': - wanted_action = input("Would you like to search by team number or name? Enter 'number' or 'name': ") - if wanted_action == 'number': - requested_team = int(input("Which team would you like to confirm is in our database?: ")) - if requested_team in teams: - print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - else: - print('Team not found. Please search for another team.') - if wanted_action == 'name': - requested_team = input("Which team would you like to confirm is in our database?: ") - if requested_team in team_names: - print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - else: - print('Team not found. Please search for another team.') + requested_team = input("Which team would you like to confirm is in our database?: ") + if requested_team in teams or requested_team in teams.values(): + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + else: + print('Team not found. Please search for another team.') uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' \ No newline at end of file From 2ce2391439eca5190585f72b816bb905410c1114 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Thu, 3 Oct 2019 20:31:55 -0700 Subject: [PATCH 08/25] Finished chapter 2 assignment --- ch_2_assignment_Jackson_Anglin-Hill.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index ee352e5..dcf37fe 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -94,10 +94,11 @@ while request == 'Search for team': requested_team = input("Which team would you like to confirm is in our database?: ") - if requested_team in teams or requested_team in teams.values(): + if requested_team in teams: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - else: - print('Team not found. Please search for another team.') + for team in teams.values(): + if team['Name'] == requested_team: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' \ No newline at end of file From 028c0ee8c3ce6d5b90d02d429674b1b3af6eba56 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Thu, 3 Oct 2019 20:42:42 -0700 Subject: [PATCH 09/25] Finished chapter 2 assignment --- ch_2_assignment_Jackson_Anglin-Hill.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index dcf37fe..9b8ddaa 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -93,12 +93,16 @@ request = 'Done' while request == 'Search for team': + good = 'bad' requested_team = input("Which team would you like to confirm is in our database?: ") if requested_team in teams: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") for team in teams.values(): if team['Name'] == requested_team: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + good = 'good' + if requested_team not in teams and good != 'good': + print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' \ No newline at end of file From 3c3b0189ef6911edc3bd92e1fcaabfecf3f7ee5d Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 16 Oct 2019 19:09:27 -0700 Subject: [PATCH 10/25] Turn in ch_3 assignment --- ch_3_assign_Jackson_Anglin-Hill.py | 122 +++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 ch_3_assign_Jackson_Anglin-Hill.py diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py new file mode 100644 index 0000000..5184091 --- /dev/null +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -0,0 +1,122 @@ +teams = {} +allowed_actions = [ + 'Add team', + 'Remove team', + 'View team information', + 'Modify team information', + 'Search for team', + ] +on = True +def mainMenu(): + print(allowed_actions) +def addTeam(): + requested_team = input('Input team number: ') + if requested_team in teams: + print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') + else: + location = input('What is the location of the team?: ') + rookie_year = input('What is their rookie year?: ') + competed_in_2019 = input('Did they compete in the 2019 competitions?: ') + competitions = input('If they did, what are the names of the competitions they participated in?: ') + locations_of_competitions = input('If they did, what are the locations of the competitions they participated in?: ') + awards_won = input('If they won any, what awards did they win?: ') + teams[requested_team] = {} + teams[requested_team]['Location'] = location + teams[requested_team]['Rookie Year'] = rookie_year + teams[requested_team]['Competed in 2019 Competitions'] = competed_in_2019 + teams[requested_team]['Competition Names'] = competitions + teams[requested_team]['Competition Locations'] = locations_of_competitions + teams[requested_team]['Awards Won'] = awards_won + +def removeTeam(): + print(teams.keys()) + requested_team = input('Input team number: ') + if requested_team in teams: + teams.pop(requested_team) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + +def viewTeam(): + print(teams.keys()) + requested_team = input('Input team number: ') + if requested_team in teams: + print(teams[requested_team]) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + +def modifyTeam(): + print(teams.keys()) + requested_team = input("What team's information would you like to edit?: ") + if requested_team in teams: + change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in 2019 Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") + if change == 'Location': + location = input('Where is the team located?: ') + teams[requested_team].pop('Location') + teams[requested_team]['Location'] = location + if change == 'Rookie Year': + rookie_year = input('What is their rookie year?: ') + teams[requested_team].pop('Rookie Year') + teams[requested_team]['Rookie Year'] = rookie_year + if change == 'Competed in 2019 Competitions': + competed_in_2019 = input('Did they compete in the 2019 Competitions?: ') + teams[requested_team].pop('Competed in 2019 Competitions') + teams[requested_team]['Competed in 2019 Competitions'] = competed_in_2019 + if change == 'Competition Names': + competitions = input('What are the names of the competitions they participated in?: ') + teams[requested_team].pop('Competition Names') + teams[requested_team]['Competition Names'] = competitions + if change == 'Competition Locations': + locations_of_competitions = input('Where were the competitions they participated in?: ') + teams[requested_team].pop('Competition Locations') + teams[requested_team]['Competition Locations'] = locations_of_competitions + if change == 'Awards Won': + awards_won = input('What awards did they win?: ') + teams[requested_team].pop('Awards Won') + teams[requested_team]['Awards Won'] = awards_won + elif requested_team not in teams: + print('Team not found. Try another team or make sure you entered the team number correctly.') + +def searchTeam(): + requested_team = input("Which team would you like to confirm is in our database?: ") + if requested_team in teams: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + if requested_team not in teams: + print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') +while on: + mainMenu() + request = input('What would you like to do? Please enter exactly as shown: ') + while request == 'Add team': + addTeam() + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'No' + else: + request = 'Add team' + while request == 'Remove team': + removeTeam() + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'No' + else: + request = 'Remove team' + while request == 'View team information': + viewTeam() + uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'No' + else: + request = 'View team information' + while request == 'Modify team information': + modifyTeam() + uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'No' + else: + request = 'Modify team information' + while request == 'Search for team': + searchTeam() + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") + if uncontinue == 'No': + request = 'No' + else: + request = 'Search for team' \ No newline at end of file From 256ebc250bdb6e4a3da707c6a214bc6d9a961bbd Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 16 Oct 2019 19:17:50 -0700 Subject: [PATCH 11/25] Finish chapter 3 assingment --- ch_3_assign_Jackson_Anglin-Hill.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 5184091..46714be 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -6,7 +6,7 @@ 'Modify team information', 'Search for team', ] -on = True +running = True def mainMenu(): print(allowed_actions) def addTeam(): @@ -82,7 +82,8 @@ def searchTeam(): print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") if requested_team not in teams: print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') -while on: + +while running: mainMenu() request = input('What would you like to do? Please enter exactly as shown: ') while request == 'Add team': From 160a528fe4bcf6374d391b0fc3023c836e4b1c65 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 16 Oct 2019 19:21:06 -0700 Subject: [PATCH 12/25] Finish chapter 3 assignment --- ch_3_assign_Jackson_Anglin-Hill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 46714be..e9e51fc 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -120,4 +120,4 @@ def searchTeam(): if uncontinue == 'No': request = 'No' else: - request = 'Search for team' \ No newline at end of file + request = 'Search for team' \ No newline at end of file From d67e8deac185402273fe89e5d34a9cb19fd84e29 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Thu, 24 Oct 2019 20:28:06 -0700 Subject: [PATCH 13/25] Finish chapter 4 assignment --- ch_4_assign_Jackson_Antlin-Hill.py | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 ch_4_assign_Jackson_Antlin-Hill.py diff --git a/ch_4_assign_Jackson_Antlin-Hill.py b/ch_4_assign_Jackson_Antlin-Hill.py new file mode 100644 index 0000000..c86637a --- /dev/null +++ b/ch_4_assign_Jackson_Antlin-Hill.py @@ -0,0 +1,66 @@ +import math +class Points: + def __init__ (self, x, y): + self.x = x + self.y = y + def Distance(self): + return float(math.sqrt((self.x ** 2) + (self.y ** 2))) + +class Points_3D(Points): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + def Distance_3D(self): + return float(math.sqrt((self.x ** 2) + (self.y ** 2) + (self.z ** 2))) +while 0 == 0: + activated = "On" + while activated == 'On': + validation_1_x = input('What is the x value of Point 1?: ') + validation_1_y = input('What is the y value of Point 1?: ') + validation_2_x = input('What is the x value of Point 2?: ') + validation_2_y = input('What is the y value of Point 2?: ') + validation_2_z = input('What is the z value of Point 2?: ') + try: + point_1_x = float(validation_1_x) + except: + print("Only intergers are allowed.") + activated = 'Off' + try: + point_1_y = float(validation_1_y) + except: + print("Only intergers are allowed.") + activated = 'Off' + try: + point_2_x = float(validation_2_x) + except: + print("Only intergers are allowed.") + activated = 'Off' + try: + point_2_y = float(validation_2_y) + except: + print("Only intergers are allowed.") + activated = 'Off' + try: + point_2_z = float(validation_2_z) + except: + print("Only intergers are allowed.") + activated = 'Off' + if activated == 'Off': + print('You entered something that was not an interger. Please try again using only numbers.') + else: + point_1 = Points(point_1_x, point_1_y) + point_2 = Points_3D(point_2_x, point_2_y, point_2_z) + point_2_xy = Points(point_2_x, point_2_y) + + if point_1.Distance() > point_2.Distance_3D(): + print('Point 1 is further from the origin than Point 2, with a distance of ' + str(point_1.Distance()) + '.') + elif point_2.Distance_3D() > point_1.Distance(): + print('Point 2 is further from the origin than Point 1, with a distance of ' + str(point_2.Distance_3D()) + '.') + elif point_1.Distance() == point_2.Distance_3D(): + print('The points are the same distance from the origin, with a distance of ' + str(point_1.Distance()) + '.') + if point_1.Distance() > point_2_xy.Distance(): + print('Point 1 is further from the origin on the xy axis than Point 2, with a distance of ' + str(point_1.Distance()) + '.') + elif point_2_xy.Distance() > point_1.Distance(): + print('Point 2 is further from the origin on the xy axis than Point 1, with a distance of ' + str(point_2_xy.Distance()) + '.') + elif point_1.Distance() == point_2_xy.Distance(): + print('The points are the same distance from the origin on the xy axis, with a distance of ' + str(point_1.Distance()) + '.') \ No newline at end of file From 331f3da7ccab4b5dfe93a2430e0f1aff7e5e5ffc Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 30 Oct 2019 19:23:44 -0700 Subject: [PATCH 14/25] Edit assignments --- ch_2_assignment_Jackson_Anglin-Hill.py | 35 +++++++++++++++++--------- ch_3_assign_Jackson_Anglin-Hill.py | 17 +++++++------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index 9b8ddaa..9b674f8 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -8,6 +8,7 @@ 'View team information', 'Modify team information', 'Search for team', + 'List all teams' ] while on: print(teams.keys()) @@ -35,6 +36,8 @@ #Returns to main menu if uncontinue == 'No': request = 'Done' + elif request == 'Yes': + request = 'Add team' while request == 'Remove team': print(teams.keys()) @@ -44,9 +47,10 @@ else: print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': + elif uncontinue == 'No': request = 'Done' - + elif request == 'Yes': + request = 'Remove team' while request == 'View team information': requested_team = input('Input team number: ') if requested_team in teams: @@ -54,9 +58,10 @@ else: print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': + elif uncontinue == 'No': request = 'Done' - + elif request == 'Yes': + request = 'View team information' while request == 'Modify team information': print(teams.keys()) requested_team = input("What team's information would you like to edit?: ") @@ -66,23 +71,23 @@ name = input('What is the team name?: ') teams[requested_team].pop('Name') teams[requested_team]['Name'] = name - if change == 'Program': + elif change == 'Program': program = input('What program is the team using?: ') teams[requested_team].pop('Program') teams[requested_team]['Program'] = program - if change == 'Width': + elif change == 'Width': width = input('What width is the robot?: ') teams[requested_team].pop('Width') teams[requested_team]['Width'] = width - if change == 'Length': + elif change == 'Length': length = input('What length is the robot?: ') teams[requested_team].pop('Length') teams[requested_team]['Length'] = length - if change == 'Camera': + elif change == 'Camera': camera = input('Does the robot have a camera system?: ') teams[requested_team].pop('Camera') teams[requested_team]['Camera'] = camera - if change == 'Drivetrain#': + elif change == 'Drivetrain#': drivetrain = input('How many drivetrains is the robot using?: ') teams[requested_team].pop('Drivetrain#') teams[requested_team]['Drivetrain#'] = drivetrain @@ -91,6 +96,8 @@ uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' + elif request == 'Yes': + request = 'Modify team information' while request == 'Search for team': good = 'bad' @@ -101,8 +108,12 @@ if team['Name'] == requested_team: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") good = 'good' - if requested_team not in teams and good != 'good': + elif requested_team not in teams and good != 'good': print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - request = 'Done' \ No newline at end of file + elif uncontinue == 'No': + request = 'Done' + elif request == 'Yes': + request = 'Search for team' + if request == 'List all teams': + print(teams) \ No newline at end of file diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index e9e51fc..014ea46 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -5,6 +5,7 @@ 'View team information', 'Modify team information', 'Search for team', + 'List all teams' ] running = True def mainMenu(): @@ -53,23 +54,23 @@ def modifyTeam(): location = input('Where is the team located?: ') teams[requested_team].pop('Location') teams[requested_team]['Location'] = location - if change == 'Rookie Year': + elif change == 'Rookie Year': rookie_year = input('What is their rookie year?: ') teams[requested_team].pop('Rookie Year') teams[requested_team]['Rookie Year'] = rookie_year - if change == 'Competed in 2019 Competitions': + elif change == 'Competed in 2019 Competitions': competed_in_2019 = input('Did they compete in the 2019 Competitions?: ') teams[requested_team].pop('Competed in 2019 Competitions') teams[requested_team]['Competed in 2019 Competitions'] = competed_in_2019 - if change == 'Competition Names': + elif change == 'Competition Names': competitions = input('What are the names of the competitions they participated in?: ') teams[requested_team].pop('Competition Names') teams[requested_team]['Competition Names'] = competitions - if change == 'Competition Locations': + elif change == 'Competition Locations': locations_of_competitions = input('Where were the competitions they participated in?: ') teams[requested_team].pop('Competition Locations') teams[requested_team]['Competition Locations'] = locations_of_competitions - if change == 'Awards Won': + elif change == 'Awards Won': awards_won = input('What awards did they win?: ') teams[requested_team].pop('Awards Won') teams[requested_team]['Awards Won'] = awards_won @@ -88,7 +89,7 @@ def searchTeam(): request = input('What would you like to do? Please enter exactly as shown: ') while request == 'Add team': addTeam() - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'No' else: @@ -120,4 +121,6 @@ def searchTeam(): if uncontinue == 'No': request = 'No' else: - request = 'Search for team' \ No newline at end of file + request = 'Search for team' + if request == 'List all teams': + print(teams) \ No newline at end of file From c3f192c46769d9d3875571dc12274735afc3345b Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 30 Oct 2019 20:10:57 -0700 Subject: [PATCH 15/25] Edit assignments --- ch_2_assignment_Jackson_Anglin-Hill.py | 38 ++++++++++++---------- ch_3_assign_Jackson_Anglin-Hill.py | 45 +++++++++++++++----------- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index 9b674f8..a443bc8 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -11,7 +11,6 @@ 'List all teams' ] while on: - print(teams.keys()) print(allowed_actions) request = input('What would you like to do? Please enter exactly as shown: ') while request == 'Add team': @@ -36,8 +35,11 @@ #Returns to main menu if uncontinue == 'No': request = 'Done' - elif request == 'Yes': + elif uncontinue == 'Yes': request = 'Add team' + else: + break + print('That is not a valid entry.') while request == 'Remove team': print(teams.keys()) @@ -47,7 +49,7 @@ else: print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - elif uncontinue == 'No': + if uncontinue == 'No': request = 'Done' elif request == 'Yes': request = 'Remove team' @@ -58,10 +60,13 @@ else: print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") - elif uncontinue == 'No': + if uncontinue == 'No': request = 'Done' - elif request == 'Yes': + elif uncontinue == 'Yes': request = 'View team information' + else: + break + print('That is not a valid entry.') while request == 'Modify team information': print(teams.keys()) requested_team = input("What team's information would you like to edit?: ") @@ -69,36 +74,32 @@ change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetrain#': ") if change == 'Name': name = input('What is the team name?: ') - teams[requested_team].pop('Name') teams[requested_team]['Name'] = name elif change == 'Program': program = input('What program is the team using?: ') - teams[requested_team].pop('Program') teams[requested_team]['Program'] = program elif change == 'Width': width = input('What width is the robot?: ') - teams[requested_team].pop('Width') teams[requested_team]['Width'] = width elif change == 'Length': length = input('What length is the robot?: ') - teams[requested_team].pop('Length') teams[requested_team]['Length'] = length elif change == 'Camera': camera = input('Does the robot have a camera system?: ') - teams[requested_team].pop('Camera') teams[requested_team]['Camera'] = camera elif change == 'Drivetrain#': drivetrain = input('How many drivetrains is the robot using?: ') - teams[requested_team].pop('Drivetrain#') teams[requested_team]['Drivetrain#'] = drivetrain elif requested_team not in teams: print('Team not found. Try another team or make sure you entered the team number correctly.') uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") if uncontinue == 'No': request = 'Done' - elif request == 'Yes': + elif uncontinue == 'Yes': request = 'Modify team information' - + else: + break + print('That is not a valid entry.') while request == 'Search for team': good = 'bad' requested_team = input("Which team would you like to confirm is in our database?: ") @@ -108,12 +109,15 @@ if team['Name'] == requested_team: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") good = 'good' - elif requested_team not in teams and good != 'good': + if requested_team not in teams and good != 'good': print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - elif uncontinue == 'No': + if uncontinue == 'No': request = 'Done' - elif request == 'Yes': + elif uncontinue == 'Yes': request = 'Search for team' + else: + break + print('That is not a valid entry.') if request == 'List all teams': - print(teams) \ No newline at end of file + print(teams.keys()) \ No newline at end of file diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 014ea46..2c48018 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -52,27 +52,21 @@ def modifyTeam(): change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in 2019 Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") if change == 'Location': location = input('Where is the team located?: ') - teams[requested_team].pop('Location') teams[requested_team]['Location'] = location elif change == 'Rookie Year': rookie_year = input('What is their rookie year?: ') - teams[requested_team].pop('Rookie Year') teams[requested_team]['Rookie Year'] = rookie_year elif change == 'Competed in 2019 Competitions': competed_in_2019 = input('Did they compete in the 2019 Competitions?: ') - teams[requested_team].pop('Competed in 2019 Competitions') teams[requested_team]['Competed in 2019 Competitions'] = competed_in_2019 elif change == 'Competition Names': competitions = input('What are the names of the competitions they participated in?: ') - teams[requested_team].pop('Competition Names') teams[requested_team]['Competition Names'] = competitions elif change == 'Competition Locations': locations_of_competitions = input('Where were the competitions they participated in?: ') - teams[requested_team].pop('Competition Locations') teams[requested_team]['Competition Locations'] = locations_of_competitions elif change == 'Awards Won': awards_won = input('What awards did they win?: ') - teams[requested_team].pop('Awards Won') teams[requested_team]['Awards Won'] = awards_won elif requested_team not in teams: print('Team not found. Try another team or make sure you entered the team number correctly.') @@ -89,38 +83,53 @@ def searchTeam(): request = input('What would you like to do? Please enter exactly as shown: ') while request == 'Add team': addTeam() - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") if uncontinue == 'No': - request = 'No' - else: + break + elif uncontinue == 'Yes': request = 'Add team' + else: + break + print('That is not a valid entry.') while request == 'Remove team': removeTeam() uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") if uncontinue == 'No': - request = 'No' - else: + break + elif uncontinue == 'Yes': request = 'Remove team' + else: + break + print('That is not a valid entry.') while request == 'View team information': viewTeam() uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") if uncontinue == 'No': - request = 'No' - else: + break + elif uncontinue == 'Yes': request = 'View team information' + else: + break + print('That is not a valid entry.') while request == 'Modify team information': modifyTeam() uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") if uncontinue == 'No': - request = 'No' - else: + break + elif uncontinue == 'Yes': request = 'Modify team information' + else: + break + print('That is not a valid entry.') while request == 'Search for team': searchTeam() uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") if uncontinue == 'No': - request = 'No' + break + elif uncontinue == 'Yes': + request = 'Search for team' else: - request = 'Search for team' + break + print('That is not a valid entry.') if request == 'List all teams': - print(teams) \ No newline at end of file + print(teams.keys()) \ No newline at end of file From 46c0bc3f24c410d88dacc87ec2e0582ad063334c Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 6 Nov 2019 20:06:31 -0800 Subject: [PATCH 16/25] Edit Chapter 2 Assignment --- ch_2_assignment_Jackson_Anglin-Hill.py | 305 ++++++++++++++++--------- 1 file changed, 201 insertions(+), 104 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index a443bc8..29cf2f1 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -2,122 +2,219 @@ #teams is a dictionary with teams numbers as the keys and their information as the definitions. teams = {} #team_names is a list containing the names of the teams. -allowed_actions = [ +allowed_actions_1 = [ 'Add team', 'Remove team', 'View team information', 'Modify team information', 'Search for team', 'List all teams' -] -while on: - print(allowed_actions) - request = input('What would you like to do? Please enter exactly as shown: ') - while request == 'Add team': - requested_team = input('Input team number: ') - if requested_team in teams: - print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') - else: - name = input('What is the team name?: ') - program = input('What programming language do they use?: ') - width = input('What is the width of the robot?: ') - length = input('What is the length of the robot?: ') - camera = input('Do they have a camera system?: ') - drivetrain = input('How many drivetrain motors do they have?: ') - teams[requested_team] = {} - teams[requested_team]['Name'] = name - teams[requested_team]['Program'] = program - teams[requested_team]['Width'] = width - teams[requested_team]['Length'] = length - teams[requested_team]['Camera'] = camera - teams[requested_team]['Drivetrain#'] = drivetrain - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") -#Returns to main menu - if uncontinue == 'No': - request = 'Done' - elif uncontinue == 'Yes': - request = 'Add team' - else: - break - print('That is not a valid entry.') + ] +#allowed_actions_1 is for display, allowed_actions_2 is used for input validation +allowed_actions_2 = [ + 'add team', + 'remove team', + 'view team information', + 'modify team information', + 'search for team', + 'list all teams' + ] - while request == 'Remove team': - print(teams.keys()) - requested_team = input('Input team number: ') - if requested_team in teams: - teams.pop(requested_team) - else: - print('Team not found. Try another team or make sure you entered the team number correctly.') - uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - request = 'Done' - elif request == 'Yes': - request = 'Remove team' - while request == 'View team information': - requested_team = input('Input team number: ') - if requested_team in teams: - print(teams[requested_team]) - else: - print('Team not found. Try another team or make sure you entered the team number correctly.') - uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - request = 'Done' - elif uncontinue == 'Yes': - request = 'View team information' - else: - break - print('That is not a valid entry.') - while request == 'Modify team information': - print(teams.keys()) - requested_team = input("What team's information would you like to edit?: ") - if requested_team in teams: - change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetrain#': ") - if change == 'Name': +while on: + print(allowed_actions_1) + request = input('What would you like to do?: ') + spacer = 'O' +#spacer is used because if break command is used, it cycles back through to where request is reset instead of request remaining as defined in later code. + while spacer == 'O': + try: + request = str(request.lower()) + except: + print('Please enter a command without numbers.') + spacer = 'back to main menu' + request = request.lower() + while request == 'add team': + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + except: + print("Enter the team number with no letters.") + request = 'add team' + break + if requested_team in teams: + print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') + else: name = input('What is the team name?: ') + program = input('What programming language do they use?: ') + width = input('What is the width of the robot?: ') + length = input('What is the length of the robot?: ') + camera = input('Do they have a camera system?: ') + drivetrain = input('How many drivetrain motors do they have?: ') + teams[requested_team] = {} teams[requested_team]['Name'] = name - elif change == 'Program': - program = input('What program is the team using?: ') teams[requested_team]['Program'] = program - elif change == 'Width': - width = input('What width is the robot?: ') teams[requested_team]['Width'] = width - elif change == 'Length': - length = input('What length is the robot?: ') teams[requested_team]['Length'] = length - elif change == 'Camera': - camera = input('Does the robot have a camera system?: ') teams[requested_team]['Camera'] = camera - elif change == 'Drivetrain#': - drivetrain = input('How many drivetrains is the robot using?: ') teams[requested_team]['Drivetrain#'] = drivetrain - elif requested_team not in teams: - print('Team not found. Try another team or make sure you entered the team number correctly.') - uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - request = 'Done' - elif uncontinue == 'Yes': - request = 'Modify team information' - else: - break - print('That is not a valid entry.') - while request == 'Search for team': - good = 'bad' - requested_team = input("Which team would you like to confirm is in our database?: ") - if requested_team in teams: - print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - for team in teams.values(): - if team['Name'] == requested_team: + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") +#Returns to main menu + while True: + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + spacer = 'go back to main' + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'add team' + else: + print('That is not a valid entry.') + spacer = 'go back to main' + break + while request == 'remove team': + print(teams.keys()) + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + except: + print("Enter the team number with no letters.") + request = 'remove team' + break + if requested_team in teams: + teams.pop(requested_team) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") + while True: + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + spacer = 'go back to main' + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'remove team' + else: + print('That is not a valid entry.') + spacer = 'go back to main' + break + while request == 'view team information': + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + except: + print("Enter the team number with no letters.") + request = 'view team information' + break + if requested_team in teams: + print(teams[requested_team]) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") + while True: + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + spacer = 'go back to main' + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'view team information' + else: + print('That is not a valid entry.') + spacer = 'go back to main' + break + while request == 'modify team information': + print(teams.keys()) + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + except: + print("Enter the team number with no letters.") + request = 'modify team information' + break + if requested_team in teams: + change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetraincount': ") + try: + change = str(change.lower()) + except: + print('Do not use numbers while entering the requested section') + request = 'modify team information' + break + if change == 'name': + name = input('What is the team name?: ') + teams[requested_team]['name'] = name + elif change == 'program': + program = input('What program is the team using?: ') + teams[requested_team]['program'] = program + elif change == 'width': + width = input('What width is the robot?: ') + teams[requested_team]['width'] = width + elif change == 'length': + length = input('What length is the robot?: ') + teams[requested_team]['length'] = length + elif change == 'camera': + camera = input('Does the robot have a camera system?: ') + teams[requested_team]['camera'] = camera + elif change == 'drivetraincount': + drivetrain = input('How many drivetrains is the robot using?: ') + teams[requested_team]['drivetraincount'] = drivetrain + elif requested_team not in teams: + print('Team not found. Try another team or make sure you entered the team number correctly.') + uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") + while True: + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + spacer = 'go back to main' + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'modify team information' + else: + print('That is not a valid entry.') + spacer = 'go back to main' + break + + while request == 'search for team': + good = 'bad' + requested_team = input("Which team would you like to confirm is in our database?: ") + if requested_team in teams: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - good = 'good' - if requested_team not in teams and good != 'good': - print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') - uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - request = 'Done' - elif uncontinue == 'Yes': - request = 'Search for team' - else: - break - print('That is not a valid entry.') - if request == 'List all teams': - print(teams.keys()) \ No newline at end of file + for team in teams.values(): + if team['Name'] == requested_team: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + good = 'good' + if requested_team not in teams and good != 'good': + print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") + while True: + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + spacer = 'go back to main' + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'search for team' + else: + print('That is not a valid entry.') + spacer = 'go back to main' + break + if request == 'list all teams': + print(teams.keys()) + spacer = 'go back to main' + request = 'o' + if request not in allowed_actions_2: + spacer = 'go back to main' + request = 'o' \ No newline at end of file From 0d8f892eabb5f1568981a25759df5b5b4af2aaf8 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Mon, 11 Nov 2019 20:59:46 -0800 Subject: [PATCH 17/25] Modify assignment 2 --- ch_2_assignment_Jackson_Anglin-Hill.py | 84 ++++++++++++++++++-------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index 29cf2f1..1055cb8 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -45,10 +45,28 @@ else: name = input('What is the team name?: ') program = input('What programming language do they use?: ') - width = input('What is the width of the robot?: ') - length = input('What is the length of the robot?: ') + while True: + width = input('What is the width of the robot in centimeters?: ') + try: + width = int(width) + break + except: + print("Please use numbers.") + while True: + length = input('What is the length of the robot in centimeters?: ') + try: + length = int(length) + break + except: + print("Please use numbers.") camera = input('Do they have a camera system?: ') - drivetrain = input('How many drivetrain motors do they have?: ') + while True: + drivetrain = input('How many drivetrain motors do they have?: ') + try: + drivetrain = int(drivetrain) + break + except: + print("Please use numbers.") teams[requested_team] = {} teams[requested_team]['Name'] = name teams[requested_team]['Program'] = program @@ -56,9 +74,8 @@ teams[requested_team]['Length'] = length teams[requested_team]['Camera'] = camera teams[requested_team]['Drivetrain#'] = drivetrain - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") -#Returns to main menu while True: + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") try: uncontinue = uncontinue.lower() break @@ -70,7 +87,7 @@ elif uncontinue.lower() == 'yes': request = 'add team' else: - print('That is not a valid entry.') + print('That is not a valid entry. You will be automatically sent back to the main menu.') spacer = 'go back to main' break while request == 'remove team': @@ -86,8 +103,8 @@ teams.pop(requested_team) else: print('Team not found. Try another team or make sure you entered the team number correctly.') - uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") while True: + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") try: uncontinue = uncontinue.lower() break @@ -99,7 +116,7 @@ elif uncontinue.lower() == 'yes': request = 'remove team' else: - print('That is not a valid entry.') + print('That is not a valid entry. You will be automatically sent back to the main menu.') spacer = 'go back to main' break while request == 'view team information': @@ -114,8 +131,8 @@ print(teams[requested_team]) else: print('Team not found. Try another team or make sure you entered the team number correctly.') - uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") while True: + uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") try: uncontinue = uncontinue.lower() break @@ -127,7 +144,7 @@ elif uncontinue.lower() == 'yes': request = 'view team information' else: - print('That is not a valid entry.') + print('That is not a valid entry. You will be automatically sent back to the main menu.') spacer = 'go back to main' break while request == 'modify team information': @@ -154,21 +171,39 @@ program = input('What program is the team using?: ') teams[requested_team]['program'] = program elif change == 'width': - width = input('What width is the robot?: ') + while True: + width = input('What width is the robot in centimeters?: ') + try: + width = int(width) + break + except: + print("Please use numbers.") teams[requested_team]['width'] = width elif change == 'length': - length = input('What length is the robot?: ') + while True: + length = input('What length is the robot in centimeters?: ') + try: + length = int(length) + break + except: + print("Please use numbers.") teams[requested_team]['length'] = length elif change == 'camera': camera = input('Does the robot have a camera system?: ') teams[requested_team]['camera'] = camera elif change == 'drivetraincount': - drivetrain = input('How many drivetrains is the robot using?: ') + while True: + drivetrain = input('How many drivetrains is the robot using?: ') + try: + drivetrain = int(drivetrain) + break + except: + print("Please use numbers.") teams[requested_team]['drivetraincount'] = drivetrain elif requested_team not in teams: print('Team not found. Try another team or make sure you entered the team number correctly.') - uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") while True: + uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") try: uncontinue = uncontinue.lower() break @@ -180,23 +215,24 @@ elif uncontinue.lower() == 'yes': request = 'modify team information' else: - print('That is not a valid entry.') + print('That is not a valid entry. You will be automatically sent back to the main menu.') spacer = 'go back to main' break while request == 'search for team': - good = 'bad' - requested_team = input("Which team would you like to confirm is in our database?: ") + while True: + requested_team = input("Which team would you like to confirm is in our database?: ") + try: + requested_team = int(requested_team) + break + except: + print("Please use numbers.") if requested_team in teams: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - for team in teams.values(): - if team['Name'] == requested_team: - print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - good = 'good' - if requested_team not in teams and good != 'good': + if requested_team not in teams: print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') - uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") while True: + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") try: uncontinue = uncontinue.lower() break @@ -208,7 +244,7 @@ elif uncontinue.lower() == 'yes': request = 'search for team' else: - print('That is not a valid entry.') + print('That is not a valid entry. You will be automatically sent back to the main menu.') spacer = 'go back to main' break if request == 'list all teams': From a63cd4873541c8551a3462e9e9ef5da76c5fd3b2 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Mon, 11 Nov 2019 22:51:13 -0800 Subject: [PATCH 18/25] Edit assignments 2 and 3 --- ch_2_assignment_Jackson_Anglin-Hill.py | 97 +++++---- ch_3_assign_Jackson_Anglin-Hill.py | 271 ++++++++++++++++++------- 2 files changed, 265 insertions(+), 103 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index 1055cb8..d91fd4b 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -27,19 +27,19 @@ #spacer is used because if break command is used, it cycles back through to where request is reset instead of request remaining as defined in later code. while spacer == 'O': try: - request = str(request.lower()) + request = request.lower() except: - print('Please enter a command without numbers.') - spacer = 'back to main menu' - request = request.lower() + print('Enter the command without numbers.') + break while request == 'add team': - requested_team = input('Input team number: ') - try: - requested_team = int(requested_team) - except: - print("Enter the team number with no letters.") - request = 'add team' - break + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + except: + print("Enter the team number with no letters.") + request = 'add team' + break if requested_team in teams: print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') else: @@ -59,7 +59,20 @@ break except: print("Please use numbers.") - camera = input('Do they have a camera system?: ') + while True: + camera = input('Do they have a camera system?: ') + try: + camera = camera.lower() + except: + print("Please enter 'Yes' or 'No'") + if camera == 'yes': + camera = True + break + elif camera == 'no': + camera == False + break + else: + print("Please enter 'Yes' or 'No'") while True: drivetrain = input('How many drivetrain motors do they have?: ') try: @@ -92,13 +105,13 @@ break while request == 'remove team': print(teams.keys()) - requested_team = input('Input team number: ') - try: - requested_team = int(requested_team) - except: - print("Enter the team number with no letters.") - request = 'remove team' - break + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter team number without letters.') if requested_team in teams: teams.pop(requested_team) else: @@ -120,13 +133,14 @@ spacer = 'go back to main' break while request == 'view team information': - requested_team = input('Input team number: ') - try: - requested_team = int(requested_team) - except: - print("Enter the team number with no letters.") - request = 'view team information' - break + while True: + try: + requested_team = int(requested_team) + break + except: + print("Enter the team number with no letters.") + request = 'view team information' + break if requested_team in teams: print(teams[requested_team]) else: @@ -149,13 +163,15 @@ break while request == 'modify team information': print(teams.keys()) - requested_team = input('Input team number: ') - try: - requested_team = int(requested_team) - except: - print("Enter the team number with no letters.") - request = 'modify team information' - break + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print("Enter the team number with no letters.") + request = 'modify team information' + break if requested_team in teams: change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetraincount': ") try: @@ -189,7 +205,20 @@ print("Please use numbers.") teams[requested_team]['length'] = length elif change == 'camera': - camera = input('Does the robot have a camera system?: ') + while True: + camera = input('Do they have a camera system?: ') + try: + camera = camera.lower() + except: + print("Please enter 'Yes' or 'No'") + if camera == 'yes': + camera = True + break + elif camera == 'no': + camera == False + break + else: + print("Please enter 'Yes' or 'No'") teams[requested_team]['camera'] = camera elif change == 'drivetraincount': while True: diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 2c48018..b68f123 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -7,17 +7,50 @@ 'Search for team', 'List all teams' ] +allowed_actions_2 = [ + 'add team', + 'remove team', + 'view team information', + 'modify team information', + 'search for team', + 'list all teams' + ] running = True def mainMenu(): print(allowed_actions) def addTeam(): - requested_team = input('Input team number: ') + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter the team number without letters.') if requested_team in teams: print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') else: location = input('What is the location of the team?: ') - rookie_year = input('What is their rookie year?: ') - competed_in_2019 = input('Did they compete in the 2019 competitions?: ') + while True: + rookie_year = input('What is their rookie year?: ') + try: + rookie_year = int(rookie_year) + break + except: + print('Enter rookie year without letters.') + while True: + competed_in_2019 = input('Did they compete in the 2019 competitions?: ') + try: + competed_in_2019 = competed_in_2019.lower() + except: + print("Please enter 'Yes' or 'No'") + if competed_in_2019 == 'yes': + competed_in_2019 = True + break + elif competed_in_2019 == 'no': + competed_in_2019 == False + break + else: + print("Please enter 'Yes' or 'No'") competitions = input('If they did, what are the names of the competitions they participated in?: ') locations_of_competitions = input('If they did, what are the locations of the competitions they participated in?: ') awards_won = input('If they won any, what awards did they win?: ') @@ -31,7 +64,13 @@ def addTeam(): def removeTeam(): print(teams.keys()) - requested_team = input('Input team number: ') + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter team number without letters.') if requested_team in teams: teams.pop(requested_team) else: @@ -39,7 +78,13 @@ def removeTeam(): def viewTeam(): print(teams.keys()) - requested_team = input('Input team number: ') + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter team number without letters.') if requested_team in teams: print(teams[requested_team]) else: @@ -47,32 +92,69 @@ def viewTeam(): def modifyTeam(): print(teams.keys()) - requested_team = input("What team's information would you like to edit?: ") + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter team number without letters.') if requested_team in teams: - change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in 2019 Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") - if change == 'Location': + while True: + change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") + try: + change = change.lower() + break + except: + print('Please enter the change without numbers.') + if change == 'location': location = input('Where is the team located?: ') teams[requested_team]['Location'] = location - elif change == 'Rookie Year': - rookie_year = input('What is their rookie year?: ') + elif change == 'rookie year': + while True: + rookie_year = input('What is their rookie year?: ') + try: + rookie_year = int(rookie_year) + break + except: + print('Enter rookie year without letters.') teams[requested_team]['Rookie Year'] = rookie_year - elif change == 'Competed in 2019 Competitions': - competed_in_2019 = input('Did they compete in the 2019 Competitions?: ') + elif change == 'competed in competitions': + while True: + competed_in_2019 = input('Did they compete in the 2019 competitions?: ') + try: + competed_in_2019 = competed_in_2019.lower() + except: + print("Please enter 'Yes' or 'No'") + if competed_in_2019 == 'yes': + competed_in_2019 = True + break + elif competed_in_2019 == 'no': + competed_in_2019 == False + break + else: + print("Please enter 'Yes' or 'No'") teams[requested_team]['Competed in 2019 Competitions'] = competed_in_2019 - elif change == 'Competition Names': + elif change == 'competition names': competitions = input('What are the names of the competitions they participated in?: ') teams[requested_team]['Competition Names'] = competitions - elif change == 'Competition Locations': + elif change == 'competition locations': locations_of_competitions = input('Where were the competitions they participated in?: ') teams[requested_team]['Competition Locations'] = locations_of_competitions - elif change == 'Awards Won': + elif change == 'awards won': awards_won = input('What awards did they win?: ') teams[requested_team]['Awards Won'] = awards_won elif requested_team not in teams: print('Team not found. Try another team or make sure you entered the team number correctly.') def searchTeam(): - requested_team = input("Which team would you like to confirm is in our database?: ") + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter team number without letters.') if requested_team in teams: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") if requested_team not in teams: @@ -80,56 +162,107 @@ def searchTeam(): while running: mainMenu() - request = input('What would you like to do? Please enter exactly as shown: ') - while request == 'Add team': - addTeam() - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - break - elif uncontinue == 'Yes': - request = 'Add team' - else: - break - print('That is not a valid entry.') - while request == 'Remove team': - removeTeam() - uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - break - elif uncontinue == 'Yes': - request = 'Remove team' - else: - break - print('That is not a valid entry.') - while request == 'View team information': - viewTeam() - uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") - if uncontinue == 'No': - break - elif uncontinue == 'Yes': - request = 'View team information' - else: - break - print('That is not a valid entry.') - while request == 'Modify team information': - modifyTeam() - uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") - if uncontinue == 'No': - break - elif uncontinue == 'Yes': - request = 'Modify team information' - else: - break - print('That is not a valid entry.') - while request == 'Search for team': - searchTeam() - uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - if uncontinue == 'No': - break - elif uncontinue == 'Yes': - request = 'Search for team' - else: - break - print('That is not a valid entry.') - if request == 'List all teams': - print(teams.keys()) \ No newline at end of file + request = input('What would you like to do?: ') + spacer = 'O' + while spacer == 'O': + while True: + try: + request = request.lower() + break + except: + print('Enter the command without numbers.') + while request == 'add team': + addTeam() + while True: + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + spacer = 'go back to main' + elif uncontinue.lower() == 'yes': + request = 'add team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + spacer = 'go back to main' + while request == 'remove team': + removeTeam() + while True: + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + spacer = 'go back to main' + elif uncontinue.lower() == 'yes': + request = 'remove team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + spacer = 'go back to main' + while request == 'view team information': + viewTeam() + while True: + uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + spacer = 'go back to main' + elif uncontinue.lower() == 'yes': + request = 'view team information' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + spacer = 'go back to main' + while request == 'modify team information': + modifyTeam() + while True: + uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + spacer = 'go back to main' + elif uncontinue.lower() == 'yes': + request = 'modify team information' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + spacer = 'go back to main' + while request == 'search for team': + searchTeam() + while True: + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + spacer = 'go back to main' + elif uncontinue.lower() == 'yes': + request = 'search for team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + spacer = 'go back to main' + if request == 'list all teams': + print(teams.keys()) + spacer = 'go back to main' + if request not in allowed_actions_2: + spacer = 'back to main' \ No newline at end of file From 2d03161bc5bd47e892c7ee381ba699897b8f7dff Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Tue, 12 Nov 2019 17:22:35 -0800 Subject: [PATCH 19/25] Modify assignments #2 and #3 --- ch_2_assignment_Jackson_Anglin-Hill.py | 425 ++++++++++++------------- ch_3_assign_Jackson_Anglin-Hill.py | 205 ++++++------ 2 files changed, 288 insertions(+), 342 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index d91fd4b..e703a6c 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -10,55 +10,178 @@ 'Search for team', 'List all teams' ] -#allowed_actions_1 is for display, allowed_actions_2 is used for input validation -allowed_actions_2 = [ - 'add team', - 'remove team', - 'view team information', - 'modify team information', - 'search for team', - 'list all teams' - ] while on: print(allowed_actions_1) request = input('What would you like to do?: ') - spacer = 'O' -#spacer is used because if break command is used, it cycles back through to where request is reset instead of request remaining as defined in later code. - while spacer == 'O': - try: - request = request.lower() - except: - print('Enter the command without numbers.') - break - while request == 'add team': + request = request.lower() + while request == 'add team': + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print("Enter the team number with no letters.") + request = 'add team' + if requested_team in teams: + print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') + else: + name = input('What is the team name?: ') + program = input('What programming language do they use?: ') + while True: + width = input('What is the width of the robot in centimeters?: ') + try: + width = int(width) + break + except: + print("Please use numbers.") + while True: + length = input('What is the length of the robot in centimeters?: ') + try: + length = int(length) + break + except: + print("Please use numbers.") while True: - requested_team = input('Input team number: ') + camera = input('Do they have a camera system?: ') try: - requested_team = int(requested_team) + camera = camera.lower() except: - print("Enter the team number with no letters.") - request = 'add team' + print("Please enter 'Yes' or 'No'") + if camera == 'yes': + camera = True + break + elif camera == 'no': + camera == False + break + else: + print("Please enter 'Yes' or 'No'") + while True: + drivetrain = input('How many drivetrain motors do they have?: ') + try: + drivetrain = int(drivetrain) break - if requested_team in teams: - print('This team is already in the system. Please add a different team, confirm you have entered the team number correctly, or edit the information already existing in this team.') - else: + except: + print("Please use numbers.") + teams[requested_team] = {} + teams[requested_team]['Name'] = name + teams[requested_team]['Program'] = program + teams[requested_team]['Width'] = width + teams[requested_team]['Length'] = length + teams[requested_team]['Camera'] = camera + teams[requested_team]['Drivetrain#'] = drivetrain + while True: + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'add team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + reqest = 'o' + while request == 'remove team': + print(teams.keys()) + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print('Enter team number without letters.') + if requested_team in teams: + teams.pop(requested_team) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + while True: + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'remove team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + while request == 'view team information': + requested_team = input('Input team number: ') + while True: + try: + requested_team = int(requested_team) + break + except: + print("Enter the team number with no letters.") + if requested_team in teams: + print(teams[requested_team]) + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + while True: + uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'view team information' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + while request == 'modify team information': + print(teams.keys()) + while True: + requested_team = input('Input team number: ') + try: + requested_team = int(requested_team) + break + except: + print("Enter the team number with no letters.") + request = 'modify team information' + break + if requested_team in teams: + change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetraincount': ") + try: + change = str(change.lower()) + except: + print('Do not use numbers while entering the requested section') + request = 'modify team information' + break + if change == 'name': name = input('What is the team name?: ') - program = input('What programming language do they use?: ') + teams[requested_team]['Name'] = name + elif change == 'program': + program = input('What program is the team using?: ') + teams[requested_team]['Program'] = program + elif change == 'Width': while True: - width = input('What is the width of the robot in centimeters?: ') + width = input('What width is the robot in centimeters?: ') try: width = int(width) break except: print("Please use numbers.") + teams[requested_team]['Width'] = width + elif change == 'length': while True: - length = input('What is the length of the robot in centimeters?: ') + length = input('What length is the robot in centimeters?: ') try: length = int(length) break except: print("Please use numbers.") + teams[requested_team]['Length'] = length + elif change == 'camera': while True: camera = input('Do they have a camera system?: ') try: @@ -73,213 +196,61 @@ break else: print("Please enter 'Yes' or 'No'") + teams[requested_team]['Camera'] = camera + elif change == 'drivetraincount': while True: - drivetrain = input('How many drivetrain motors do they have?: ') + drivetrain = input('How many drivetrains is the robot using?: ') try: drivetrain = int(drivetrain) break except: print("Please use numbers.") - teams[requested_team] = {} - teams[requested_team]['Name'] = name - teams[requested_team]['Program'] = program - teams[requested_team]['Width'] = width - teams[requested_team]['Length'] = length - teams[requested_team]['Camera'] = camera - teams[requested_team]['Drivetrain#'] = drivetrain - while True: - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - spacer = 'go back to main' - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'add team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - spacer = 'go back to main' + teams[requested_team]['Drivetraincount'] = drivetrain + else: + print('Team not found. Try another team or make sure you entered the team number correctly.') + while True: + uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() break - while request == 'remove team': - print(teams.keys()) - while True: - requested_team = input('Input team number: ') - try: - requested_team = int(requested_team) - break - except: - print('Enter team number without letters.') - if requested_team in teams: - teams.pop(requested_team) - else: - print('Team not found. Try another team or make sure you entered the team number correctly.') - while True: - uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - spacer = 'go back to main' - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'remove team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - spacer = 'go back to main' + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'modify team information' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + + while request == 'search for team': + while True: + requested_team = input("Which team would you like to confirm is in our database? If no response is given from your entry, the team is not in our database.: ") + try: + requested_team = int(requested_team) + if requested_team in teams: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") break - while request == 'view team information': - while True: - try: - requested_team = int(requested_team) - break - except: - print("Enter the team number with no letters.") - request = 'view team information' - break - if requested_team in teams: - print(teams[requested_team]) - else: - print('Team not found. Try another team or make sure you entered the team number correctly.') - while True: - uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - spacer = 'go back to main' - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'view team information' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - spacer = 'go back to main' + except: + requested_team.lower() + for team in teams.values(): + if team['Name'] == requested_team: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") break - while request == 'modify team information': - print(teams.keys()) - while True: - requested_team = input('Input team number: ') - try: - requested_team = int(requested_team) - break - except: - print("Enter the team number with no letters.") - request = 'modify team information' - break - if requested_team in teams: - change = input("What would you like to change for this team? Enter 'Name' 'Program' 'Width' 'Length' 'Camera' 'Drivetraincount': ") - try: - change = str(change.lower()) - except: - print('Do not use numbers while entering the requested section') - request = 'modify team information' - break - if change == 'name': - name = input('What is the team name?: ') - teams[requested_team]['name'] = name - elif change == 'program': - program = input('What program is the team using?: ') - teams[requested_team]['program'] = program - elif change == 'width': - while True: - width = input('What width is the robot in centimeters?: ') - try: - width = int(width) - break - except: - print("Please use numbers.") - teams[requested_team]['width'] = width - elif change == 'length': - while True: - length = input('What length is the robot in centimeters?: ') - try: - length = int(length) - break - except: - print("Please use numbers.") - teams[requested_team]['length'] = length - elif change == 'camera': - while True: - camera = input('Do they have a camera system?: ') - try: - camera = camera.lower() - except: - print("Please enter 'Yes' or 'No'") - if camera == 'yes': - camera = True - break - elif camera == 'no': - camera == False - break - else: - print("Please enter 'Yes' or 'No'") - teams[requested_team]['camera'] = camera - elif change == 'drivetraincount': - while True: - drivetrain = input('How many drivetrains is the robot using?: ') - try: - drivetrain = int(drivetrain) - break - except: - print("Please use numbers.") - teams[requested_team]['drivetraincount'] = drivetrain - elif requested_team not in teams: - print('Team not found. Try another team or make sure you entered the team number correctly.') - while True: - uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - spacer = 'go back to main' - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'modify team information' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - spacer = 'go back to main' + while True: + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() break - - while request == 'search for team': - while True: - requested_team = input("Which team would you like to confirm is in our database?: ") - try: - requested_team = int(requested_team) - break - except: - print("Please use numbers.") - if requested_team in teams: - print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - if requested_team not in teams: - print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') - while True: - uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - spacer = 'go back to main' - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'search for team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - spacer = 'go back to main' - break - if request == 'list all teams': - print(teams.keys()) - spacer = 'go back to main' + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'search for team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') request = 'o' - if request not in allowed_actions_2: - spacer = 'go back to main' - request = 'o' \ No newline at end of file + if request == 'list all teams': + print(teams.keys()) + request = 'o' \ No newline at end of file diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index b68f123..9710695 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -7,14 +7,7 @@ 'Search for team', 'List all teams' ] -allowed_actions_2 = [ - 'add team', - 'remove team', - 'view team information', - 'modify team information', - 'search for team', - 'list all teams' - ] + running = True def mainMenu(): print(allowed_actions) @@ -144,125 +137,107 @@ def modifyTeam(): elif change == 'awards won': awards_won = input('What awards did they win?: ') teams[requested_team]['Awards Won'] = awards_won - elif requested_team not in teams: + else: print('Team not found. Try another team or make sure you entered the team number correctly.') def searchTeam(): while True: - requested_team = input('Input team number: ') + requested_team = input("Which team would you like to confirm is in our database? If no response is given from your entry, the team is not in our database.: ") try: requested_team = int(requested_team) + if requested_team in teams: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") break except: - print('Enter team number without letters.') - if requested_team in teams: - print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") - if requested_team not in teams: - print('Requested team is not in our database. Make sure you entered it correctly or search for another team.') - + requested_team.lower() + for team in teams.values(): + if team['Name'] == requested_team: + print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") + break while running: mainMenu() request = input('What would you like to do?: ') - spacer = 'O' - while spacer == 'O': + request = request.lower() + while request == 'add team': + addTeam() while True: + uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") try: - request = request.lower() + uncontinue = uncontinue.lower() break except: - print('Enter the command without numbers.') - while request == 'add team': - addTeam() - while True: - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - request = 'o' - spacer = 'go back to main' - elif uncontinue.lower() == 'yes': - request = 'add team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - request = 'o' - spacer = 'go back to main' - while request == 'remove team': - removeTeam() - while True: - uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - request = 'o' - spacer = 'go back to main' - elif uncontinue.lower() == 'yes': - request = 'remove team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - request = 'o' - spacer = 'go back to main' - while request == 'view team information': - viewTeam() - while True: - uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - request = 'o' - spacer = 'go back to main' - elif uncontinue.lower() == 'yes': - request = 'view team information' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - request = 'o' - spacer = 'go back to main' - while request == 'modify team information': - modifyTeam() - while True: - uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - request = 'o' - spacer = 'go back to main' - elif uncontinue.lower() == 'yes': - request = 'modify team information' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - request = 'o' - spacer = 'go back to main' - while request == 'search for team': - searchTeam() - while True: - uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': - request = 'o' - spacer = 'go back to main' - elif uncontinue.lower() == 'yes': - request = 'search for team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') - request = 'o' - spacer = 'go back to main' - if request == 'list all teams': - print(teams.keys()) - spacer = 'go back to main' - if request not in allowed_actions_2: - spacer = 'back to main' \ No newline at end of file + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'add team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + while request == 'remove team': + removeTeam() + while True: + uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'remove team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + while request == 'view team information': + viewTeam() + while True: + uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'view team information' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + while request == 'modify team information': + modifyTeam() + while True: + uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'modify team information' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + while request == 'search for team': + searchTeam() + while True: + uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") + try: + uncontinue = uncontinue.lower() + break + except: + print("Enter 'Yes' or 'No' with no numbers.") + if uncontinue.lower() == 'no': + request = 'o' + elif uncontinue.lower() == 'yes': + request = 'search for team' + else: + print('That is not a valid entry. You will be automatically sent back to the main menu.') + request = 'o' + if request == 'list all teams': + print(teams.keys()) + request = 'o' \ No newline at end of file From 6b3fce055b6859a4391c7138904fb2f3bf0ce6c8 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Tue, 12 Nov 2019 18:06:22 -0800 Subject: [PATCH 20/25] Modify assignment 2 --- ch_2_assignment_Jackson_Anglin-Hill.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index e703a6c..fa8ea88 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -53,7 +53,7 @@ camera = True break elif camera == 'no': - camera == False + camera = False break else: print("Please enter 'Yes' or 'No'") @@ -113,8 +113,8 @@ print('That is not a valid entry. You will be automatically sent back to the main menu.') request = 'o' while request == 'view team information': - requested_team = input('Input team number: ') while True: + requested_team = input('Input team number: ') try: requested_team = int(requested_team) break @@ -192,7 +192,7 @@ camera = True break elif camera == 'no': - camera == False + camera = False break else: print("Please enter 'Yes' or 'No'") From 6fbdc3165771b18e48ff0752d550d40a38544bc2 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Tue, 12 Nov 2019 18:12:17 -0800 Subject: [PATCH 21/25] Edit assignment 2 --- ch_2_assignment_Jackson_Anglin-Hill.py | 37 +++++--------------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/ch_2_assignment_Jackson_Anglin-Hill.py b/ch_2_assignment_Jackson_Anglin-Hill.py index fa8ea88..2020fb4 100644 --- a/ch_2_assignment_Jackson_Anglin-Hill.py +++ b/ch_2_assignment_Jackson_Anglin-Hill.py @@ -45,10 +45,7 @@ print("Please use numbers.") while True: camera = input('Do they have a camera system?: ') - try: - camera = camera.lower() - except: - print("Please enter 'Yes' or 'No'") + camera = camera.lower() if camera == 'yes': camera = True break @@ -73,12 +70,8 @@ teams[requested_team]['Drivetrain#'] = drivetrain while True: uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") - if uncontinue.lower() == 'no': + uncontinue = uncontinue.lower() + if uncontinue == 'no': request = 'o' elif uncontinue.lower() == 'yes': request = 'add team' @@ -100,11 +93,7 @@ print('Team not found. Try another team or make sure you entered the team number correctly.') while True: uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -126,11 +115,7 @@ print('Team not found. Try another team or make sure you entered the team number correctly.') while True: uncontinue = input("Would you like to view another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -210,11 +195,7 @@ print('Team not found. Try another team or make sure you entered the team number correctly.') while True: uncontinue = input("Would you like to modify another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -239,11 +220,7 @@ break while True: uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': From ad11dd8db55f33c7a0b99ab65d90c05ccd90d1ff Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Tue, 12 Nov 2019 18:12:47 -0800 Subject: [PATCH 22/25] Edit assignment 3 --- ch_3_assign_Jackson_Anglin-Hill.py | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 9710695..bc5d9a6 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -162,11 +162,7 @@ def searchTeam(): addTeam() while True: uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -178,11 +174,7 @@ def searchTeam(): removeTeam() while True: uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -194,11 +186,7 @@ def searchTeam(): viewTeam() while True: uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -210,11 +198,7 @@ def searchTeam(): modifyTeam() while True: uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': @@ -226,11 +210,7 @@ def searchTeam(): searchTeam() while True: uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - try: - uncontinue = uncontinue.lower() - break - except: - print("Enter 'Yes' or 'No' with no numbers.") + uncontinue = uncontinue.lower() if uncontinue.lower() == 'no': request = 'o' elif uncontinue.lower() == 'yes': From 05cbe1453eefe6e16e2d7e7fe8650c2d11b3fe15 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Tue, 12 Nov 2019 18:31:51 -0800 Subject: [PATCH 23/25] Edit chapter 3 assign --- ch_3_assign_Jackson_Anglin-Hill.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index bc5d9a6..831e0d5 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -95,11 +95,7 @@ def modifyTeam(): if requested_team in teams: while True: change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") - try: - change = change.lower() - break - except: - print('Please enter the change without numbers.') + change = change.lower() if change == 'location': location = input('Where is the team located?: ') teams[requested_team]['Location'] = location From 5d89de4205c82032e0a6195b83fa7597a341b399 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Tue, 12 Nov 2019 20:03:11 -0800 Subject: [PATCH 24/25] Edit chapter 3 assignment --- ch_3_assign_Jackson_Anglin-Hill.py | 75 +++++++++++------------------- 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 831e0d5..05427d3 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -93,9 +93,8 @@ def modifyTeam(): except: print('Enter team number without letters.') if requested_team in teams: - while True: - change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") - change = change.lower() + change = input("What would you like to change for this team? Enter 'Location' 'Rookie Year' 'Competed in Competitions' 'Competition Names' 'Competition Locations' 'Awards Won': ") + change = change.lower() if change == 'location': location = input('Where is the team located?: ') teams[requested_team]['Location'] = location @@ -154,65 +153,45 @@ def searchTeam(): mainMenu() request = input('What would you like to do?: ') request = request.lower() + c = {'True' : 1} + def uncontinue(): + while True: + uncontinue = input("Would you like to repeat this action?: ") + if uncontinue.lower() == 'no': + print("You have chosen to return to the main menu.") + c['True'] = 0 + break + elif uncontinue.lower() == 'yes': + print("You have chosen to repeat this action.") + break + else: + print("You have entered an invalid command and will be returned to the main menu.") + c['True'] = 0 + break while request == 'add team': addTeam() - while True: - uncontinue = input("Would you like to add another team? Enter 'Yes' 'No': ") - uncontinue = uncontinue.lower() - if uncontinue.lower() == 'no': - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'add team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') + uncontinue() + if c['True'] == 0: request = 'o' while request == 'remove team': removeTeam() - while True: - uncontinue = input("Would you like to remove another team? Enter 'Yes' 'No': ") - uncontinue = uncontinue.lower() - if uncontinue.lower() == 'no': - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'remove team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') + uncontinue() + if c['True'] == 0: request = 'o' while request == 'view team information': viewTeam() - while True: - uncontinue = input("Would you like to view another team's information? Enter 'Yes' 'No': ") - uncontinue = uncontinue.lower() - if uncontinue.lower() == 'no': - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'view team information' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') + uncontinue() + if c['True'] == 0: request = 'o' while request == 'modify team information': modifyTeam() - while True: - uncontinue = input("Would you like to modify another team's information? Enter 'Yes' 'No': ") - uncontinue = uncontinue.lower() - if uncontinue.lower() == 'no': - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'modify team information' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') + uncontinue() + if c['True'] == 0: request = 'o' while request == 'search for team': searchTeam() - while True: - uncontinue = input("Would you like to search for another team? Enter 'Yes' 'No': ") - uncontinue = uncontinue.lower() - if uncontinue.lower() == 'no': - request = 'o' - elif uncontinue.lower() == 'yes': - request = 'search for team' - else: - print('That is not a valid entry. You will be automatically sent back to the main menu.') + uncontinue() + if c['True'] == 0: request = 'o' if request == 'list all teams': print(teams.keys()) From 31cadd257eacf10b0deba56ca06bbfac0a0b4771 Mon Sep 17 00:00:00 2001 From: Jackson Anglin-Hill Date: Wed, 13 Nov 2019 15:56:57 -0800 Subject: [PATCH 25/25] Edit chapter 3 assignment --- ch_3_assign_Jackson_Anglin-Hill.py | 37 +++++++++++------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/ch_3_assign_Jackson_Anglin-Hill.py b/ch_3_assign_Jackson_Anglin-Hill.py index 05427d3..98d53ce 100644 --- a/ch_3_assign_Jackson_Anglin-Hill.py +++ b/ch_3_assign_Jackson_Anglin-Hill.py @@ -149,49 +149,38 @@ def searchTeam(): if team['Name'] == requested_team: print("Requested team is in database. You can view its information using command 'View team information' and entering the team number again.") break -while running: - mainMenu() - request = input('What would you like to do?: ') - request = request.lower() - c = {'True' : 1} - def uncontinue(): +def uncontinue(): while True: uncontinue = input("Would you like to repeat this action?: ") if uncontinue.lower() == 'no': - print("You have chosen to return to the main menu.") - c['True'] = 0 - break + return True elif uncontinue.lower() == 'yes': - print("You have chosen to repeat this action.") - break + return False else: - print("You have entered an invalid command and will be returned to the main menu.") - c['True'] = 0 - break + return True +while running: + mainMenu() + request = input('What would you like to do?: ') + request = request.lower() while request == 'add team': addTeam() - uncontinue() - if c['True'] == 0: + if uncontinue(): request = 'o' while request == 'remove team': removeTeam() - uncontinue() - if c['True'] == 0: + if uncontinue(): request = 'o' while request == 'view team information': viewTeam() - uncontinue() - if c['True'] == 0: + if uncontinue(): request = 'o' while request == 'modify team information': modifyTeam() - uncontinue() - if c['True'] == 0: + if uncontinue(): request = 'o' while request == 'search for team': searchTeam() - uncontinue() - if c['True'] == 0: + if uncontinue(): request = 'o' if request == 'list all teams': print(teams.keys())