Algorithm 如何在不使用决策结构的情况下将python中的负数更改为零
我有一个程序,可以确定你每天从一个活动中获得的点数,持续5天 源代码:Algorithm 如何在不使用决策结构的情况下将python中的负数更改为零,algorithm,python-3.x,validation,negative-number,Algorithm,Python 3.x,Validation,Negative Number,我有一个程序,可以确定你每天从一个活动中获得的点数,持续5天 源代码: total=0 for x in range (5): points=int(input('How many points did you get today?')) total=total+points print ('You got {0} points this event'.format(total)) 我的问题是如何让它在不使用决策语句的情况下使任何小于或等于零的数字变为0(if's,case
total=0
for x in range (5):
points=int(input('How many points did you get today?'))
total=total+points
print ('You got {0} points this event'.format(total))
我的问题是如何让它在不使用决策语句的情况下使任何小于或等于零的数字变为0(if's,case's,我认为while或for循环也是不允许的)可以使用内置函数吗?因为这通常是通过以下方式完成的:
max(0, points)
>>> f=lambda a: (abs(a)+a)/2
>>> f(a)
0
>>> f(3)
3
>>> f(-3)
0
>>> f(0)
0