diff --git a/ch_1_Lesson_Jonathan_Ho_Welcome_Back.py b/ch_1_Lesson_Jonathan_Ho_Welcome_Back.py new file mode 100644 index 0000000..deb306e --- /dev/null +++ b/ch_1_Lesson_Jonathan_Ho_Welcome_Back.py @@ -0,0 +1 @@ +print("Hello, World... again XD") \ No newline at end of file diff --git a/ch_1_assign_Jonathan_Ho.py b/ch_1_assign_Jonathan_Ho.py new file mode 100644 index 0000000..ba68a29 --- /dev/null +++ b/ch_1_assign_Jonathan_Ho.py @@ -0,0 +1,52 @@ +Robot_Team = int(input("What Robotics Team do you want to look into?")) +Robot_Stat = input("What statistic would you like to see?") + + +Robot_TeamB = {1678: {'Location': 'Davis, CA, USA', 'Rookie': '2005', 'Participate?': 'Yes', + 'Competition Names': [ + 'Central Valley Regional', + 'Sacramento Regional', + 'Aerospace Valley Regional', + 'Carver Division', + 'Einstein Field', + 'RCC Qianjiang International Robotics Invitational' + ], + 'Competition Location': [ + 'Fresno, CA, USA', + 'Davis, CA, USA', + 'Lancaster, CA, USA', + 'Houston, TX, USA', + 'Houston TX, USA', + 'Hangzhou, Zhejiang, China' + ], + 'Awards': [ + 'Regional Chairman`s Award and Regional Winners', + 'FIRST Dean`s List Finalist Award (Katie Stachowicz), Regional Winners, and Industrial Design Award sponsored by General Motors', + 'Regional Winners and Excellence in Engineering Award sponsored by Delphi', 'Championship Subdivision Winner and Entrepreneurship Award sponsored by Kleiner Perkins Caufield and Byers' + ,]}, + 1111: {'Location': 'Edgewater, Maryland, USA', 'Rookie': '2003', 'Participate?': 'Yes', + 'Competition Names': [ + 'CHS District Bethesda MD Event sponsored by Bechtel', + 'CHS District Owings Mills MD Event sponsored by Leidos', + 'FIRST Chesapeake District Championship' + ], + 'Competition Location': [ + 'Bethesda, MD 20817, USA', + 'Owings Mills, MD 21117, USA', + 'Fairfax, VA 22030, USA' + ], + 'Awards': [ + 'Autonomous Award sponsored by Ford', + 'District Chairman`s Award', + 'Team Spirit Award sponsored by FCA Foundation' + ]}, + 2222: {'Location': 'Tacoma, WA, USA', 'Rookie': '2007', 'Participate?': 'No', 'Competition': 'Pacific Northwest Regional 2007', + 'Competition Location': 'Pioneer Courthouse Square in Portland, OR, USA', 'Award': 'None'}, + 3333: {'Location': 'Julesburg, CO, USA', 'Rookie': '2010', 'Participate?': 'No', 'Competition': 'Colorado Regional 2010', + 'Competition Location': 'Ritchie Center in Denver, CO, USA', 'Award': 'Judges Award' + }, + 5555: {'Show Location': 'Warren, Michigan', 'Rookie Year': '2015', 'Participate?': 'Yes', + 'Competitions': ['FIM District Center Line Event','FIM District Marysville Event'], 'Competitions Location': ['Center Line, MI, USA', 'Marysville, MI, USA'], + 'Awards': 'District Event Winner'}} +# Prints out the input variables above and the answers for specific information are shown once the questions are answered +print(Robot_TeamB[Robot_Team][Robot_Stat]) diff --git a/ch_2_assign_Jonathan_Ho.py b/ch_2_assign_Jonathan_Ho.py new file mode 100644 index 0000000..6f2665c --- /dev/null +++ b/ch_2_assign_Jonathan_Ho.py @@ -0,0 +1,101 @@ +teams = {} + +''' +Robot_Team_all = {'1678': {'Number': '1678', 'Name': 'Citrus Circuits', 'Prog. Language': 'Java', 'Width': '15 inches', 'Length': '16 inches', 'Camera Vision?': 'Does not have camera vision system', + 'Drivetrain Motors': '12 drivetrain motors'}, + '744': {'Number': '744', 'Name': 'Shark Attack', 'Prog. Language': 'C++', 'Width': '13 inches', 'Length': '15 inches', 'Camera Vision?': 'Does have camera vision system', + 'Drivetrain Motors': '10 drivetrain motors'}, + '5852': {'Number': '5852', 'Name': 'Illusion Robotics', 'Prog. Language': 'C+', 'Width': '17 inches', 'Length': '16 inches', 'Camera Vision?': 'Does not have camera video system', + 'Drivetrain Motors': '9 drivetrain motors'}} +''' +def list_teams(list_of_teams): + for team in list_of_teams: + print(str(team) + "\n") + +def add(): + Player_Add = input("Let's add a team! Choose any team. ") + if Player_Add != None: + teams[Player_Add] = {} + # Add Number + num_question = input("Insert team Number ") + # Add name + name_question = input("Insert its name ") + # Add Programming Language + lang_question = input("Insert Programming Language ") + # Add Width + wide_question = input("Insert robot width (In inches) ") + # Add Length + long_question = input("Insert robot length (In inches) ") + # Add Cam Vision + cam_question = input("Insert Yes or No for Camera Vision on Robot ") + # Add Drivetrain Motor Number + drive_question = input("Insert Number of Drivetrain Motors on robot ") + if num_question.isdigit() and wide_question.isdigit() and long_question.isdigit() and drive_question.isdigit() and (cam_question == "Yes" or cam_question == "No"): + teams[Player_Add]["Number"] = num_question + teams[Player_Add]["Name"] = name_question + teams[Player_Add]["Prog. Language"] = lang_question + teams[Player_Add]["Width"] = wide_question + teams[Player_Add]["Length"] = long_question + teams[Player_Add]["Camera Vision?"] = cam_question + teams[Player_Add]["Number of Drivetrain Motors"] = drive_question + print(teams) + else: + print("Uh oh! One of your inputs was invalid. Make sure that the questions involving numbers are actually numbers, 'kay?") + teams.pop(Player_Add) + +def remove(): + Player_Delete = input("Let's see. What team do you want to delete? ") + if Player_Delete != None: + if Player_Delete in teams: + teams.pop(Player_Delete) + print(teams) + else: + print("Sorry. That's not in the database. Try again.") + +def view(): + view_input = input("Whose data do you want to view?: ") + team_information_input = input("What datapoint would you like to see?: ") + if view_input in teams and team_information_input in teams[view_input]: + print(teams[view_input][team_information_input]) + else: + print("Sorry. I don't think your value is in the data files. Make sure your values are strings and try again.") + +def modify(): + modifier_team = input("\n Whose team's data would you like to modify?: ") + modifier_datapoint = input("\nWhat datapoint would you like to modify?: ") + if modifier_team in teams: + print("The current value for " + str(modifier_datapoint) + " of team " + str(modifier_team) + " is " + teams[modifier_team][modifier_datapoint]) + modifiee_datapoint = input("\nWhat value would you like to change it to?: ") + teams[modifier_team][modifier_datapoint] = modifiee_datapoint + print("The new value has been changed to: " + str(modifiee_datapoint)) + else: + print("Sorry. I'm afraid your input is not in the database. Try again") + +def search(): + search_team = input("Which team do you want to look for? ") + name_team = input("What is the name of the team, for safety measures? ") + if search_team in teams and name_team in teams[search_team]['Name']: + print(str(search_team in teams)) + else: + print(False) + + +while True: + Player_Use = input("Hello, User. Welcome to the FIRST Robotics Team Menu! What would you like to do? ") + if Player_Use == 'add' or Player_Use == 'Add': + add() + elif Player_Use == 'view' or Player_Use == 'View': + view() + elif Player_Use == 'remove' or Player_Use == 'Remove': + remove() + elif Player_Use == 'search' or Player_Use == 'Search': + search() + elif Player_Use.lower() == "modify": + modify() + elif Player_Use.lower() == "view all teams": + list_teams(teams) + elif Player_Use == "quit": + print("Thanks for using this! See ya real soon!") + break; + else: + print("Sorry! I didn't get that! Please try again.") \ No newline at end of file diff --git a/ch_3_assign_Jonathan_Ho.py b/ch_3_assign_Jonathan_Ho.py new file mode 100644 index 0000000..ba70a37 --- /dev/null +++ b/ch_3_assign_Jonathan_Ho.py @@ -0,0 +1,120 @@ +Team_Data = {'1678': {'Name': 'Citrus Circuits', 'Location': 'Davis, CA, USA', 'Rookie': '2005', + 'Competition Names': [ + 'Central Valley Regional', + 'Sacramento Regional', + 'Aerospace Valley Regional', + 'Carver Division', + 'Einstein Field', + 'RCC Qianjiang International Robotics Invitational' + ], + + 'Competition Location': [ + 'Fresno, CA, USA', + 'Davis, CA, USA', + 'Lancaster, CA, USA', + 'Houston, TX, USA', + 'Houston TX, USA', + 'Hangzhou, Zhejiang, China' + ], + 'Awards': [ + 'Regional Chairman`s Award and Regional Winners', + 'FIRST Dean`s List Finalist Award (Katie Stachowicz), Regional Winners, and Industrial Design Award sponsored by General Motors', + 'Regional Winners and Excellence in Engineering Award sponsored by Delphi', 'Championship Subdivision Winner and Entrepreneurship Award sponsored by Kleiner Perkins Caufield and Byers' + ,]}, + + '41': {'Name': 'RoboWarriors', 'Location': 'Warren, NJ, USA', 'Rookie': '1997', + 'Competition Names': [ + 'FMA District Mount Olive Event', + 'FMA District Montgomery Event', + 'FIRST Mid-Atlantic District Championship' + ], + 'Competition Location': [ + 'Flanders, NJ, USA', + 'Skillman, NJ, USA', + 'Bethlehem, PA, USA' + ], + 'Awards': 'Innovation in Control Award sponsored by Rockwell Automation', + }, + + '7823': {'Name': 'Double Negative', 'Location': 'Rogers City, MI, USA', 'Rookie': '1997', + 'Competition Names': [ + 'FIM District Alpena Event #1', + 'FIM District Alpena Event #2', + 'Michigan State Championship - Ford Division', + ], + 'Competition Location': [ + 'Alpena, MI, USA', + 'Alpena, MI, USA', + 'University Center, MI, USA' + ], + 'Awards': [ + 'Highest Rookie Seed and Rookie Inspiration Award sponsored by National Instruments', + 'Rookie All Star Award and District Event Finalist', + 'Judges` Award' + ],} + } + + + +def list_teams_all(list_of_teams): + for Team_Data in list_of_teams: + print(str(Team_Data) + "\n") + +def add_team(): + Player_Add = input("Alright, let's add a some teams to our database! Choose a team or piece of info to place in the database. ") + if Player_Add.isdigit and Player_Add != None: + Team_Data[Player_Add] = {} + +def delete_team(): + Player_Delete = input("As you wish it. Which team would you like to remove from the database? ") + if Player_Delete.isdigit and Player_Delete != None: + Team_Data.pop(Player_Delete) + +def view_info(): + print("Just a head's up. Everything in the database for each team shown here is capitalized, so make sure the letter is uppercase for the second question. :P") + view_team = input("Now, which team would you like to view? ") + view_data = input("What would you like to know about it? ") + if view_team in Team_Data and view_data in Team_Data[view_team]: + print(Team_Data[view_team][view_data]) + else: + print("Sorry. This isn't in the data files. Try again.") + + +def modify_info(): + print("Just a head's up. Everything in the database for each team shown here is capitalized, so make sure the letter is uppercase for the second question. :P") + change_team = input("What team's data would you like to modify? ") + change_data = input("What datapoint would you like to change? ") + if change_team in Team_Data and change_data in Team_Data[change_team]: + print("This team's current value for " + change_data + " is " + Team_Data[change_team][change_data]) + change_datapoint = input("\n So what do you want to change about " + change_data + "? ") + Team_Data[change_team][change_data] = change_datapoint + print("Drumroll! The team's new value has been modified to... " + str(change_datapoint) + "!") + else: + print("Sorry. What you want to modify is not in our files. Try again.") + +def search(): + team_search = input("What team would ya like to look for? ") + print("Let's see... is " + str(team_search) + " anywhere in our database? " + str(team_search in Team_Data)) + +while True: + Player_Control = input('''Good morning, afternoon, and evening to all! Welcome to our FIRST Robotics Menu! What would you like to do here? Type in 'add' to add a team to the database, 'remove' to remove it + 'view' to check a team's data, 'modify' to change the data of the team, 'search' to ensure the teams you added to the database are in there, and 'see all teams' to look at the data in + the database. To leave, just type 'quit'. + ''') + if Player_Control == 'add' or Player_Control == 'Add': + add_team() + elif Player_Control == 'remove' or Player_Control == 'delete': + delete_team() + elif Player_Control == 'view' or Player_Control == 'View': + view_info() + elif Player_Control == 'modify' or Player_Control == 'change': + modify_info() + elif Player_Control == 'search' or Player_Control == 'Search': + search() + elif Player_Control == 'see all teams': + list_teams_all(Team_Data) + elif Player_Control == 'quit': + print("Gotcha! See ya around!") + break; + else: + print("Sorry! Did you say something else? Your reply is not valid. Please try again! :)") diff --git a/ch_4_assign_Jonathan_Ho.py b/ch_4_assign_Jonathan_Ho.py new file mode 100644 index 0000000..c8fabaa --- /dev/null +++ b/ch_4_assign_Jonathan_Ho.py @@ -0,0 +1,84 @@ +from math import sqrt + +# 2D Pythagorean Theorem +class Point(): + def __init__(self, x, y): + self.x = float(x) + self.y = float(y) + + # Pythagorean Theorem + def Distance(self): + hypo = self.x ** 2 + self.y ** 2 + return sqrt(hypo) + +# Three Dimensional Pythagorean Theorem +class Point_3D(Point): + def __init__(self, x, y, z): + self.z = float(z) + super().__init__(x, y) + + + def Distance(self): + hypo_2 = super().Distance() ** 2 + self.z ** 2 + return sqrt(hypo_2) + +while True: + Operation = input("What type of dimension do you want to use for the Pythagorean Theorem? If you wish to leave, type 'exit'.") + if Operation == "2D": + x = input("Enter the first value of your first leg of your triangle.") + y = input("Enter the second value of your next leg.") + # Assure if x and y are integers + if x.isdigit() and y.isdigit(): + point = Point(x, y).Distance() + print(point) + else: + print("Sorry, the variable is not a number. Try again.") + + elif Operation == "3D": + x = input("Enter the first value of the length of the side of your 3D rectangle.") + y = input("Enter the next value of the second length of your 3D rectangle.") + z = input("Now enter the height of your 3D rectangle") + # Validates if the inputs are integers for the code to use the if statement + if x.isdigit() and y.isdigit() and z.isdigit(): + calc_3D_point = Point_3D(x, y, z).Distance() + print(calc_3D_point) + else: + print("Sorry, your variable wasn't an integer. Try using a number.") + + # If the user wants to compare 2D and 3D points + elif Operation == "Origin": + # 2D + x = input("Enter the first value of your first leg of your triangle.") + y = input("Enter the second value of your next leg.") + # Assure if x and y are integers + if x.isdigit() and y.isdigit(): + point = Point(x, y) + print(point) + else: + print("Sorry, the variable is not a number. Try again.") + # 3D + x2 = input("Enter the first value of the length of the side of your 3D rectangle.") + y2 = input("Enter the next value of the second length of your 3D rectangle.") + z2 = input("Now enter the height of your 3D rectangle") + # Validates if the inputs are integers for the code to use the if statement + if x2.isdigit() and y2.isdigit() and z2.isdigit(): + calc_3D_point = Point_3D(x2, y2, z2) + print(calc_3D_point) + if point.Distance() > calc_3D_point.Distance(): + print("The point farthest from the origin is: (" + str(x) + ", " + str(y) + ").") + elif point.Distance() < calc_3D_point.Distance(): + print("The point farthest from the origin is: (" + str(x2) + ", " + str(y2) + ", " + str(z2) + ").") + elif point.Distance() == calc_3D_point.Distance(): + print("My, my. The distance from the origin between those two coordinates are equal. How coincidential!") + else: + print("Oops! I didn't get that. Try again.") + else: + print("Sorry, your variable wasn't an integer. Try using a number.") + + # If the user wishes to leave + elif Operation == "exit": + print("So long! Till we meet again.") + break; + # If the user types it incorrectly + else: + print("Sorry. Your response wasn't valid. Try 3D, 2D, or Origin.")