码迷,mamicode.com
首页 > 其他好文 > 详细

codewars--kyu8-The falling speed of petals

时间:2020-07-18 15:37:24      阅读:58      评论:0      收藏:0      [点我收藏+]

标签:code   case   types   pes   pre   cer   一个   type   com   

这个题目计算花瓣落下的速度。距离一定送一个速度计算落下的时间。

如果速度送的是小于等于0 ,就返回0 .

1 def sakura_fall(v):
2     if v<=0 :
3         return 0
4     return 5*80/v
5     # your code here

 

 

When it‘s spring Japanese cherries blossom, it‘s called "sakura" and it‘s admired a lot. The petals start to fall in late April.

Suppose that the falling speed of a petal is 5 centimeters per second (5 cm/s), and it takes 80 seconds for the petal to reach the ground from a certain branch.

Write a function that receives the speed (in cm/s) of a petal as input, and returns the time it takes for that petal to reach the ground from the same branch.

Notes:

  • The movement of the petal is quite complicated, so in this case we can see the velocity as a constant during its falling.
  • Pay attention to the data types.
  • If the initial velocity is non-positive, the return value should be 0

codewars--kyu8-The falling speed of petals

标签:code   case   types   pes   pre   cer   一个   type   com   

原文地址:https://www.cnblogs.com/zivaro/p/13335164.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!