diff --git a/ch_1_assign_kelly_su.py b/ch_1_assign_kelly_su.py new file mode 100644 index 0000000..14b1bcd --- /dev/null +++ b/ch_1_assign_kelly_su.py @@ -0,0 +1,60 @@ +teams = { + 1: { + 'location': 'Pontiac, Michigan, USA.', + 'rookie year': 1997, + 'competed in 2019 season': True, + '2019 competitions': ['FIM District Center Line Event: Center Line, MI, USA.', + 'FIM District Troy Event: Troy, MI, USA.'], + '2019 season awards':'Imagery Award' + }, + 16: { + 'location': 'Mountain Home, Arkansas, USA.', + 'rookie year': 1996, + 'competed in 2019 season': True, + '2019 competitions': ['Midwest Regional: Chicago, IL, USA.', + 'Rocket City Regional: Huntsville, AL, USA.', + 'Darwin Division: Detroit, MI, USA.'], + '2019 season awards': 'Industrial Design Award, Regional Finalists, Excellence in Engineering Award' + }, + 253: { + 'location': 'Millbrae, California, USA.', + 'rookie year': 1999, + 'competed in 2019 season': True, + '2019 competitions': ['San Fransisco Regional: San Fransisco, California, USA.', + 'Monterey Bay Regional: Seaside, CA, USA.', + 'Newton Division: Houston, TX, USA.'], + '2019 season awards': 'Team Spirit Award' + }, + 342: {'location': 'North Charleston, South Carolina, USA.', + 'rookieyear': 2000, + 'competed in 2019 season': True, + '2019 competitions': ['Palmetto Regional: Myrtle Beach, SC USA.', + 'Rocket City Regional: Huntsville, AL, USA.'], + '2019 season awards': False + }, + 554: { + 'location': 'Ft. Thomas, Kentucky, USA.', + 'rookie year': 2001, + 'competed in 2019 season': True, + '2019 competitions': ['Miami Valley Regional: Dayton, OH, USA.'], + '2019 season awards': False + }, +} + +input_team = int(input("Out of teams 1, 16, 253, 342, and 554, which one would you like to view?\n==>")) +input_requested_information = input( +"""What would you like to know about this team? + Please enter one of the following: + location + rookie year + competed in 2019 season + 2019 competitions + 2019 season awards\n==>""") +if isinstance(teams[input_team][input_requested_information], list): + print("\n".join(teams[input_team][input_requested_information])) +else: + print(teams[input_team][input_requested_information]) + + + + diff --git a/ch_1_lesson_kelly_su.py b/ch_1_lesson_kelly_su.py new file mode 100644 index 0000000..91c2faf --- /dev/null +++ b/ch_1_lesson_kelly_su.py @@ -0,0 +1 @@ +print ('Hello, world!') \ No newline at end of file diff --git a/ch_1_robot_assignment_kelly_su.py b/ch_1_robot_assignment_kelly_su.py new file mode 100644 index 0000000..5ac6b79 --- /dev/null +++ b/ch_1_robot_assignment_kelly_su.py @@ -0,0 +1,7 @@ +teams = { + 1678: {"weight": 150, "color": "purple", "wheels": 4} + 2874: {"weight": 110, "color": "green", "wheels": 6} + 259: {"weight": 248, "color": "blue", "wheels": 2} +} +requested_team_number = input("Team Number: ") +requested_robot_attribute = input("Robot Attribute: ") diff --git a/ch_2_assign_kelly_su.py b/ch_2_assign_kelly_su.py new file mode 100644 index 0000000..71694d4 --- /dev/null +++ b/ch_2_assign_kelly_su.py @@ -0,0 +1,150 @@ +all_team_dict = {} +team_dict = {} +def add_team(): + while True: + input_num = input("Please enter a team number to add/update or 0 to exit.\n(If the team already exists, the information will be updated.)\n==>") + if input_num == '0': + print("Exiting...") + return + elif (input_num.isdigit()): + team_dict["number"] = input_num + break + else: + print("Invalid input.") + + while True: + input_name = input("Please enter the team name.\n==>") + if (input_name.isdigit()): + print("Invalid input.") + else: + team_dict["name"] = input_name + break + + input_prog_lang = input("Please enter the programming language.\n==>") + if isinstance(input_name, str): + team_dict["prog_lang"] = input_prog_lang + else: + print("Invalid input.") + return + + while True: + input_w = input("Please enter the width.\n==>") + if (input_w.isdigit()): + team_dict["w"] = input_w + break + else: + print("Invalid input.") + + while True: + input_l = input ("Please enter the length.\n==>") + if (input_l.isdigit()): + team_dict["l"] = input_l + break + else: + print("Invalid input.") + + while True: + input_cam_vision = input("Does it have a camera vision system? Please answer 'true' or 'false'.\n==>") + if input_cam_vision == 'true': + team_dict["cam_vision"] = input_cam_vision + break + elif input_cam_vision == 'false': + team_dict["cam_vision"] = input_cam_vision + break + else: + print("Invalid input.") + + while True: + input_motors = input("Please enter the number of drivetrain motors.\n==>") + if (input_motors.isdigit()): + team_dict["motors"] = input_motors + break + else: + print("Invalid input.") + + all_team_dict.update( {input_num : team_dict} ) + print("Successfully added team " + input_num + "!") + +def search_team(): + if len(team_dict) == 0: + print("No teams found.") + return + input_searchteam = input("Please enter a team number to check if it exists or 0 to exit.\n==>") + if input_searchteam == '0': + print("Exiting...") + return + elif input_searchteam in all_team_dict.keys(): + print("Yes, team " + input_searchteam + " does exist.") + elif input_searchteam == team_dict["name"]: + print("Yes, team " + input_searchteam + " does exist.") + else: + print("Team " + input_searchteam + " does not exist!") + +def view_team(): + input_viewteam = input("Please enter a team number to view or 0 to exit.\n==>") + if input_viewteam == '0': + print("Exiting...") + return + + elif input_viewteam in all_team_dict.keys(): + team_dict = all_team_dict.get(input_viewteam) + print(" Number = " + team_dict ["number"] + '\n' + + " Name = " + team_dict ["name"] + '\n' + + " Programming Language = " + team_dict ["prog_lang"] + '\n' + + " Width = " + team_dict ["w"] + '\n' + + " Length = " + team_dict ["l"] + '\n' + + " Camera Vision System = " + team_dict ["cam_vision"] + '\n' + + " Number of drivetrain motors = " + team_dict ["motors"] + '\n' + ) + + else: + print("Team " + input_viewteam + " not found!") + +def remove_team(): + input_removeteam = input("Please enter a team number to delete or 0 to exit. \n==>") + if input_removeteam == '0': + print("Exiting...") + return + elif input_removeteam in all_team_dict.keys(): + all_team_dict.pop(input_removeteam) + print("Team " + input_removeteam + " removed!") + else: + print("Team " + input_removeteam + " not found!") + + +def list_teams(): + big_list = all_team_dict.values() + for team_dict in big_list: + print(" Number = " + team_dict ["number"] + '\n' + + " Name = " + team_dict ["name"] + '\n' + + " Programming Language = " + team_dict ["prog_lang"] + '\n' + + " Width = " + team_dict ["w"] + '\n' + + " Length = " + team_dict ["l"] + '\n' + + " Camera Vision System = " + team_dict ["cam_vision"] + '\n' + + " Number of drivetrain motors = " + team_dict ["motors"] + '\n' + + "------------------------------------------------" + ) + return + else: + print("No teams found!") + return + +while True: + print("MAIN MENU:") + selection = input("Press \n 1 to add/update a team,\n 2 to search for a team,\n 3 to view a team's information,\n 4 to remove a team,\n 5 to list all teams.\n==>") + if selection == '1': + add_team() + elif selection == '2': + search_team() + elif selection == '3': + view_team() + elif selection == '4': + remove_team() + elif selection == '5': + list_teams() + else: + print("I'm sorry, I did not understand that.") + + + + diff --git a/ch_3_assign_kelly_su.py b/ch_3_assign_kelly_su.py new file mode 100644 index 0000000..705272f --- /dev/null +++ b/ch_3_assign_kelly_su.py @@ -0,0 +1,124 @@ +all_team_dict = {} +team_dict = {} +def add_team(): + while True: + input_num = input("Please enter a team number to add/update or 0 to exit.\n(If the team already exists, the information will be updated.)\n==>") + if input_num == '0': + print("Exiting...") + return + elif (input_num.isdigit()): + team_dict["number"] = input_num + break + else: + print("Invalid input.") + + while True: + input_name = input("Please enter the team name.\n==>") + if (input_name.isdigit()): + print("Invalid input.") + else: + team_dict["name"] = input_name + break + + while True: + input_location = input("Please enter the location of the team.\n==>") + if (input_location.isdigit()): + print("Invalid input.") + else: + team_dict["location"] = input_location + break + + while True: + input_rookie_year = input("Please enter the rookie year of the team.\n==>") + if (input_rookie_year.isdigit()): + team_dict["rookie year"] = input_rookie_year + break + else: + print("Invalid input.") + + while True: + input_2019_season = input("Did this team compete in the 2019 season? Please answer 'true' or 'false'.\n==>") + if input_2019_season == 'true': + input_2019_season = input("Which 2019 competitions did this team compete in? \n==>") + team_dict["2019 competitions"] = input_2019_season + break + elif input_2019_season == 'false': + team_dict["2019 competitions"] = input_2019_season + break + else: + print("Invalid input.") + + while True: + input_2019_awards = input("Did this team win any awards in the 2019 season? Please answer 'true or 'false' \n==>") + if input_2019_awards == 'true': + input_awards_won = input("Which awards did this team win? \n==>") + team_dict["2019 awards"] = input_awards_won + break + elif input_2019_awards == 'false': + team_dict["2019 awards"] = input_2019_awards + break + else: + print("Invalid input.") + + all_team_dict.update( {input_num : team_dict} ) + print("Successfully added team " + input_num + "!") + +def view_team(): + input_viewteam = input("Please enter a team number to view or 0 to exit.\n==>") + if input_viewteam == '0': + print("Exiting...") + return + elif input_viewteam in all_team_dict.keys(): + team_dict = all_team_dict.get(input_viewteam) + print(" Number = " + team_dict["number"] + '\n' + + " Name = " + team_dict["name"] + '\n' + + " Location = " + team_dict["location"] + '\n' + + " Rookie Year = " + team_dict["rookie year"] + '\n' + + " 2019 competitions = " + team_dict["2019 competitions"] + '\n' + " 2019 awards = " + team_dict["2019 awards"] + '\n' + ) + else: + print("Team " + input_viewteam + " not found!") + +def remove_team(): + input_viewteam = input("Please enter a team number to delete or 0 to exit. \n==>") + if input_viewteam == '0': + print("Exiting...") + return + elif input_viewteam in all_team_dict.keys(): + all_team_dict.pop(input_viewteam) + print("Team " + input_viewteam + " removed!") + else: + print("Team " + input_viewteam + " not found!") + + +def list_teams(): + big_list = all_team_dict.values() + for team_dict in big_list: + print(" Number = " + team_dict["number"] + '\n' + + " Name = " + team_dict["name"] + '\n' + + " Location = " + team_dict["location"] + '\n' + + " Rookie Year = " + team_dict["rookie year"] + '\n' + + " 2019 competitions = " + team_dict["2019 competitions"] + '\n' + " 2019 awards = " + team_dict["2019 awards"] + '\n' + + "--------------------------------------------------" + ) + else: + print("No teams found!") + return + +while True: + print("MAIN MENU:") + selection = input("Press \n 1 to add/update a team,\n 2 to view a team,\n 3 to remove a team,\n 4 to list all teams.\n==>") + if selection == '1': + add_team() + elif selection == '2': + view_team() + elif selection == '3': + remove_team() + elif selection == '4': + list_teams() + else: + print("I'm sorry, I did not understand that.") + + + + diff --git a/ch_4_assign_kelly_su.py b/ch_4_assign_kelly_su.py new file mode 100644 index 0000000..27662c1 --- /dev/null +++ b/ch_4_assign_kelly_su.py @@ -0,0 +1,76 @@ +from math import sqrt; +import math; +class Point: + def __init__(self, x, y): + self.x = x + self.y = y + def distance_2D (self): + return float(sqrt(math.pow(int(self.x), 2) + math.pow(int(self.y),2))) + +while True: + x = input("Please enter your 2D x value.\n==>") + if (x.isdigit()): + break + else: + print("Invalid input.") + +while True: + y = input("Please enter your 2D y value.\n==>") + if (y.isdigit()): + break + else: + print("Invalid input.") + + +point_one = Point(x, y) +print("The distance is " + str(point_one.distance_2D()) + "\n") + +class Point_3D(Point): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + def distance_3D(self): + return float(sqrt(math.pow(int(self.x), 2) + math.pow(int(self.y), 2) + math.pow(int(self.z), 2))) + def distance_2D(self): + return super().distance_2D() + +while True: + x = input("Please enter your 3D x value.\n==>") + if (x.isdigit()): + break + else: + print("Invalid input.") + +while True: + y = input("Please enter your 3D y value.\n==>") + if (y.isdigit()): + break + else: + print("Invalid input.") + +while True: + z = input("Please enter your 3D z value.\n==>") + if (z.isdigit()): + break + else: + print("Invalid input.") + +point_two = Point_3D(x, y, z) +print("The distance is " + str(point_two.distance_3D()) + "\n") + +if (point_one.distance_2D()) > (point_two.distance_3D()): + print("The 2D point is furthest from the origin.") +elif (point_one.distance_2D()) < (point_two.distance_3D()): + print("The 3D point is furthest from the origin.") +elif (point_one.distance_2D()) == (point_two.distance_3D()): + print("The 2D and 3D point have equally furthest from the origin.") + +if (point_one.distance_2D()) > (point_two.distance_2D()): + print("The 2D point has x and y coordinates furthest from the origin.") +elif (point_one.distance_2D()) < (point_two.distance_2D()): + print("The 3D point has x and y coordinates furthest from the origin.") +elif (point_one.distance_2D()) == (point_two.distance_2D()): + print("The 2D and 3D x and y coordinates have equal values.") + + +