diff --git a/ch_1_assign_Claire_Hays.py b/ch_1_assign_Claire_Hays.py new file mode 100644 index 0000000..5584f88 --- /dev/null +++ b/ch_1_assign_Claire_Hays.py @@ -0,0 +1,104 @@ +teams = { + 1678:{ + 'location': 'Davis, CA, USA', + 'rookie year': 2005, + '2019 compete': True , + 'names and locations of 2019 competitions': { + 'Central Valley Regional': 'Fresno, CA, USA', + 'Sacramento Regional': 'Davis, CA, USA', + 'Aerospace Valley Regional': 'Lancaster, CA, USA', + 'Carver Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA', + 'RCC': 'Hangzhou, Zhejian, China', + 'Chezy Champs': 'San Jose, CA, USA' + }, + '2019 awards': [ + 'Regional Chairmans', + 'Regional Winner', + 'Regional Winner', + 'FIRST Deans List Finalist Award', + 'Industrial Design Award', + 'Regional Winner', + 'Excellence in Engineering Award', + 'Division Winner', + 'Entrepreneurship Award' + ] + }, + + 1323: { + 'location': 'Madera, CA, USA', + 'rookie year': 2004, + '2019 compete': True , + 'names and locations of 2019 competitions': { + 'Central Valley Regional': 'Fresno, CA, USA', + 'Sacramento Regional': 'Davis, CA, USA', + 'Newton Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA' + }, + '2019 awards': [ + 'Regional Winner', + 'Autonomous Award', + 'Regional Winner', + 'Quality Award', + 'Division Winner', + 'Industrial Design Award', + 'Houston Champs Winner'] + }, + + 254: { + 'location': 'San Jose, CA, USA', + 'rookie year': 1999, + '2019 compete': True , + 'names and locations of 2019 competitions': { + 'San Francisco Regional': 'San Francisco, CA, USA', + 'Silicon Valley Regional': 'San Jose, CA, USA', + 'Turing Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA', + 'Chezy Champs': 'San Jose, CA, USA'}, + '2019 awards': [ + 'Regional Winner', + 'Innovation in Control Award', + 'Regional Winner', + 'Excellence in Engineering Award', + 'Division Winner', + 'Industrial Design Award', + 'Houston Champs Finalist'] + }, + + 3132: { + 'location': 'Sydney, New South Wales, Australia', + 'rookie year': 2010, + '2019 compete': True , + 'names and locations of 2019 competitions': { + 'Southern Cross Regional': 'Sydney Olympic Park, NSW, Australia', + 'South Pacific Regional': 'Sydney Olympic Park, NSW, Australia', + 'Carver Division': 'Houston, TX, USA', + 'Einstein Field': 'Houston, TX, USA'}, + '2019 awards': [ + 'Woodie Flowers Finalist Award', + 'Gracious Professionalism Award', + 'Regional Engineering Inspiration Award', + 'Safety Award','Division Winner'] + }, + + 3476:{ + 'location': 'Irvine, CA, USA', + 'rookie year': 2011, + '2019 compete': True , + 'names and locations of 2019 competitions': { + 'Los Angeles Regional': 'Los Angeles, CA, USA', + 'Aerospace Valley Regional': 'Lancaster, CA, USA', + 'Hopper Division': 'Houston, TX, USA', + 'Battleship Blast': 'San Pedro, CA, USA', + 'Chezy Champs': 'San Jose, CA, USA', + 'Beach Blitz': 'Huntington Beach, CA, USA'}, + '2019 awards': [ + 'Gracious Professionalism Award', + 'Autonomous Award', + 'Regional Winner', + 'Quality Award'] + } +} +team_num = int(input("Team number: ")) +attribute = input("Attribute: ") +print(teams[team_num][attribute]) \ No newline at end of file diff --git a/ch_1_lesson_Claire_Hays.py b/ch_1_lesson_Claire_Hays.py new file mode 100644 index 0000000..4648e70 --- /dev/null +++ b/ch_1_lesson_Claire_Hays.py @@ -0,0 +1 @@ +print("Hello, World!") \ No newline at end of file diff --git a/ch_2_assign_Claire_Hays.py b/ch_2_assign_Claire_Hays.py new file mode 100644 index 0000000..87112f7 --- /dev/null +++ b/ch_2_assign_Claire_Hays.py @@ -0,0 +1,263 @@ +teams = {} +while True: + command = input("""Enter the command (add a team, remove a team, search for a team, list all teams, +view team's information, modify team's information, view all teams and information, or quit): """) + + + if command == "add a team": + check = False + while check == False: + team_num = input("What is the team number? ") + if team_num == 'quit': + check = True + elif team_num.isdigit(): + team_num = int(team_num) + check = True + else: + print("Please type your team number as an integer") + if team_num == 'quit': + continue + + team_name = input("What is the team name? ") + if team_name == 'quit': + continue + + team_prog_lang = input("What is the team's programming language? ") + if team_prog_lang == 'quit': + continue + + check = False + while check == False: + robot_width = input("What is the robot's width? ") + if robot_width == 'quit': + check = True + elif robot_width.isnumeric(): + robot_width = float(robot_width) + check = True + else: + print("Please type your robot width as an float") + if robot_width == 'quit': + continue + + check = False + while check == False: + robot_length = input("What is the robot's length? ") + if robot_length == 'quit': + check = True + elif robot_length.isnumeric(): + robot_length = float(robot_length) + check = True + else: + print("Please type your robot length as an float") + if robot_length == 'quit': + continue + + check = False + while check == False: + robot_vision = input("Does the robot have camera vision? ") + if robot_vision == 'quit': + check = True + elif robot_vision.lower() == "yes": + robot_vision = True + check = True + elif robot_vision.lower() == "no": + robot_vision == False + check = True + else: + print("Please type either yes or no") + if robot_vision == 'quit': + continue + + check = False + while check == False: + robot_motors = input("How many drivetrain motors does the robot have? ") + if robot_motors == 'quit': + check = True + elif robot_motors.isdigit(): + robot_motors = int(robot_motors) + check = True + else: + print("Please type the number of motors as an integer") + if robot_motors == 'quit': + continue + + attributes = {"Name": team_name, "Programming Language": team_prog_lang, + "Width": robot_width, "Length": robot_length, "Camera Vision": robot_vision, + "Drivetrain Motors": robot_motors} + new_team = {team_num: attributes} + teams.update(new_team) + + + elif command == "remove a team": + check = False + while check == False: + remove_team_num = input("What team number would you like to remove? ") + if remove_team_num == 'quit': + check = True + elif remove_team_num.isdigit(): + remove_team_num = int(remove_team_num) + check = True + else: + print("Please type your team number as a n integer") + if remove_team_num == 'quit': + continue + teams.pop(remove_team_num) + print("Team number successfully removed. To view new team list, type 'list all teams'") + + + elif command == "search for a team": + team_search = str(input("What team would you like to search for? ")) + if team_search == 'quit': + continue + elif team_search.isdigit() == True: + team_get = teams.get(int(team_search)) + if team_get == None: + print("The team you searched for was not found in the database. ") + else: + print("The team you searched for was found in the database. ") + else: + names = [] + for team_num, team_attributes in teams.items(): + names.append(team_attributes["Name"]) + if team_search in names: + print("The team you searched for was found in the database.") + else: + print("The team you searched for was not in the database.") + + + + if command == "list all teams": + print(teams.keys()) + + + if command == "view team's information": + check = False + while check == False: + view_team_num = input("What team's information would you like to view? ") + if view_team_num == 'quit': + check = True + elif view_team_num.isdigit(): + view_team_num = int(view_team_num) + check = True + else: + print("Please type your team number as a n integer") + if view_team_num == 'quit': + continue + view_team_attribute = str(input("""What attribute would you like to view (Name, + Programming Language, Width, Length, Camera Vision, Drivetrain Motors? """)) + if view_team_attribute == 'quit': + continue + else: + print(teams[view_team_num][view_team_attribute]) + + + if command == "modify team's information": + print("If attribute hasn't changed, type none") + + check = False + while check == False: + chng_team_num = input("What team number's information would you like to change? ") + if chng_team_num == 'quit': + check = True + elif chng_team_num.isdigit(): + chng_team_num = int(chng_team_num) + check = True + else: + print("Please type your team number as an integer") + if chng_team_num == 'quit': + continue + + new_team_name = input("What is the new team name? ") + if new_team_name == 'quit': + continue + elif new_team_name == "none": + new_team_name = teams[chng_team_num]["Name"] + + new_team_prog_lang = input("What is the team's new programming language? ") + if new_team_prog_lang == 'quit': + continue + elif new_team_prog_lang == "none": + new_team_prog_lang = teams[chng_team_num]["Programming Language"] + + check = False + while check == False: + new_robot_width = input("What is the robot's new width? ") + if new_robot_width == 'quit': + check = True + elif new_robot_width == 'none': + new_robot_width = teams[chng_team_num]["Width"] + check = True + elif new_robot_width.isnumeric(): + new_robot_width = float(new_robot_width) + check = True + else: + print("Please type your robot width as an float") + if new_robot_width == 'quit': + continue + + check = False + while check == False: + new_robot_length = input("What is the robot's new length? ") + if new_robot_length == 'quit': + check = True + elif new_robot_length == "none": + new_robot_length = teams[chng_team_num]["Length"] + check = True + elif new_robot_length.isnumeric(): + new_robot_length = float(new_robot_length) + check = True + else: + print("Please type your robot length as an float") + if new_robot_length == 'quit': + continue + + + check = False + while check == False: + new_robot_vision = input("Does the new robot have camera vision? ") + if new_robot_vision == 'quit': + check = True + elif new_robot_vision == "none": + new_robot_vision = teams[chng_team_num]["Camera Vision"] + check = True + elif new_robot_vision.lower() == "yes": + new_robot_vision = True + check = True + elif new_robot_vision.lower() == "no": + new_robot_vision == False + check = True + else: + print("Please type either yes or no") + if new_robot_vision == 'quit': + continue + + + check = False + while check == False: + new_robot_motors = input("How many drivetrain motors does the new robot have? ") + if new_robot_motors == 'quit': + check = True + elif new_robot_motors == "none": + new_robot_motors = teams[chng_team_num]["Drivetrain Motors"] + check = True + elif new_robot_motors.isdigit(): + new_robot_motors = int(new_robot_motors) + check = True + else: + print("Please type the number of motors as an integer") + if new_robot_motors == 'quit': + continue + + new_attributes = {"Name": new_team_name, "Programming Language": new_team_prog_lang, + "Width": new_robot_width, "Length": new_robot_length, "Camera Vision": new_robot_vision, + "Drivetrain Motors": new_robot_motors} + teams[chng_team_num] = new_attributes + + + elif command == "view all teams and information": + print(teams) + + + elif command == "quit": + break + diff --git a/ch_3_assign_Claire_Hays.py b/ch_3_assign_Claire_Hays.py new file mode 100644 index 0000000..c4fa0ac --- /dev/null +++ b/ch_3_assign_Claire_Hays.py @@ -0,0 +1,230 @@ +teams = {} +while True: + command = input("""Enter the command (add a team, remove a team, search for a team, list all teams, +view team's information, modify team's information, view all teams and information, or quit): """) + def check_if_int(a): + while True: + if a == 'quit': + return None + elif a.isdigit() == True: + a = int(a) + return a + else: + a = input("Please type attribute as an integer: ") + def check_if_bool(b): + while True: + if b == 'quit': + return None + elif b.lower() == 'yes': + b = True + return b + elif b.lower() == 'no': + b = False + return b + else: + b = input("Please type either 'yes' or 'no': ") + def check_if_quit(c): + if c == 'quit': + return True + + if command.lower() == "add a team": + team_num = input("What is the team number? ") + team_num = check_if_int(team_num) + if team_num is None: # User entered 'quit' + break + + location = input("What is the location of the team? ") + if check_if_quit(location) == True: + break + + rookie_year = input("What was the team's rookie year? ") + rookie_year = check_if_int(rookie_year) + if rookie_year is None: # User entered 'quit' + break + + + compete_2019 = input("Did the team compete in 2019? ") + if check_if_quit(compete_2019) == True: + break + compete_2019 = check_if_bool(compete_2019) + if compete_2019 is None: # User entered 'quit' + break + + num_of_comp = input("How many competitions did the team compete in during the 2019 season? ") + if check_if_quit == True: + break + num_of_comp = check_if_int(num_of_comp) + if num_of_comp is None: # User entered 'quit' + break + competitions = {} + while num_of_comp > 0: + comp_name = input("What is the name of the competition? ") + if check_if_quit(comp_name) == True: + break + else: + comp_loc = input("What is the location of the competition? ") + comp = {comp_name: comp_loc} + competitions.update(comp) + num_of_comp -= 1 + + num_of_awards = input("How many awards did the team earn during the 2019 season? ") + if check_if_quit(num_of_awards) == True: + break + num_of_awards = check_if_int(num_of_awards) + if num_of_awards is None: # User entered 'quit' + break + awards = [] + while num_of_awards > 0: + award = input("What is the name of the award? ") + if check_if_quit(award) == True: + break + awards.append(award) + num_of_awards -= 1 + + attributes = {'location': location, + 'rookie year': rookie_year, + '2019 compete': compete_2019, + 'names and locations of 2019 competitions': competitions, + '2019 awards': awards} + new_team = {team_num: attributes} + teams.update(new_team) + + + elif command == "remove a team": + remove_team_num = input("What team number would you like to remove? ") + if check_if_quit(remove_team_num) == True: + break + remove_team_num = check_if_int(remove_team_num) + if remove_team_num is None: # User entered 'quit' + break + teams.pop(remove_team_num) + print("Team number successfully removed. To view new team list, type 'list all teams'") + + + elif command == "search for a team": + team_search = input("What team would you like to search for? ") + if check_if_quit(team_search) == True: + break + team_search = check_if_int(team_search) + if team_search is None: # User entered 'quit' + break + print(teams.get(team_search)) + + + elif command == "list all teams": + print(teams.keys()) + + + elif command == "view team's information": + view_team_num = input("What team's information would you like to view? ") + if check_if_quit(view_team_num) == True: + break + view_team_num = check_if_int(view_team_num) + if view_team_num is None: # User entered 'quit' + break + view_team_attribute = str(input("""What attribute would you like to view (location, rookie year, 2019 compete, +names and locations of 2019 competitions, or 2019 awards)? """)) + if check_if_quit(view_team_attribute) == True: + break + print(teams[view_team_num][view_team_attribute]) + + + elif command == "modify team's information": + chng_team_num = input("What team number's information would you like to change? ") + if check_if_quit(chng_team_num) == True: + break + chng_team_num = check_if_int(chng_team_num) + if chng_team_num is None: # User entered 'quit' + break + chng_attribute = input("""What attribute would you like to change (location, rookie year, 2019 compete, +names and locations of 2019 competitions, or 2019 awards)? """) + if check_if_quit(chng_attribute) == True: + break + + if chng_attribute == 'location': + new_location = input("What is the location of the team? ") + if check_if_quit(new_location) == True: + break + new_rookie_year = teams[chng_team_num]['rookie year'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == 'rookie year': + new_rookie_year = input("What was the team's rookie year? ") + new_rookie_year = check_if_int(new_rookie_year) + if new_rookie_year is None: # User entered 'quit' + break + new_location = teams[chng_team_num]['location'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == '2019 compete': + new_compete_2019 = input("Did the team compete in 2019? ") + if check_if_quit(new_compete_2019) == True: + break + new_compete_2019 = check_if_bool(new_compete_2019) + if new_compete_2019 is None: # User entered 'quit' + break + new_location = teams[chng_team_num]['location'] + new_rookie_year = teams[chng_team_num]['rookie year'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == 'names and locations of 2019 competitions': + new_num_of_comp = input("How many competitions did the team compete in during the 2019 season? ") + if check_if_quit(new_num_of_comp) == True: + break + new_num_of_comp = check_if_int(new_num_of_comp) + if new_num_of_comp is None: # User entered 'quit' + break + new_competitions = {} + while new_num_of_comp > 0: + new_comp_name = input("What is the name of the competition? ") + if check_if_quit(new_comp_name) == True: + break + else: + new_comp_loc = input("What is the location of the competition? ") + new_comp = {new_comp_name: new_comp_loc} + new_competitions.update(new_comp) + new_num_of_comp -= 1 + new_location = teams[chng_team_num]['location'] + new_rookie_year = teams[chng_team_num]['rookie year'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_awards = teams[chng_team_num]['2019 awards'] + + elif chng_attribute == '2019 awards': + new_num_of_awards = input("How many awards did the team earn during the 2019 season? ") + if check_if_quit(new_num_of_awards) == True: + break + new_num_of_awards = check_if_int(new_num_of_awards) + if new_num_of_awards is None: # User entered 'quit' + break + new_awards = [] + while new_num_of_awards > 0: + new_award = input("What is the name of the award? ") + if check_if_quit(new_award) == True: + break + new_awards.append(new_award) + new_num_of_awards -= 1 + new_location = teams[chng_team_num]['location'] + new_rookie_year = teams[chng_team_num]['rookie year'] + new_compete_2019 = teams[chng_team_num]['2019 compete'] + new_competitions = teams[chng_team_num]['names and locations of 2019 competitions'] + + new_attributes = {'location': new_location, + 'rookie year': new_rookie_year, + '2019 compete': new_compete_2019, + 'names and locations of 2019 competitions': new_competitions, + '2019 awards': new_awards} + teams[chng_team_num] = new_attributes + + elif command == "view all teams and information": + print(teams) + + elif command == "quit": + break + + + diff --git a/ch_4_assign_Claire_Hays.py b/ch_4_assign_Claire_Hays.py new file mode 100644 index 0000000..721f5f3 --- /dev/null +++ b/ch_4_assign_Claire_Hays.py @@ -0,0 +1,72 @@ +import math +class Point: + def __init__ (self, x, y): + self.x = x + self.y = y + def dist(self): + return math.sqrt(self.x**2 + self.y**2) + +class Point3D(Point): + def __init__ (self, x, y, z): + super().__init__ (x, y) + self.z = z + def dist(self): + return math.sqrt((super().dist())**2 + self.z**2) + +class Determine(Point3D): + def __init__(self, x2D, y2D, x, y, z): + super().__init__ (x, y, z) + self.x2D = x2D + self.y2D = y2D + def compare_tot_dist(self): + if super().dist() > Point(self.x2D, self.y2D).dist(): + return "3D point is farther from the origin." + elif super().dist() == Point(self.x2D, self.y2D).dist(): + return "Points are equidistant from origin." + else: + return "2D point is farther from origin." +def check_if_int(a): + while True: + if a == 'quit': + return None + elif a.isdigit() == True: + a = int(a) + return a + else: + a = input("Please type value as an integer: ") + + +x = input("What is the x coordinate of the 2D point? ") +x = check_if_int(x) + +y = input("What is the y coordinate of the 2D point? ") +y = check_if_int(y) + +point_2D = Point(x, y) +dist_2D = point_2D.dist() +print(dist_2D) + + +x3D = input("What is the x coordinate of the 3D point? ") +x3D = check_if_int(x3D) + +y3D = input("What is the y coordinate of the 3D point? ") +y3D = check_if_int(y3D) + +z = input("What is the z coordinate of the 3D point? ") +z = check_if_int(z) + +point_3D = Point3D(x3D, y3D, z) +dist_3D = point_3D.dist() +print(dist_3D) + +compare = Determine(x, y, x3D, y3D, z) +dist_tot_compare = compare.compare_tot_dist() +print(dist_tot_compare) + + + + + + +