From 5147bd58495b366a78d92708bf2dac85130a4f0c Mon Sep 17 00:00:00 2001 From: ThomasDoherty5 <55568221+ThomasDoherty5@users.noreply.github.com> Date: Wed, 25 Sep 2019 18:56:38 -0700 Subject: [PATCH 1/3] Add files via upload --- filename.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 filename.py diff --git a/filename.py b/filename.py new file mode 100644 index 0000000..75d53c4 --- /dev/null +++ b/filename.py @@ -0,0 +1 @@ +print('5') From a4dbbb2e98be8b4c7f46550d24f9a73b0298fe77 Mon Sep 17 00:00:00 2001 From: ThomasDoherty5 Date: Wed, 30 Oct 2019 20:08:18 -0700 Subject: [PATCH 2/3] Add assignments --- ch_0_assign_tommy_doherty.py | 2 + ch_2_assign_tommy_doherty.py | 119 +++++++++++++++++++++++++++++ ch_3_assign_tommy_doherty.py | 142 +++++++++++++++++++++++++++++++++++ ch_4_assign_tommy_doherty.py | 62 +++++++++++++++ 4 files changed, 325 insertions(+) create mode 100644 ch_0_assign_tommy_doherty.py create mode 100644 ch_2_assign_tommy_doherty.py create mode 100644 ch_3_assign_tommy_doherty.py create mode 100644 ch_4_assign_tommy_doherty.py diff --git a/ch_0_assign_tommy_doherty.py b/ch_0_assign_tommy_doherty.py new file mode 100644 index 0000000..2d91c06 --- /dev/null +++ b/ch_0_assign_tommy_doherty.py @@ -0,0 +1,2 @@ +Sam = 'sexy' +print(Sam) \ No newline at end of file diff --git a/ch_2_assign_tommy_doherty.py b/ch_2_assign_tommy_doherty.py new file mode 100644 index 0000000..c7b1e3c --- /dev/null +++ b/ch_2_assign_tommy_doherty.py @@ -0,0 +1,119 @@ +teams = {} +command = '' +while command != 'quit': + command = input ('What would you like to do"(add a team, update a team, search a team, delete a team, list all teams, quit) ') + if command == 'add a team': #if you type add a team into menu + team_number = input('Team Number ') #makes team_number equal to user input + if team_number.isnumeric(): + teams[team_number] = {} #add team 7-20 + team_name = input ('Team Name ') + teams[team_number]["Team Name"] = team_name + programming_language = input ('Programming Language ') + teams[team_number]['Programming Language'] = programming_language + width = input ('Width ') + if width.isnumeric(): + teams[team_number]['Width'] = width + length = input ('Length ') + if length.isnumeric(): + teams[team_number]['Length'] = length + has_camera_vision = input ('Camera Vision, Enter Yes or No ') + if has_camera_vision == 'Yes' or has_camera_vision == 'No': + teams[team_number]['Camera Vision'] = has_camera_vision + number_of_drivetrain_motors = input ('Number of Drivetrain Motors ') + if number_of_drivetrain_motors.isnumeric(): + teams[team_number]['Number of Drivetrain Motors'] = number_of_drivetrain_motors + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + + if command == 'update a team': #update a team 21-42 + team_number = input('What team would you like to change? ') + if team_number.isnumeric(): + if team_number in teams.keys(): + attribute = input('What attribute would you like to change? ') + if attribute == 'team name' or attribute == 'programming language' or attribute == 'width' or attribute == 'length' or attribute == 'has camera vision' or attribute == 'number of drivetrain motors': + if attribute == 'team name': + team_name = input('Enter Team Name ') + if not team_name.isnumeric(): + teams[team_number]['Team Name'] = team_name + else: + print('Bruh') + if attribute == 'programming language': + programming_language = input('Enter Programming Language ') + if not programming_language.isnumeric(): #team name, team number, language, length, width + teams[team_number]['Programming Language'] = programming_language + else: + print('Bruh') + if attribute == 'width': + width = input('Enter Width ') + if width.isnumeric(): + teams[team_number]['Width'] = width + else: + print('bruh') + if attribute == 'length': + length = input('Enter Length ') + if length.isnumeric(): + teams[team_number]['Length'] = length + else: + print('Bruh') + if attribute == 'has camera vision': + has_camera_vision = input('Enter Yes or No ') + if has_camera_vision == 'Yes' or has_camera_vision == 'No': + teams[team_number]['Camera Vision'] = has_camera_vision + else: + print('Bruh') + if attribute == 'number of drivetrain motors': + number_of_drivetrain_motors = input('Number of Drivetrain Motors ') + if number_of_drivetrain_motors.isnumeric(): + teams[team_number]['Number of Drivetrain Motors'] = number_of_drivetrain_motors + else: + print('Bruh') + else: + print('Bruh') + else: + print('this is not an existing team') + else: + print('Bruh') + #end of update teams lines + + + + if command == 'list all teams': #list all teams 43-44 + print(teams) + if command == 'search for a team': #search for a team + search_team = input("What is the team you want to search? ") + if search_team not in teams: + print('Not In Dictionary') + if search_team in teams: + print("Yes, the team you are looking is in the dictionary") + print(teams[search_team]) + if command == 'delete a team': + delete_a_team = input('Which team would you like to delete?') + if delete_a_team not in teams: + print('Not in Dictionary') + if delete_a_team in teams: + teams.pop(delete_a_team) +#end of code + + + + + + + + + + + + + + + + diff --git a/ch_3_assign_tommy_doherty.py b/ch_3_assign_tommy_doherty.py new file mode 100644 index 0000000..c2286b3 --- /dev/null +++ b/ch_3_assign_tommy_doherty.py @@ -0,0 +1,142 @@ +#value = "hello". if not value.isalpha() == True: print("value is a number") +def add_team(): + team_number = input('Team Number ') #makes team_number equal to user input + if team_number.isnumeric(): + teams[team_number] = {} #add team 7-20 + team_name = input ('Team Name ') + if team_name.isalpha(): + teams[team_number]["Team Name"] = team_name + programming_language = input ('Programming Language ') + if programming_language.isalpha(): + teams[team_number]['Programming Language'] = programming_language + width = input ('Width ') + if width.isnumeric(): + teams[team_number]['Width'] = width + length = input ('Length ') + if length.isnumeric(): + teams[team_number]['Length'] = length + has_camera_vision = input ('Camera Vision, Enter Yes or No ') + if has_camera_vision == 'Yes' or has_camera_vision == 'No': + teams[team_number]['Camera Vision'] = has_camera_vision + number_of_drivetrain_motors = input ('Number of Drivetrain Motors ') + if number_of_drivetrain_motors.isnumeric(): + teams[team_number]['Number of Drivetrain Motors'] = number_of_drivetrain_motors + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + else: + print('Bruh') + + +def update_team(): + team_number = input('What team would you like to change? ') + if team_number.isnumeric(): + if team_number in teams.keys(): + attribute = input('What attribute would you like to change? ') + if attribute == 'team name' or attribute == 'programming language' or attribute == 'width' or attribute == 'length' or attribute == 'has camera vision' or attribute == 'number of drivetrain motors': + if attribute == 'team name': + team_name = input('Enter Team Name ') + if not team_name.isnumeric(): + teams[team_number]['Team Name'] = team_name + else: + print('Bruh') + if attribute == 'programming language': + programming_language = input('Enter Programming Language ') + if not programming_language.isnumeric(): #team name, team number, language, length, width + teams[team_number]['Programming Language'] = programming_language + else: + print('Bruh') + if attribute == 'width': + width = input('Enter Width ') + if width.isnumeric(): + teams[team_number]['Width'] = width + else: + print('bruh') + if attribute == 'length': + length = input('Enter Length ') + if length.isnumeric(): + teams[team_number]['Length'] = length + else: + print('Bruh') + if attribute == 'has camera vision': + has_camera_vision = input('Enter Yes or No ') + if has_camera_vision == 'Yes' or has_camera_vision == 'No': + teams[team_number]['Camera Vision'] = has_camera_vision + else: + print('Bruh') + if attribute == 'number of drivetrain motors': + number_of_drivetrain_motors = input('Number of Drivetrain Motors ') + if number_of_drivetrain_motors.isnumeric(): + teams[team_number]['Number of Drivetrain Motors'] = number_of_drivetrain_motors + else: + print('Bruh') + else: + print('Bruh') + else: + print('this is not an existing team') + else: + print('Bruh') + +def list_all_teams(): + print(teams) + +def search_for_a_team(): + search_team = input("What is the team you want to search? ") + if search_team not in teams: + print('Not In Dictionary') + if search_team in teams: + print("Yes, the team you are looking is in the dictionary") + print(teams[search_team]) + +def delete_a_team(): + delete_a_team = input('Which team would you like to delete?') + if delete_a_team not in teams: + print('Not in Dictionary') + if delete_a_team in teams: + teams.pop(delete_a_team) + +teams = {} +command = '' +while command != 'quit': + command = input ('What would you like to do"(add a team, update a team, search a team, delete a team, list all teams, quit) ') + + if command == 'add a team': + add_team() + + if command == 'update a team': + update_team() + + + if command == 'list all teams': + list_all_teams() + + if command == 'search for a team': + search_for_a_team() + + if command == 'delete a team': + delete_a_team() + + + + + + + + + + + + + + + + diff --git a/ch_4_assign_tommy_doherty.py b/ch_4_assign_tommy_doherty.py new file mode 100644 index 0000000..a5de203 --- /dev/null +++ b/ch_4_assign_tommy_doherty.py @@ -0,0 +1,62 @@ +from math import sqrt #imports math and square root +import math + +def number_validation(number): #validation + return number.isdigit() + +class Point3D: #3D point class + def __init__(self, x, y, z): + self.x = x + self.y = y + self.z = z + def distance(self): + d = (sqrt(math.pow(int(self.x), 2) + math.pow(int(self.y), 2) + math.pow(int(self.z), 2))) + return d + +class Point2D: #2D point class + def __init__(self, x_1, y_1,): + self.x_1 = x_1 + self.y_1 = y_1 + def distance(self): + d_1 = (sqrt(math.pow(int(x_1), 2) + math.pow(int(y_1), 2))) + return d_1 + +x = input('What is your x value? ') #takes input for 3D point +while not number_validation(x): + print('not valid') + x = input('What is your x value? ') +y = input('What is your y value? ') +while not number_validation(y): + print('not valid') + y = input('What is your y value? ') +z = input('What is your z value ') +while not number_validation(z): + print('not valid') + z = input('What is your z value ') + +p = Point3D(x, y, z) #prints 3D distance +print(p.distance()) + +x_1 = input('What is your x value for the 2D distance? ') #takes 2D input +while not number_validation(x_1): + print('not valid') + x_1 = input('What is your x value for the 2D distance? ') +y_1 = input('What is your y value for the 2D distance? ') +while not number_validation(y_1): + print('not valid') + y_1 = input('What is your y value for the 2D distance? ') + +print('your 2D point is') #prints 2D point +p_1 = Point2D(x_1, y_1) +print(p_1.distance()) + +if p.distance() > p_1.distance(): #determines which point is longer + print('The 3D distance is larger than the 2D point') +else: + print('The 2D distance is larger than the 3D point') +if p.distance() == p_1.distance(): + print('The distances are equal') +if (sqrt(math.pow(int(x_1), 2) + math.pow(int(y_1), 2))) > (sqrt(math.pow(int(x), 2) + math.pow(int(y), 2))): #prints which xy distance is furthest + print('The 2D x,y is further away from the orgin than the 3D points x,y') +else: + print('The 3D x,y is further away from the orgin than the 2D points x,y') From 420676fb0f870e1d47cc0a086aaf9d2a1669ceb6 Mon Sep 17 00:00:00 2001 From: ThomasDoherty5 Date: Wed, 6 Nov 2019 19:40:48 -0800 Subject: [PATCH 3/3] Fix Inheritance --- ch_4_assign_tommy_doherty.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/ch_4_assign_tommy_doherty.py b/ch_4_assign_tommy_doherty.py index a5de203..0bd2eee 100644 --- a/ch_4_assign_tommy_doherty.py +++ b/ch_4_assign_tommy_doherty.py @@ -4,23 +4,22 @@ def number_validation(number): #validation return number.isdigit() -class Point3D: #3D point class - def __init__(self, x, y, z): +class Point2D: #2D point class + def __init__(self, x, y): self.x = x self.y = y + def distance(self): + d_1 = (sqrt(math.pow(int(x), 2) + math.pow(int(y), 2))) + return d_1 + +class Point3D(Point2D): #3D point class + def __init__(self, x, y, z): + super().__init__(x, y) self.z = z def distance(self): d = (sqrt(math.pow(int(self.x), 2) + math.pow(int(self.y), 2) + math.pow(int(self.z), 2))) return d -class Point2D: #2D point class - def __init__(self, x_1, y_1,): - self.x_1 = x_1 - self.y_1 = y_1 - def distance(self): - d_1 = (sqrt(math.pow(int(x_1), 2) + math.pow(int(y_1), 2))) - return d_1 - x = input('What is your x value? ') #takes input for 3D point while not number_validation(x): print('not valid') @@ -37,17 +36,17 @@ def distance(self): p = Point3D(x, y, z) #prints 3D distance print(p.distance()) -x_1 = input('What is your x value for the 2D distance? ') #takes 2D input -while not number_validation(x_1): +x = input('What is your x value for the 2D distance? ') #takes 2D input +while not number_validation(x): print('not valid') - x_1 = input('What is your x value for the 2D distance? ') -y_1 = input('What is your y value for the 2D distance? ') -while not number_validation(y_1): + x = input('What is your x value for the 2D distance? ') +y = input('What is your y value for the 2D distance? ') +while not number_validation(y): print('not valid') - y_1 = input('What is your y value for the 2D distance? ') + y = input('What is your y value for the 2D distance? ') print('your 2D point is') #prints 2D point -p_1 = Point2D(x_1, y_1) +p_1 = Point2D(x, y) print(p_1.distance()) if p.distance() > p_1.distance(): #determines which point is longer @@ -56,7 +55,7 @@ def distance(self): print('The 2D distance is larger than the 3D point') if p.distance() == p_1.distance(): print('The distances are equal') -if (sqrt(math.pow(int(x_1), 2) + math.pow(int(y_1), 2))) > (sqrt(math.pow(int(x), 2) + math.pow(int(y), 2))): #prints which xy distance is furthest +if (sqrt(math.pow(int(x), 2) + math.pow(int(y), 2))) > (sqrt(math.pow(int(x), 2) + math.pow(int(y), 2))): #prints which xy distance is furthest print('The 2D x,y is further away from the orgin than the 3D points x,y') else: print('The 3D x,y is further away from the orgin than the 2D points x,y')