Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2070698
add ch_1_lesson_emily_xia.py to repository
emxia18 Sep 12, 2019
01f5a75
Add files via upload
emxia18 Sep 15, 2019
d46025d
add ch_1_assign_emily_xia.py to repository
emxia18 Sep 16, 2019
0126076
Merge branch 'master' of https://github.com/emxia18/software-training
emxia18 Sep 16, 2019
0e42bc4
add lines 91-93 on ch_1_assign_emily_xia.py
emxia18 Sep 22, 2019
ee89495
edit lines 91-101
emxia18 Sep 26, 2019
6a1d829
combine two lists: "Names_of_Competition" and
emxia18 Sep 27, 2019
8fc0c84
write the code
emxia18 Sep 27, 2019
5c6ead9
add modified version of ch_2_assign_emily_xia.py
emxia18 Sep 27, 2019
1bdd0f1
add comments and improve code
emxia18 Sep 27, 2019
1fc36f4
add search function
emxia18 Oct 3, 2019
87aaf3a
add validation in search function
emxia18 Oct 3, 2019
1cc9abd
delete string, integer, etc from add part to prevent code from crashing~
emxia18 Oct 4, 2019
0a56a38
remove extra file
emxia18 Oct 4, 2019
dd81089
add modify function
emxia18 Oct 4, 2019
f88971f
write code, some validation still needed
emxia18 Oct 15, 2019
f29c1dc
add verification, does not take into account first dictionary as part of
emxia18 Oct 16, 2019
6363482
improve validation
emxia18 Oct 17, 2019
7678afb
write code
emxia18 Oct 24, 2019
fe5a080
remove ; from code
emxia18 Oct 24, 2019
75d28e7
improve code based on comment
emxia18 Oct 31, 2019
c98f5d0
improve code based on comments
emxia18 Oct 31, 2019
15e8f22
improve modify function
emxia18 Nov 7, 2019
2ff3943
add validation
emxia18 Nov 8, 2019
8355718
add validation
emxia18 Nov 9, 2019
525ff97
add validation
emxia18 Nov 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions ch-1_assign_emily_xia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
teams_dictionary={
1678:{
"Location":"Davis_CA",
"Rookie_year":2005,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Central_Valley_Regional",
"Sacramento_Regional",
"Aerospace_Valley_Regional",
"Carver_Division",
"Einstein_Field",
"RCC_Qianjiang_International_Robotics_Invitational",
"Chezy_Champs"],
"Competition_Location":[
"Fresno_CA",
"Davis_CA",
"Lancaster_CA",
"Houston_TX",
"Houston_TX",
"Hangzhou_CN",
"San_Jose_CA"],
"Competition_Awards":[
"Regional_Chairmans_Award",
"Regional_Winner",
"Deans_List",
"Regional_Winner",
"Industrial_Design_Award",
"Excellence_in_Engineering",
"Championship_Subdivision_Winner",
"Entrepreneurship-Award"]},
3132:{
"Location":"Sydney_Australia",
"Rookie_year":2010,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Southern_Cross_Regional",
"South_Pacific_Regional",
"Carver_Division",
"Einstein_Field"],
"Competition_Location":[
"Sydeny_Olympic_Park",
"Sydeny_Olympic_Park",
"Houston_TX",
"Houston_TX"],
"Competition_Awards":[
"Woodie_Flowers",
"Gracious_Professionalism",
"Regional_Engineering_Inspiration",
"Safety_Award"]},
1902:{
"Location":"Orlando_FL",
"Rookie_year":2006,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Palmetto_Regional",
"Orlando_Regional",
"Newton_Division",
"Einstein_Field"],
"Competition_Location":[
"Myrtle_Beach",
"Orlando_FL",
"Houston_TX",
"Houston_TX"],
"Competition_Awards":[
"Regional_Chairmans_Award",
"Deans_List",
"Entrepreneurship-Award",
"Chairmans_Award_Finalist"]},
5458:{
"Location":"Woodland_CA",
"Rookie_year":2015,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Central_Valley_Regional",
"Sacramento_Regional"],
"Competition_Location":[
"Fresno_CA",
"Davis_CA"],
"Competition_Awards":[
"None"]},
6174:{
"Location":"Winters_CA",
"Rookie_year":2016,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Sacramento_Regional"],
"Competition_Location":[
"Davis_CA"],
"Competition_Awards":[
"None"]}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to ask for user input to retrieve a piece of information about a specific team. Right now, this is just a dictionary that does nothing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, got it. Thanks! I will try to work on that when I have time. If I have any questions, should I ask them via slack or can I ask them here? Thanks!!

101 changes: 101 additions & 0 deletions ch_1_assign_emily_xia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
teams_dictionary={
1678:{
"Location":"Davis_CA",
"Rookie_year":2005,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Central_Valley_Regional",
"Sacramento_Regional",
"Aerospace_Valley_Regional",
"Carver_Division",
"Einstein_Field",
"RCC_Qianjiang_International_Robotics_Invitational",
"Chezy_Champs"],
"Competition_Location":[
"Fresno_CA",
"Davis_CA",
"Lancaster_CA",
"Houston_TX",
"Houston_TX",
"Hangzhou_CN",
"San_Jose_CA"],
"Competition_Awards":[
"Regional_Chairmans_Award",
"Regional_Winner",
"Deans_List",
"Regional_Winner",
"Industrial_Design_Award",
"Excellence_in_Engineering",
"Championship_Subdivision_Winner",
"Entrepreneurship-Award"]},
3132:{
"Location":"Sydney_Australia",
"Rookie_year":2010,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Southern_Cross_Regional",
"South_Pacific_Regional",
"Carver_Division",
"Einstein_Field"],
"Competition_Location":[
"Sydeny_Olympic_Park",
"Sydeny_Olympic_Park",
"Houston_TX",
"Houston_TX"],
"Competition_Awards":[
"Woodie_Flowers",
"Gracious_Professionalism",
"Regional_Engineering_Inspiration",
"Safety_Award"]},
1902:{
"Location":"Orlando_FL",
"Rookie_year":2006,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Palmetto_Regional",
"Orlando_Regional",
"Newton_Division",
"Einstein_Field"],
"Competition_Location":[
"Myrtle_Beach",
"Orlando_FL",
"Houston_TX",
"Houston_TX"],
"Competition_Awards":[
"Regional_Chairmans_Award",
"Deans_List",
"Entrepreneurship-Award",
"Chairmans_Award_Finalist"]},
5458:{
"Location":"Woodland_CA",
"Rookie_year":2015,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Central_Valley_Regional",
"Sacramento_Regional"],
"Competition_Location":[
"Fresno_CA",
"Davis_CA"],
"Competition_Awards":[
"None"]},
6174:{
"Location":"Winters_CA",
"Rookie_year":2016,
"2019_Competition_Status":True,
"Names_of_Competions":[
"Sacramento_Regional"],
"Competition_Location":[
"Davis_CA"],
"Competition_Awards":[
"None"]}}
team_number = int(input("Out of 1678, 3132, 1902, 5458, and 6174, what is the number of the desired team?"))
team_attribute = str(input(
"""Out of:
Location,
Rookie_year,
2019_Competition_Status,
Names_of_Competitions,
Competition_Locations,
Competition_Awards
what is the desired attribute?"""))
print(teams_dictionary[team_number][team_attribute])
1 change: 1 addition & 0 deletions ch_1_lesson_emily_xia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print ('Hello, world')
167 changes: 167 additions & 0 deletions ch_2_assign_emily_xia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
team_dictionary = {}
user_action = input("""Enter the number of the action you want to do
1 add a team
2 modify a team
3 view a team
4 remove a team
5 search a team
6 list all teams
7 leave \n """)
while True:
if user_action == "0":
#returning to main menu
user_action = input("""Enter the number of the action you want to do
1 add a team
2 modify a team
3 view a team
4 remove a team
5 search a team
6 list all teams
7 leave \n """)
elif user_action == "1":
#adding a team
number = input("What is your team number? \n")
while number.isdigit() == False:
number = input("Your input is not an integer, please input an integer \n")
name = input("What is the name of your team? \n")
while name.isdigit() == True:
name = input("Your input is not a string, please input a string\n")
programming_language = input("What is the programming language of your team? \n")
while programming_language.isdigit() == True:
programming_language = input("Your input is not a string, please input a string\n")
width = input("What is the width of your robot? \n")
while width.isdigit() == False:
width = input("Your input is not an integer, please input an integer \n")
length = input("What is the length of your robot? \n")
while length.isdigit() == False:
length = input("Your input is not an integer, please input an integer \n")
camera_vision_system = input("True or False, your robot has a camera vision system? \n")
while True:
if camera_vision_system != "True":
if camera_vision_system != "False":
camera_vision_system = input("Your input is not a boolean, please input either 'True' or 'False' \n")
if camera_vision_system == "True":
break
elif camera_vision_system == "False":
break
else:
break
else:
break
number_of_motors = input("How many motors does your robot have? \n")
while number_of_motors.isdigit() == False:
number_of_motors = input("Your input is not an integer, please input an integer \n")
added_team_information = {
"number": number,
"name": name,
"programming_language": programming_language,
"width": width,
"length": length,
"camera_vision_system": camera_vision_system,
"number_of_motors": number_of_motors}
team_dictionary.update({number:added_team_information})
user_action = input("""If you want to continue, press 1. \nIf you want to exit the "add" function, press 0. \n """)
elif user_action == "2":
#modify a team
modify_team = input("What is the team you want to modify? \n")
modify_attribute = None
new_attribute = None
if modify_team in team_dictionary:
print(team_dictionary[modify_team])
modify_attribute = input("What is the attribute that you want to modify? \n")
if modify_attribute in team_dictionary[modify_team]:
new_attribute = input("What do you want the new "+modify_attribute+" to be? \n")
if modify_attribute == "number":
while new_attribute.isdigit() == False:
new_attribute = input("Your input is not an integer, please input a integer\n")
elif modify_attribute == "name":
while new_attribute.isdigit() == True:
new_attribute = input("Your input is not a string, please input a string\n")
elif modify_attribute == "programming_language":
while new_attribute.isdigit() == True:
new_attribute = input("Your input is not a string, please input a string\n")
elif modify_attribute == "width":
while new_attribute.isdigit() == False:
new_attribute = input("Your input is not an integer, please input a integer\n")
elif modify_attribute == "length":
while new_attribute.isdigit() == False:
new_attribute = input("Your input is not an integer, please input a integer\n")
elif modify_attribute == "camera_vision_system":
while True:
if new_attribute != "True":
if new_attribute != "False":
new_attribute = input("Your input is not a boolean, please input either 'True' or 'False' \n")
if new_attribute == "True":
break
elif new_attribute == "False":
break
else:
break
else:
break
elif modify_attribute == "number_of_motors":
while new_attribute.isdigit() == False:
new_attribute = input("Your input is not an integer, please input a integer\n")
team_dictionary[modify_team].update({modify_attribute:new_attribute})
print(team_dictionary[modify_team])
user_action = input("""If you want to continue, press 2. \nIf you want to exit the "modify" function, press 0. \n""")
if modify_attribute == "number":
team_dictionary[new_attribute] = team_dictionary[modify_team]
team_dictionary.pop(modify_team)
elif modify_team not in team_dictionary[modify_team]:
print("I'm sorry, the team you want to modify is not in the dictionary.")
user_action = input("""If you want to continue, press 2. \nIf you want to exit the "modify" function, press 0. \n""")
elif modify_team not in team_dictionary:
print("I'm sorry, the team you want to modify is not in the dictionary.")
user_action = input("""If you want to continue, press 2. \nIf you want to exit the "modify" function, press 0. \n""")
elif user_action == "3":
#viewing a team
view_team = input("What is the number of the team you want to view? \n ")
if view_team in team_dictionary:
print(team_dictionary[view_team])
elif view_team not in team_dictionary:
print("I'm sorry, the team you are looking for does not exist.")
user_action = input("""If you want to continue, press 3. \nIf you want to exit the "view" function, press 0. \n """)
elif user_action == "4":
#removing a team
print(team_dictionary)
remove_team = input("What is the number of the team you want to remove? \n ")
if remove_team in team_dictionary:
team_dictionary.pop(remove_team)
print("Team " +remove_team+ " has been removed from the team dictionary!")
elif remove_team not in team_dictionary:
print("I'm sorry, the team you are looking for does not exist.")
user_action = input("""If you want to continue, press 4. \nIf you want to exit the "remove" function, press 0.\n """)
elif user_action == "5":
#searching for a team
search_team = input("What is the number or name of the team you want to search for?\n")
if search_team in team_dictionary:
print("Yes, the team you are looking for is in the team dictionary")
else:
result=None
for key in team_dictionary:
if team_dictionary[key]["name"] == search_team:
print("Yes, the team you are looking for is in the team dictionary")
result=team_dictionary[key]
break
if not result:
print("""I'm sorry, but the team you are looking for is not in the team dictionary.
Please make sure that your input is an integer.""")
user_action = input("""If you want to continue, press 5. \n If you want to exit the "search" function, press 0.\n """)
elif user_action == "6":
#listing all teams
print(team_dictionary)
user_action = input("""If you want to continue, press 6. \nIf you want to exit the "list" function, press 0.\n """)
elif user_action not in ["0", "1", "2", "3", "4", "5", "6", "7"]:
#returning to main menu if user_action is not a known value
print("I'm sorry, could you please re-enter your command?")
user_action = input("""Enter the number of the action you want to do
1 add a team
2 modify a team
3 view a team
4 remove a team
5 search a team
6 list all teams
7 leave \n""")
elif user_action == "7":
break
Loading