我有likes variable
和dislikes variable
,我应该如何将其更改为0到5的等级?
示例:
0 Likes - 0 Dislikes
= 0评分1 Likes - 0 Dislikes
= 5评级5 Likes - 5 Dislikes
= 2.5评分非常感谢...
答案 0 :(得分:2)
5 *喜欢/(喜欢+不喜欢)
UPD:从评论中添加以保留格式:
if dislikes is 0:
if likes is 0:
0
else:
5
else:
5 * likes / (likes + dislikes)