当前位置:网站首页>[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
边栏推荐
- Philosopher's walk gym divide and conquer + fractal
- "Initial C language" (Part 2)
- How to download online printing on Web pages to local PDF format (manual personal test)
- office2016+visio2016
- C. Unstable String
- A blog allows you to understand the use of material design
- fatal: refusing to merge unrelated histories
- Population standard deviation and sample standard deviation
- MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)
- 2D prefix and
猜你喜欢

Browser independent way to detect when image has been loaded

How to download online printing on Web pages to local PDF format (manual personal test)

1. Mx6u image burning principle (no specific process)

Unique in Pimpl_ PTR compilation errors and Solutions

How are pub and sub connected in ros1?

9. class and object practice and initialization list
![[hdu] P6964 I love counting](/img/ff/f8e79d28758c9bd3019816c8f46723.png)
[hdu] P6964 I love counting

Epoll introduction and principle explanation

3D printing microstructure

Detailed explanation of clip attribute parameters
随机推荐
Is it safe for Hongyuan futures to open an account? Can Hongyuan futures company reduce the handling fee?
2022-1-14
SYSTEMd summary
ERROR { err: YAMLException: end of the stream or a document separator is expected at line 6, colum
Google benchmark user manual and examples
Pat class A - 1007 maximum subsequence sum
Network module packaging
Day575: divide candy
1. Mx6u bare metal program (5) - external interrupt
Foundation Consolidation - Flex width is content width
[ZOJ] P3228 Searching the String
[Title Fine brushing] 2023 Hesai FPGA
3D打印微组织
How are pub and sub connected in ros1?
Classical questions of function recursion
"Initial C language" (Part 2)
Knowledge point learning
Score and loop statements (including goto statements) -part3
Branch and loop statements (including goto statements) -part1
[cmake command notes]find_ path