Skip to content

Commit

Permalink
Added a plugin to convert integers to binary numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
CrsiX authored and pnhofmann committed Oct 2, 2019
1 parent f914822 commit 1447bcc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions jarviscli/plugins/binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from plugin import plugin
from colorama import Fore


@plugin("binary")
def binary(jarvis, s):
"""
Converts an integer into a binary number
"""

if s == "":
s = jarvis.input("What's your number? ")

try:
n = int(s)
except ValueError:
jarvis.say("This is no number, right?", Fore.RED)
return
else:
jarvis.say(bin(n)[2:], Fore.YELLOW)

0 comments on commit 1447bcc

Please sign in to comment.