From f9ac57a72e0103933b5f4f286534a38c2eb61bc1 Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Wed, 11 Sep 2019 19:42:06 -0700 Subject: [PATCH 01/12] Add ch_-1_lesson_Harry_Jiang.py to the repositorty --- ch_1_lesson_Harry_Jiang.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 ch_1_lesson_Harry_Jiang.py diff --git a/ch_1_lesson_Harry_Jiang.py b/ch_1_lesson_Harry_Jiang.py new file mode 100644 index 0000000..8c854ae --- /dev/null +++ b/ch_1_lesson_Harry_Jiang.py @@ -0,0 +1 @@ +print('Hello, world!') \ No newline at end of file From b0cf679d4274749198766398dc70cd9fa35e6c8a Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Sun, 15 Sep 2019 14:20:42 -0700 Subject: [PATCH 02/12] I added my assignment to GitHub. :wq /Users/harryjiang/Desktop/ch_1_lesson_2_Harry_Jiang.py --- ch_1_lesson_2_Harry_Jiang.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 ch_1_lesson_2_Harry_Jiang.py diff --git a/ch_1_lesson_2_Harry_Jiang.py b/ch_1_lesson_2_Harry_Jiang.py new file mode 100644 index 0000000..62ab70a --- /dev/null +++ b/ch_1_lesson_2_Harry_Jiang.py @@ -0,0 +1,40 @@ +team_dict = { + + '1_dict' : {'1_location' : "Pontact, Michigan, USA", + '1_rookie_year' : 1997 , + '1_2019_competition' : True, + "1_2019_competition_names" : ['FIM Distric Center Line Event', 'FIM District Troy Event'], + '1_2019_competition_location' : ['Center Line, MI,USA', 'Troy, MI, USA'], + "1_2019_awards" : False }, + + + '20_dict' : {'20_location' : "Clifton Park, New Yourk, USA", + '20_rookie_year' : 1992 , + '20_2019_competition' : True, + "20_2019_competition_names" : ['New York Tech Valley Regional', 'Hudson Valley Regional', 'Curie Division'], + '20_2019_competition_location' : ['Troy, NY, 12180, USA', 'Suffern, NY, USA', 'Detroit, MI, USA'], + "20_2019_awards" : False }, + + '4_dict' : {'4_location' : "Van Nuys, California, USA", + '4_rookie_year' : 1997, + '4_2019_competition' : True, + "4_2019_competition_names" : ['Los Angeles North Regional', 'Los Angeles Regional', 'Wings Over Camarillo', 'Batlleship Blast'], + '4_2019_competition_location' : ['Valencia, CA, USA', 'Los Angeles, CA, USA', 'Camarillo, CA, USA', 'San Pedro, CA, USA'], + '4_2019_awards' : False }, + + '5_dict' : {'5_location' : "Melvindale, MI, USA", + '5_rookie_year' : 1998, + '5_2019_compeition' : True, + "5_2019_competition_names" : ['Big Bang!'], + "5_2019_competition_location" : ['Taylor, MI, USA'], + '5_2019_awards' : False }, + + '8_dict' : {'8_location' : 'Palo Alto, California, USA', + '8_rookie_year' : 1996, + '8_2019_compitetion' : True, + "8_competition_names" : ['Del Mar Regional presented by Qualcomm', 'Great Northern Regional', 'Silicon Valley Regional'], + "8_competition_location" : ['Del Mar, CA, USA', 'Grand Forks, ND, USA', 'San Jose, CA, USA'], + '8_2019_awards' : False }, + +} +print(team_dict['8_dict']['8_competition_names']) \ No newline at end of file From adadc8c42d9c629b967068e293327f3d263907ec Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Wed, 18 Sep 2019 18:56:50 -0700 Subject: [PATCH 03/12] I added my file ch_1_lesson_2_Harry_Jiang.py --- ch_1_lesson_2_Harry_Jiang.py | 2 +- ch_1_lesson_Harry_Jiang.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 ch_1_lesson_Harry_Jiang.py diff --git a/ch_1_lesson_2_Harry_Jiang.py b/ch_1_lesson_2_Harry_Jiang.py index 62ab70a..192233d 100644 --- a/ch_1_lesson_2_Harry_Jiang.py +++ b/ch_1_lesson_2_Harry_Jiang.py @@ -37,4 +37,4 @@ '8_2019_awards' : False }, } -print(team_dict['8_dict']['8_competition_names']) \ No newline at end of file +print(team_dict) diff --git a/ch_1_lesson_Harry_Jiang.py b/ch_1_lesson_Harry_Jiang.py deleted file mode 100644 index 8c854ae..0000000 --- a/ch_1_lesson_Harry_Jiang.py +++ /dev/null @@ -1 +0,0 @@ -print('Hello, world!') \ No newline at end of file From 3b551aa69310baf87e8a5b42b465a4e10cf93edb Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Wed, 18 Sep 2019 20:08:44 -0700 Subject: [PATCH 04/12] Formatted the hw1 file --- ch_1_lesson_2_Harry_Jiang.py | 49 ++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/ch_1_lesson_2_Harry_Jiang.py b/ch_1_lesson_2_Harry_Jiang.py index 192233d..4dd39f3 100644 --- a/ch_1_lesson_2_Harry_Jiang.py +++ b/ch_1_lesson_2_Harry_Jiang.py @@ -1,40 +1,45 @@ team_dict = { - '1_dict' : {'1_location' : "Pontact, Michigan, USA", - '1_rookie_year' : 1997 , - '1_2019_competition' : True, + "1_dict" : + {'1_location' : "Pontact, Michigan, USA", + "1_rookie_year" : 1997 , + "1_2019_competition" : True, "1_2019_competition_names" : ['FIM Distric Center Line Event', 'FIM District Troy Event'], - '1_2019_competition_location' : ['Center Line, MI,USA', 'Troy, MI, USA'], + "1_2019_competition_location" : ['Center Line, MI,USA', 'Troy, MI, USA'], "1_2019_awards" : False }, - '20_dict' : {'20_location' : "Clifton Park, New Yourk, USA", - '20_rookie_year' : 1992 , - '20_2019_competition' : True, + "20_dict" : + {'20_location' : "Clifton Park, New Yourk, USA", + "20_rookie_year" : 1992 , + "20_2019_competition" : True, "20_2019_competition_names" : ['New York Tech Valley Regional', 'Hudson Valley Regional', 'Curie Division'], - '20_2019_competition_location' : ['Troy, NY, 12180, USA', 'Suffern, NY, USA', 'Detroit, MI, USA'], + "20_2019_competition_location" : ['Troy, NY, 12180, USA', 'Suffern, NY, USA', 'Detroit, MI, USA'], "20_2019_awards" : False }, - '4_dict' : {'4_location' : "Van Nuys, California, USA", - '4_rookie_year' : 1997, - '4_2019_competition' : True, + "4_dict" : + {'4_location' : "Van Nuys, California, USA", + "4_rookie_year" : 1997, + "4_2019_competition" : True, "4_2019_competition_names" : ['Los Angeles North Regional', 'Los Angeles Regional', 'Wings Over Camarillo', 'Batlleship Blast'], - '4_2019_competition_location' : ['Valencia, CA, USA', 'Los Angeles, CA, USA', 'Camarillo, CA, USA', 'San Pedro, CA, USA'], - '4_2019_awards' : False }, + "4_2019_competition_location" : ['Valencia, CA, USA', 'Los Angeles, CA, USA', 'Camarillo, CA, USA', 'San Pedro, CA, USA'], + "4_2019_awards" : False }, - '5_dict' : {'5_location' : "Melvindale, MI, USA", - '5_rookie_year' : 1998, - '5_2019_compeition' : True, + "5_dict" : + {'5_location' : "Melvindale, MI, USA", + "5_rookie_year" : 1998, + "5_2019_compeition" : True, "5_2019_competition_names" : ['Big Bang!'], "5_2019_competition_location" : ['Taylor, MI, USA'], - '5_2019_awards' : False }, + "5_2019_awards" : False }, - '8_dict' : {'8_location' : 'Palo Alto, California, USA', - '8_rookie_year' : 1996, - '8_2019_compitetion' : True, + "8_dict" : + {'8_location' : 'Palo Alto, California, USA', + "8_rookie_year" : 1996, + "8_2019_compitetion" : True, "8_competition_names" : ['Del Mar Regional presented by Qualcomm', 'Great Northern Regional', 'Silicon Valley Regional'], "8_competition_location" : ['Del Mar, CA, USA', 'Grand Forks, ND, USA', 'San Jose, CA, USA'], - '8_2019_awards' : False }, + "8_2019_awards" : False }, } -print(team_dict) +print(team_dict["8_dict"]) \ No newline at end of file From e91e9a5218c39caef17946ef1bb10faf6a693eb6 Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Wed, 25 Sep 2019 20:01:13 -0700 Subject: [PATCH 05/12] changed formatting and added user input --- ch_1_lesson_2_Harry_Jiang.py | 87 +++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/ch_1_lesson_2_Harry_Jiang.py b/ch_1_lesson_2_Harry_Jiang.py index 4dd39f3..9606e17 100644 --- a/ch_1_lesson_2_Harry_Jiang.py +++ b/ch_1_lesson_2_Harry_Jiang.py @@ -1,45 +1,50 @@ team_dict = { - "1_dict" : - {'1_location' : "Pontact, Michigan, USA", - "1_rookie_year" : 1997 , - "1_2019_competition" : True, - "1_2019_competition_names" : ['FIM Distric Center Line Event', 'FIM District Troy Event'], - "1_2019_competition_location" : ['Center Line, MI,USA', 'Troy, MI, USA'], - "1_2019_awards" : False }, - - - "20_dict" : - {'20_location' : "Clifton Park, New Yourk, USA", - "20_rookie_year" : 1992 , - "20_2019_competition" : True, - "20_2019_competition_names" : ['New York Tech Valley Regional', 'Hudson Valley Regional', 'Curie Division'], - "20_2019_competition_location" : ['Troy, NY, 12180, USA', 'Suffern, NY, USA', 'Detroit, MI, USA'], - "20_2019_awards" : False }, - - "4_dict" : - {'4_location' : "Van Nuys, California, USA", - "4_rookie_year" : 1997, - "4_2019_competition" : True, - "4_2019_competition_names" : ['Los Angeles North Regional', 'Los Angeles Regional', 'Wings Over Camarillo', 'Batlleship Blast'], - "4_2019_competition_location" : ['Valencia, CA, USA', 'Los Angeles, CA, USA', 'Camarillo, CA, USA', 'San Pedro, CA, USA'], - "4_2019_awards" : False }, - - "5_dict" : - {'5_location' : "Melvindale, MI, USA", - "5_rookie_year" : 1998, - "5_2019_compeition" : True, - "5_2019_competition_names" : ['Big Bang!'], - "5_2019_competition_location" : ['Taylor, MI, USA'], - "5_2019_awards" : False }, - - "8_dict" : - {'8_location' : 'Palo Alto, California, USA', - "8_rookie_year" : 1996, - "8_2019_compitetion" : True, - "8_competition_names" : ['Del Mar Regional presented by Qualcomm', 'Great Northern Regional', 'Silicon Valley Regional'], - "8_competition_location" : ['Del Mar, CA, USA', 'Grand Forks, ND, USA', 'San Jose, CA, USA'], - "8_2019_awards" : False }, + 1 :{ + 'location' : "Pontact, Michigan, USA", + "rookie_year" : 1997 , + "2019_competition" : True, + "2019_competition_names" : ['FIM Distric Center Line Event', 'FIM District Troy Event'], + "2019_competition_location" : ['Center Line, MI,USA', 'Troy, MI, USA'], + "2019_awards" : False }, + + + 20 :{ + 'location' : "Clifton Park, New Yourk, USA", + "rookie_year" : 1992 , + "2019_competition" : True, + "2019_competition_names" : ['New York Tech Valley Regional', 'Hudson Valley Regional', 'Curie Division'], + "2019_competition_location" : ['Troy, NY, 12180, USA', 'Suffern, NY, USA', 'Detroit, MI, USA'], + "2019_awards" : False }, + + 4 :{ + 'location' : "Van Nuys, California, USA", + "rookie_year" : 1997, + "2019_competition" : True, + "2019_competition_names" : ['Los Angeles North Regional', 'Los Angeles Regional', 'Wings Over Camarillo', 'Batlleship Blast'], + "2019_competition_location" : ['Valencia, CA, USA', 'Los Angeles, CA, USA', 'Camarillo, CA, USA', 'San Pedro, CA, USA'], + "2019_awards" : False }, + + 5 :{ + 'location' : "Melvindale, MI, USA", + "rookie_year" : 1998, + "2019_competition" : True, + "2019_competition_names" : ['Big Bang!'], + "2019_competition_location" : ['Taylor, MI, USA'], + "2019_awards" : False }, + + 8 :{ + 'location' : 'Palo Alto, California, USA', + "rookie_year" : 1996, + "2019_compitition" : True, + "2019_competition_names" : ['Del Mar Regional presented by Qualcomm', 'Great Northern Regional', 'Silicon Valley Regional'], + "2019_competition_location" : ['Del Mar, CA, USA', 'Grand Forks, ND, USA', 'San Jose, CA, USA'], + "2019_awards" : False }, } -print(team_dict["8_dict"]) \ No newline at end of file +print("Search a team") +team_dictionary = input("what team numbe: ") +print("What field(location, rookie_year, 2019_competition, 2019_competition_names, 2019_competition_location, 2019_award") +team_field = input("what field: ") + +print(team_dict[int(team_dictionary)][team_field]) \ No newline at end of file From 49bdefad7a4d01e8873dfe368b25eb76652514ec Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Wed, 25 Sep 2019 20:04:12 -0700 Subject: [PATCH 06/12] forgot to save new one --- ch_1_lesson_2_Harry_Jiang.py | 62 +++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/ch_1_lesson_2_Harry_Jiang.py b/ch_1_lesson_2_Harry_Jiang.py index 9606e17..7c5a0aa 100644 --- a/ch_1_lesson_2_Harry_Jiang.py +++ b/ch_1_lesson_2_Harry_Jiang.py @@ -1,29 +1,48 @@ team_dict = { - - 1 :{ + 1: { 'location' : "Pontact, Michigan, USA", "rookie_year" : 1997 , "2019_competition" : True, - "2019_competition_names" : ['FIM Distric Center Line Event', 'FIM District Troy Event'], - "2019_competition_location" : ['Center Line, MI,USA', 'Troy, MI, USA'], - "2019_awards" : False }, + "2019_competition_names" : [ + 'FIM Distric Center Line Event', + 'FIM District Troy Event' + ], + "2019_competition_location" : [ + 'Center Line, MI,USA', + 'Troy, MI, USA'], + "2019_awards" : False + }, - 20 :{ + 20: { 'location' : "Clifton Park, New Yourk, USA", "rookie_year" : 1992 , "2019_competition" : True, - "2019_competition_names" : ['New York Tech Valley Regional', 'Hudson Valley Regional', 'Curie Division'], - "2019_competition_location" : ['Troy, NY, 12180, USA', 'Suffern, NY, USA', 'Detroit, MI, USA'], - "2019_awards" : False }, + "2019_competition_names" : [ + 'New York Tech Valley Regional', + 'Hudson Valley Regional', + 'Curie Division'], + "2019_competition_location" : ['Troy, NY, 12180, USA', + 'Suffern, NY, USA', + 'Detroit, MI, USA'], + "2019_awards" : False + }, 4 :{ 'location' : "Van Nuys, California, USA", "rookie_year" : 1997, "2019_competition" : True, - "2019_competition_names" : ['Los Angeles North Regional', 'Los Angeles Regional', 'Wings Over Camarillo', 'Batlleship Blast'], - "2019_competition_location" : ['Valencia, CA, USA', 'Los Angeles, CA, USA', 'Camarillo, CA, USA', 'San Pedro, CA, USA'], - "2019_awards" : False }, + "2019_competition_names" : [ + 'Los Angeles North Regional', + 'Los Angeles Regional', 'Wings Over Camarillo', + 'Batlleship Blast'], + "2019_competition_location" : [ + 'Valencia, CA, USA', + 'Los Angeles, CA, USA', + 'Camarillo, CA, USA', + 'San Pedro, CA, USA'], + "2019_awards" : False + }, 5 :{ 'location' : "Melvindale, MI, USA", @@ -31,20 +50,27 @@ "2019_competition" : True, "2019_competition_names" : ['Big Bang!'], "2019_competition_location" : ['Taylor, MI, USA'], - "2019_awards" : False }, + "2019_awards" : False + }, 8 :{ 'location' : 'Palo Alto, California, USA', "rookie_year" : 1996, "2019_compitition" : True, - "2019_competition_names" : ['Del Mar Regional presented by Qualcomm', 'Great Northern Regional', 'Silicon Valley Regional'], - "2019_competition_location" : ['Del Mar, CA, USA', 'Grand Forks, ND, USA', 'San Jose, CA, USA'], - "2019_awards" : False }, + "2019_competition_names" : [ + 'Del Mar Regional presented by Qualcomm', + 'Great Northern Regional', + 'Silicon Valley Regional'], + "2019_competition_location" : [ + 'Del Mar, CA, USA', + 'Grand Forks, ND, USA', + 'San Jose, CA, USA'], + "2019_awards" : False + }, } print("Search a team") -team_dictionary = input("what team numbe: ") +team_dictionary = input("what team number: ") print("What field(location, rookie_year, 2019_competition, 2019_competition_names, 2019_competition_location, 2019_award") team_field = input("what field: ") - print(team_dict[int(team_dictionary)][team_field]) \ No newline at end of file From cc05a37fc77f6335c8ea0dcfe55e6c8cf0b45730 Mon Sep 17 00:00:00 2001 From: Harry Jiang Date: Sun, 29 Sep 2019 15:35:29 -0700 Subject: [PATCH 07/12] initial commit for assignment 2 --- ch_2_assign_Harry_Jiang.py | 93 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 ch_2_assign_Harry_Jiang.py diff --git a/ch_2_assign_Harry_Jiang.py b/ch_2_assign_Harry_Jiang.py new file mode 100644 index 0000000..e89121e --- /dev/null +++ b/ch_2_assign_Harry_Jiang.py @@ -0,0 +1,93 @@ +teams = {'teddy': {'number': '7', 'programming_language': '5', 'width': '5', 'length': '5', 'vision_system': 'yes', 'number_of_drivetrain_motors': '3'}, 'emily': {'number': '4', 'programming_language': 'c++', 'width': '3', 'length': '5', 'vision_system': 'no', 'number_of_drivetrain_motors': '9'}} +command = '' +while command != 'quit': + command = input ("What is your command(add a team, update a team, search a team, delete a team, list all teams, quit)") + #print(command); + if command == 'add a team' : + team_name = input ("What is team name? ") + print(team_name) + # Number, name, programming language, width, length, has camera vision system, number of drivetrain motors + number = input('number:') + if not number.isnumeric(): + print("your input for team number: "+ number + " is invalid") + else: + programming_language = input('progamming language:') + if value.lower() not in ['java', 'python', 'c++']: + print("input is invalid") + isInputValid = False + else: + width = input('width:') + if not width.isnumeric(): + print("your input for width: "+ width +" is invalid") + else: + length = input('length:') + if not length.isnumeic(): + print("your input for length: "+ length +" is invalid") + else: + vision_system = input('has a camera vision system:') + if vision_system != 'yes' or vision_system != 'no': + print("your input for vision system: "+ vision_system +" is invalid") + else: + number_of_drivetrain_motors = input('number of drivetrain motors:') + team_info = {} + team_info.update(number = number) + team_info.update(programming_language = programming_language) + team_info.update(width = width) + team_info.update(length = length) + team_info.update(vision_system = vision_system) + team_info.update(number_of_drivetrain_motors = number_of_drivetrain_motors) + #print(team_info) + teams[team_name] = team_info + print('team ' + team_name + ' has created successfully.') + print(teams[team_name]) + if command == 'update a team': + print('update a team') + team_name = input('What team needs an update? ') + print(teams[team_name]) + if team_name in teams.keys(): + print("number, programming_language, width, length, vision_system, number_of_drivetrain_motors") + field = input('What field needs and update: ') + value = input('value: ') + isInputValid = True + if field in ['number','width', 'length', 'number_of_drivetrain_motors']: + if not value.isnumeric(): + print('input is not valid') + isInputValid = False + elif field == "vision_system": + if value.lower() != 'yes' and value.lower() !='no': + print("input is invalid") + isInputValid = False + elif field == "programming_language": + if value.lower() not in ['java', 'python', 'c++']: + print("input is invalid") + isInputValid = False + else: + print("field you want to update is invalid") + isInputValid = False + + + if isInputValid: + teams[team_name][field] = value + print("team updated successfully") + print(teams[team_name]) + + + else: + print('team does not exist') + if command == 'search a team': + team_name = input('What team? ') + if team_name in teams.keys(): + print(teams[team_name]) + else: + print('team does not exist') + if command == 'delete a team': + team_name = input('delete which team? ') + if team_name in teams.keys(): + print(teams.keys()) + teams.pop(team_name) + print(teams.keys()) + else: + print('team ' + team_name +' does not exist') + if command == 'list all teams': + print(teams) +print('end') \ No newline at end of file From b91f108360d0e204b950dd61695d2f597be29ce8 Mon Sep 17 00:00:00 2001 From: adamhwu Date: Thu, 3 Oct 2019 21:53:37 -0700 Subject: [PATCH 08/12] allowed user search with team number --- ch_2_assign_Harry_Jiang.py | 191 ++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 85 deletions(-) diff --git a/ch_2_assign_Harry_Jiang.py b/ch_2_assign_Harry_Jiang.py index e89121e..08fe4ce 100644 --- a/ch_2_assign_Harry_Jiang.py +++ b/ch_2_assign_Harry_Jiang.py @@ -1,93 +1,114 @@ teams = {'teddy': {'number': '7', 'programming_language': '5', 'width': '5', 'length': '5', 'vision_system': 'yes', 'number_of_drivetrain_motors': '3'}, 'emily': {'number': '4', 'programming_language': 'c++', 'width': '3', 'length': '5', 'vision_system': 'no', 'number_of_drivetrain_motors': '9'}} command = '' while command != 'quit': - command = input ("What is your command(add a team, update a team, search a team, delete a team, list all teams, quit)") - #print(command); - if command == 'add a team' : - team_name = input ("What is team name? ") - print(team_name) - # Number, name, programming language, width, length, has camera vision system, number of drivetrain motors - number = input('number:') - if not number.isnumeric(): - print("your input for team number: "+ number + " is invalid") - else: - programming_language = input('progamming language:') - if value.lower() not in ['java', 'python', 'c++']: - print("input is invalid") - isInputValid = False - else: - width = input('width:') - if not width.isnumeric(): - print("your input for width: "+ width +" is invalid") - else: - length = input('length:') - if not length.isnumeic(): - print("your input for length: "+ length +" is invalid") - else: - vision_system = input('has a camera vision system:') - if vision_system != 'yes' or vision_system != 'no': - print("your input for vision system: "+ vision_system +" is invalid") - else: - number_of_drivetrain_motors = input('number of drivetrain motors:') - team_info = {} - team_info.update(number = number) - team_info.update(programming_language = programming_language) - team_info.update(width = width) - team_info.update(length = length) - team_info.update(vision_system = vision_system) - team_info.update(number_of_drivetrain_motors = number_of_drivetrain_motors) - #print(team_info) - teams[team_name] = team_info - print('team ' + team_name + ' has created successfully.') - print(teams[team_name]) - if command == 'update a team': - print('update a team') - team_name = input('What team needs an update? ') - print(teams[team_name]) - if team_name in teams.keys(): - print("number, programming_language, width, length, vision_system, number_of_drivetrain_motors") - field = input('What field needs and update: ') - value = input('value: ') - isInputValid = True - if field in ['number','width', 'length', 'number_of_drivetrain_motors']: - if not value.isnumeric(): - print('input is not valid') - isInputValid = False - elif field == "vision_system": - if value.lower() != 'yes' and value.lower() !='no': - print("input is invalid") - isInputValid = False - elif field == "programming_language": - if value.lower() not in ['java', 'python', 'c++']: - print("input is invalid") - isInputValid = False - else: - print("field you want to update is invalid") - isInputValid = False + command = input ("What is your command(add a team, update a team, search a team, delete a team, list all teams, quit)") + #print(command); + if command == 'add a team' : + team_name = input ("What is team name? ") + print(team_name) + # Number, name, programming language, width, length, has camera vision system, number of drivetrain motors + number = input('number:') + if not number.isnumeric(): + print("your input for team number: "+ number + " is invalid") + else: + programming_language = input('progamming language: ') + #print(programming_language) + if programming_language.lower() not in ['java', 'python', 'c++']: + print("input is invalid") + isInputValid = False + else: + width = input('width:') + if not width.isnumeric(): + print("your input for width: "+ width +" is invalid") + else: + length = input('length:') + if not length.isnumeric(): + print("your input for length: "+ length +" is invalid") + else: + vision_system = input('has a camera vision system:') + if vision_system != 'yes' and vision_system != 'no': + print("your input for vision system: "+ vision_system +" is invalid") + else: + number_of_drivetrain_motors = input('number of drivetrain motors:') + team_info = {} + team_info.update(number = number) + team_info.update(programming_language = programming_language) + team_info.update(width = width) + team_info.update(length = length) + team_info.update(vision_system = vision_system) + team_info.update(number_of_drivetrain_motors = number_of_drivetrain_motors) + #print(team_info) + teams[team_name] = team_info + print('team ' + team_name + ' has created successfully.') + print(teams[team_name]) + if command == 'update a team': + print('update a team') + team_name = input('What team needs an update? ') + print(teams[team_name]) + if team_name in teams.keys(): + print("number, programming_language, width, length, vision_system, number_of_drivetrain_motors") + field = input('What field needs and update: ') + value = input('value: ') + isInputValid = True + if field in ['number','width', 'length', 'number_of_drivetrain_motors']: + if not value.isnumeric(): + print('input is not valid') + isInputValid = False + elif field == "vision_system": + if value.lower() != 'yes' and value.lower() !='no': + print("input is invalid") + isInputValid = False + elif field == "programming_language": + if value.lower() not in ['java', 'python', 'c++']: + print("input is invalid") + isInputValid = False + else: + print("field you want to update is invalid") + isInputValid = False - if isInputValid: - teams[team_name][field] = value - print("team updated successfully") - print(teams[team_name]) + if isInputValid: + teams[team_name][field] = value + print("team updated successfully") + print(teams[team_name]) - else: - print('team does not exist') - if command == 'search a team': - team_name = input('What team? ') - if team_name in teams.keys(): - print(teams[team_name]) - else: - print('team does not exist') - if command == 'delete a team': - team_name = input('delete which team? ') - if team_name in teams.keys(): - print(teams.keys()) - teams.pop(team_name) - print(teams.keys()) - else: - print('team ' + team_name +' does not exist') - if command == 'list all teams': - print(teams) + else: + print('team does not exist') + if command == 'search a team': + team_name_type = input('would you like to search by name or number? \n') + if team_name_type == "name": + team_name = input('What team? ') + if team_name in teams.keys(): + print("Yes, team is in dictionary") + pass + else: + print('team does not exist') + pass + + if team_name_type == "number": + team_number = input('what team number? ') + if team_number.isnumeric(): + isTeamNumberValid = False + for key, value in teams.items(): + #print(team_number) + #print(value["number"]) + if team_number == value["number"]: + isTeamNumberValid = True + break + if isTeamNumberValid: + print("Yes, team is in dicitionary") + else: + print("Team does not exist") + + if command == 'delete a team': + team_name = input('delete which team? ') + if team_name in teams.keys(): + print(teams.keys()) + teams.pop(team_name) + print(teams.keys()) + else: + print('team ' + team_name +' does not exist') + if command == 'list all teams': + print(teams) print('end') \ No newline at end of file From f42504a38031ac5434bd3b812868d3782d32ada9 Mon Sep 17 00:00:00 2001 From: adamhwu Date: Wed, 9 Oct 2019 20:35:44 -0700 Subject: [PATCH 09/12] add functions --- ch_3_assign_Harry_Jiang.py | 128 +++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 ch_3_assign_Harry_Jiang.py diff --git a/ch_3_assign_Harry_Jiang.py b/ch_3_assign_Harry_Jiang.py new file mode 100644 index 0000000..415b1fa --- /dev/null +++ b/ch_3_assign_Harry_Jiang.py @@ -0,0 +1,128 @@ +def add_a_team(): + team_name = input ("What is team name? ") + print(team_name) + # Number, name, programming language, width, length, has camera vision system, number of drivetrain motors + number = input('number:') + if not number.isnumeric(): + print("your input for team number: "+ number + " is invalid") + else: + programming_language = input('progamming language: ') + #print(programming_language) + if programming_language.lower() not in ['java', 'python', 'c++']: + print("input is invalid") + isInputValid = False + else: + width = input('width:') + if not width.isnumeric(): + print("your input for width: "+ width +" is invalid") + else: + length = input('length:') + if not length.isnumeric(): + print("your input for length: "+ length +" is invalid") + else: + vision_system = input('has a camera vision system:') + if vision_system != 'yes' and vision_system != 'no': + print("your input for vision system: "+ vision_system +" is invalid") + else: + number_of_drivetrain_motors = input('number of drivetrain motors:') + team_info = {} + team_info.update(number = number) + team_info.update(programming_language = programming_language) + team_info.update(width = width) + team_info.update(length = length) + team_info.update(vision_system = vision_system) + team_info.update(number_of_drivetrain_motors = number_of_drivetrain_motors) + #print(team_info) + teams[team_name] = team_info + print('team ' + team_name + ' has created successfully.') + print(teams[team_name]) +def update_a_team(): + print('update a team') + team_name = input('What team needs an update? ') + print(teams[team_name]) + if team_name in teams.keys(): + print("number, programming_language, width, length, vision_system, number_of_drivetrain_motors") + field = input('What field needs and update: ') + value = input('value: ') + isInputValid = True + if field in ['number','width', 'length', 'number_of_drivetrain_motors']: + if not value.isnumeric(): + print('input is not valid') + isInputValid = False + elif field == "vision_system": + if value.lower() != 'yes' and value.lower() !='no': + print("input is invalid") + isInputValid = False + elif field == "programming_language": + if value.lower() not in ['java', 'python', 'c++']: + print("input is invalid") + isInputValid = False + else: + print("field you want to update is invalid") + isInputValid = False + + + if isInputValid: + teams[team_name][field] = value + print("team updated successfully") + print(teams[team_name]) + + + else: + print('team does not exist') +def search_a_team(): + team_name_type = input('would you like to search by name or number? \n') + if team_name_type == "name": + team_name = input('What team? ') + if team_name in teams.keys(): + print("Yes, team is in dictionary") + pass + else: + print('team does not exist') + pass + + if team_name_type == "number": + team_number = input('what team number? ') + if team_number.isnumeric(): + isTeamNumberValid = False + for key, value in teams.items(): + #print(team_number) + #print(value["number"]) + if team_number == value["number"]: + isTeamNumberValid = True + break + if isTeamNumberValid: + print("Yes, team is in dicitionary") + else: + print("Team does not exist") +def delete_a_team(): + team_name = input('delete which team? ') + if team_name in teams.keys(): + print(teams.keys()) + teams.pop(team_name) + print(teams.keys()) + else: + print('team ' + team_name +' does not exist') +def list_all_teams(): + print(teams) +teams = {'teddy': {'number': '7', 'programming_language': '5', 'width': '5', 'length': '5', 'vision_system': 'yes', 'number_of_drivetrain_motors': '3'}, 'emily': {'number': '4', 'programming_language': 'c++', 'width': '3', 'length': '5', 'vision_system': 'no', 'number_of_drivetrain_motors': '9'}} +command = '' +while command != 'quit': + command = input ("What is your command(add a team, update a team, search a team, delete a team, list all teams, quit)") + #print(command); + if command == 'add a team' : + add_a_team() + + if command == 'update a team': + update_a_team() + + if command == 'search a team': + search_a_team() + + if command == 'delete a team': + delete_a_team() + + if command == 'list all teams': + list_all_teams() + +print('end') \ No newline at end of file From d24fb0f4b16010b1fd319fd76e77fd7d14088d18 Mon Sep 17 00:00:00 2001 From: adamhwu Date: Wed, 30 Oct 2019 19:22:53 -0700 Subject: [PATCH 10/12] turn in assignment for the first time --- ch_4_assign_Harry_Jiang.py | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 ch_4_assign_Harry_Jiang.py diff --git a/ch_4_assign_Harry_Jiang.py b/ch_4_assign_Harry_Jiang.py new file mode 100644 index 0000000..621244a --- /dev/null +++ b/ch_4_assign_Harry_Jiang.py @@ -0,0 +1,61 @@ +import math + +class Point: + x = 0 + y = 0 + distance = 0 + def __init__(self, x, y): + self.x = x + self.y = y + + #calculate distance + def calculateDistance(self): + return math.sqrt(self.x*self.x + self.y*self.y) + +class Point_3D(Point): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + + def calculateDistance(self): + return math.sqrt(self.x*self.x + self.y*self.y + self.z*self.z) + + + +#aPoint = Point(1,1) +#print(aPoint.calculateDistance()) +#aPoint = Point_3D(1, 1, 1) +#print(aPoint.calculateDistance()) +IsInputValid = False +while IsInputValid == False: + pointinput = input('please enter the value of two dimensional point\n') + coordinate = pointinput.split(',') + if not coordinate[0].isnumeric() or not coordinate[1].isnumeric(): + IsInputValid = False + else: + aPoint = Point(float(coordinate[0]), float(coordinate[1])) + distance2D = aPoint.calculateDistance() + print(distance2D) + IsInputValid = True + +Is3dInputValid = False +while Is3dInputValid == False: + point3Dinput = input('please enter the value of the three dimensional point\n') + coordinate3D = point3Dinput.split(',') + if not coordinate3D[0].isnumeric() or not coordinate3D[1].isnumeric() or not coordinate3D[2].isnumeric(): + Is3dInputValid = False + else: + bPoint = Point_3D(float(coordinate3D[0]), float(coordinate3D[1]), float(coordinate3D[2])) + distance3D = bPoint.calculateDistance() + print(distance3D) + Is3dInputValid = True + +if distance2D > distance3D: + print('two dimensional point distance is larger') +elif distance3D == distance2D: + print('two dimensional point and three dimensional point distance are equal') +else: + print('three dimensional point distance is larger') + + + From 3e9dcf6297a8c97781d60d45158e72e791c5baa7 Mon Sep 17 00:00:00 2001 From: adamhwu Date: Wed, 30 Oct 2019 19:43:05 -0700 Subject: [PATCH 11/12] fix team update varification --- ch_2_assign_Harry_Jiang.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/ch_2_assign_Harry_Jiang.py b/ch_2_assign_Harry_Jiang.py index 08fe4ce..df2125d 100644 --- a/ch_2_assign_Harry_Jiang.py +++ b/ch_2_assign_Harry_Jiang.py @@ -44,7 +44,6 @@ if command == 'update a team': print('update a team') team_name = input('What team needs an update? ') - print(teams[team_name]) if team_name in teams.keys(): print("number, programming_language, width, length, vision_system, number_of_drivetrain_motors") field = input('What field needs and update: ') @@ -66,13 +65,11 @@ print("field you want to update is invalid") isInputValid = False - if isInputValid: teams[team_name][field] = value print("team updated successfully") print(teams[team_name]) - else: print('team does not exist') if command == 'search a team': From 88d3faa528de231e23b589f350fbd6cb6ade9c81 Mon Sep 17 00:00:00 2001 From: adamhwu Date: Wed, 6 Nov 2019 19:23:32 -0800 Subject: [PATCH 12/12] fix validation for 3D point and 2D point --- ch_4_assign_Harry_Jiang.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ch_4_assign_Harry_Jiang.py b/ch_4_assign_Harry_Jiang.py index 621244a..48b44c7 100644 --- a/ch_4_assign_Harry_Jiang.py +++ b/ch_4_assign_Harry_Jiang.py @@ -28,27 +28,35 @@ def calculateDistance(self): #print(aPoint.calculateDistance()) IsInputValid = False while IsInputValid == False: - pointinput = input('please enter the value of two dimensional point\n') + pointinput = input('please enter the value of two dimensional point. put a "," between values\n') coordinate = pointinput.split(',') - if not coordinate[0].isnumeric() or not coordinate[1].isnumeric(): - IsInputValid = False + if not len(coordinate) == 2: + print("your input is invalid") else: - aPoint = Point(float(coordinate[0]), float(coordinate[1])) - distance2D = aPoint.calculateDistance() - print(distance2D) - IsInputValid = True + if not coordinate[0].isnumeric() or not coordinate[1].isnumeric(): + print("your input is incorrect") + IsInputValid = False + else: + aPoint = Point(float(coordinate[0]), float(coordinate[1])) + distance2D = aPoint.calculateDistance() + print(distance2D) + IsInputValid = True Is3dInputValid = False while Is3dInputValid == False: - point3Dinput = input('please enter the value of the three dimensional point\n') + point3Dinput = input('please enter the value of the three dimensional point. put a "," between values\n') coordinate3D = point3Dinput.split(',') - if not coordinate3D[0].isnumeric() or not coordinate3D[1].isnumeric() or not coordinate3D[2].isnumeric(): - Is3dInputValid = False + if not len(coordinate3D) == 3: + print("your input is invalid") else: - bPoint = Point_3D(float(coordinate3D[0]), float(coordinate3D[1]), float(coordinate3D[2])) - distance3D = bPoint.calculateDistance() - print(distance3D) - Is3dInputValid = True + if not coordinate3D[0].isnumeric() or not coordinate3D[1].isnumeric() or not coordinate3D[2].isnumeric: + print("your input is incorrect") + Is3dInputValid = False + else: + bPoint = Point_3D(float(coordinate3D[0]), float(coordinate3D[1]), float(coordinate3D[2])) + distance3D = bPoint.calculateDistance() + print(distance3D) + Is3dInputValid = True if distance2D > distance3D: print('two dimensional point distance is larger')