Skip to content
76 changes: 76 additions & 0 deletions ch_1_assign_adam_wu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
teams_dictionary = {
1678:{
"location":"Davis_CA_USA",
"rookie_year":"2005",
"2019_comp_status":True,
"2019_comp_name":[
"Central_Valley_Regional",
"Sacramento_Regional",
"Aerospace_Valley_Regional",
"Carver_Division",
"Einstein_Field_Houston",
"RCC_Qianjiang_International_Robotics_Invitational",
"Chezy_Champs"],
"2019_comp_location":[
"Fresno_CA_USA",
"Davis_CA_USA",
"Lancaster_CA_USA",
"Houston_TX_USA",
"Houston_TX_USA",
"Hangzhou_Zhejiang_CHN",
"SanJose_CA_USA"],
"2019_season_awards":[
"Regional_Chairmans",
"Regional_Winners",
"Deans_List_Finalist",
"Regional_Winners",
"Industrial_Design",
"Regional_Winners",
"Excellence_Engineering",
"Championship_Subdivision_Winner"]},
5000:{
"location":"Hingham_MA_USA",
"rookie_year":"2014",
"2019_comp_status":True,
"2019_comp_name":[
"NE_District_SE_Mass_Event",
"NE_District_Rhode_Island_Event"],
"2019_comp_location":[
"Bridgewater_MA_02324_USA",
"Smithfield_RI_02917_USA"],
"2019_season_awards":[]},
69:{
"location":"Quincy_MA_USA",
"rookie_year":"1998",
"2019_comp_status":True,
"2019_comp_name":[
"NE_District_SE_Mass_Event",
"NE_District_UNH_Event",
"New_England_District_Championship"],
"2019_comp_location":[
"Bridgewater_MA_02324_USA",
"Durham_NH_03824_USA",
"Worcester_MA_USA"],
"2019_season_awards":[
"District_Event_Finalist",
"Creativity_Award_sponsored_by_Xerox",]},
590:{
"location":"Choctaw_MS_USA",
"rookie_year":"2001",
"2019_comp_status":True,
"2019_comp_name":[
"Bayou_Regional"],
"2019_comp_location":[
"Kenner_LA_70065_USA"],
"2019_season_awards":[]},
3686:{
"location":"Memphis_TN_USA",
"rookie_year":"2011",
"2019_comp_status":False,
"2019_comp_name":[],
"2019_comp_location":[],
"2019_season_awards":[]}
}
team_input = int(input('choose an FRC team: 1678, 5000, 69, 590, or 3689.\n'))
team_attribute = str(input('enter an attribute, "location", "rookie_year", "2019_comp_status", "2019_comp_name", "2019_comp_location", or "2019_season_awards".\n').lower())
print(teams_dictionary[team_input][team_attribute])
1 change: 1 addition & 0 deletions ch_1_lesson_Adam_Wu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('Hello, World!')
120 changes: 120 additions & 0 deletions ch_2_assign_adam_wu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
def team_add_function():
team_number = input('Please enter team number you would like to add/change:\n')
if team_number.isnumeric():
teams.update({team_number:{}})
else:
print('please enter a number')

return

user_input = '1'
while True:


for key in team_menu.keys():
print(str(key) +': '+team_menu[key]['property'])

#user_input will allow you to exit the program
user_input = int(input('enter number corresponding to what you would like to add/change \n'))
key_entered = user_input

if user_input == 0:
break

want_to_change = team_menu[key_entered]

#val_change is the variable for new values
if user_input == 4:
val_change = input('enter 1 for true and 0 for false\n')
else:
val_change = input('what is the new value for ' + want_to_change['property']+'\n')
try:
if want_to_change['type'] == 'str':
try:
if val_change.isnumeric():
print('please enter a number')
except:
print("Oops! please make sure you enter a " + str(want_to_change['type']))
print("Next entry.")

elif want_to_change['type'] == 'int':
val_change = int(val_change)
elif want_to_change['type'] == 'bool':
val_change = int(val_change)
val_change = val_change == 1
teams[team_number][want_to_change['property']] = val_change

except:
print("Oops! please make sure you enter a " + want_to_change['type'])
print("Next entry.")

print(teams)

def team_delete_function():
team_name = input('delete which team? \n')
if team_name.isnumeric():
if team_name in teams.keys():
print(teams.keys())
teams.pop(team_name)
print(teams.keys())
else:
print('team ' + team_name +' does not exist')
else:
print('please enter an integer \n')

def team_search_function():
team_search = input('what team would you like to search? \n')
#team_search_validation = False
if team_search in teams.keys():
print('yes it is in the database')

else:
for team_number, team_info in teams.items():
for key, value in team_info.items():
if team_search == value:
print('yes it is in the dictionary')
else:
print('this is not in the dictionary')


def teams_show_function():
for key, value in teams.items():
print (key)
for subkey, subvalue in value.items():
print(' '+ str(subkey) + ' = ' + str(subvalue))

teams = {};
user_menu = {
1: 'add/change_team_info',
2: 'Remove_team',
3: 'search_team',
4: 'show_all_teams',
0: 'quit'}
team_menu = {
1: {'property': 'team_name','type':'str'},
2: {'property': 'location','type':'str'},
3: {'property': 'program_language', 'type':'str'},
4: {'property': 'camera_vision_system','type':'bool'},
5: {'property': 'width','type':'int'},
6: {'property': 'length','type':'int'},
7: {'property': 'number_drivetrain_motor','type':'int'},
0: {'property': 'main_menu'}}

user_menu_selection = ''
while user_menu_selection != 0:

for key, value in user_menu.items():
print(str(key) + ': ' + str(value))

user_menu_selection = str(input('please enter number of selection you would like to make \n'))

if user_menu_selection == '0':
break
if user_menu_selection == '1':
team_add_function()
if user_menu_selection == '2':
team_delete_function()
if user_menu_selection == '3':
team_search_function()
if user_menu_selection == '4':
teams_show_function()
120 changes: 120 additions & 0 deletions ch_3_assign_adam_wu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
def team_add_function():
team_number = input('Please enter team number you would like to add/change:\n')
if team_number.isnumeric():
teams.update({team_number:{}})
else:
print('please enter a number')

return

user_input = '1'
while True:


for key in team_menu.keys():
print(str(key) +': '+team_menu[key]['property'])

#user_input will allow you to exit the program
user_input = int(input('enter number corresponding to what you would like to add/change \n'))
key_entered = user_input

if user_input == 0:
break

want_to_change = team_menu[key_entered]

#val_change is the variable for new values
if user_input == 4:
val_change = input('enter 1 for true and 0 for false\n')
else:
val_change = input('what is the new value for ' + want_to_change['property']+'\n')
try:
if want_to_change['type'] == 'str':
try:
if val_change.isnumeric():
print('please enter a number')
except:
print("Oops! please make sure you enter a " + str(want_to_change['type']))
print("Next entry.")

elif want_to_change['type'] == 'int':
val_change = int(val_change)
elif want_to_change['type'] == 'bool':
val_change = int(val_change)
val_change = val_change == 1
teams[team_number][want_to_change['property']] = val_change

except:
print("Oops! please make sure you enter a " + want_to_change['type'])
print("Next entry.")

print(teams)

def team_delete_function():
team_name = input('delete which team? \n')
if team_name.isnumeric():
if team_name in teams.keys():
print(teams.keys())
teams.pop(team_name)
print(teams.keys())
else:
print('team ' + team_name +' does not exist')
else:
print('please enter an integer \n')

def team_search_function():
team_search = input('what team would you like to search? \n')
#team_search_validation = False
if team_search in teams.keys():
print('yes it is in the database')

else:
for team_number, team_info in teams.items():
for key, value in team_info.items():
if team_search == value:
print('yes it is in the dictionary')
else:
print('this is not in the dictionary')


def teams_show_function():
for key, value in teams.items():
print (key)
for subkey, subvalue in value.items():
print(' '+ str(subkey) + ' = ' + str(subvalue))

teams = {};
user_menu = {
1: 'add/change_team_info',
2: 'Remove_team',
3: 'search_team',
4: 'show_all_teams',
0: 'quit'}
team_menu = {
1: {'property': 'team_name','type':'str'},
2: {'property': 'location','type':'str'},
3: {'property': 'program_language', 'type':'str'},
4: {'property': 'camera_vision_system','type':'bool'},
5: {'property': 'width','type':'int'},
6: {'property': 'length','type':'int'},
7: {'property': 'number_drivetrain_motor','type':'int'},
0: {'property': 'main_menu'}}

user_menu_selection = ''
while user_menu_selection != 0:

for key, value in user_menu.items():
print(str(key) + ': ' + str(value))

user_menu_selection = str(input('please enter number of selection you would like to make \n'))

if user_menu_selection == '0':
break
if user_menu_selection == '1':
team_add_function()
if user_menu_selection == '2':
team_delete_function()
if user_menu_selection == '3':
team_search_function()
if user_menu_selection == '4':
teams_show_function()
56 changes: 56 additions & 0 deletions ch_4_assign_adam_wu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from math import sqrt;
import math;

def number_validation(number):
return number.isdigit()

class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def calculateDistance(self):
return math.sqrt(self.x**2 + self.y**2)

class Point3D(Point):
def __init__(self, x, y, z):
super().__init__(x, y)
self.z = z
def calculateDistance(self):
return math.sqrt(super().calculateDistance() + self.z**2)

x = input('what is the x value\n')
while number_validation(x) == False:
print('not valid')
x = input('what is the x value')
y = input('what is the y value\n')
while number_validation(y) == False:
print('not valid')
y = input('what is your 2d y value')
aPoint = Point( float(x), float(y))
distance2D = aPoint.calculateDistance()

print(distance2D)

x = input('what is the 3D x value\n')
while number_validation(x) == False:
print('not valid')
x = input('what is your 3D x value\n')
y = input('what is the 3D y value\n')
while number_validation(y) == False:
print('not valid')
y = input('what is your 3D y value\n')
z = input('what is the 3D z value\n')
while number_validation(z) == False:
print('not valid')
z = input('what is your z value\n')
bPoint = Point3D( float(x), float(y), float(z))
distance3D = bPoint.calculateDistance()

print(distance3D)

if distance2D>distance3D:
print('the 2d distance point is farther\n')
elif distance3D == distance2D:
print('the two points are equally far from origin\n')
else:
print('the 3d distance point is farther\n')