commit 169e85b5fa63c391e11c79d13c2afd30bf9932c8 Author: Lyx Date: Thu Mar 20 19:16:37 2025 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/__pycache__/alphabet.cpython-312.pyc b/__pycache__/alphabet.cpython-312.pyc new file mode 100644 index 0000000..d58f285 Binary files /dev/null and b/__pycache__/alphabet.cpython-312.pyc differ diff --git a/__pycache__/functions.cpython-312.pyc b/__pycache__/functions.cpython-312.pyc new file mode 100644 index 0000000..4c9d1e5 Binary files /dev/null and b/__pycache__/functions.cpython-312.pyc differ diff --git a/__pycache__/wordList.cpython-312.pyc b/__pycache__/wordList.cpython-312.pyc new file mode 100644 index 0000000..6cac09f Binary files /dev/null and b/__pycache__/wordList.cpython-312.pyc differ diff --git a/__pycache__/wordlist.cpython-312.pyc b/__pycache__/wordlist.cpython-312.pyc new file mode 100644 index 0000000..0597322 Binary files /dev/null and b/__pycache__/wordlist.cpython-312.pyc differ diff --git a/alphabet.py b/alphabet.py new file mode 100644 index 0000000..719517a --- /dev/null +++ b/alphabet.py @@ -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)" +} diff --git a/functions.py b/functions.py new file mode 100644 index 0000000..7aa61f0 --- /dev/null +++ b/functions.py @@ -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') \ No newline at end of file diff --git a/gamemodes.py b/gamemodes.py new file mode 100644 index 0000000..23eaca6 --- /dev/null +++ b/gamemodes.py @@ -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) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..aa706d6 --- /dev/null +++ b/main.py @@ -0,0 +1,4 @@ +from functions import binarian +from alphabet import alphabet + +print(binarian("I am making duolingo for binary")) \ No newline at end of file diff --git a/wordlist.py b/wordlist.py new file mode 100644 index 0000000..a86c0f6 --- /dev/null +++ b/wordlist.py @@ -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 +}