Introduction
In a recent post, Sam Altman expressed his gratitude to coders who know how to write code from scratch. This simple yet powerful message sparked a wave of memes and jokes online, highlighting the importance of understanding fundamental programming concepts. In this tutorial, we'll explore how to create a basic Python program that demonstrates the core principles of coding from scratch - no frameworks, no libraries, just pure Python functionality. This hands-on approach will help you understand what Altman was celebrating: the ability to build something functional using only basic programming constructs.
Prerequisites
To follow along with this tutorial, you'll need:
- A computer with internet access
- Python 3 installed on your system (you can download it from python.org)
- A simple text editor or IDE (like VS Code, Sublime Text, or even Notepad)
- Basic understanding of what a computer program is
Step-by-Step Instructions
Step 1: Setting Up Your Environment
First, we need to make sure Python is properly installed and accessible from your command line. Open your terminal or command prompt and type:
python --version
If Python is installed correctly, you should see a version number like Python 3.9.7. If you get an error, you'll need to install Python first from python.org.
Step 2: Creating Your First Python File
Now we'll create a simple Python file that demonstrates basic coding concepts. Open your text editor and create a new file named hello_coder.py. This file will be our playground for understanding fundamental programming concepts.
Step 3: Writing Your First Program
Let's start with a simple program that prints a message to the screen:
print("Hello, fellow coder!")
print("You're writing code from scratch!")
Save this file and run it by typing in your terminal:
python hello_coder.py
This demonstrates the most basic concept in programming: outputting information to the user. The print() function is one of the fundamental building blocks that every programmer learns first.
Step 4: Adding Variables and Data Types
Variables are containers that store information. Let's modify our program to use variables:
# This is a comment - it explains what the code does
name = "Alice" # String variable
age = 25 # Integer variable
height = 5.6 # Float variable
is_coder = True # Boolean variable
print("Hello, " + name + "!")
print("You are " + str(age) + " years old.")
print("Your height is " + str(height) + " feet.")
print("Are you a coder? " + str(is_coder))
We're learning about data types here - strings (text), integers (whole numbers), floats (decimal numbers), and booleans (True/False). Notice how we had to convert numbers to strings using str() to combine them with text in the print statements.
Step 5: Creating a Simple Function
Functions are reusable blocks of code. Let's create a function that greets a coder:
def greet_coder(coder_name):
return "Hello, " + coder_name + "! Happy coding!"
# Using our function
message = greet_coder("Bob")
print(message)
This shows how we can create reusable code blocks. Functions help us avoid repeating ourselves and make our programs more organized and readable.
Step 6: Adding User Input
Let's make our program interactive by asking users for input:
user_name = input("What's your name, coder? ")
user_language = input("What programming language are you learning? ")
print("Welcome, " + user_name + "!")
print("Learning " + user_language + " is a great choice!")
This demonstrates how programs can interact with users, making them dynamic rather than static. The input() function is essential for creating interactive programs.
Step 7: Building a Simple Calculator
Now let's create a tiny calculator that performs basic arithmetic operations:
def add_numbers(a, b):
return a + b
def multiply_numbers(a, b):
return a * b
# Get input from user
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# Perform calculations
sum_result = add_numbers(num1, num2)
multiply_result = multiply_numbers(num1, num2)
# Display results
print("The sum is: " + str(sum_result))
print("The product is: " + str(multiply_result))
This shows how we can combine multiple programming concepts - functions, user input, data types, and output to create something useful.
Step 8: Running and Testing Your Code
Save your final program and run it from the command line:
python hello_coder.py
Watch how your program responds to different inputs. Try entering different names, numbers, and languages to see how your code handles various scenarios.
Summary
In this tutorial, we've explored the fundamental concepts that Sam Altman was celebrating: the ability to write code from scratch. We've learned about:
- Basic output using
print() - Variables and different data types
- Functions for reusable code
- User input with
input() - Basic arithmetic operations
These simple building blocks form the foundation of all programming. While modern development often relies on frameworks and libraries, understanding these core concepts is crucial for any programmer. As Altman noted, being able to write code from scratch demonstrates true programming skill and understanding.
Remember, every expert programmer started exactly where you are now - with basic concepts and simple programs. Keep practicing these fundamentals, and you'll be able to tackle more complex projects in the future!



