From e2703f522faf40895256e8719e5f5213b063db36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BB=D0=B0=D1=81=D1=81?= Date: Fri, 8 May 2026 13:34:01 +0300 Subject: [PATCH] secound --- main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 7f4f555..1a679d4 100644 --- a/main.py +++ b/main.py @@ -5,12 +5,26 @@ def to_binary(n: int)->str: - pass + answer = "" + while n: + answer =str( n % 2) + answer + n //= 2 + return answer + + + # Press the green button in the gutter to run the script. if __name__ == '__main__': - to_binary(12) + assert to_binary(5) == "101" + assert to_binary(1) == "1" + assert to_binary(8) == "1000" + assert to_binary(15) == "1111" + print(to_binary(5)) + print(to_binary(1)) + print(to_binary(8)) + print(to_binary(15)) # See PyCharm help at https://www.jetbrains.com/help/pycharm/