# Type your text here import math import kandinsky as kd import ion def draw_interface(): kd.fill_rect(0, 0, 320, 222, (255, 255, 255)) # Fond blanc kd.draw_string("NumWorks AI", 10, 10, (0, 0, 0), (255, 255, 255)) kd.draw_string("> ", 10, 50, (0, 0, 0), (255, 255, 255)) def get_input(): input_str = "" x, y = 25, 50 while True: for key in range(256): if ion.keypad.keydown(key): if key == ion.keypad.KEY_OK: return input_str elif key == ion.keypad.KEY_BACK: input_str = input_str[:-1] elif key == ion.keypad.KEY_EXE: return input_str elif 32 <= key <= 126: input_str += chr(key) kd.fill_rect(25, 50, 300, 20, (255, 255, 255)) kd.draw_string(input_str, 25, 50, (0, 0, 0)) def process_input(user_input): user_input = user_input.lower() responses = { "bonjour": "Bonjour! Comment puis-je t'aider?", "qui es-tu": "Je suis une IA simplifiee pour NumWorks.", "quel est le sens de la vie": "42, bien sûr!", } if user_input in responses: return responses[user_input] try: return str(eval(user_input)) # Calculer les expressions mathématiques simples except: return "Je ne comprends pas." def main(): draw_interface() while True: user_input = get_input() response = process_input(user_input) kd.fill_rect(25, 80, 300, 20, (255, 255, 255)) # Effacer la réponse précédente kd.draw_string(response, 25, 80, (0, 0, 0)) main()