Jump to content

I was wondering if anybody wanted to share some simple apps like a calculator, magic 8-Ball program, a game of hangman, or even Pong with a GUI can be coded using only a text editor. I'm using VS Code on Linux Mint (Python version 3.10.12 64-bit). Show me you're most complex code in full if you want to really spice up this forum. Have any of you coded graphics without a game engine and only in a text editor?

 

Have fun trying to see who has the most elaborate and insane Python creation known to man!

Link to comment
https://linustechtips.com/topic/1572728-want-to-share-python-creations/
Share on other sites

Link to post
Share on other sites

I'm currently a software developer apprentice, this is the most I've done with Python as I am mainly a C# developer:

# Proof of concept for how I would implement a password checker with Python

# Gather the username
print("Welcome to the signup page!")
username = input("Please enter a username: ")

# Gather the password

print("------------------------------------------------")
print(f"Hello {username}, now please enter a password.")

while True:

    print("Password must contain:")
    print("1 number, 1 special character (@, !, $, #) and be 8 characters in length.")
    print("--------------------------------------------------------")
    password = input("Please enter a password: ")

    # Validation checks for password
    if any(char.isdigit() for char in password) and any(char in ["@", "!", "$", "#"] for char in password) and len(password) >= 8:
        print("Password accepted!")
        break  # Break out of the loop if the password is accepted
    else:
        print("Password declined!")
        print("-----------------")


# Sign-up confirmation
print("------------------")
censoredPassword = "*" * len(password)
print(f"Username: {username}")
print(f"Password: {censoredPassword}")


# Sign-in
signIn = input("Would you like to sign in now? (Y/N): ")

def signInFunction():
    signInUsername = input("Please enter your username: ")
    if (signInUsername == username):
        signInPassword = input("Please enter your password: ")
        if (signInPassword == password):
            print("You have been logged in!")
            print("------------------------")
        else:
            print("Incorrect password!")
            print("-------------------")
            signInFunction()
    else:
        print("Incorrect username!")
        print("-------------------")
        signInFunction()

if (signIn.lower() == "y"):
    signInFunction()
else:
    print("No worries, see you soon!")

 

Console.WriteLine("Hello World!");

Link to post
Share on other sites

Here's my source code for 4 function calculator

 

# Define the functions for each operation
operations = {
    '1': lambda x, y: x + y,
    '2': lambda x, y: x - y,
    '3': lambda x, y: x * y,
    '4': lambda x, y: x / y if y != 0 else "Error: Division by zero is not allowed"
}

def calculator():
    print("Select operation:")
    print("1. Add")
    print("2. Subtract")
    print("3. Multiply")
    print("4. Divide")

    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))

    for operation in operations:
        print(operation, "-", operations[operation].__name__)

    choice = input("Enter choice (1/2/3/4): ")

    if choice in operations:
        print(num1, operations[choice].__name__, num2, "=", operations[choice](num1, num2))
    else:
        print("Invalid Input")

# Call the calculator function
calculator()
Link to post
Share on other sites

I don't have many simple programs or games written in Python since I mainly use it for work and university projects now, so all I've got are larger/more complex programs. Here's a few of the cool ones I've done recently.

 

1. A machine learning classifier that listens to car engine audio through a microphone and predicts the car's brand. It was a very interesting project, but I wasn't very happy with the final performance of our ML model - we just didn't have enough audio data for a problem of this complexity. This one was the capstone project for my Computer Engineering undergraduate degree and was contracted to us by General Dynamics. Because of this, I can't show the code publicly but I do have some presentation materials we created:

Spoiler

Slide1.thumb.jpg.2322b55f936a59d91b5e73381e341e59.jpg

 

2. A test bench for training ML models intended for cognitive radio or signal jamming applications. A cognitive radio is a wireless transmitter that uses machine learning to find the best frequencies to transmit on that reduce noise or prevent interference with other devices. This was a project I worked on at my job for the past year and it lets you simulate an environment with a bunch of wireless devices transmitting data like WiFi or Bluetooth. You can then place a reinforcement learning agent in the environment with some goal you choose - learn to avoid other devices' wireless transmissions or learn a specific device's transmission patterns. With this, you can create a model that is capable of transmitting effectively in very busy environments like apartments or large crowds, or a jammer that prevents a single device from transmitting instead of wiping out every transmission in the area.

 

Computer engineering PhD student and RFML researcher

 

Daily Driver:

CPU: Ryzen 7 4800H | GPU: RTX 2060 | RAM: 32GB DDR4 3200MHz C16 | OS: Debian 13

 

Gaming PC:

CPU: Ryzen 5 5600X | GPU: EVGA RTX 2080Ti | RAM: 32GB DDR4 3200MHz C16 | OS: Windows 11

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×