From 5fcea261ea1303346ad465544d74fbe773821869 Mon Sep 17 00:00:00 2001 From: atozprogramming <50784282+atozprogramming@users.noreply.github.com> Date: Wed, 11 Sep 2019 19:31:44 -0700 Subject: [PATCH 01/27] First commit message --- ch_1_Arthur_Zarins.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 ch_1_Arthur_Zarins.py diff --git a/ch_1_Arthur_Zarins.py b/ch_1_Arthur_Zarins.py new file mode 100644 index 0000000..e378fc3 --- /dev/null +++ b/ch_1_Arthur_Zarins.py @@ -0,0 +1 @@ +print('Hello, world! ipjsed42d') \ No newline at end of file From d6bf0d6cc9797ad1791e924d6c9e7acce790b0e3 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 12 Sep 2019 17:19:29 -0700 Subject: [PATCH 02/27] 9/12/2019 @ 5:19 PM --- 1678/ch_1_Arthur_Zarins.py | 1 + ch_1_Arthur_Zarins.py | 3 ++- ch_1_Arthur_Zarins_hw.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 1678/ch_1_Arthur_Zarins.py create mode 100644 ch_1_Arthur_Zarins_hw.py diff --git a/1678/ch_1_Arthur_Zarins.py b/1678/ch_1_Arthur_Zarins.py new file mode 100644 index 0000000..e378fc3 --- /dev/null +++ b/1678/ch_1_Arthur_Zarins.py @@ -0,0 +1 @@ +print('Hello, world! ipjsed42d') \ No newline at end of file diff --git a/ch_1_Arthur_Zarins.py b/ch_1_Arthur_Zarins.py index e378fc3..14253e9 100644 --- a/ch_1_Arthur_Zarins.py +++ b/ch_1_Arthur_Zarins.py @@ -1 +1,2 @@ -print('Hello, world! ipjsed42d') \ No newline at end of file +print('Hello, world! ipjsed42d') +print("To run this in VS code, use Ctrl Fn F5") \ No newline at end of file diff --git a/ch_1_Arthur_Zarins_hw.py b/ch_1_Arthur_Zarins_hw.py new file mode 100644 index 0000000..27be3da --- /dev/null +++ b/ch_1_Arthur_Zarins_hw.py @@ -0,0 +1,5 @@ +teams = { + '1678': {'Weight':200, 'Wheels': 4, 'Speed': 9}, + '2583': {'Weight': 300, 'Wheels': '325', 'Speed': 3} +} +print(teams['1678']['Weight']) \ No newline at end of file From 199b3e861df0e5da7f16a2d9bb31f08891f5d366 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 12 Sep 2019 20:12:53 -0700 Subject: [PATCH 03/27] Completed the Chapter 1 assignment: ch_1_assign_Arthur_Zarins_.py --- ch_1_Arthur_Zarins.py | 5 +++-- ch_1_Arthur_Zarins_hw.py | 5 ++++- ch_1_assign_Arthur_Zarins_.py | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 ch_1_assign_Arthur_Zarins_.py diff --git a/ch_1_Arthur_Zarins.py b/ch_1_Arthur_Zarins.py index 14253e9..54f6339 100644 --- a/ch_1_Arthur_Zarins.py +++ b/ch_1_Arthur_Zarins.py @@ -1,2 +1,3 @@ -print('Hello, world! ipjsed42d') -print("To run this in VS code, use Ctrl Fn F5") \ No newline at end of file +print('Hello, world!') +print("To run this in VS code, use Ctrl Fn F5") +print("1678 PARENT INFO NIGHT this saturday! 4:30-6:30") \ No newline at end of file diff --git a/ch_1_Arthur_Zarins_hw.py b/ch_1_Arthur_Zarins_hw.py index 27be3da..e416439 100644 --- a/ch_1_Arthur_Zarins_hw.py +++ b/ch_1_Arthur_Zarins_hw.py @@ -1,5 +1,8 @@ +#Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 teams = { '1678': {'Weight':200, 'Wheels': 4, 'Speed': 9}, - '2583': {'Weight': 300, 'Wheels': '325', 'Speed': 3} + '2583': {'Weight': 300, 'Wheels': 325, 'Speed': 3} } +def teamStats(teamName): + print("Team " + teamName + " is awesome") print(teams['1678']['Weight']) \ No newline at end of file diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py new file mode 100644 index 0000000..aa4274f --- /dev/null +++ b/ch_1_assign_Arthur_Zarins_.py @@ -0,0 +1,39 @@ +#Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 +teams = { + '1678': {'Last Year': 2019, + 'Location': "Davis CA", + 'Rookie Year': 2005, + 'Events': 'Sac Regional, Central Valley Regional' + }, + '2551': {'Last Year': 2019, + 'Location': "Novato CA", + 'Rookie Year': 2008, 'Events': + 'Sac Regional, SF Regional, Galileo divison'}, + '3421': {'Last Year': 2013, + 'Location': "Marysville MI", + 'Rookie Year': 2010, + 'Events': 'MY Regional'}, + '2942': {'Last Year': 2018, + 'Location': "Seattle, WA", + 'Rookie Year': 2009, + 'Events': ''} +} +#reference = "is" +def teamStats(teamName, attribute): + #New variable refernce will handle grammer related to pluralities + reference = "is" + stringTest = teams[teamName][attribute].split() + attributeDisplay = attribute + if attribute == "Events" and len(stringTest) > 2: + reference = "are" + else: + if attribute == "Events": + attributeDisplay = "only Event" + reference = "is" + print("Team " + teamName + "'s " + attributeDisplay + " " + reference + " " + teams[teamName][attribute]) + +#The big test: +teamStats('1678', 'Location') +teamStats('1678', 'Events') +#1 event: the grammer works! +teamStats('3421', 'Events') \ No newline at end of file From e6bb109867a394d49928a6951b319386b996757b Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 18 Sep 2019 18:58:51 -0700 Subject: [PATCH 04/27] Turn-in Assignment The assignment is complete, with all of the events and stats for the teams. The program has proper grammer, and answers 3 sample questions --- ch_1_assign_Arthur_Zarins_.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index aa4274f..27070a0 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -2,8 +2,8 @@ teams = { '1678': {'Last Year': 2019, 'Location': "Davis CA", - 'Rookie Year': 2005, - 'Events': 'Sac Regional, Central Valley Regional' + 'Rookie Year': 2005, + 'Events': 'Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs' }, '2551': {'Last Year': 2019, 'Location': "Novato CA", @@ -12,10 +12,10 @@ '3421': {'Last Year': 2013, 'Location': "Marysville MI", 'Rookie Year': 2010, - 'Events': 'MY Regional'}, + 'Events': 'MI FRC state championship'}, '2942': {'Last Year': 2018, 'Location': "Seattle, WA", - 'Rookie Year': 2009, + 'Rookie Year': 2009, 'Events': ''} } #reference = "is" @@ -32,8 +32,8 @@ def teamStats(teamName, attribute): reference = "is" print("Team " + teamName + "'s " + attributeDisplay + " " + reference + " " + teams[teamName][attribute]) -#The big test: +#The big test, comprised of 3 questions: teamStats('1678', 'Location') teamStats('1678', 'Events') -#1 event: the grammer works! +#Just one event: demonstration of proper grammer teamStats('3421', 'Events') \ No newline at end of file From 5f717adad2424c33b1665a73502d0757579ce44c Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 18 Sep 2019 19:05:57 -0700 Subject: [PATCH 05/27] Submit Assignment improve Grammer --- ch_1_assign_Arthur_Zarins_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index 27070a0..f6f7606 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -22,7 +22,7 @@ def teamStats(teamName, attribute): #New variable refernce will handle grammer related to pluralities reference = "is" - stringTest = teams[teamName][attribute].split() + stringTest = teams[teamName][attribute].split(",") attributeDisplay = attribute if attribute == "Events" and len(stringTest) > 2: reference = "are" From 6019e1c8ad7c3292d1d7882b57ab05389992681b Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 18 Sep 2019 19:30:37 -0700 Subject: [PATCH 06/27] Turned-in assignment: Input, and comments --- ch_1_assign_Arthur_Zarins_.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index f6f7606..46d4f2b 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -36,4 +36,8 @@ def teamStats(teamName, attribute): teamStats('1678', 'Location') teamStats('1678', 'Events') #Just one event: demonstration of proper grammer -teamStats('3421', 'Events') \ No newline at end of file +teamStats('3421', 'Events') +x = input('attribute') +y = input('teamName') +print('x is ' + x + " and y is " + y) +teamStats(y, x) \ No newline at end of file From 6616353b822b4263e055efc04f7201846d326f8d Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 19 Sep 2019 20:01:21 -0700 Subject: [PATCH 07/27] Turn-in Assignment --- ch_2_assign_Arthur_Zarins.py | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 ch_2_assign_Arthur_Zarins.py diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py new file mode 100644 index 0000000..2fcc030 --- /dev/null +++ b/ch_2_assign_Arthur_Zarins.py @@ -0,0 +1,64 @@ +#Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 +teams = {} +def add(team): + teams.update({str(team):{"name": "", + "language": "", + "width": "", + "length": "", + "motors": "", + "cameraVision": False + }}) +def update(team, stat, updateTxt): + if search(team) == True: + teams[team].update({str(stat): str(updateTxt)}) + print("Successfully updated an attribute of " + team) +def remove(team): + if(search(team)): + teams.pop(str(team), None) +def search(team): + if(str(team) in teams): + print("Team " + team + " exists") + return True + else: + print("Error: team " + team + " does not exist") + return False +def listTeams(): + teamList = [] + for i in teams.keys(): + teamList.append(i) + print("All teams: ") + print(teamList) +def teamStats(team): + if(search(team)): + print("Stats for team " + team + ":") + print(teams[team]) +#Now we can ask questions +while True: + #constant prompt + function = input("HOME. Type one of the following commands: 1)add 2)update 3)remove 4)search 5)listTeams 6)teamStats\n ") + if function == "add": + #Adds a new team to the database + a1 = input("What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") + add(str(a1)) + print("Team " + a1 + " added successfully.\n ") + elif function == "update": + #Updates a team attribute + a1 = input("What is the team number?\n ") + a2 = input("What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") + a3 = input("What is the team attribute NEW value?\n ") + update(a1, a2, a3) + elif function == "remove": + #Removes a team + a1 = input("What is the team number?\n ") + remove(a1) + elif function == "search": + #States if a team exists + a1 = input("What is the team number?\n ") + search(a1) + elif function == "listTeams": + #State all existing teams + listTeams() + elif function == "teamStats": + #States the stats for the team, specifically the attributes + a1 = input("What is the team number?\n ") + teamStats(a1) \ No newline at end of file From 42afe95f9d6abf3abd8b92c18a3c0d5e9e3662f3 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 25 Sep 2019 20:26:22 -0700 Subject: [PATCH 08/27] Chapter 1 assignment revised --- Island_Survival_Game_Arthur_Zarins.py | 76 ++++++++++ PRACTICE_Classes 1.py | 25 ++++ ch_1_assign_Arthur_Zarins_.py | 30 ++-- ch_2_assign_Arthur_Zarins.py | 196 +++++++++++++++++--------- 4 files changed, 248 insertions(+), 79 deletions(-) create mode 100644 Island_Survival_Game_Arthur_Zarins.py create mode 100644 PRACTICE_Classes 1.py diff --git a/Island_Survival_Game_Arthur_Zarins.py b/Island_Survival_Game_Arthur_Zarins.py new file mode 100644 index 0000000..0821c6d --- /dev/null +++ b/Island_Survival_Game_Arthur_Zarins.py @@ -0,0 +1,76 @@ +import random +squares = {} +size = 3 +xPos = size // 2 +yPos = size // 2 +for x in range(size): + for y in range(size): + #Add a square + squares.update({str(x) + "-" + str(y): True}) +#print(squares) +def printBoard(): + for y in range(size): + line = "" + for x in range(size): + #Add a square + boolo = squares[str(x) + "-" + str(y)] + if boolo == True: + if y == yPos and x == xPos: + line = line + "Pl" + else: + line = line + "[]" + else: + line = line + " " + print(line) + # else: + #Off-board +#End of function +game = True +while game == True: + printBoard() + legalMove = False + while legalMove == False: + oX = xPos + oY = yPos + move = input("Where will you move? wasd controls\n ") + if move == "w": + yPos = yPos - 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + elif move == "a": + xPos = xPos - 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + elif move == "s": + yPos = yPos + 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + elif move == "d": + xPos = xPos + 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + else: + print("Invalid move") + #Return to last pos if unaccepted + if legalMove == False: + xPos = oX + yPos = oY + #end + #Remove terrain + RX = 0 + RY = 0 + while (RX == xPos and RY == yPos) or squares[str(RX) + "-" + str(RY)] == False: + #We want to remove a new part of the Island, and not kill the player + RX = random.randint(0, size) + RY = random.randint(0, size) + if RX > 9: + RX = 9 + if RY > 9: + RY = 9 + if RX == xPos and RY == yPos: + print() + else: + squares.update({str(RX) + "-" + str(RY): False}) + if squares[str(xPos) + "-" + str(xPos)] == False: + print ("GAME OVER") + game = False \ No newline at end of file diff --git a/PRACTICE_Classes 1.py b/PRACTICE_Classes 1.py new file mode 100644 index 0000000..1a1bb57 --- /dev/null +++ b/PRACTICE_Classes 1.py @@ -0,0 +1,25 @@ +class Bot(): + + def __init__(self, pos, name): + self.name = name + self.pos = pos + self.arm = 0 + self.cube = False + def roll(self, distance): + self.pos = self.pos + distance + def armMove(self, distance): + self.arm = self.arm + distance + def pick(self): + if self.pos == 3: + self.cube = True +Rob = Bot(0, "Rob") +while True: + print("Robot is at pos " + str(Rob.pos) + " with arm pos " + str(Rob.arm) + " and cube is " + str(Rob.cube)) + func = input("cube, roll, armMove?") + if func == "cube": + Rob.pick() + elif func == "armMove": + Rob.armMove(1) + elif func == "roll": + Rob.roll(1) + \ No newline at end of file diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index 46d4f2b..79bc15a 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -1,19 +1,19 @@ #Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 teams = { - '1678': {'Last Year': 2019, + 1678: {'Last Year': 2019, 'Location': "Davis CA", 'Rookie Year': 2005, - 'Events': 'Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs' + 'Events': "Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs" }, - '2551': {'Last Year': 2019, + 2551: {'Last Year': 2019, 'Location': "Novato CA", 'Rookie Year': 2008, 'Events': 'Sac Regional, SF Regional, Galileo divison'}, - '3421': {'Last Year': 2013, + 3421: {'Last Year': 2013, 'Location': "Marysville MI", 'Rookie Year': 2010, 'Events': 'MI FRC state championship'}, - '2942': {'Last Year': 2018, + 2942: {'Last Year': 2018, 'Location': "Seattle, WA", 'Rookie Year': 2009, 'Events': ''} @@ -22,7 +22,7 @@ def teamStats(teamName, attribute): #New variable refernce will handle grammer related to pluralities reference = "is" - stringTest = teams[teamName][attribute].split(",") + stringTest = str(teams[teamName][attribute]).split(",") attributeDisplay = attribute if attribute == "Events" and len(stringTest) > 2: reference = "are" @@ -30,14 +30,14 @@ def teamStats(teamName, attribute): if attribute == "Events": attributeDisplay = "only Event" reference = "is" - print("Team " + teamName + "'s " + attributeDisplay + " " + reference + " " + teams[teamName][attribute]) - + print("Team " + str(teamName) + "'s " + str(attributeDisplay) + " " + str(reference) + " " + str(teams[teamName][attribute])) #The big test, comprised of 3 questions: -teamStats('1678', 'Location') -teamStats('1678', 'Events') +teamStats(1678, 'Location') +teamStats(1678, 'Events') #Just one event: demonstration of proper grammer -teamStats('3421', 'Events') -x = input('attribute') -y = input('teamName') -print('x is ' + x + " and y is " + y) -teamStats(y, x) \ No newline at end of file +teamStats(3421, 'Events') +while True: + x = input('attribute') + y = input('teamName') + print('attribute is ' + x + " and teamname is " + y) + teamStats(int(y), x) \ No newline at end of file diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py index 2fcc030..92d4ad5 100644 --- a/ch_2_assign_Arthur_Zarins.py +++ b/ch_2_assign_Arthur_Zarins.py @@ -1,64 +1,132 @@ -#Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 -teams = {} -def add(team): - teams.update({str(team):{"name": "", - "language": "", - "width": "", - "length": "", - "motors": "", - "cameraVision": False - }}) -def update(team, stat, updateTxt): - if search(team) == True: - teams[team].update({str(stat): str(updateTxt)}) - print("Successfully updated an attribute of " + team) -def remove(team): - if(search(team)): - teams.pop(str(team), None) -def search(team): - if(str(team) in teams): - print("Team " + team + " exists") - return True - else: - print("Error: team " + team + " does not exist") - return False -def listTeams(): - teamList = [] - for i in teams.keys(): - teamList.append(i) - print("All teams: ") - print(teamList) -def teamStats(team): - if(search(team)): - print("Stats for team " + team + ":") - print(teams[team]) -#Now we can ask questions -while True: - #constant prompt - function = input("HOME. Type one of the following commands: 1)add 2)update 3)remove 4)search 5)listTeams 6)teamStats\n ") - if function == "add": - #Adds a new team to the database - a1 = input("What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") - add(str(a1)) - print("Team " + a1 + " added successfully.\n ") - elif function == "update": - #Updates a team attribute - a1 = input("What is the team number?\n ") - a2 = input("What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") - a3 = input("What is the team attribute NEW value?\n ") - update(a1, a2, a3) - elif function == "remove": - #Removes a team - a1 = input("What is the team number?\n ") - remove(a1) - elif function == "search": - #States if a team exists - a1 = input("What is the team number?\n ") - search(a1) - elif function == "listTeams": - #State all existing teams - listTeams() - elif function == "teamStats": - #States the stats for the team, specifically the attributes - a1 = input("What is the team number?\n ") - teamStats(a1) \ No newline at end of file +functions = False +if(functions == True): + # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 + teams = {} + + def add(team): + teams.update({str(team): {"name": "", + "language": "", + "width": "", + "length": "", + "motors": "", + "cameraVision": False + }}) + + def update(team, stat, updateTxt): + if search(team) == True: + teams[team].update({str(stat): str(updateTxt)}) + print("Successfully updated an attribute of " + team) + + def remove(team): + if(search(team)): + teams.pop(str(team), None) + + def search(team): + if(str(team) in teams): + print("Team " + team + " exists") + return True + else: + print("Error: team " + team + " does not exist") + return False + + def listTeams(): + teamList = [] + for i in teams.keys(): + teamList.append(i) + print("All teams: ") + print(teamList) + + def teamStats(team): + if(search(team)): + print("Stats for team " + team + ":") + print(teams[team]) + # Now we can ask questions + while True: + # constant prompt + function = input( + "HOME. Type one of the following commands: 1)add 2)update 3)remove 4)search 5)listTeams 6)teamStats\n ") + if function == "add": + # Adds a new team to the database + a1 = input( + "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") + add(str(a1)) + print("Team " + a1 + " added successfully.\n ") + elif function == "update": + # Updates a team attribute + a1 = input("What is the team number?\n ") + a2 = input( + "What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") + a3 = input("What is the team attribute NEW value?\n ") + update(a1, a2, a3) + elif function == "remove": + # Removes a team + a1 = input("What is the team number?\n ") + remove(a1) + elif function == "search": + # States if a team exists + a1 = input("What is the team number?\n ") + search(a1) + elif function == "listTeams": + # State all existing teams + listTeams() + elif function == "teamStats": + # States the stats for the team, specifically the attributes + a1 = input("What is the team number?\n ") + teamStats(a1) + + + +else: + print("Functions disabled.") + # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 + teams = {} + + # Now we can ask questions + while True: + # constant prompt + function = input( + "HOME. Type one of the following commands: 1)add 2)update 3)remove 4)search 5)listTeams 6)teamStats\n ") + if function == "add": + # Adds a new team to the database + a1 = input( + "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") + teams.update({str(a1): {"name": "", + "language": "", + "width": "", + "length": "", + "motors": "", + "cameraVision": False + }}) + print("Team " + a1 + " added successfully.\n ") + elif function == "update": + # Updates a team attribute + a1 = input("What is the team number?\n ") + a2 = input( + "What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") + a3 = input("What is the team attribute NEW value?\n ") + if str(a1) in teams: + teams[a1].update({str(a2): str(a3)}) + print("Successfully updated an attribute of " + a1) + elif function == "remove": + # Removes a team + a1 = input("What is the team number?\n ") + teams.pop(str(a1), None) + elif function == "search": + # States if a team exists + a1 = input("What is the team number?\n ") + if str(a1) in teams: + print("Team " + a1 + " exists") + else: + print("Error: team " + a1 + " does not exist") + elif function == "listTeams": + # State all existing teams + teamList = [] + for i in teams.keys(): + teamList.append(i) + print("All teams: ") + print(teamList) + elif function == "teamStats": + # States the stats for the team, specifically the attributes + a1 = input("What is the team number?\n ") + print("Stats for team " + a1 + ":") + print(teams[a1]) From dbae3ec86f292908c251b48a8e226b44be5a9571 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 25 Sep 2019 20:46:53 -0700 Subject: [PATCH 09/27] Assignment 2 syntax improved --- ch_2_assign_Arthur_Zarins.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py index 92d4ad5..2841494 100644 --- a/ch_2_assign_Arthur_Zarins.py +++ b/ch_2_assign_Arthur_Zarins.py @@ -1,4 +1,6 @@ functions = False +# There are 2 code snippets: the first has functions, the second does not. +#Both work, and you can choose which one to run, by setting functions to "True" or "False". if(functions == True): # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 teams = {} @@ -75,7 +77,6 @@ def teamStats(team): teamStats(a1) - else: print("Functions disabled.") # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 From 824f9ce89f86f4db588e7b640168ac2eaca80651 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 2 Oct 2019 19:21:56 -0700 Subject: [PATCH 10/27] The Island minigame (fun project) has been debugged! It's redy for gameplay --- Island_Survival_Game_Arthur_Zarins.py | 48 +++++++++++++++++---------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/Island_Survival_Game_Arthur_Zarins.py b/Island_Survival_Game_Arthur_Zarins.py index 0821c6d..47f2310 100644 --- a/Island_Survival_Game_Arthur_Zarins.py +++ b/Island_Survival_Game_Arthur_Zarins.py @@ -1,18 +1,20 @@ import random squares = {} -size = 3 +size = 7 xPos = size // 2 yPos = size // 2 for x in range(size): for y in range(size): - #Add a square + # Add a square squares.update({str(x) + "-" + str(y): True}) -#print(squares) +# print(squares) + + def printBoard(): for y in range(size): line = "" for x in range(size): - #Add a square + # Add a square boolo = squares[str(x) + "-" + str(y)] if boolo == True: if y == yPos and x == xPos: @@ -22,9 +24,10 @@ def printBoard(): else: line = line + " " print(line) + # else: - #Off-board -#End of function + # Off-board +# End of function game = True while game == True: printBoard() @@ -51,26 +54,35 @@ def printBoard(): legalMove = True else: print("Invalid move") - #Return to last pos if unaccepted + # Return to last pos if unaccepted if legalMove == False: xPos = oX yPos = oY - #end - #Remove terrain + # end + # Remove terrain RX = 0 RY = 0 - while (RX == xPos and RY == yPos) or squares[str(RX) + "-" + str(RY)] == False: - #We want to remove a new part of the Island, and not kill the player + while (RX == xPos and RY == yPos) or squares[str(str(RX) + "-" + str(RY))] == False: + # We want to remove a new part of the Island, and not kill the player RX = random.randint(0, size) RY = random.randint(0, size) - if RX > 9: - RX = 9 - if RY > 9: - RY = 9 + if RX >= size: + RX = size - 1 + if RY >= size: + RY = size - 1 if RX == xPos and RY == yPos: print() else: squares.update({str(RX) + "-" + str(RY): False}) - if squares[str(xPos) + "-" + str(xPos)] == False: - print ("GAME OVER") - game = False \ No newline at end of file + good = 0 + for x in range(size): + for y in range(size): + # Add to good square count + if squares[str(xPos) + "-" + str(yPos)] == True: + good = good + 1 + if squares[str(xPos) + "-" + str(yPos)] == False: + print("GAME OVER") + game = False + if good < 1: + print("You win!") + game = False From 9603e1deb1b7c424e26f5f80da5eb541fa456055 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 3 Oct 2019 20:18:11 -0700 Subject: [PATCH 11/27] Chapter 2 complete --- ch_1_Arthur_Zarins.py | 6 +++++- ch_2_assign_Arthur_Zarins.py | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ch_1_Arthur_Zarins.py b/ch_1_Arthur_Zarins.py index 54f6339..34c7f24 100644 --- a/ch_1_Arthur_Zarins.py +++ b/ch_1_Arthur_Zarins.py @@ -1,3 +1,7 @@ print('Hello, world!') print("To run this in VS code, use Ctrl Fn F5") -print("1678 PARENT INFO NIGHT this saturday! 4:30-6:30") \ No newline at end of file +print("1678 PARENT INFO NIGHT this saturday! 4:30-6:30") +print("Get dad's signature on da WPR") +x = "a" +y = isinstance(x, int) +print(y) \ No newline at end of file diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py index 2841494..3eaf61c 100644 --- a/ch_2_assign_Arthur_Zarins.py +++ b/ch_2_assign_Arthur_Zarins.py @@ -1,24 +1,26 @@ -functions = False +functions = True # There are 2 code snippets: the first has functions, the second does not. -#Both work, and you can choose which one to run, by setting functions to "True" or "False". +# Both work, and you can choose which one to run, by setting functions to "True" or "False". if(functions == True): # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 teams = {} def add(team): - teams.update({str(team): {"name": "", - "language": "", - "width": "", - "length": "", - "motors": "", - "cameraVision": False - }}) + if isinstance(team, int) == True: + teams.update({str(team): {"name": "", + "language": "", + "width": "", + "length": "", + "motors": "", + "cameraVision": False + }}) + else: + print("Team name must be a number") def update(team, stat, updateTxt): if search(team) == True: teams[team].update({str(stat): str(updateTxt)}) print("Successfully updated an attribute of " + team) - def remove(team): if(search(team)): teams.pop(str(team), None) @@ -51,7 +53,8 @@ def teamStats(team): # Adds a new team to the database a1 = input( "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") - add(str(a1)) + if isinstance(a1, int) == True: + add(str(a1)) print("Team " + a1 + " added successfully.\n ") elif function == "update": # Updates a team attribute @@ -131,3 +134,4 @@ def teamStats(team): a1 = input("What is the team number?\n ") print("Stats for team " + a1 + ":") print(teams[a1]) +5555 From e9797285134ad57cf279f8abe5a9569e3f2a143e Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 9 Oct 2019 20:34:08 -0700 Subject: [PATCH 12/27] Chapter 3 assignment (w/ input validation) completed --- .../ch_1_assign_Arthur_Zarins_.cpython-37.pyc | Bin 0 -> 1071 bytes .../ch_2_assign_Arthur_Zarins.cpython-37.pyc | Bin 0 -> 2420 bytes ch_1_assign_Arthur_Zarins_.py | 19 +-- ch_2_assign_Arthur_Zarins.py | 131 +++++------------- ch_3_assign_Arthur_Zarins.py | 3 + 5 files changed, 46 insertions(+), 107 deletions(-) create mode 100644 __pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc create mode 100644 __pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc create mode 100644 ch_3_assign_Arthur_Zarins.py diff --git a/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc b/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f444df1e717887441297dd9727afe08bc265d597 GIT binary patch literal 1071 zcmZWnO>fgM7`79qOS={J#l~(vfr<*!#s&i+#OO9OX`4jLhp38*7kjN)mQ=P^)Tlj; z1OI@_gn%1A2nix_VJFVqcH(tbUK9-*;+Q+!<>ZI}_IQquWZ36!WDU;=>FEIrWhmlP<#8mx*$u@lrh2+7p?|uyAyXTh+uES()e6-hP|(1t0`
UETiOv$VJHn+|8MVg1>QgY|O090aE zC=mssUH}3awH^s=>f?VZRwZz;-Y29cK*vcXxZQZHh0+a{G**S)GjXS(<6ZL#1YU*5 zD_RBfLHS@q9u4ArW IEZ~Ck3uKHQ_5c6? literal 0 HcmV?d00001 diff --git a/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc b/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..27f67dd9e0c17e2e1ba2e1e7a1b548521bf0a379 GIT binary patch literal 2420 zcmZ`*UvC>l5Z}FjK09_2kf3TPbU_03KqP8fDik4#o48P^bs=#Z$x0Pny_fhJ`_A3n zYm$@0i}?^dAe25J!M8v>@fq%wC%ytt%{$-{elCQ6n&3{PydU zYjr~Y!Ntk2;N=^5Vo zET4n9!s!MH=KqDANV`XIf`K!hzY33B2cpQBC_1q?-Lu49Wj(Wx9p#S6gu=NeKbt$h zcrkrRDN!DGjr%zC{@%AIU5I9#kT9QlG)!Oht) zlZri!SjduW_%sqhrKrI^iBw_IiwZkVRI$+OZ(rXIrHprz?WR!uOl)^U0ZQA2tKc+Q zc-e@D3iPECg*yV73TWY=@DC#9AWr|?>8)%%l97;GVZOB%$vu^hwq&}a_CpbUu0$9o zak9GwXDz?+ti{n`VS`ULM*eLegwDdxDt~qBT}!+L+#V|6z}bao6(0E|5WFh57QCpN ziaxW(=wNYThfU z=zvK3_W`^Z|HK0Nru{;1$xEwDE7}fRfq^?Ut*}SwNShW=ZPhs=3Qt7C^hNXzd?oQL zLVYT5^@G*{ycjFchCNSwq-;(xmfR}iX>SnVIhyB|Ja5A!ex-eqy%iQ6#8Syl zUT+DJiWP>b#PT`D(@3%;RYu`%;F!psMq9`DjoxVIFN29vBM2nVJaw#js`)+O>wy?D z4eKpf?2;pLa7B@4^w@ey*2t6DBXH^19_xC3KEFwn!y$#Bw!y7w6{7c5+CPG{rnNmR{ZcXmlAouN${9%=B)=FZA1W40hUcJC3Fo(2rw?5C>!RZoXiUoAzvz6el>hLWc#4|0*)?oLOQx4Coo!`HCyj4O_q`?4_5!oz zXBThD+O19YA{=DVZ4)MqSozi0zA!DXRAMH{v6ghI2DQSClToHb1zA24>@NmyG^QgE zp8v`z{GBZ6DQLxAE4&WRa$$ux&KGn;WXWops5r^eOfJGkav2DrmSs_o`kG>Y^DQ4b z9B|6_n&udaGI15Y3Vc(S+P;fS)0$`Oz^*K?!xa8k!<1)(=xhA%Mq+n@og2REJHGE% GeD8mzRvVK5 literal 0 HcmV?d00001 diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index 79bc15a..cad48a0 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -1,19 +1,19 @@ #Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 teams = { - 1678: {'Last Year': 2019, + "1678": {'Last Year': 2019, 'Location': "Davis CA", 'Rookie Year': 2005, 'Events': "Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs" }, - 2551: {'Last Year': 2019, + "2551": {'Last Year': 2019, 'Location': "Novato CA", 'Rookie Year': 2008, 'Events': 'Sac Regional, SF Regional, Galileo divison'}, - 3421: {'Last Year': 2013, + "3421": {'Last Year': 2013, 'Location': "Marysville MI", 'Rookie Year': 2010, 'Events': 'MI FRC state championship'}, - 2942: {'Last Year': 2018, + "2942": {'Last Year': 2018, 'Location': "Seattle, WA", 'Rookie Year': 2009, 'Events': ''} @@ -32,12 +32,7 @@ def teamStats(teamName, attribute): reference = "is" print("Team " + str(teamName) + "'s " + str(attributeDisplay) + " " + str(reference) + " " + str(teams[teamName][attribute])) #The big test, comprised of 3 questions: -teamStats(1678, 'Location') -teamStats(1678, 'Events') +teamStats("1678", 'Location') +teamStats("1678", 'Events') #Just one event: demonstration of proper grammer -teamStats(3421, 'Events') -while True: - x = input('attribute') - y = input('teamName') - print('attribute is ' + x + " and teamname is " + y) - teamStats(int(y), x) \ No newline at end of file +teamStats("3421", 'Events') \ No newline at end of file diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py index 3eaf61c..570bbc5 100644 --- a/ch_2_assign_Arthur_Zarins.py +++ b/ch_2_assign_Arthur_Zarins.py @@ -1,50 +1,49 @@ -functions = True -# There are 2 code snippets: the first has functions, the second does not. -# Both work, and you can choose which one to run, by setting functions to "True" or "False". -if(functions == True): - # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 - teams = {} - - def add(team): - if isinstance(team, int) == True: - teams.update({str(team): {"name": "", +import ch_1_assign_Arthur_Zarins_ +# Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 +def add(team): + if isinstance(team, int) == True: + ch_1_assign_Arthur_Zarins_.teams.update({str(team): {"name": "", "language": "", "width": "", "length": "", "motors": "", "cameraVision": False }}) - else: - print("Team name must be a number") + print("Team " + str(team) + " added successfully.\n ") + else: + print("Team name must be a number") + +def update(team, stat, updateTxt): + if search(team) == True: + ch_1_assign_Arthur_Zarins_.teams[team].update({str(stat): str(updateTxt)}) + print("Successfully updated an attribute of " + team) - def update(team, stat, updateTxt): - if search(team) == True: - teams[team].update({str(stat): str(updateTxt)}) - print("Successfully updated an attribute of " + team) - def remove(team): - if(search(team)): - teams.pop(str(team), None) +def remove(team): + if(search(team)): + ch_1_assign_Arthur_Zarins_.teams.pop(str(team), None) - def search(team): - if(str(team) in teams): - print("Team " + team + " exists") - return True - else: - print("Error: team " + team + " does not exist") - return False +def search(team): + if(str(team) in ch_1_assign_Arthur_Zarins_.teams): + print("Team " + team + " exists") + return True + else: + print("Error: team " + team + " does not exist") + return False - def listTeams(): - teamList = [] - for i in teams.keys(): - teamList.append(i) - print("All teams: ") - print(teamList) +def listTeams(): + teamList = [] + for i in ch_1_assign_Arthur_Zarins_.teams.keys(): + teamList.append(i) + print("All teams: ") + print(teamList) - def teamStats(team): - if(search(team)): - print("Stats for team " + team + ":") - print(teams[team]) - # Now we can ask questions +def teamStats(team): + if(search(team)): + print("Stats for team " + team + ":") + print(ch_1_assign_Arthur_Zarins_.teams[team]) +# Now we can ask questions + +def runContinuous(): while True: # constant prompt function = input( @@ -55,7 +54,6 @@ def teamStats(team): "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") if isinstance(a1, int) == True: add(str(a1)) - print("Team " + a1 + " added successfully.\n ") elif function == "update": # Updates a team attribute a1 = input("What is the team number?\n ") @@ -78,60 +76,3 @@ def teamStats(team): # States the stats for the team, specifically the attributes a1 = input("What is the team number?\n ") teamStats(a1) - - -else: - print("Functions disabled.") - # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 - teams = {} - - # Now we can ask questions - while True: - # constant prompt - function = input( - "HOME. Type one of the following commands: 1)add 2)update 3)remove 4)search 5)listTeams 6)teamStats\n ") - if function == "add": - # Adds a new team to the database - a1 = input( - "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") - teams.update({str(a1): {"name": "", - "language": "", - "width": "", - "length": "", - "motors": "", - "cameraVision": False - }}) - print("Team " + a1 + " added successfully.\n ") - elif function == "update": - # Updates a team attribute - a1 = input("What is the team number?\n ") - a2 = input( - "What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") - a3 = input("What is the team attribute NEW value?\n ") - if str(a1) in teams: - teams[a1].update({str(a2): str(a3)}) - print("Successfully updated an attribute of " + a1) - elif function == "remove": - # Removes a team - a1 = input("What is the team number?\n ") - teams.pop(str(a1), None) - elif function == "search": - # States if a team exists - a1 = input("What is the team number?\n ") - if str(a1) in teams: - print("Team " + a1 + " exists") - else: - print("Error: team " + a1 + " does not exist") - elif function == "listTeams": - # State all existing teams - teamList = [] - for i in teams.keys(): - teamList.append(i) - print("All teams: ") - print(teamList) - elif function == "teamStats": - # States the stats for the team, specifically the attributes - a1 = input("What is the team number?\n ") - print("Stats for team " + a1 + ":") - print(teams[a1]) -5555 diff --git a/ch_3_assign_Arthur_Zarins.py b/ch_3_assign_Arthur_Zarins.py new file mode 100644 index 0000000..c5f4de2 --- /dev/null +++ b/ch_3_assign_Arthur_Zarins.py @@ -0,0 +1,3 @@ +import ch_2_assign_Arthur_Zarins +import ch_1_assign_Arthur_Zarins_ +ch_2_assign_Arthur_Zarins.runContinuous() \ No newline at end of file From 036b2285968be3f878402f856c69f523ea23cbf5 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 10 Oct 2019 20:37:29 -0700 Subject: [PATCH 13/27] Proper data input types, Chapter 3 assignment improved --- .../ch_2_assign_Arthur_Zarins.cpython-37.pyc | Bin 2420 -> 2538 bytes ch_2_assign_Arthur_Zarins.py | 11 ++++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc b/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc index 27f67dd9e0c17e2e1ba2e1e7a1b548521bf0a379..a9573b470c59cf135327f2c190dc1b9df7c8c292 100644 GIT binary patch delta 1184 zcmZ`(%W4!s6zyC6n3^$dl9`wxB;y0rI2#`*5mX|1xe7tZLyd~G=?+XXGd)&UOCl43 zOctUbgxX2K$Ig9Ly6`uo|3JZ=3vnUdTOG$S#BTalSDoAEoT|Fj-}7G!?zrpb47^5u zyuN>T+Z}-E?cvGI9=~_XSmZv;8s+>K!e^F%8oa3G_)OpvoyM@)zFhkZo#X@!ITi8C_@6#dqdbr^>cjb%DwqWeS*== zY$bY7k82MDVUm(|2@E(`a2P}e$NsTIxVCf?Us6LptTHhvVTHXhr9~Ef*1k>O+HorI z7Hv!0w^O`m_)bwzrEYR*Z-0K~I9f^xxPC!fOoM|WiRt-%7GI(~1_Qd#7u&nLSU(d5 zb(FoBcM%hZDRfilq0oz=Yzq1=u_Eco#cbU0JsHfc$$cvNtA0$3NRw2CKy<5LY;39z z`=U*sn2oTZ>C2#*_YozI2x{TuV34>h&BZ|!)t344oHo^FO6?s;B1rR?8nX(}r{=BY z8|{x0Yc*Jp631&ag1VnluthEduQpwYWCE4_ezH{@pF=zvR$v!kP#v+obW*fFe`ofe z`DBTE78fr%OH)dhheHpDlKN;5Y<|GewOxr-*@6wMP@iEroWZ_{eUKno6A`N0M+{L5 z(FH_pjbb5S%dnrp)|6%wnyhKI%)M-m*$qUqI@=_w77tRv7KEb6vKet~JG*AGMPX|X zdl3Yoz4gZ#^FpaC0=1YN)yf z7s`9-C-4@48DEu(_ykk_1mb|D61@S<6vLcyc{OKCP5TM9P6T;5$&xfPt+XBIB1uht zvVH&VIXenq%yENRCz*ZlHe^AVhh{-6DZlxfAZ zOg2kw#qmjG)2DFV#>X`}3VNKJzT)K37sC_`U>jwnI7;dwt_7~aKz|1eN2Ph_{%nNt z`UoV|Jmd&2p;sZ;cVI?(+UB^HI0{r8^m$(l#6CJi^b?Gh9oi?R{m2MLUJN6_p-5#8 zLwiOJ@GEdBBV1F8f+YL{y;aD#YEK6p7_-lVZLx}~iR3%f>_>Ta-W?-dqC1RcIWHw? zw`X)fE=gvLj1z^^Dapp&ye{6dQ8;OBXt+Nzz`Ym(AfD*?BY!IOpJlbhc`5 yhtusd=x)m54qc{yCP9!U Date: Wed, 16 Oct 2019 20:45:30 -0700 Subject: [PATCH 14/27] Great Chapter 3 overwriting-prevention function --- .../ch_2_assign_Arthur_Zarins.cpython-37.pyc | Bin 2538 -> 2592 bytes ch_2_assign_Arthur_Zarins.py | 24 ++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc b/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc index a9573b470c59cf135327f2c190dc1b9df7c8c292..88a4f1d73a73ea817a2356d549afbb877aabdc13 100644 GIT binary patch delta 414 zcmaDQyg-E4iIpEi8G|Ii38;s846QMSX0Xv0A-KA|xZT zSfL~}F;^imrzkZsrBWfaBD1)pSd;A*b8$)0Eve*;c*Dv3jH06Pw^%{yii_BRuDQil zT9A@hk~%qqNkdW$oU0CmbR770x5V0J?&zr|dTUjS4tz$V4PR+O5XUzRFAiDixeFHl1f!cak=0!g+a z5um8@tO-{Y$}XKn@!oSGcpQH=H+uyAm2uye2h00ZPzw*UYD delta 343 zcmZ1=@=BQ3iIq+{P#` z&jJz`XGmca2hxlTc^oCIDeNFt3PUi1CdcG+jMeO#Y(?xqGbU#-Df8Z9D=kP#EJ?k^ zTwGE#c@~p~s1V3DMjl2!MkXlaVG^5so2gHL7bsE02O{`EguvuVW&=?WQw)fU*?)Ja`SSqa Date: Wed, 23 Oct 2019 18:56:54 -0700 Subject: [PATCH 15/27] Chapter 4 completed --- ch_4_assign_Arthur_Zarins.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ch_4_assign_Arthur_Zarins.py diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py new file mode 100644 index 0000000..9dacdc9 --- /dev/null +++ b/ch_4_assign_Arthur_Zarins.py @@ -0,0 +1,21 @@ +import math +class BasicPoint: + def __init__(self, x, y): + self.x = x + self.y = y + + def distance(self): + return math.sqrt(self.x **2 + self.y **2) + +class AwesumPointz(BasicPoint): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + + def distance(self): + return math.sqrt(self.z * self.z + math.sqrt(self.x **2 + self.y **2) **2) + +boringPoint2d = BasicPoint(3, 4) +coolPoint = AwesumPointz(3, -4, 4) +print(boringPoint2d.distance()) +print(coolPoint.distance()) \ No newline at end of file From 8038332c17144eb3d905b3cae87b2c70b00a80b6 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 23 Oct 2019 20:33:58 -0700 Subject: [PATCH 16/27] Added a bonus project: Rubik's cubes! This program tells you the number of combonations (pardon the spelling) from a 2x2 to Infinity x Infinity cubes! Have fun learning how the cubes progressively become more advanced! :) --- Rubik's cube math.py | 26 ++++++++++++++++++++++++++ ch_4_assign_Arthur_Zarins.py | 29 ++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 Rubik's cube math.py diff --git a/Rubik's cube math.py b/Rubik's cube math.py new file mode 100644 index 0000000..8c10444 --- /dev/null +++ b/Rubik's cube math.py @@ -0,0 +1,26 @@ + +# Credits: +# Christopher Mowla for providing the function @ https://docs.google.com/file/d/0Bx0h7-zg0f4NTUM1MWUtaDJrbms/edit +# Arthur Zarins for compiling the code +import math + + +class cube(): + def __init__(self, size): + self.size = size + + def combos(self): + # 8 corners have 8 possibilities + total = math.factorial(8) * (3 ** 7) / 24 ** ((self.size + 1) % 2) + # add center edges + total = total * ((math.factorial(12) * (2 ** 10)) ** (self.size % 2)) + # add wing edges + total = total * (math.factorial(24) ** round((self.size - 2) / 2)) + # add centers + total = total * ((math.factorial(24) / (math.factorial(4) ** 6)) + ** round(((self.size - 2) / 2) ** 2)) + return total + + +myCube = cube(2) +print(myCube.combos()) diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py index 9dacdc9..60a65d6 100644 --- a/ch_4_assign_Arthur_Zarins.py +++ b/ch_4_assign_Arthur_Zarins.py @@ -1,21 +1,36 @@ import math -class BasicPoint: +def is_number(s): + try: + float(s) + return True + except ValueError: + pass +class Point: def __init__(self, x, y): self.x = x self.y = y def distance(self): - return math.sqrt(self.x **2 + self.y **2) + if (is_number(self.x) and is_number(self.y)): + return math.sqrt(self.x **2 + self.y **2) + else: + return -1 -class AwesumPointz(BasicPoint): +class Point3d(Point): def __init__(self, x, y, z): super().__init__(x, y) self.z = z def distance(self): - return math.sqrt(self.z * self.z + math.sqrt(self.x **2 + self.y **2) **2) + if (is_number(self.x) and is_number(self.y) and is_number(self.z)): + return math.sqrt(self.z **2 + super().distance() ** 2) + else: + return -1 -boringPoint2d = BasicPoint(3, 4) -coolPoint = AwesumPointz(3, -4, 4) +boringPoint2d = Point(3, 4) +coolPoint = Point3d(3, -4, 4) +wrong = Point3d("q", -4, 4) print(boringPoint2d.distance()) -print(coolPoint.distance()) \ No newline at end of file +print(coolPoint.distance()) +print(wrong.distance()) +#We know the last one's bogus because it's value is -1 \ No newline at end of file From 8f35752b6055479d037663b8fa4c23a0206429c5 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 30 Oct 2019 19:15:13 -0700 Subject: [PATCH 17/27] Added clarification comments + better code for assignments 1 and 2 --- Rubik's cube math.py | 4 +- .../ch_1_assign_Arthur_Zarins_.cpython-37.pyc | Bin 1071 -> 1360 bytes ch_1_assign_Arthur_Zarins_.py | 82 +++++++++++------- ch_2_assign_Arthur_Zarins.py | 2 + 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/Rubik's cube math.py b/Rubik's cube math.py index 8c10444..5b4719c 100644 --- a/Rubik's cube math.py +++ b/Rubik's cube math.py @@ -21,6 +21,6 @@ def combos(self): ** round(((self.size - 2) / 2) ** 2)) return total - -myCube = cube(2) +#Disclaimer: This may return inf (infinity) for 10x10 cubes and up. Sadly, computer calculators are also limited. +myCube = cube(9) print(myCube.combos()) diff --git a/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc b/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc index f444df1e717887441297dd9727afe08bc265d597..86a40dffe96a169c263b3cf1c58212e3e5ba6569 100644 GIT binary patch delta 547 zcmYLGv2GJV5S^J_oAWu22m#Jc0Sk&qEYc)DfFLb$0fhw;QV#YcpN^bicTYmrol-bu zn&@gIB2l48KnpD&K<$RlK%!#yY{W=2^WMzt?Ck94;Ago0sMiaDW#i$u7axQ3^*&C{ zcj7hOKZWO{2Tx(R_4VvMo_yh&5;bOI6?GlOyqQpuryO<*)S<(Y&qsGacOzgTnSfqvF#X34 z>I=GYzc(_(gU-57rqe7<)UzZu27RRSIJU0g3rg)D+^c`kZnx!<_}DIlb*BDJpH!bq ztv5gl1C)4^^*Xl6V@Xth7h5N;Vq3p z1MgFeX1B+a*s0ViH%XKqLFL8q%fvhgRU@;=7wjza*2V5$Vn~bDIL+S_&TR61Oex-H zJun+gm*yIyMb8xZ;WT$?UQ7$S&mkMI0VIA_fF@!*8Vck8zG-Em`j@zeyLDUM?X-f; I5JL*ZU)C6S{{R30 delta 263 zcmYL@ze)o^5Qk@G=Pu`lTQo}km4eZL50F|?r%5ds+!PYD*xPa!i!`=j1uI2c8}Ut2 zN?yaxLL3fBrkMHQV`hG9{ZW{UveY2;{q%Bqov%z6uU4lsp2D#E`S^_Y58^CF^58K* z4+8dJiLYeo4WkMeIiOVwawD&TTB79zyOGTz-R=LIvCSjbH`q2j1ljL^Ejl2~HSg6- zJKp|EUu2A)Z0M%?!E;BFCLO4=rmDQ#WPU!otmNX#7HZmSzPK8WPhWmOl XB-a$_4%06WaF9;2 2: - reference = "are" - else: - if attribute == "Events": - attributeDisplay = "only Event" - reference = "is" - print("Team " + str(teamName) + "'s " + str(attributeDisplay) + " " + str(reference) + " " + str(teams[teamName][attribute])) -#The big test, comprised of 3 questions: + # New variable refernce will handle grammer related to pluralities + if (attribute == "Events" or attribute == "Rookie Year" or attribute == "Location" or attribute == "Last Year"): + if(teamName in teams): + reference = "is" + stringTest = str(teams[teamName][attribute]).split(",") + attributeDisplay = attribute + if attribute == "Events" and len(stringTest) > 2: + reference = "are" + else: + if attribute == "Events": + attributeDisplay = "only Event" + reference = "is" + + print("Team " + str(teamName) + "'s " + str(attributeDisplay) + + " " + str(reference) + " " + str(teams[teamName][attribute])) + + +# The big test, comprised of 3 questions: teamStats("1678", 'Location') teamStats("1678", 'Events') -#Just one event: demonstration of proper grammer -teamStats("3421", 'Events') \ No newline at end of file +# Just one event: demonstration of proper grammer +teamStats("3421", 'Events') + + +def runContinuous(): + while(True): + a1 = input("What is the team number?\n ") + a2 = input("What's the stat?\n ") + teamStats(a1, a2) + +#If you want to run the program, uncomment the following line (commented so chapter 3 can work): +#runContinuous() diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py index 09d89cc..282bbc2 100644 --- a/ch_2_assign_Arthur_Zarins.py +++ b/ch_2_assign_Arthur_Zarins.py @@ -85,3 +85,5 @@ def runContinuous(): # States the stats for the team, specifically the attributes a1 = input("What is the team number?\n ") teamStats(a1) +#Uncomment the following line to run the program: +#runContinuous() \ No newline at end of file From b98610d00c15969985cbbfa54c4f8e1139645da2 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 30 Oct 2019 19:58:13 -0700 Subject: [PATCH 18/27] Updated chapter 4 --- ch_4_assign_Arthur_Zarins.py | 45 +++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py index 60a65d6..9118678 100644 --- a/ch_4_assign_Arthur_Zarins.py +++ b/ch_4_assign_Arthur_Zarins.py @@ -1,21 +1,26 @@ import math + + def is_number(s): try: float(s) return True except ValueError: pass + + class Point: def __init__(self, x, y): self.x = x self.y = y - + def distance(self): if (is_number(self.x) and is_number(self.y)): - return math.sqrt(self.x **2 + self.y **2) + return math.sqrt(float(self.x) ** 2 + float(self.y) ** 2) else: return -1 - + + class Point3d(Point): def __init__(self, x, y, z): super().__init__(x, y) @@ -23,14 +28,32 @@ def __init__(self, x, y, z): def distance(self): if (is_number(self.x) and is_number(self.y) and is_number(self.z)): - return math.sqrt(self.z **2 + super().distance() ** 2) + return math.sqrt(float(self.z) ** 2 + super().distance() ** 2) else: return -1 -boringPoint2d = Point(3, 4) -coolPoint = Point3d(3, -4, 4) -wrong = Point3d("q", -4, 4) -print(boringPoint2d.distance()) -print(coolPoint.distance()) -print(wrong.distance()) -#We know the last one's bogus because it's value is -1 \ No newline at end of file + +while True: + a1 = input("give the x value of the 2d point \n") + a2 = input("give the y value of the 2d point\n") + a3 = input("give the x value of the 3d point\n") + a4 = input("give the y value of the 3d point\n") + a5 = input("give the z value of the 3d point\n") + boringPoint2d = Point(a1, a2) + coolPoint = Point3d(a3, a4, a5) + + if boringPoint2d.distance() == -1: + print("The 2d point has arguements that are not real numbers") + if coolPoint.distance() == -1: + print("The 3d point has arguements that are not real numbers") + if boringPoint2d.distance() == coolPoint.distance(): + print("They have equal distances") + if boringPoint2d.distance() > coolPoint.distance(): + print("The 2d point's furthur away from the orgin") + else: + print("The 3d point's furthur away from the orgin") + print("The distance from the 2d point to orgin: " + + str(boringPoint2d.distance())) + print("The distance from the 3d point to orgin: " + str(coolPoint.distance())) + +# We know the last one's bogus because it's value is -1 From 600d3832ea71cbe2128f41a809a0eff193b171f3 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 31 Oct 2019 16:46:46 -0700 Subject: [PATCH 19/27] . --- ch_4_assign_Arthur_Zarins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py index 9118678..b8389d9 100644 --- a/ch_4_assign_Arthur_Zarins.py +++ b/ch_4_assign_Arthur_Zarins.py @@ -55,5 +55,5 @@ def distance(self): print("The distance from the 2d point to orgin: " + str(boringPoint2d.distance())) print("The distance from the 3d point to orgin: " + str(coolPoint.distance())) - -# We know the last one's bogus because it's value is -1 + +# We know the last one's bogus because it's value is -1 \ No newline at end of file From e7f4efd9236cd67664f3957cef2284dc2c9bb812 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 6 Nov 2019 16:26:17 -0800 Subject: [PATCH 20/27] Added user input --- ch_4_assign_Arthur_Zarins.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py index b8389d9..f15d835 100644 --- a/ch_4_assign_Arthur_Zarins.py +++ b/ch_4_assign_Arthur_Zarins.py @@ -56,4 +56,3 @@ def distance(self): str(boringPoint2d.distance())) print("The distance from the 3d point to orgin: " + str(coolPoint.distance())) -# We know the last one's bogus because it's value is -1 \ No newline at end of file From c7d8530e91a670b023eeaecbc1eb71dd8282f7f6 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 6 Nov 2019 16:28:30 -0800 Subject: [PATCH 21/27] Changed a for loop --- ch_4_assign_Arthur_Zarins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py index f15d835..303a7e4 100644 --- a/ch_4_assign_Arthur_Zarins.py +++ b/ch_4_assign_Arthur_Zarins.py @@ -50,7 +50,7 @@ def distance(self): print("They have equal distances") if boringPoint2d.distance() > coolPoint.distance(): print("The 2d point's furthur away from the orgin") - else: + elif boringPoint2d.distance() < coolPoint.distance(): print("The 3d point's furthur away from the orgin") print("The distance from the 2d point to orgin: " + str(boringPoint2d.distance())) From 863bb78901abcf5a0a5c2a23520fb42f41d48eb3 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 6 Nov 2019 19:04:16 -0800 Subject: [PATCH 22/27] Added a 5th team to Assignment 1 --- ch_1_assign_Arthur_Zarins_.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index 337bda3..ac6b0f0 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -16,7 +16,11 @@ "2942": {'Last Year': 2018, 'Location': "Seattle, WA", 'Rookie Year': 2009, - 'Events': ''} + 'Events': ''}, + "3890": {'Last Year': 2015, + 'Location': "Boulder, Colorado", + 'Rookie Year': 2003, + 'Events': 'Colorado Regional'} } #reference = "is" From ec4bbd6b15bb2f68b8bccc274acbc3ef8b587687 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Wed, 6 Nov 2019 20:46:07 -0800 Subject: [PATCH 23/27] runs --- Tester.py | 17 +++++++++++++++++ ch_1_assign_Arthur_Zarins_.py | 1 + 2 files changed, 18 insertions(+) create mode 100644 Tester.py diff --git a/Tester.py b/Tester.py new file mode 100644 index 0000000..43621fd --- /dev/null +++ b/Tester.py @@ -0,0 +1,17 @@ +# Fun test program +testA = "3|(y + |(y^2 + z^3)) + 3|(y - |(y^2 + z^3)) - b/3a" +testB = "c/3a - b^2/9a^2" +testC = "-b^3/37a^3 + bc/6a^2 - d/2a" +answerA = input("x = ") +if(answerA == testA or answerA == "skip"): + answerB = input("z = ") + if(answerB == testB or answerB == "skip"): + answerC = input("y = ") + if(answerC== testC or answerC == "skip"): + answerC = input("Congrats! All questions are correct") + else: + print("x ACTUALLY = " + testC) + else: + print("x ACTUALLY = " + testB) +else: + print("x ACTUALLY = " + testA) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index ac6b0f0..45b2f17 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -58,3 +58,4 @@ def runContinuous(): #If you want to run the program, uncomment the following line (commented so chapter 3 can work): #runContinuous() +runContinuous() \ No newline at end of file From 2683c7613c80eb9fabf90e3ac268274bd2db4d5f Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 7 Nov 2019 16:56:52 -0800 Subject: [PATCH 24/27] Fixed chapter 1 --- ch_1_assign_Arthur_Zarins_.py | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index 45b2f17..8161d68 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -3,31 +3,38 @@ "1678": {'Last Year': 2019, 'Location': "Davis CA", 'Rookie Year': 2005, - 'Events': "Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs" + 'Events': "Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs", + 'Awards': "Capital City Classic 2019, 2018 Madtown Finalist, 2018 Chezy Champs Finalist" }, "2551": {'Last Year': 2019, 'Location': "Novato CA", - 'Rookie Year': 2008, 'Events': - 'Sac Regional, SF Regional, Galileo divison'}, + 'Rookie Year': 2008, + 'Events': 'Sac Regional, SF Regional, Galileo divison', + 'Awards': "UC Davis highest rookie seed award, 2018 Sac regional innovation in control" + }, "3421": {'Last Year': 2013, 'Location': "Marysville MI", 'Rookie Year': 2010, - 'Events': 'MI FRC state championship'}, + 'Events': 'MI FRC state championship', + 'Awards': "Liviona district 2012 cooperation award"}, "2942": {'Last Year': 2018, 'Location': "Seattle, WA", 'Rookie Year': 2009, - 'Events': ''}, + 'Events': 'Seattle', + 'Awards': "2009 Seattle Imagery award"}, "3890": {'Last Year': 2015, 'Location': "Boulder, Colorado", 'Rookie Year': 2003, - 'Events': 'Colorado Regional'} + 'Events': 'South pacific regional', + 'Awards': "South pacific regional Woodie Flowers award"}, + } #reference = "is" def teamStats(teamName, attribute): # New variable refernce will handle grammer related to pluralities - if (attribute == "Events" or attribute == "Rookie Year" or attribute == "Location" or attribute == "Last Year"): + if (attribute == "Events" or attribute == "Rookie Year" or attribute == "Location" or attribute == "Last Year" or attribute == "Awards"): if(teamName in teams): reference = "is" stringTest = str(teams[teamName][attribute]).split(",") @@ -40,15 +47,11 @@ def teamStats(teamName, attribute): reference = "is" print("Team " + str(teamName) + "'s " + str(attributeDisplay) + - " " + str(reference) + " " + str(teams[teamName][attribute])) - - -# The big test, comprised of 3 questions: -teamStats("1678", 'Location') -teamStats("1678", 'Events') -# Just one event: demonstration of proper grammer -teamStats("3421", 'Events') - + " " + str(reference) + " " + str(teams[teamName][attribute])) + else: + print("That team does not exist") + else: + print("That stat does not exist") def runContinuous(): while(True): @@ -56,6 +59,7 @@ def runContinuous(): a2 = input("What's the stat?\n ") teamStats(a1, a2) -#If you want to run the program, uncomment the following line (commented so chapter 3 can work): -#runContinuous() -runContinuous() \ No newline at end of file + +# If you want to run the program, uncomment the following line (commented so chapter 3 can work): +# runContinuous() +runContinuous() From dcfe699c4c03fd87a5afeae110bb13025e128672 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Thu, 7 Nov 2019 17:15:27 -0800 Subject: [PATCH 25/27] Added competition locations --- ch_1_assign_Arthur_Zarins_.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py index 8161d68..81db8db 100644 --- a/ch_1_assign_Arthur_Zarins_.py +++ b/ch_1_assign_Arthur_Zarins_.py @@ -4,29 +4,34 @@ 'Location': "Davis CA", 'Rookie Year': 2005, 'Events': "Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs", - 'Awards': "Capital City Classic 2019, 2018 Madtown Finalist, 2018 Chezy Champs Finalist" + 'Awards': "Capital City Classic 2019, 2018 Madtown Finalist, 2018 Chezy Champs Finalist", + "Competed At": "Davis CA, Fresno CA, Houston TX, Lancaster CA" }, "2551": {'Last Year': 2019, 'Location': "Novato CA", 'Rookie Year': 2008, 'Events': 'Sac Regional, SF Regional, Galileo divison', - 'Awards': "UC Davis highest rookie seed award, 2018 Sac regional innovation in control" + 'Awards': "UC Davis highest rookie seed award, 2018 Sac regional innovation in control", + "Competed At": "San Francisco CA, Sacramento CA, Houston TX, Elk Grove CA" }, "3421": {'Last Year': 2013, 'Location': "Marysville MI", 'Rookie Year': 2010, 'Events': 'MI FRC state championship', - 'Awards': "Liviona district 2012 cooperation award"}, + 'Awards': "Liviona district 2012 cooperation award", + "Competed At": "Flint MI, Livonia MI, Ypsilanti MI"}, "2942": {'Last Year': 2018, 'Location': "Seattle, WA", 'Rookie Year': 2009, 'Events': 'Seattle', - 'Awards': "2009 Seattle Imagery award"}, + 'Awards': "2009 Seattle Imagery award", + "Competed At": "Auburn WA"}, "3890": {'Last Year': 2015, 'Location': "Boulder, Colorado", 'Rookie Year': 2003, 'Events': 'South pacific regional', - 'Awards': "South pacific regional Woodie Flowers award"}, + 'Awards': "South pacific regional Woodie Flowers award", + "Competed At": "San Francisco CA, Houston TX, Elk Grove CA, Sacramento CA"} } #reference = "is" @@ -34,7 +39,7 @@ def teamStats(teamName, attribute): # New variable refernce will handle grammer related to pluralities - if (attribute == "Events" or attribute == "Rookie Year" or attribute == "Location" or attribute == "Last Year" or attribute == "Awards"): + if (attribute == "Events" or attribute == "Rookie Year" or attribute == "Location" or attribute == "Last Year" or attribute == "Awards" or attribute == "Competed At"): if(teamName in teams): reference = "is" stringTest = str(teams[teamName][attribute]).split(",") From d3b9c2cf0227f90b47ce02ba1fb1345ee04b3409 Mon Sep 17 00:00:00 2001 From: azarins1 Date: Fri, 8 Nov 2019 16:59:40 -0800 Subject: [PATCH 26/27] Fix chapter 1 and 2's running errors (Running when imported or not running at all when called) --- .../ch_1_assign_Arthur_Zarins_.cpython-37.pyc | Bin 1360 -> 2080 bytes ch_1_assign_Arthur_Zarins_.py | 4 +++- ch_2_assign_Arthur_Zarins.py | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc b/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc index 86a40dffe96a169c263b3cf1c58212e3e5ba6569..973676aac3392efbecda6912ca4ae3be37666000 100644 GIT binary patch literal 2080 zcmZuy&2Jk;6yF`Mowbv+3A9a93LQ#O3AiXREi|ZnxNcJ-l1RiUp;nMJ*_p(H*E7q^ z*sWLgDf|Q6djJkd{1Y4zMf4go0R z6~(lWfJGU9B)i&3fww*@<251z0vRaKEEMA68Zh`CBP#LNWRS)fPi{)t=4>P`-0lHx zIw@4|6Ge4AS(BZJ8Afr{#KjHSBgT5+e^|s{KaO~PWenvz5Przy2umsAkMGv-DBKp` zZ!ri%jofMm#)VqCINZglY*0!z87g85@EP?_K$ToS!cwUkd^UvmH!En z#zZEG&s7!|mvP47)ehNbsy_lKE>^p{T_x5cS|7zuD>auHE z7@C~#L4O^h8NcytIo_6%LI+z$b7lEz1?cO`ivfby!;XCR)nL`X!8CBG+eUg3R+O!|Z1u7=pREOW6n-8!#%UMS zk91;)jBA{MGY>ZAodfq9ME!5wVQ%0Ky^&QFncN_E;L>8-QxPos>=@Ti9p3vjI=3u|;eEEy<=t)ZnAE+5iQ3sx@*$rhAK6cTRYb8(a zqspZ_#%^1JxPI)G|FuUOIigrxk|ONm^n%9uEk-&x&Ry2{v5VugTP&;+wYFB_JNWWZ=K+z#T&SP$=rqwM8Ge2MEfDwnt^lZNwM0 zEv)b#V_Iy4uIP4lnfjoF(-F_v4NwECw-_HP7EqGsBI=qn5a1A5g0GSyGMZ)}j$~SO zMGYP`F1qk)zXu}i!{oRKQuAGP+HUfj%?^OnY;G)g%BoYNM>+xZX*S0!Thvu*-oMe2 lv>USbZT9*mOb9HGeg%N)@OO+pk|MV-Mo$&|(|*xM{{h{&PAdQa delta 675 zcmYk4zi-n(6vy9tKD(|HL(;T$(6Po#{X)A|YDwA`!X7(%D&%tqkeV z6?yGYq>ddJ5&r-yvyoU>_%nFt2Bjyx@B7@Z@4GwQRqLlWd+GZgNNd0N{`T4h_+vW% zoAlwiMEXI5fsu(VR+mcHW`|d5c6pUOZq(dlpYQSgnp>A@2;Ania~R?Xxx?#oLa1qD zK^vP~BL}=C%ZR(j5N?0I{zjoHf8kEKO$X&~8kFy>U{*n>DiuB6e==14y}hVXyMult z{B+QNPjW=l>_r?(PQQxe$QV=FlT3?jEwYM9-{g=%?C2Y|3(7Eq9J;cn3v;|8cD`U? zT Date: Sat, 9 Nov 2019 16:27:43 -0800 Subject: [PATCH 27/27] Allow team names to be used to issue commands --- .../ch_1_assign_Arthur_Zarins_.cpython-37.pyc | Bin 2080 -> 2725 bytes ch_1_assign_Arthur_Zarins_.py | 53 ++++++++++++++---- ch_2_assign_Arthur_Zarins.py | 50 ++++++++++++----- 3 files changed, 77 insertions(+), 26 deletions(-) diff --git a/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc b/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc index 973676aac3392efbecda6912ca4ae3be37666000..eca510238f47f8d5b16ac9f1bbdae9bcb0b11c62 100644 GIT binary patch delta 1191 zcmZWn&1(}u6rY)$-E23>wpNY(@T1!L5x>A96;V{IC_*j83hJVSHE*d)(oH%u!B{pH zi3d+2?$tvD74+u8t9TInA6D=p2>t=yeX~hbbe8wtyx;8me(OW8wyvEo79E0T=Z(*| z3!4b}rj?CTz{@!#`3xBlpuoTY4klQTd!7RukpXZZ4+SV@hzo--1e;(OHp7+-*$O4t z1|u*EV=$f}+hGUngk3NJyW!HF44QmydIY9m?<3+-*a!PjGB^Nblm;AxLnwJ*!r>Yd zPXgX0l)#ZiQa$iHRbRlh zpn5m?${r4S#RWeC|7zn-LxokDRE$fmSGefcf@^`locVced|0AbxjqIGN18>FQ^=M` zhqlLJvQA!*3*@%jVKH5&F?&HNS#htEm|}i(zRXfy3+~I*@|(>dg0hiv2&*dP^-!wR zz_&L*^wP;-bL(lKmggmUUqmkB+H>ffp8bh1=t@S=#KUD}}vQ|My&_C!oE zrI8L(n9wNBZIr|WTUUzNB3UV2CxEhS%nR-E2NEixu!b@<6;>}(vnj$zl?^Yi^+hFg zLp)n6^DTU*ZK2nu$MV{6K>x9LF9@2)P?b7kLT&sUI)q%{Zjma}C?2y#kYiWAdKw9T&=ojV^9ujSB%zhebo$CD!~P`N=Pg zL~oTDlP=XJXnd!qbqE?y?LlDpkGmg3N9zdLpY{%zp qOYGCj4QSPaGrEg%0U4vo*IX(2o^un&&d6o7z-`O6?MZvUX1@TCjR+|K delta 623 zcmYjLL2DC16rOpryP4f2O;SzNnrgKzZEjUWFI7twL?{LA$$%^iZx3OUO*%6Hkw_^O z5j@FUd+?xw2M_*%o}_s2;K9>g{Ug5Jq~aUi_r33%nQ!J(^F#e$yIKtx)%&^A=btN# z{mI2ym1)?b)-MQMGg|1)~=dgx#Y!rGP&*6D&Vhb-6`XXM! z1-y)HTrBjJW4F7?@G367W?hcg@H#QX0+$m|CWa%%8LsTH&g!?*+njq=z;Qa7-lSH?9AAmu}ASgCd{zJQzv$-w9-~1BPQaAqn|ix zguyFF>(f9rv2RKbVgHx?Sz1^Idgx{O>2R3z;-zPCq!iB`e<#vrs)hCCe#gyR6GsD` z32jv7>QTREGSQFI%pIv-YC3LL<_C7|M|sEj!c@(!xsO|Z?(Lb#=yi(KZ2|@xmisLi z0#FTm%YS>&AhQD*L^r5!sv5~D)M?79YMee8rlyyUhhu%0EG-Eb2QF!;W`0P9;UMaz zVYu6IRKBh9(0_YrG>F6SzvSYLB3^E;4~97I$M*!?(Axw+(bMI@*#z7Jdl 2: + reference = "are" + else: + if attribute == "Events": + attributeDisplay = "only Event" + reference = "is" + + print("Team " + str(teamname) + "'s " + str(attributeDisplay) + + " " + str(reference) + " " + str(teams[teamname][attribute])) + elif (nameSweep(teamname) in teams): + teamname = nameSweep(teamname) reference = "is" - stringTest = str(teams[teamName][attribute]).split(",") + stringTest = str(teams[teamname][attribute]).split(",") attributeDisplay = attribute if attribute == "Events" and len(stringTest) > 2: reference = "are" @@ -51,8 +82,8 @@ def teamStats(teamName, attribute): attributeDisplay = "only Event" reference = "is" - print("Team " + str(teamName) + "'s " + str(attributeDisplay) + - " " + str(reference) + " " + str(teams[teamName][attribute])) + print("Team " + str(teamname) + "'s " + str(attributeDisplay) + + " " + str(reference) + " " + str(teams[teamname][attribute])) else: print("That team does not exist") else: diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py index 3f1b6e8..8543643 100644 --- a/ch_2_assign_Arthur_Zarins.py +++ b/ch_2_assign_Arthur_Zarins.py @@ -1,21 +1,25 @@ import ch_1_assign_Arthur_Zarins_ # Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 + + def is_number(s): try: float(s) return True except ValueError: pass + + def add(team): if(str(team) not in ch_1_assign_Arthur_Zarins_.teams): if is_number(team) == True: ch_1_assign_Arthur_Zarins_.teams.update({str(team): {"name": "", - "language": "", - "width": "", - "length": "", - "motors": "", - "cameraVision": False - }}) + "language": "", + "width": "", + "length": "", + "motors": "", + "cameraVision": False + }}) print("Team " + str(team) + " added successfully.\n ") else: print("Team name must be a number") @@ -25,13 +29,16 @@ def add(team): def update(team, stat, updateTxt): if search(team) == True: - ch_1_assign_Arthur_Zarins_.teams[team].update({str(stat): str(updateTxt)}) + ch_1_assign_Arthur_Zarins_.teams[team].update( + {str(stat): str(updateTxt)}) print("Successfully updated an attribute of " + team) + def remove(team): if(search(team)): ch_1_assign_Arthur_Zarins_.teams.pop(str(team), None) + def search(team): if(str(team) in ch_1_assign_Arthur_Zarins_.teams): print("Team " + team + " exists") @@ -40,6 +47,7 @@ def search(team): print("Error: team " + team + " does not exist") return False + def listTeams(): teamList = [] for i in ch_1_assign_Arthur_Zarins_.teams.keys(): @@ -47,12 +55,14 @@ def listTeams(): print("All teams: ") print(teamList) + def teamStats(team): if(search(team)): print("Stats for team " + team + ":") print(ch_1_assign_Arthur_Zarins_.teams[team]) # Now we can ask questions + def runContinuous(): while True: # constant prompt @@ -61,31 +71,41 @@ def runContinuous(): if function == "add": # Adds a new team to the database a1 = input( - "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM NAME OVERWRITES OLD DATA\n ") + "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM name OVERWRITES OLD DATA\n ") add(str(a1)) elif function == "update": # Updates a team attribute - a1 = input("What is the team number?\n ") + # MUST REFER TO IT Y NUMBER + a1 = input( + "What is the team number? NAMES NOT ALLOWED for this attribute\n ") a2 = input( "What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") a3 = input("What is the team attribute NEW value?\n ") update(a1, a2, a3) elif function == "remove": # Removes a team - a1 = input("What is the team number?\n ") + a1 = input("What is the team number / name?\n ") + if(int(ch_1_assign_Arthur_Zarins_.nameSweep(a1)) > 0): + a1 = ch_1_assign_Arthur_Zarins_.nameSweep(a1) remove(a1) elif function == "search": # States if a team exists - a1 = input("What is the team number?\n ") + a1 = input("What is the team number / name?\n ") + if(int(ch_1_assign_Arthur_Zarins_.nameSweep(a1)) > 0): + a1 = ch_1_assign_Arthur_Zarins_.nameSweep(a1) search(a1) elif function == "listTeams": # State all existing teams listTeams() elif function == "teamStats": # States the stats for the team, specifically the attributes - a1 = input("What is the team number?\n ") + a1 = input("What is the team number / name?\n ") + if(int(ch_1_assign_Arthur_Zarins_.nameSweep(a1)) > 0): + a1 = ch_1_assign_Arthur_Zarins_.nameSweep(a1) teamStats(a1) -#Uncomment the following line to run the program: + + +# Uncomment the following line to run the program: if __name__ == "__main__": - #only run the program if chapter 2 is called - runContinuous() \ No newline at end of file + # only run the program if chapter 2 is called + runContinuous()