[英]What qualifies as an algorithm?
class Athlete:
def __init__(self, name, points):
self.name = name
self.points = points
def calculateRacePoints(name):
for i in range(eventTotalVar):
racePoints = checkOverallPlacement(placementVar, eventType=eventVar) + checkPercentagePlacement(placementVar, totalVar, eventType=eventVar) + checkImprovement(seedTime, prelimTime, finalTime) # uses created 2 functions and finds the total
racePoints = racePoints + racePoints
return float(racePoints / eventTotalVar)
This is basically creating an athlete
with inputted specifications.这基本上是创建具有输入规格的
athlete
。 It will return the average points attained in the race (total points divided by number of events).它将返回比赛中获得的平均分(总分除以事件数)。
Do classes
qualify as an algorithm? classes
有资格作为算法吗? If so, do my two functions within it also qualify as an algorithm?如果是这样,我在其中的两个函数是否也有资格作为算法? What specifically makes an algorithm, well, an algorithm?
是什么让一个算法,好吧,一个算法?
Oxford Dictionary defines an Algorithm as:牛津词典将算法定义为:
"A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer".
“在计算或其他解决问题的操作中要遵循的过程或一组规则,尤其是计算机”。
By that definition something as simple as print("Hello World")
would technically be considered an algorithm.根据该定义,像
print("Hello World")
这样简单的东西在技术上将被视为一种算法。
looking at your code:查看您的代码:
class Athlete:
def __init__(self, name, points):
self.name = name
self.points = points
def calculateRacePoints(name):
for i in range(eventTotalVar):
racePoints = checkOverallPlacement(placementVar, eventType=eventVar) + checkPercentagePlacement(placementVar, totalVar, eventType=eventVar) + checkImprovement(seedTime, prelimTime, finalTime) # uses created 2 functions and finds the total
racePoints = racePoints + racePoints
return float(racePoints / eventTotalVar)
You have multiple algorithms at work.你有多种算法在工作。
class Athlete class 运动员
def __init__(self, name, points) def __init__(self, name, points)
def calculateRacePoints(name) def calculateRacePoints(名称)
Both of your class methods are algorithms that work together to help the program create new athletes and interact with them.您的两种 class 方法都是协同工作以帮助程序创建新运动员并与他们互动的算法。
I would imagine you need to provide more detail to complete the assignment, but I hope this gets you started.我想你需要提供更多细节来完成作业,但我希望这能让你开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.