This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
def click(event): | |
text = event.widget.cget("text") | |
if text == "=": | |
try: | |
result = str(eval(str(entry.get()))) | |
entry.delete(0, tk.END) | |
entry.insert(tk.END, result) | |
except Exception as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(x, y): | |
return x + y | |
def subtract(x, y): | |
return x - y | |
def multiply(x, y): | |
return x * y | |
def divide(x, y): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import time | |
import random | |
# Initialize pygame | |
pygame.init() | |
# Define screen dimensions | |
WIDTH, HEIGHT = 600, 400 | |
screen = pygame.display.set_mode((WIDTH, HEIGHT)) |