Friendly Number

Friendly Number

Elementary+
DE EN FR PL RU UK 简体中文

长数字可以变得更漂亮,让我们编写一些代码来做到这一点。

您应该编写一个函数,使用几种规则将number 转换为字符串。

首先,您需要以给定的基数(base 参数;默认为 1000)剪切数字。

数值为浮点数,小数点后有小数 (decimals 参数;默认为 0)。 对于数值,如果小数点 = 0,则使用四舍五入规则(5.6 ⇒ 5,-5.6 ⇒ -5,取整数部分)、 否则使用标准四舍五入程序。

如果小数点后的位数大于当前位数,则将数值尾数为零。

数字应该是一个用字母表示幂的值。 您将得到一个幂的指定列表 (powers 参数;默认["", "k", "M", "G", "T", "P", "E", "Z", "Y"] )。如果没有足够的幂数,请保持最大值。

如果给出了后缀 (suffix 参数;默认为""),则必须添加后缀。

如果没有幂,0 总是 0,但有后缀。

让我们看看示例。这会更简单。

数字结果解释
102"102"默认基数为 1000,102 低于此基数
10240...
12000000,小数点后=3"12.000M"尾数为零
12461,小数点后=1"12.5k"标准四舍五入
1024000000,基数=1024,后缀="iB""976MiB不同的基数和后缀
-150, base=100, powers=["", "d", "D"]"-1d"负数和四舍五入为零
-155、基数=100、小数=1、幂=["", "d", "D"]"-1.6d"负数和标准四舍五入
255000000000, powers=["", "k", "M"]"255000M"幂次不够
You should be an authorized user in order to see the full description and start solving this mission.
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission