SlideShare a Scribd company logo
For any help regarding Python Homework Help
visit : - https://www.pythonhomeworkhelp.com/,
Email :- support@pythonhomeworkhelp.com or
call us at :- +1 (315) 557-6473
Introduction To Python Programming
1. OOP
The following definitions have been entered into a Python shell:
class Account:
chargeRate = 0.01
def init (self, start):
self.value = start
def debit(self, amount):
debitAmt = min(amount, self.value)
self.value = self.value - debitAmt
return debitAmt
def deposit(self, amount):
self.value += amount
def fee(self, baseAmt):
self.debit(baseAmt * self.chargeRate)
def withdraw(self, amount):
if self.value >= 10000.0:
self.fee(amount/2.0)
else:
self.fee(amount)
return self.debit(amount)
Assume that the following expressions have been evaluated:
Eric = Checking(4000.0)
Ellen = Account(4000.0)
Write the values of the following expressions. Write None when there is no value;
write Error when an error results and explain briefly why it’s an error.
Q.1.1 Eric.withdraw(3000.0)
Ellen.withdraw(3000.0)
Q.1.2 Eric.value
Ellen.value
Q.1.3 Eric.withdraw(1000.0)
Ellen.withdraw(1000.0)
Q.1.4 Eric.value
Ellen.value
Q.1.5 Eric.deposit(5000.0)
Ellen.deposit(5000.0)
Q.1.6 Eric.value
Ellen.value
Solution:
1.1 Eric.withdraw(3000.0)
Ellen.withdraw(3000.0)
1.2 Eric.value (850.0)
Ellen.value (970.0)
1.3 Eric.withdraw(800.0)
Ellen.withdraw(960.0)
1.4 Eric.value(0.0)
Ellen.value(0.0)
1.5 Eric.deposit(None)
Ellen.deposit(None)
1.6 Eric.value(4750.0)
Ellen.value(5000.0)
2. So who Kicks
Here are some class definitions, meant to represent a league of football teams.
class Team:
def init (self, name, wins, losses, pointsFor, pointsAgainst):
self.name = name
self.wins = wins
self.losses = losses
self.pointsFor = pointsFor
self.pointsAgainst = pointsAgainst
class League:
def init (self):
self.teams = {}
def addTeam(self, team):
self.teams[team.name] = team
def updateGame(self, teamName, ptsFor, ptsAgin):
# to be filled in
def computeStat(self, proc, filt):
return [proc(team) for team in self.teams.values() if filt(team)]
Imagine instantiating these classes by:
Pats = Team(’Pats’, 5, 1, 150, 100)
Ravens = Team(’Ravens’, 4, 2, 80, 30)
Colts = Team(’Colts’, 1, 4, 100, 200)
NFL = League()
NFL.addTeam(Pats)
NFL.addTeam(Ravens)
NFL.addTeam(Colts)
We would like to be able to update our information by adding in new game data.
For example, if the Pats beat the Colts, by a score of 30 to 15, the record for the Pats
should include another win, and an updated record of points for and points
against; similarly for the Colts. We would do this by calling
NFL.updateGame(’Pats’, 30, 15)
NFL.updateGame(’Colts, 15, 30)
Q.2.1 Write a Python procedure that will complete the definition of updateGame.
You may assume that all teams exist in the instance of the league, and that there are
no ties, only wins and losses. Please make sure that the indentation of your written
solution is clear.
Q.2.2 Assume that the NFL has been defined as above, but with more teams. Write
an expression using computeStat, to be evaluated by the Python interpreter, that
will return a list of wins for all teams in the NFL. (It is okay to define and use helper
functions.) For the example instance defined above, your expression should return
the list:
[5, 4, 1]
Q.2.3 Write an expression using computeStat, to be evaluated by the Python
interpreter, that will return a list of the losses for the Pats and the Colts, where each
entry includes the name of the team. (It is okay to define and use helper functions.)
For the example instance defined above, your expression should return the list:
[[’Pats’, 1], [’Colts’, 4]]
Solution:
2.1 def updateGame(self, teamName, ptsFor, ptsAgin):
team = self.teams[teamName]
if ptsFor > ptsAgin:
team.wins += 1
else:
team.losses += 1
team.pointsFor += ptsFor
team.pointsAgainst += ptsAgain
2.2 NFL.computeStat(lambda y: y.wins, lambda x: True)
2.3 NFL.computeStat(lambda y: [y.name, y.losses],
lambda x: x.name == ’Pats’ or x.name == ’Colts’)

More Related Content

Similar to Introduction to Python Programming.pptx

Similar to Introduction to Python Programming.pptx (20)

pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Code Tuning
Code TuningCode Tuning
Code Tuning
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
Loop structures chpt_6
Loop structures chpt_6Loop structures chpt_6
Loop structures chpt_6
 
Windows 7
Windows 7Windows 7
Windows 7
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
if else python.pdf
if else python.pdfif else python.pdf
if else python.pdf
 
Python Intro-Functions
Python Intro-FunctionsPython Intro-Functions
Python Intro-Functions
 

More from Python Homework Help

Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Homework Help
 

More from Python Homework Help (20)

Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Complete my Python Homework
Complete my Python HomeworkComplete my Python Homework
Complete my Python Homework
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
 
Basic Python Programming.pptx
Basic Python Programming.pptxBasic Python Programming.pptx
Basic Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptx
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Perfect Python Homework Help
Perfect Python Homework HelpPerfect Python Homework Help
Perfect Python Homework Help
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfTamralipta Mahavidyalaya
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfjoachimlavalley1
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxDenish Jangid
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfkaushalkr1407
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasGeoBlogs
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdfCarlosHernanMontoyab2
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativePeter Windle
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

Introduction to Python Programming.pptx

  • 1. For any help regarding Python Homework Help visit : - https://www.pythonhomeworkhelp.com/, Email :- support@pythonhomeworkhelp.com or call us at :- +1 (315) 557-6473 Introduction To Python Programming
  • 2. 1. OOP The following definitions have been entered into a Python shell: class Account: chargeRate = 0.01 def init (self, start): self.value = start def debit(self, amount): debitAmt = min(amount, self.value) self.value = self.value - debitAmt return debitAmt def deposit(self, amount): self.value += amount def fee(self, baseAmt): self.debit(baseAmt * self.chargeRate) def withdraw(self, amount): if self.value >= 10000.0: self.fee(amount/2.0) else: self.fee(amount) return self.debit(amount)
  • 3. Assume that the following expressions have been evaluated: Eric = Checking(4000.0) Ellen = Account(4000.0) Write the values of the following expressions. Write None when there is no value; write Error when an error results and explain briefly why it’s an error. Q.1.1 Eric.withdraw(3000.0) Ellen.withdraw(3000.0) Q.1.2 Eric.value Ellen.value Q.1.3 Eric.withdraw(1000.0) Ellen.withdraw(1000.0) Q.1.4 Eric.value Ellen.value Q.1.5 Eric.deposit(5000.0) Ellen.deposit(5000.0)
  • 4. Q.1.6 Eric.value Ellen.value Solution: 1.1 Eric.withdraw(3000.0) Ellen.withdraw(3000.0) 1.2 Eric.value (850.0) Ellen.value (970.0) 1.3 Eric.withdraw(800.0) Ellen.withdraw(960.0) 1.4 Eric.value(0.0) Ellen.value(0.0) 1.5 Eric.deposit(None) Ellen.deposit(None) 1.6 Eric.value(4750.0) Ellen.value(5000.0)
  • 5. 2. So who Kicks Here are some class definitions, meant to represent a league of football teams. class Team: def init (self, name, wins, losses, pointsFor, pointsAgainst): self.name = name self.wins = wins self.losses = losses self.pointsFor = pointsFor self.pointsAgainst = pointsAgainst class League: def init (self): self.teams = {} def addTeam(self, team): self.teams[team.name] = team def updateGame(self, teamName, ptsFor, ptsAgin): # to be filled in def computeStat(self, proc, filt): return [proc(team) for team in self.teams.values() if filt(team)]
  • 6. Imagine instantiating these classes by: Pats = Team(’Pats’, 5, 1, 150, 100) Ravens = Team(’Ravens’, 4, 2, 80, 30) Colts = Team(’Colts’, 1, 4, 100, 200) NFL = League() NFL.addTeam(Pats) NFL.addTeam(Ravens) NFL.addTeam(Colts) We would like to be able to update our information by adding in new game data. For example, if the Pats beat the Colts, by a score of 30 to 15, the record for the Pats should include another win, and an updated record of points for and points against; similarly for the Colts. We would do this by calling NFL.updateGame(’Pats’, 30, 15) NFL.updateGame(’Colts, 15, 30) Q.2.1 Write a Python procedure that will complete the definition of updateGame. You may assume that all teams exist in the instance of the league, and that there are no ties, only wins and losses. Please make sure that the indentation of your written solution is clear.
  • 7. Q.2.2 Assume that the NFL has been defined as above, but with more teams. Write an expression using computeStat, to be evaluated by the Python interpreter, that will return a list of wins for all teams in the NFL. (It is okay to define and use helper functions.) For the example instance defined above, your expression should return the list: [5, 4, 1] Q.2.3 Write an expression using computeStat, to be evaluated by the Python interpreter, that will return a list of the losses for the Pats and the Colts, where each entry includes the name of the team. (It is okay to define and use helper functions.) For the example instance defined above, your expression should return the list: [[’Pats’, 1], [’Colts’, 4]] Solution: 2.1 def updateGame(self, teamName, ptsFor, ptsAgin): team = self.teams[teamName] if ptsFor > ptsAgin: team.wins += 1
  • 8. else: team.losses += 1 team.pointsFor += ptsFor team.pointsAgainst += ptsAgain 2.2 NFL.computeStat(lambda y: y.wins, lambda x: True) 2.3 NFL.computeStat(lambda y: [y.name, y.losses], lambda x: x.name == ’Pats’ or x.name == ’Colts’)