| icon | python |
|---|
Whether you're new to Python or just want to create a basic app, this tutorial will walk you through building a small, functional Python application from scratch. By the end, you’ll have a working script and a sense of how to expand it into something bigger.
- Python 3.8+
- Code editor (e.g. VS Code, PyCharm, or just Notepad++)
- Terminal / Command Prompt
Check your Python installation:
python --versionIf not installed, download Python here: https://www.python.org/downloads/
Let's create a folder to hold our app:
mkdir my_python_app
cd my_python_appCreate a Python file:
touch app.pyOr on Windows:
type nul > app.pyOpen app.py and write the following code:
def greet_user(name):
return f"Hello, {name}! Welcome to DevNet App."
def main():
user_name = input("Enter your name: ")
greeting = greet_user(user_name)
print(greeting)
if __name__ == "__main__":
main()This is a simple CLI (Command Line Interface) app that greets the user.
In your terminal, run:
python app.pyYou’ll be prompted to enter your name. Try it!
Enter your name: Alice
Hello, Alice! Welcome to DevNet App.
Let’s enhance it. Modify app.py to let the user choose an action:
def greet_user(name):
return f"Hello, {name}! Welcome to DevNet App."
def add(a, b):
return a + b
def main():
name = input("Enter your name: ")
print(greet_user(name))
print("Choose an action:")
print("1. Add two numbers")
print("2. Exit")
choice = input("Your choice: ")
if choice == "1":
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(f"The result is: {add(num1, num2)}")
else:
print("Goodbye!")
if __name__ == "__main__":
main()Now it's a multi-functional CLI app!
From here, you can:
- Add more features (e.g. multiplication, string tools, file saving)
- Turn it into a web app using Flask or FastAPI
- Package it using
pyinstallerorsetuptools - Upload to GitHub or share with friends
If your app uses external libraries (like requests or flask), create a requirements.txt:
pip install requests
pip freeze > requirements.txtThen others can install your app's dependencies with:
pip install -r requirements.txtThis guide showed you how to build and run a basic Python CLI app, extend it, and prep it for sharing. Python is incredibly versatile — this is just the beginning.
Happy coding! 🧠💻