当前位置:网站首页>[CodeWars] Convert Decimal Degrees to Degrees, Minutes, Seconds
[CodeWars] Convert Decimal Degrees to Degrees, Minutes, Seconds
2022-06-23 01:50:00 【Rookie's attack】
CodeWars Inside 7kyu subject Convert Decimal Degrees, Minutes, Seconds
Title Description :
Description:
Convert Decimal Degrees to Degrees, Minutes, Seconds.
Remember: 1 degree = 60 minutes; 1 minute = 60 seconds.
Input: Positive number.
Output: Array [degrees, minutes, seconds]. E.g [30, 25, 25]
Trailing zeroes should be omitted in the output. E.g
convert (50)
//correct output -> [50]
//wrong output -> [50, 0, 0]
convert(80.5)
//correct output -> [ 80, 30 ]
//wrong output -> [80, 30, 0]
convert(0.0001388888888888889)
//correct output -> [ 0, 0, 1 ]
//wrong output -> [1]
Round the seconds to the nearest integer.
python resolvent :
Code :
def convert(degrees):
l = []
h = int(degrees // 1)
degrees = (degrees % 1) * 60
m = int(degrees // 1)
degrees = (degrees - m) * 60
s = int(degrees // 1)
if degrees % 1 > 0.5:
s = s + 1
if s == 60:
m = m + 1
s = 0
if m == 60:
h = h + 1
m = 0
if s == 0:
if m == 0:
l.append(h)
else:
l = [h, m]
else:
l = [h, m, s]
return l
边栏推荐
- Day575: divide candy
- Primary pointer part
- Autumn move script C
- 人民币的单位的大写
- Questions not written in the monthly contest
- Is it safe for Hongyuan futures to open an account? Can Hongyuan futures company reduce the handling fee?
- office2016+visio2016
- //1.13 auto increment and auto decrement operators (+ +, --)
- Pat class A - 1015 reversible primes
- 1. Mx6u image burning principle (no specific process)
猜你喜欢
![[learning notes] roll back Mo team](/img/19/d374dd172b9609a3f57de50791b19e.png)
[learning notes] roll back Mo team

2D prefix and

Autumn move script a

1. Mx6u bare metal program (5) - external interrupt

Do you know the memory components of MySQL InnoDB?

Foundation Consolidation - Flex width is content width

fatal: refusing to merge unrelated histories

Autumn move script B

1. Mx6u startup mode and equipment

LeetCode 206. Reverse linked list (iteration + recursion)
随机推荐
[ZOJ] P3228 Searching the String
C. Diluc and Kaeya——Codeforces Round #724 (Div. 2)
Garbled code of SecureCRT, double lines, double characters, unable to input (personal detection)
Constexpr keyword
A blog allows you to understand the use of material design
3D打印微组织
崔鹏团队:万字长文梳理「稳定学习」全景图
Rebirth -- C language and the story I have to tell (text)
Branch and loop statements (including goto statements) -part2
Day575: divide candy
[hdu] p1466 calculate the number of intersections of straight lines
1. introduction to MySQL database connection pool function technology points
Day500: keyboard line
11. function template, class template, implementation vector sequence container, and space adapter
office2016+visio2016
Modulenotfounderror: no module named 'rospy', PIP could not find the installation package
278. digital combination
Using WordPress to create a MySQL based education website (learning notes 2) (technical notes 1) xampp error1045 solution
It's still like this
Exercise analysis summary