use*_*896 18 algorithm validation negative-number python-3.x
我有一个程序可以确定您每天获得的积分数,为期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))
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在不使用决策语句的情况下使任何数字低于或等于零(如果是,情况,我认为不允许或for循环)
Mar*_*cus 12
>>> f=lambda a: (abs(a)+a)/2
>>> f(a)
0
>>> f(3)
3
>>> f(-3)
0
>>> f(0)
0
Run Code Online (Sandbox Code Playgroud)