diff --git "a/\"ch_1_lesson_sophia_palomares.py\"" "b/\"ch_1_lesson_sophia_palomares.py\"" new file mode 100644 index 0000000..eb3d840 --- /dev/null +++ "b/\"ch_1_lesson_sophia_palomares.py\"" @@ -0,0 +1,3 @@ +"ch_1_lesson_sophia_palomares.py" + +print('Hello, World') \ No newline at end of file diff --git a/ch_1_assign_remake_sophia_palomares.py b/ch_1_assign_remake_sophia_palomares.py new file mode 100644 index 0000000..f4cbca0 --- /dev/null +++ b/ch_1_assign_remake_sophia_palomares.py @@ -0,0 +1,64 @@ + +dictionary_1678 = { + "rookie year" : 2005, + "location" : "Davis, California, USA", + "compete in 2019" : True, + "competitions and locations" : "Central Valley Regional: Fresno, Ca, USA; Sacramento Reagional: Sacramento, CA, USA; Aerospace Valley Regional: Lancaster, CA, USA; Carver Division: Houston, TX, USA; Einstein Field: Houston, TX, USA.", + "awards" : "CHAIRMAN'S AWARD, CENTRAL VALLEY REGIONAL WINNER, SACRAMENTO REGIONAL WINNER, AEROSPACE VALLEY REGIONAL WINNER", +} + +dictionary_1682 = { + "rookie year" : 2005, + "location" : "Riverside, California, USA", + "compete in 2019" : False, + "competitions" : "None", + "competitions and locations" : "None", + "awards" : "None" +} + +dictionary_1690 = { + "rookie year" : 2005, + "location" : "Binyamina, HaZafon, Israel", + "competions and locations" : "ISR District Event #1: Haifa, HA 00000, Israel; ISR District Event #4: Tel Aviv-Yafo, TA 00000, Israel; FIRST Israel District Championship: Tel Aviv-Yafo, TA 00000, Israel; Darwin Division: Detroit, MI, USA; Indiana Robotics Invitational: Indianapolis, IN, USA;", + "awards" : "None" +} + +dictionary_1700 = { + "rookie year" : 2005, + "location" : "Palo Alto, California, USA", + "compete in 2019" : True, + "competitions and locations" : "San Francisco Regionals: San Francisco, CA, USA; Utah Regionals: West Valley City, Utah, USA; Turing Devision: Houston, TX, USA", + "awards" : "None" +} + +dictionary_2907 = { + "rookie year" : 2009, + "location" : "Auburn, Washington, USA", + "compete in 2019" : True, + "competitions and locations" : "PNW District Auburn Mountainview Event: Auburn, WA, USA; NW District West Valley Event: Spokane, WA, USA; PNW District Auburn Event: Auburn, WA, USA; Pacific Northwest FIRST District Championship: Tacoma, WA, USA; Roebling Division: Houston, TX, USA; Einstein Field: Houston, TX, USA; Peak Performance: Sea Tac, WA, USA;", + "awards" : "2019 PACIFIC NORTHWEST FIRST DISTRICT CHAMPIONSHIP, 2019 ROEBLING DIVISION", +} + +dictionary_3132 = { + "rookie year" : 2010, + "location" : "Sydney, New South Wales, Australia", + "compete in 2019" : True, + "competitions and locations" : "Southern Cross Regional: Sydney Olympic Park, NSW, Australia; NSouth Pacific Regional: Sydney Olympic Park, NSW, Australia; Carver Division: Houston, TX, USA; Einstein Field: Houston, TX, USA; Duel Down Under: Sydney, New South Wales, Australia;", + "awards" : "2019 SOUTHERN CROSS REGIONAL, 2019 CARVER DIVISION", +} + +teams = { + 1678 : dictionary_1678, + 1682 : dictionary_1682, + 1690 : dictionary_1690, + 1700 : dictionary_1700, + 2907 : dictionary_2907, + 3132 : dictionary_3132, +} + +def team_info(): + question1 = int(input("What team would you like to look up? options: 1678, 1682, 1690, 1700, 2907, 3132")) + question2 = input("What about the team would you like to know? options: rookie year, locations, competitions and locations, awards ") + print(teams[question1][question2]) + +team_info() \ No newline at end of file diff --git a/ch_1_assign_sophia_palomares.py b/ch_1_assign_sophia_palomares.py new file mode 100644 index 0000000..0f5e678 --- /dev/null +++ b/ch_1_assign_sophia_palomares.py @@ -0,0 +1,51 @@ +teams = { + 1678 : { + "rookie year" : 2005, + "location" : "Davis, California, USA", + "compete in 2019" : True, + "competitions and locations" : "Central Valley Regional: Fresno, Ca, USA; Sacramento Reagional: Sacramento, CA, USA; Aerospace Valley Regional: Lancaster, CA, USA; Carver Division: Houston, TX, USA; Einstein Field: Houston, TX, USA.", + "awards" : "CHAIRMAN'S AWARD, CENTRAL VALLEY REGIONAL WINNER, SACRAMENTO REGIONAL WINNER, AEROSPACE VALLEY REGIONAL WINNER", + }, + 1682 : { + "rookie year" : 2005, + "location" : "Riverside, California, USA", + "compete in 2019" : False, + "competitions" : "None", + "competitions and locations" : "None", + "awards" : "None" + }, + 1690 : { + "rookie year" : 2005, + "location" : "Binyamina, HaZafon, Israel", + "compete in 2019" : True, + "competions and locations" : "ISR District Event #1: Haifa, HA 00000, Israel; ISR District Event #4: Tel Aviv-Yafo, TA 00000, Israel; FIRST Israel District Championship: Tel Aviv-Yafo, TA 00000, Israel; Darwin Division: Detroit, MI, USA; Indiana Robotics Invitational: Indianapolis, IN, USA;", + "awards" : "None", + }, + 1700 : { + "rookie year" : 2005, + "location" : "Palo Alto, California, USA", + "compete in 2019" : True, + "competitions and locations" : "San Francisco Regionals: San Francisco, CA, USA; Utah Regionals: West Valley City, Utah, USA; Turing Devision: Houston, TX, USA", + "awards" : "None" + }, + 2907 : { + "rookie year" : 2009, + "location" : "Auburn, Washington, USA", + "compete in 2019" : True, + "competitions and locations" : "PNW District Auburn Mountainview Event: Auburn, WA, USA; NW District West Valley Event: Spokane, WA, USA; PNW District Auburn Event: Auburn, WA, USA; Pacific Northwest FIRST District Championship: Tacoma, WA, USA; Roebling Division: Houston, TX, USA; Einstein Field: Houston, TX, USA; Peak Performance: Sea Tac, WA, USA;", + }, + 3132 : { + "rookie year" : 2010, + "location" : "Sydney, New South Wales, Australia", + "compete in 2019" : True, + "competitions and locations" : "Southern Cross Regional: Sydney Olympic Park, NSW, Australia; NSouth Pacific Regional: Sydney Olympic Park, NSW, Australia; Carver Division: Houston, TX, USA; Einstein Field: Houston, TX, USA; Duel Down Under: Sydney, New South Wales, Australia;", + "awards" : "2019 SOUTHERN CROSS REGIONAL, 2019 CARVER DIVISION", + }, +} + +def look_team(): + question1 = int(input("What team would you like to look up? options: 1678, 1682, 1690, 1700, 2907, 3132 ")) + question2 = input("What about the team would you like to know? options: rookie year, location, competitions and locations, awards ") + print(teams[question1][question2]) + +look_team() \ No newline at end of file diff --git a/ch_1_lesson_sophia_palomares.py b/ch_1_lesson_sophia_palomares.py new file mode 100644 index 0000000..eb3d840 --- /dev/null +++ b/ch_1_lesson_sophia_palomares.py @@ -0,0 +1,3 @@ +"ch_1_lesson_sophia_palomares.py" + +print('Hello, World') \ No newline at end of file diff --git a/ch_2_assign_sophia_palomares.py b/ch_2_assign_sophia_palomares.py new file mode 100644 index 0000000..94da108 --- /dev/null +++ b/ch_2_assign_sophia_palomares.py @@ -0,0 +1,180 @@ +teams = {} +team_aspects = ["name", "programming language", "width", "length", "camera vision system", "drivetrain motors", "team number"] +number_aspects = ["width", "length", "drivetrain motors"] +word_aspects = ["name", "programming language", "camera vision system"] + +#List of Function Operations: +#name_number functions: make team names and number interchangeable for specified functions +#remove_team: removes a team +#modify_team: modifies an attribute of a team +#search_team: searches for an attribute of a team +#add_team: adds a team to the main teams dictionary +#list_team: lists the team #, or keys in the teams dictionary +#exit_program: leaves the program +#validation: validates input for add team function +#main_function: The "main menu" for the other operations + +def remove_team_name_number(): + user_remove = input("What team do you want to remove? ") + for team_name_remove in teams: + if teams[team_name_remove]["name"] == user_remove: + remove_team(team_name_remove) + elif user_remove.isnumeric(): + if int(user_remove) == team_name_remove: + remove_team(team_name_remove) + +def remove_team(team_name_remove): + teams.pop(team_name_remove) + + main_function() + +def modify_team_name_number(): + user_modify = input("What team do you want to modify? ") + for team_name_modify in teams: + if teams[team_name_modify]["name"] == user_modify: + modify_team(team_name_modify) + elif user_modify.isnumeric(): + if int(user_modify) == team_name_modify: + modify_team(team_name_modify) + +def modify_team(team_name_modify): + print("Options:") + print(team_aspects) + team_attribute_modify = input("What would you like to modify about the team? ") + for team_aspect in team_aspects: + if team_attribute_modify == team_aspect: + new_attribute = input("What is the team's updated attribute? ") + for attribute in number_aspects: + if team_attribute_modify == attribute: + new_attribute = validation_number(new_attribute) + break + for attribute in word_aspects: + if team_attribute_modify == attribute: + new_attribute = validation_word(new_attribute) + break + teams[team_name_modify][team_aspect] = new_attribute + break + else: + print("Input Unknown") + modify_team(team_name_modify) + + main_function() + +def add_team(): + temp_team_dictionary = {} + + name = input("What is the name of your team? ") + val_name = validation_word(name) + p_language = input("What is your team's programming language? ") + val_p_language = validation_word(p_language) + width = input("What is your team's robot's width? ") + val_width = validation_number(width) + length = input("Wnat is your team's robot's length? ") + val_length = validation_number(length) + cam_vision = input("Does your team's robot's have a camera vision system? ") + val_cam_vision = validation_word(cam_vision) + drive_motors = input("How many drivetrain motors does your team have? ") + val_drive_motors = validation_number(drive_motors) + + temp_team_dictionary["name"] = val_name + temp_team_dictionary["programming language"] = val_p_language + temp_team_dictionary["width"] = val_width + temp_team_dictionary["length"] = val_length + temp_team_dictionary["camera vision system"] = val_cam_vision + temp_team_dictionary["drivetrain motors"] = val_drive_motors + + team_number_input = input("Add a team number ") + + if team_number_input[0].isdigit(): + team_number_input = int(team_number_input) + teams[team_number_input] = temp_team_dictionary + + else: + print("Input wasn't a number, please enter a team number") + team_number_input = int(input("Add a team number ")) + teams[team_number_input] = temp_team_dictionary + + main_function() + +def validation_number(user_input): + if user_input.isdigit(): + user_input = int(user_input) + return user_input + else: + print("User input wasn't a number, please enter a number.") + user_new_input = input("Please enter new answer: ") + validation_number(user_new_input) + return user_new_input + +def validation_word(user_input): + if user_input.isdigit() == False: + return user_input + else: + print("User input wasn't a word, please enter a word") + user_new_input = input("Please enter new answer: ") + validation_word(user_new_input) + return user_new_input + +def search_team_name_number(): + user_search = input("What team do you want to search? ") + for team_name_search in teams: + if teams[team_name_search]["name"] == user_search: + search_team(team_name_search) + elif user_search.isnumeric(): + if int(user_search) == team_name_search: + search_team(team_name_search) + +def search_team(team_name_search): + print("Options:") + print(team_aspects) + user_search_specific = input("What would you like to look up about a team? ") + for team_aspect in team_aspects: + if user_search_specific == team_aspect: + print(user_search_specific) + print(teams[team_name_search][user_search_specific]) + break + else: + print("Unknown Input") + search_team(team_name_search) + + main_function() + +def list_team(): + print(teams.keys()) + + main_function() + +def exit_program(): + print("You are choosing to exit the program") + user_exit = input("Are you sure you want to leave? (y/n) ") + if user_exit == "y": + "You are now leaving the program" + return + elif user_exit == "n": + "You chose to stay in the program" + main_function() + else: + print("Input is unknown. Please input y or n") + exit_program() + +def main_function(): + print("Options:") + print("add team, remove team, modify team, list of teams, search for team, exit") + user_question_1 = input("What would you like to do? ") + if user_question_1 == "add team": + add_team() + elif user_question_1 == "modify team": + modify_team_name_number() + elif user_question_1 == "remove team": + remove_team_name_number() + elif user_question_1 == "search for team": + search_team_name_number() + elif user_question_1 == "list of teams": + list_team() + elif user_question_1 == "exit": + exit_program() + else: + print("Input is unknown.") + main_function() + +main_function() \ No newline at end of file diff --git a/ch_3_assign_sophia_palomares.py b/ch_3_assign_sophia_palomares.py new file mode 100644 index 0000000..11e34c4 --- /dev/null +++ b/ch_3_assign_sophia_palomares.py @@ -0,0 +1,280 @@ +teams = { + 1678 : { + "rookie year" : 2005, + "location" : "Davis, California, USA", + "compete in 2019" : True, + "competitions and locations" : { + "Central Valley Regional" : "Fresno, Ca, US", + "Sacramento Reagional" : "Sacramento, CA, USA", + "Aerospace Valley Regional" : "Lancaster, CA, USA", + "Carver Division" : "Houston, TX, USA", + "Einstein Field" : "Houston, TX, USA" + }, + "awards" : "CHAIRMAN'S AWARD, CENTRAL VALLEY REGIONAL WINNER, SACRAMENTO REGIONAL WINNER, AEROSPACE VALLEY REGIONAL WINNER", + }, + 1682 : { + "rookie year" : 2005, + "location" : "Riverside, California, USA", + "compete in 2019" : False, + "competitions" : "None", + "competitions and locations" : {}, + "awards" : "None" + }, + 1690 : { + "rookie year" : 2005, + "location" : "Binyamina, HaZafon, Israel", + "compete in 2019" : True, + "competitions and locations" : { + "ISR District Event #1" : "Haifa, HA 00000, Israel", + "ISR District Event #4" : "Tel Aviv-Yafo, TA 00000, Israel", + "FIRST Israel District Championship" : "Tel Aviv-Yafo, TA 00000, Israel", + "Darwin Division": "Detroit, MI, USA", + "Indiana Robotics Invitational" : "Indianapolis, IN, USA;" + }, + "awards" : "None", + }, + 1700 : { + "rookie year" : 2005, + "location" : "Palo Alto, California, USA", + "compete in 2019" : True, + "competitions and locations" : { + "San Francisco Regionals" : "San Francisco, CA, USA", + "Utah Regionals" : "West Valley City, Utah, USA", + "Turing Devision": "Houston, TX, USA" + }, + "awards" : "None" + }, + 2907 : { + "rookie year" : 2009, + "location" : "Auburn, Washington, USA", + "compete in 2019" : True, + "competitions and locations" : { + "PNW District Auburn Mountainview Event" : "Auburn, WA, USA", + "NW District West Valley Event" : "Spokane, WA, USA", + "PNW District Auburn Event" : "Auburn, WA, USA", + "Pacific Northwest FIRST District Championship" : "Tacoma, WA, USA", + "Roebling Division" : "Houston, TX, USA", + "Einstein Field" : "Houston, TX, USA", + "Peak Performance": "Sea Tac, WA, USA;" + }, + "awards" : "None" + }, + 3132 : { + "rookie year" : 2010, + "location" : "Sydney, New South Wales, Australia", + "compete in 2019" : True, + "competitions and locations" : { + "Southern Cross Regional" : "Sydney Olympic Park, NSW, Australia", + "NSouth Pacific Regional" : "Sydney Olympic Park, NSW, Australia", + "Carver Division" : "Houston, TX, USA", + "Einstein Field" : "Houston, TX, USA", + "Duel Down Under" : "Sydney, New South Wales, Australia;" + }, + "awards" : "2019 SOUTHERN CROSS REGIONAL, 2019 CARVER DIVISION", + }, +} + +team_aspects = ["rookie year", "location", "compete in 2019", "competitions and locations", "awards", "team number"] + +"""List of Function Operations: +remove_team: removes a team +modify_team: modifies an attribute of a team +search_team: searches for an attribute of a team +add_team: adds a team to the main teams dictionary +comp_local: makes a seperate dictionary for the competitions and locations for a team +list_team: lists the team #, or keys in the teams dictionary +exit_program: leaves the program +ensure_team: ensures all team inputs are actual teams in the dictionary +validate: validates input for add team function +main_function: The "main menu" for the other operations""" + +def remove_team(): + user_remove = input("What team? ") + user_input = ensure_team(user_remove) + teams.pop(user_input) + + main_function() + +def modify_team(): + user_modify = input("What team do you want to modify? ") + user_input = ensure_team(user_modify) + print("Options:") + print(team_aspects) + team_attribute_modify = input("What would you like to modify about the team? ") + for team_aspect in team_aspects: + if team_attribute_modify == team_aspect: + new_attribute = input("What is the team's updated attribute? ") + teams[user_input][team_aspect] = new_attribute + break + elif team_attribute_modify == team_aspects[3]: + teams[user_input]["competitions and locations"] = comp_local() + teams[user_input]["compete in 2019"] = True + break + elif team_attribute_modify == team_aspects[2]: + new_compete = input("Did the team compete in 2019? (y/n) ") + if new_compete == "y": + teams[user_input][team_aspect[2]] = True + comp_local_modify = input("Would you like to add competitions? (y/n) ") + while True: + if comp_local_modify == "y": + teams[user_input]["competitions and locations"] = comp_local() + break + elif comp_local_modify == "n": + teams[user_input]["competitions and locations"] = "None" + break + else: + print("Unknown input, please input y or n") + break + elif new_compete == "n": + teams[user_input]["compete in 2019"] = False + teams[user_input][team_aspects[3]] = "None" + break + else: + print("Input Unknown") + modify_team() + + main_function() + +def add_team(): + temp_team_dictionary = {} + + rookie = input("What is the rookie year for your team? ") + location = input("What is your team's location? ") + compete = input("Did your team compete in 2019? (yes/no) ") + if compete == "yes": + compete = True + temp_team_dictionary["competitions and locations"] = comp_local() + elif compete == "no": + compete = False + temp_team_dictionary["competitions and locations"] = ["None, didn't compete"] + awards = input("What award did your team win? ") + + temp_team_dictionary["rookie year"] = rookie + temp_team_dictionary["location"] = location + temp_team_dictionary["compete in 2019"] = compete + temp_team_dictionary["awards"] = awards + + team_number_input = input("Add a team number ") + + if team_number_input[0].isdigit(): + team_number_input = int(team_number_input) + teams[team_number_input] = temp_team_dictionary + + else: + print("Input wasn't a number, please enter a team number") + team_number_input = int(input("Add a team number ")) + teams[team_number_input] = temp_team_dictionary + + validation(team_number_input) + main_function() + +def comp_local(comp_local_dict={}): + comp_local_input = input("Would you like to add a competition and location? (y/n) ") + while True: + if comp_local_input == "y": + comp = input("What competition did your team compete in? ") + comp_location = input("Where was that competition? ") + comp_local_dict[comp] = comp_location + return comp_local(comp_local_dict) + elif comp_local_input == "n": + return comp_local_dict + else: + print("Unknown input. Please input y or n") + +def validation(team_number_input): + for data_field in ["rookie year"]: + if teams[team_number_input][data_field].isdigit(): + teams[team_number_input][data_field] = int(teams[team_number_input][data_field]) + else: + print("Input wasn't a number, please enter number for") + print(data_field) + teams[team_number_input][data_field] = int(input("Please enter the new answer ")) + for data_field in ["location", "awards"]: + if teams[team_number_input][data_field].isdigit() == False: + teams[team_number_input][data_field] = str(teams[team_number_input][data_field]) + else: + print("Input was a number, please enter a word for") + print(data_field) + teams[team_number_input][data_field] = str(input("Please enter the new answer ")) + +def search_team(): + user_search = input("What team? ") + user_input = ensure_team(user_search) + print("Options:") + print(team_aspects) + user_search_specific = input("What would you like to look up about a team? ") + for team_aspect in team_aspects: + if user_search_specific == team_aspect: + print(user_search_specific) + print(teams[user_input][user_search_specific]) + break + else: + print("Unknown Input") + search_team() + + main_function() + +def ensure_team(user_input): + if user_input.isdigit(): + user_input = int(user_input) + for team in teams.keys(): + if user_input == team: + return user_input + else: + print("Input wasn't a team number, please enter a team number") + print("Options") + print(teams.keys()) + user_input = int(input("Enter team number ")) + return user_input + elif user_input.isdigit() == False: + print("Input wasn't a number, please enter a number") + user_input = int(input("Enter team number ")) + for team in teams.keys(): + if user_input == team: + return user_input + else: + print("Input wasn't a team number, please enter a team number") + print("Options") + print(teams.keys()) + user_input = int(input("Enter team number ")) + return user_input + +def list_team(): + print(teams.keys()) + + main_function() + +def exit_program(): + print("You are choosing to exit the program") + user_exit = input("Are you sure you want to leave? (y/n) ") + if user_exit == "y": + "You are now leaving the program" + return + elif user_exit == "n": + "You chose to stay in the program" + main_function() + else: + print("Input is unknown. Please input y or n") + exit_program() + +def main_function(): + print("Options:") + print("add team, remove team, modify team, list of teams, search for team, exit") + user_question_1 = input("What would you like to do? ") + if user_question_1 == "add team": + add_team() + elif user_question_1 == "modify team": + modify_team() + elif user_question_1 == "remove team": + remove_team() + elif user_question_1 == "search for team": + search_team() + elif user_question_1 == "list of teams": + list_team() + elif user_question_1 == "exit": + exit_program() + else: + print("Input is unknown.") + main_function() + +main_function() \ No newline at end of file diff --git a/ch_4_assign_sophia_palomares.py b/ch_4_assign_sophia_palomares.py new file mode 100644 index 0000000..54b4952 --- /dev/null +++ b/ch_4_assign_sophia_palomares.py @@ -0,0 +1,72 @@ +from math import sqrt + +class Point: + def __init__(self, x, y): + self.x = x + self.y = y + + def distance(self): + self.distance_solve = sqrt(self.x**2 + self.y**2) + return self.distance_solve + +class Point3D(Point): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + + def distance(self): + self.distance_3D_solve = sqrt(super().distance()**2 + self.z**2) + return self.distance_3D_solve + +def distance_maker(): + print("you are finding the hypotonuse of a 2D triangle") + x_input = input("What is the x value? ") + x_input = validation(x_input) + y_input = input("what is the y value? ") + y_input = validation(y_input) + hyp = Point(x_input, y_input) + return hyp + +def distance_maker_3D(): + print("you are finding the hypotonuse of a 3D triangle") + x_input = input("What is the x value? ") + x_input = validation(x_input) + y_input = input("what is the y value? ") + y_input = validation(y_input) + z_input = input("What is the z value? ") + z_input = validation(z_input) + hyp_3D = Point3D(x_input, y_input, z_input) + return hyp_3D + +def checker(): + p1 = distance_maker() + print("This is the hypotenuse for the 2D triangle") + print(p1.distance()) + p2 = distance_maker_3D() + print("This is the hypotenuse for the 3D triangle") + print(p2.distance()) + if p1.distance() > p2.distance(): + print("2D-hypotenuse is bigger") + elif p1.distance() == p2.distance(): + print("The hypotenuses are equal") + else: + print("3D-hypotenuse is bigger") + +def validation(user_input): + if user_input.isdigit(): + int_user_input = int(user_input) + return int_user_input + else: + print("User input wasn't a number, please enter a number.") + user_new_input = input("Please enter new answer: ") + try: + user_new_input = int(user_new_input) + return user_new_input + except ValueError: + validation(user_new_input) + return user_new_input + except TypeError: + validation(user_new_input) + return user_new_input + +checker() \ No newline at end of file diff --git a/ch_4_sophia_palomares.py b/ch_4_sophia_palomares.py new file mode 100644 index 0000000..b861204 --- /dev/null +++ b/ch_4_sophia_palomares.py @@ -0,0 +1,64 @@ +from math import sqrt + +class Point: + def __init__(self, x, y): + self.x = x + self.y = y + + def distance(self): + self.distance_solve = sqrt(self.x**2 + self.y**2) + return self.distance_solve + +class Point3D(Point): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + + def distance(self): + self.distance_3D_solve = sqrt(super().distance()**2 + self.z**2) + return self.distance_3D_solve + +def distance_maker(): + print("you are finding the hypotonuse of a 2D triangle") + x_input = input("What is the x value? ") + x_input = validation(x_input) + y_input = input("what is the y value? ") + y_input = validation(y_input) + hyp = Point(x_input, y_input) + return hyp + +def distance_maker_3D(): + print("you are finding the hypotonuse of a 3D triangle") + x_input = input("What is the x value? ") + x_input = validation(x_input) + y_input = input("what is the y value? ") + y_input = validation(y_input) + z_input = input("What is the z value? ") + z_input = validation(z_input) + hyp_3D = Point3D(x_input, y_input, z_input) + return hyp_3D + +def checker(): + p1 = distance_maker() + print("This is the hypotenuse for the 2D triangle") + print(p1.distance()) + p2 = distance_maker_3D() + print("This is the hypotenuse for the 3D triangle") + print(p2.distance()) + if p1.distance() > p2.distance(): + print("2D-hypotenuse is bigger") + elif p1 == p2: + print("The hypotenuses are equal") + else: + print("3D-hypotenuse is bigger") + +def validation(user_input): + if user_input.isdigit(): + user_input = int(user_input) + return user_input + else: + print("Input wasn't a number, please enter a number.") + user_new_input = input("Please enter a value: ") + validation(user_new_input) + +checker() \ No newline at end of file diff --git a/div_checker.py b/div_checker.py new file mode 100644 index 0000000..7352248 --- /dev/null +++ b/div_checker.py @@ -0,0 +1,19 @@ +def div_checker(): + input1 = int(input("What is the first #? ")) + input2 = int(input("What is the second #? ")) + answer1 = input1 / input2 + answer2 = input2 / input1 + for answer in [answer1, answer2]: + if isinstance(answer,float): + answer_int = int(answer) + answer_check = answer - answer_int + if answer_check == 0.0: + print("Yes they are divisable") + print(answer) + break + else: + break + else: + print("No they aren't divisable") + +div_checker() \ No newline at end of file