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..0bd2eee --- /dev/null +++ b/ch_4_assign_tommy_doherty.py @@ -0,0 +1,61 @@ +from math import sqrt #imports math and square root +import math + +def number_validation(number): #validation + return number.isdigit() + +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 + +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 = input('What is your x value for the 2D distance? ') #takes 2D input +while not number_validation(x): + print('not valid') + 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 = input('What is your y value for the 2D distance? ') + +print('your 2D point is') #prints 2D point +p_1 = Point2D(x, y) +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), 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') 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')