mirror of
https://github.com/Lyxminxx/binarian.git
synced 2026-10-11 20:57:41 +02:00
Initial commit
This commit is contained in:
commit
169e85b5fa
11 files changed
+107
No files matched your search
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+31
@@ -0,0 +1,31 @@
|
|||||||
|
alphabet = {
|
||||||
|
"a": "(00001)",
|
||||||
|
"b": "(00010)",
|
||||||
|
"c": "(00011)",
|
||||||
|
"d": "(00100)",
|
||||||
|
"e": "(00101)",
|
||||||
|
"f": "(00110)",
|
||||||
|
"g": "(00111)",
|
||||||
|
"h": "(01000)",
|
||||||
|
"i": "(01001)",
|
||||||
|
"j": "(01010)",
|
||||||
|
"k": "(01011)",
|
||||||
|
"l": "(01100)",
|
||||||
|
"m": "(01101)",
|
||||||
|
"n": "(01110)",
|
||||||
|
"o": "(01111)",
|
||||||
|
"p": "(10000)",
|
||||||
|
"q": "(10001)",
|
||||||
|
"r": "(10010)",
|
||||||
|
"s": "(10011)",
|
||||||
|
"t": "(10100)",
|
||||||
|
"u": "(10101)",
|
||||||
|
"v": "(10110)",
|
||||||
|
"w": "(10111)",
|
||||||
|
"x": "(11000)",
|
||||||
|
"y": "(11001)",
|
||||||
|
"z": "(11010)",
|
||||||
|
"æ": "(11011)",
|
||||||
|
"ø": "(11100)",
|
||||||
|
"å": "(11101)"
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
from alphabet import alphabet
|
||||||
|
from os import system, name
|
||||||
|
|
||||||
|
|
||||||
|
def binarian(word):
|
||||||
|
wordBin = ""
|
||||||
|
word = word.lower()
|
||||||
|
for letter in word:
|
||||||
|
if letter in alphabet.keys():
|
||||||
|
wordBin += alphabet[letter]
|
||||||
|
elif letter == " ":
|
||||||
|
wordBin += " "
|
||||||
|
else:
|
||||||
|
wordBin += letter
|
||||||
|
return wordBin
|
||||||
|
|
||||||
|
def clear():
|
||||||
|
|
||||||
|
# for windows
|
||||||
|
if name == 'nt':
|
||||||
|
_ = system('cls')
|
||||||
|
|
||||||
|
# for mac and linux(here, os.name is 'posix')
|
||||||
|
else:
|
||||||
|
_ = system('clear')
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from wordlist import words
|
||||||
|
import random
|
||||||
|
from os import system, name
|
||||||
|
from functions import binarian
|
||||||
|
from functions import clear
|
||||||
|
|
||||||
|
def norToBin(level):
|
||||||
|
wordsInLevel = []
|
||||||
|
for word, word_level in words.items():
|
||||||
|
if word_level == level:
|
||||||
|
wordsInLevel.append(word)
|
||||||
|
word = random.choice(wordsInLevel)
|
||||||
|
correctTranslation = binarian(word)
|
||||||
|
|
||||||
|
print(f'Translate {word} into binary!')
|
||||||
|
userIn = input("Write anwser\n>")
|
||||||
|
clear()
|
||||||
|
if userIn == correctTranslation:
|
||||||
|
print(f'Yes the word {word} does translate to {userIn}!')
|
||||||
|
else:
|
||||||
|
print(f'No, the word {word} translates to {correctTranslation}. Better study some more!')
|
||||||
|
|
||||||
|
norToBin(2)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from functions import binarian
|
||||||
|
from alphabet import alphabet
|
||||||
|
|
||||||
|
print(binarian("I am making duolingo for binary"))
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
words = {
|
||||||
|
"cat": 1,
|
||||||
|
"dog": 1,
|
||||||
|
"fish": 1,
|
||||||
|
"apple": 1,
|
||||||
|
"ball": 1,
|
||||||
|
"house": 2,
|
||||||
|
"school": 2,
|
||||||
|
"tree": 2,
|
||||||
|
"friend": 2,
|
||||||
|
"computer": 3,
|
||||||
|
"programming": 3,
|
||||||
|
"language": 3,
|
||||||
|
"chicken": 3,
|
||||||
|
"celebrate": 4,
|
||||||
|
"dinosaur": 4,
|
||||||
|
"philosophy": 4,
|
||||||
|
"challenge": 4,
|
||||||
|
"understanding": 5,
|
||||||
|
"universe": 5,
|
||||||
|
"consciousness": 5,
|
||||||
|
"mathematics": 5,
|
||||||
|
"microprocessor": 5
|
||||||
|
}
|
||||||
Reference in new issue
Block a user