Coding/Learn/python/first program
Python Beginner Course
01.Introduction to Python
02.Your First Python Program
03.Syntax & Indentation
04.Comments & Documentation
05.Variables
06.Core Data Types
07.Numbers & Arithmetic Operators
08.Text & Strings in Depth
09.Boolean Logic
10.Type Conversion & Casting
11.Interactive User Input
12.Assignment & Shorthand Operators
13.Comparison Operators
14.Logical Operators (and, or, not)
15.If Statements & Conditional Execution
16.If-Else Branching (Dual Paths)
17.If-Elif-Else (Multi-Path Decisions)
18.While Loops & Iteration
19.For Loops & Sequence Traversal
20.The range() Function
21.Lists & Mutable Sequences
22.Tuples & Immutable Data
23.Sets & Unique Collections
24.Dictionaries & Key-Value Stores
25.List Indexing & Slicing
26.Essential List Methods
27.Essential String Methods
28.Functions & Modular Code
29.Function Parameters & Arguments
30.Return Values & Data Flow
31.Exception Handling (try / except)
32.Capstone Mini-Projects
Course Certificate0%

Complete all lessons to earn

LearnYour First Python Program
2 / 32 0%
Lesson 02 of 32
5 mins read

Your First Python Program

PreviousNext Lesson
In Plain English

Every developer in history started with "Hello, World!". It is a sacred tradition. In Python, print() is your loudspeaker: it outputs text, numbers, and calculations to the terminal, automatically starting a fresh line each time.

The Mental Model

"Think of print() as your program talking out loud. If you put text in quotes, Python speaks it word-for-word. If you give it a math problem like 5 + 3 without quotes, Python does the math first and speaks the answer: 8."

Deep Dive: How It Works

The print() function takes one or more values inside its parentheses and sends them to standard output (STDOUT).

Text must always be surrounded by quotes (single 'hello' or double "hello"). If you forget the quotes, Python thinks you are referencing a variable name and will throw a NameError.

You can pass multiple items separated by commas inside a single print statement, like print("Score:", 100), and Python will automatically separate them with a space.

Syntax Blueprint

print(item1, item2, item3, ...)

Items inside the parentheses get converted to text and printed on a single line separated by spaces.

PointCore Rules to Remember

Point star
The print() Function: Sends whatever data you provide directly to the user screen or terminal.
Point star
Quotes for Text: Words require quotes ("hello"). Numbers (42) and variables do not.
Point star
Comma Separation: Passing multiple values separated by commas joins them with a space automatically.

Common Beginner Traps & How to Fix Them

Mistake:Mixing single and double quotes on the same string

Why it happens: Starting with a double quote " and ending with a single quote ' confuses the parser.

How to fix: Pick either "double" or 'single' quotes and stay consistent on that string.

Pro Tip: Need an empty line in your output? Just call print() with nothing inside the parentheses.

Live Interactive Example

Hit Run Code to see it live
Printing Multiple Lines and Calculations
Python 3.12
1
2
3
4
Output Console
Click "Run Code" to view the rendered output.
How it works: Notice that 50 * 4 was calculated as 200 before being printed because it was not enclosed in quotes.

Another Practical Example

Joining Text and Numbers with Commas
Python 3.12
1
2
3
Output Console
Click "Run Code" to view the rendered output.
How it works: Commas inside print() insert spaces automatically between each item.

Your Turn: Micro Challenge

No pressure! Edit the starter code below and test your solution with instant feedback.

Micro Exercise

Print a multi-item status report

  • PointUse print() to output "Server status: Online" to the console.
1
2
Sandbox Output
Click "Run & Check" to test your solution.

Finished reading and practicing?

Mark this lesson as completed to update your course progress.

PreviousNext Lesson
Overview100 SheetLearnCertificates