Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 3 Consider the following class which is an ahstraction of a Student. There are a few questions ( Questions 2 , 3 and 4

QUESTION 3
Consider the following class which is an ahstraction of a Student. There are a few questions (Questions 2,3 and 4) that will wese this class.
Use this code in select the statement below that best describes why there is an error in Method_3.
class student:
def Init_{self, nare, Ib):
self, nate = nane
self. TD =10
self,_test_scores =[]
def rethad 1(self, score):
self,_test_scores, append(score)
def nethod2(self):
1f len(selt__test_scores)2E :
return sux(self._test_scores)/len(telf._test_scares)
else:
return 8
trTHIS METHoo has AN ERHOW
def rethad_3(self) :
scarn = anthad 2()
If score 9e :
return 'A'
elif score y= ge:
return "3'
elif score x=70 :
return 'C'
elsf score 66 :
return 'D'
return "F'
def rethod 4(self):
return self._nane
def rethod s(self):
return self._ID
WTHIS METHOO HAS AN ERHOR
def str_(self):
print ('Studont with 10', ID,' has current scores:', self. test_scores)
mofnod 3 noods an additionsl argement that is the list of scores
The calculationg in mefrod 2 ans incomect.
The mothod call to mothod 2 is inoormact.
mofhod 3 has mone then 1 roturn statement which is not allownd
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions