题目
题目
单项选择题

Question at position 19 Consider the following code snippet: class LinearEquation: def __init__(self, m, b): self.m = m # slope self.b = b # y-intercept # Missing code: define a method that, given x, returns y = mx + b. Which option correctly fills in the missing code?def solve(self, x): return self.m * x + self.bdef solve(self, x): print(self.m * x + self.b)def solve(self, x): return self.m + x + self.bdef solve(m, b, x): return m * x + bClear my selection

选项
A.def solve(self, x):     return self.m * x + self.b
B.def solve(self, x):     print(self.m * x + self.b)
C.def solve(self, x):     return self.m + x + self.b
D.def solve(m, b, x):     return m * x + b
查看解析

查看解析

标准答案
Please login to view
思路分析
Question at position 19 asks about completing a class method that computes y = mx + b for a given x. The class stores m as the slope and b as the y-intercept in __init__. The missing code should define a method solve(self, x) that returns the value of mx + b. Option 1: def solve(self, x): return self.m * x + self.b This option defines a method solve that takes x as input an......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!