Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON - I keep getting the same error message. I must have it as an integer and I must have all scripts into one .py

PYTHON - I keep getting the same error message. I must have it as an integer and I must have all scripts into one .py file. This is a follow up question to this question:

https://www.chegg.com/homework-help/questions-and-answers/python-anyone-please-explain-wrong-don-t-understand-wrong-line-65-using-python-38-trying-f-q68172722?trackid=V5ZR18xp

Its stating that my line 136 and line 51 are wrong, but I don't understand. What am I doing wrong here? any advise is truly appreciated

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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. In [1]: runfile" wdir=' Traceback (most recent call last): line s, in 4), "Number between @ and 4.' self.courses[course] = score self._courses.update({ course:score}) 58 59 '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] #_str_0: #This method should output a formatted string such that printing multiple Student objects will line up. Example result for 3 objects (fields shown: id, lastName, firstName, GPA, courses): def _str_(self):return '%-50 %-155 %-155 %-6.2f %-10s '%(self.id, self.lastName, self.firstName, self-gpa(), self.courses) #_repr_0: #We will not directly use this method, but it should have an output similar to _str_- #However, the column formatting is not necessary. You can use commas in between fields: 76 def _repr_(self): return str(self.id) + ',' + self.lastName + ',' + self.firstName + ',' + str(self.gpa())+ ',' + self.courses #header() signature: #def header(): #This method returns a string that can used as a header for the results of the _str_method. #Notice that this is a class method because there is no "self" parameter, so it will be called using Student.header(). @classmethod def signature(cls): return '%-55 %-155 %-155 %-65 %-105 '%('ID', "Last Name", "First Name", "GPA", "Courses") return "ID Last Name First Name GPA Courses" + " ========== ==================== " def getId(self): return self._id def setId(self,id): self._id = id def getFirstName(self): return self__firstName 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 184 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 def setFirstName(self, firstName): self._firstName = firstName def getLastName(self): return self._lastName def setLastName(self, lastName): self._lastName = lastName def getCourses(self): return self._courses #PART 2 ============== def printStudents(students): print('{:10}'.format('ID'), '{:20}'.format("Last Name'), '{:20}'.format("First Name'), '{:>5}'.format("GPA), ' Courses') print('============ ========================================================') for student in students: gpa=0 courses = student.getCourses () for course in courses: gpa/float(len(student.getCourses())) gpa += courses [ course] spa = print('{:=3.5: top.append(name) return top 1=list(gpahigh() printStudents(1) #query 5

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

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

3. Outline the four major approaches to informative speeches

Answered: 1 week ago

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago