Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python - Can anyone please explain to me what I am doing wrong here? I don't understand what I am doing wrong on line 65?

Python - Can anyone please explain to me what I am doing wrong here? I don't understand what I am doing wrong on line 65? I am using Python 3.8

image text in transcribed

I am trying to follow the instructions below (see the red markers)

image text in transcribedimage text in transcribed

Spyder (Python 3.8) File Edit Search Source Run Debug Consoles Projects Tools View Help ICC: EE >> 2. KY Source Console Object O part 3.py fraction.py TestSQLite.py read-LastNames.py Lab 5 part 2.py Lab 5 Part 3a.py Lab 5 Part 3b.py untitled3.py* Redo.py Usage class Student: 37 38 39 40 41 42 43 44 45 46 Here you can get help of any object by pressing Ctrl+ in front of it, either on the Editor or the Console. def _init_(self, id, firstName, lastName, courses = None ): self._id=id self. __firstName = firstName self._lastName = lastName Help can also be shown automatically after writing a left parenthesis next to an object. You can activate this behavior in Preferences > Help New to Spyder? Read our tutorial if courses is None: self._courses = dict() else: self._courses = courses def spa(self): if len(self.courses.keys()) == 0: return @ else: Tot = 0 for course in self.courses: Tot = Tot + self.courses[course] return (Tot/float(len(self.courses.keys()))) Variable explorer Help Plots Files def addCourse(self, courseName, score): self._courses.update({ courseName: score})" ** C Console 2/A 63 64 65 66 Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 7.16.1 -- An enhanced Interactive Python. def addCourse(self, course, score): assert isinstance(score, int), 'Needs to be an integer: 'r' % score assert (score 4), "Number between 0 and 4.' self.courses[course] = score self._courses.update({ course:score}) ""'def addCourses (self, courses): self._courses.update (courses)'*' def addcourses (self, courses): assert type(courses) is dict, "No Dictionary." for key in courses: if key not in self.courses.keys(): self.courses [key] = courses[key] In [1]: runfile('C:/Users/sgolrang/Desktop/UCSD Ext/PYTHON/Python Intermediate/Class 3/Redo.py', wdir='C:/Users/ sgolrang/Desktop/UCSD Ext/PYTHON/Python Intermediate/Class 3') Traceback (most recent call last): in

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

6.5 Identify at least 10 methods used for external recruitment.

Answered: 1 week ago

Question

Have roles been defined and assigned?

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago