Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Python
  • Python for AI: The Five Tools You Actually Need
  • Thinking Like a Python Architect in an AI-First World
  • Your First Python Program: print, Comments, sep and end
  • Set Up PyCharm for Python: Install, First Project and First Run
  • Run a Python File and Read the Error: Tracebacks in Three Steps
  • Python Data Types, Variables and Strings: Indexing, Slicing and f-strings
  • Python Operators: Arithmetic, Comparison, Logical, Membership, Identity and Precedence
  • Python Conditionals and Loops: if/elif/else, for, while, break and continue
  • Looping Over Real Data in Python: Dicts, Lists of Dicts, enumerate and zip
  • Checking AI-Written Python Code: A Six-Step Habit That Finds Three Hidden Faults
  • Python Basics Practice: Report Card, Shopping Cart and Password Checker from a Prompt
  • Python Functions: Parameters, Return, Scope (LEGB), *args and **kwargs
  • Type Hints on Python Functions: Parameters, Returns, None and Collections
  • Python lambda, map, filter, Modules and Packages (with pip and venv)
  • Python Functions Practice: Bonus Calculator, Product Pipeline and a Math Package
  • Python Lists, Tuples, Sets and Dicts, Plus Type Hints on Variables
  • Python Comprehensions: List, Dict, Set and Generator Expressions, Read as Loops
  • Python Class Methods, Static Methods and Properties: What Each One Receives
  • Python Classes and Objects: __init__, self and PEP 8 Names
  • Python Inheritance and Polymorphism: super(), Overriding and Duck Typing
  • Python Multiple Inheritance, the MRO and Mixins
  • Python Encapsulation and Special Methods: Underscores, __str__, __add__ and __len__
  • Python Composition, Abstract Classes and Dataclasses
  • Python OOP Practice: Design a Bank, an Employee System and a Library
  • Set Up a Python AI Project with uv, VS Code and an API Key in .env
  • uv and pyproject.toml: Start, Add, Run and Rebuild a Python Project
  • Python try and except Basics: Catch an Error and Keep Going
  • Read and Write a File in Python: open, with, Modes and Encoding
  • Python Custom Exceptions and Advanced Error Handling: raise, raise from and the Call Stack
  • Python Logging and Debugging: Levels, Handlers, logger.exception and breakpoint()
  • Python File Modes, pathlib and Context Managers: x, r+, rb, Path and __enter__/__exit__
  • Python CSV, JSON and Large Files: csv, json, yield Pipelines, tomllib and pickle
  • Python Practice: Build a Log File Analyzer and a File Organizer
  • Python Project Structure for AI-Assisted Development: Packages, config.py and AGENTS.md
  • Regular Expressions in Python: search, findall, Groups and Greedy vs Lazy
  • Testing Python Code with pytest: assert, parametrize, fixtures and pytest.raises
  • Async Python: async def, await, asyncio.gather and the Blocking Trap
  • Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose
  • One Blog, Three Frameworks: Routing, Models, Templates and Layout in Django, FastAPI and Flask
  • Getting Started with Flask: Routes, Jinja2 Templates and WSGI in One Small App
  • Your First Flask App with uv: From an Empty Folder to a Page in Debug Mode
  • Flask Routes, Templates and url_for: Converters, Forms, Redirects and the Signed Session
  • Flask-SQLAlchemy Models and Flask-Migrate: From a Python Class to a Real Table
  • Building a Blog with an AI Coding Agent: Plan Mode, a Master Prompt and the First Review
  • Handing a Figma Design to an AI Agent: Compare the Files, Then Review the Change
  • Inside a Flask Blog: The App Factory, Blueprints, the Instance Folder and CORS Done Right
  • How a Request and a Login Flow Through a Flask Blog: Flask-Login, CSRF and the Signed Session
  • Testing a Flask Blog with pytest: A Test App from the Factory, Fixtures and the Test Client
  1. Blog
  2. /
  3. Python
  4. /
  5. Basics

Your First Python Program: print, Comments, sep and end

Five tiny files: print and quotes, top-to-bottom order, # comments, several values with sep and end, and the SyntaxError one missing quote causes. Every output is from a real run.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Basics

What you will learn

  • Show text with print and explain what the quotes do
  • Predict output by reading a file from top to bottom
  • Use # comments to leave notes and switch a line off
  • Change what print puts between and after values with sep and end

Before you start

  • Nothing installed yet; you can read along first

Your first Python program starts with one small word: print. Every example you'll ever see in this library shows its result with print, so once you can read a print line, you can read what every example is telling you.

Before any code, think about a note you leave for a friend on how to make tea. A few short lines, in order: boil the water, add the tea, pour it into a cup. Your friend reads the first line and does it, then the second, then the third.

A Python program is the same kind of note. It's a text file of instructions, and Python carries them out. There's one difference. A friend can guess what you meant when you make a spelling mistake. Python can't, and you'll see that at the end.

Your first print

Here's hello.py:

print("Hello, world!")
print("My first Python program")
Hello, world!
My first Python program

print tells Python to show something. The brackets hold what you want to show. The double quotes mark where the text starts and ends, so Python knows this part is text and not an instruction.

Look at the output: the text comes out exactly as typed, comma included, but the quotes don't come out with it. The second print lands on its own line. Two lines of code, two lines of output, and that's a complete program.

Python reads from top to bottom

print("Step 1: wake up")
print("Step 2: make tea")
print("Step 3: start coding")
Step 1: wake up
Step 2: make tea
Step 3: start coding

Python starts at line one and shows "Step 1: wake up". Only then does it move to line two, then line three. After that there are no more lines, so the program ends. The order you write is the order you get.

Python runs a file one line at a time from top to bottom; each print line produces one line of output in the same order top_to_bottom.py 1 print("Step 1: wake up") 2 print("Step 2: make tea") 3 print("Step 3: start coding") Terminal Step 1: wake up Step 2: make tea Step 3: start coding
One line at a time, top to bottom. Line 1 runs first, so its output comes first.

Comments: notes Python skips

Sometimes you want to leave a note for the people reading your code. That's a comment, and it starts with a hash sign.

# This line is a note for people, Python skips it
print("Before the comment")
# print("This line is switched off")
print("After the comment")  # a note can sit here too
Before the comment
After the comment

Python skips everything after a #. Line one does nothing at all. Line three is a print, but with a hash in front it's switched off, which is handy when you want to stop a line without deleting it. On the last line, Python runs the code and then skips from the hash onwards.

Three hash signs in the file, and only two lines of output.

Several values, sep and end

So far each print has shown one piece of text. You can give it more than one, separated by commas:

print("Tea", "and", "toast")
print("10", "30", sep=":")
print("Loading", end="...")
print("done")
print(2 + 3)
print("2 + 3")
Tea and toast
10:30
Loading...done
5
2 + 3

Line by line:

  • print("Tea", "and", "toast") puts a space between the values on its own. We never typed those spaces.
  • sep is short for separator: what goes between the values. With sep=":", a colon goes in instead of a space, so 10 and 30 come out as 10:30.
  • end is what print writes after the last value. Normally that's a new line, which is why every print so far got its own line. With end="...", print writes three dots and stays on the same line, so the next print("done") lands right beside it.
  • print(2 + 3) has no quotes, so Python works it out and shows 5. print("2 + 3") is in quotes, so it's only text and comes out exactly as typed.

One missing quote

Now break something on purpose. In missing_quote.py the text opens with a quote but never closes:

print("Hello, world!)
print("This line never runs")
  File "S01L01_1_FirstProgram\missing_quote.py", line 1
    print("Hello, world!)
          ^
SyntaxError: unterminated string literal (detected at line 1)

A friend would guess what you meant. Python doesn't guess; it can't find where the text ends. So you get a SyntaxError saying the text was never closed, and Python tells you where it stopped: line 1.

Look at what didn't happen, too. Line two is fine, but it never ran. Python reads the whole file first, and one typo stops the program. Put the closing quote back and it's the same line that worked in hello.py.

An error isn't a disaster. Python stopped, told you where, and you fix that spot. You'll read errors properly in Run a Python file and read the error.

Common mistakes

  • Forgetting the closing quote. You get SyntaxError: unterminated string literal.
  • Expecting the quotes in the output. They only mark the text; they never print.
  • Putting a number in quotes when you want Python to work it out. "2 + 3" is text, 2 + 3 is 5.

Quick recap

You writeYou get
print("Hello, world!")the text, without quotes
# a notenothing; Python skips the rest of the line
print("Tea", "and", "toast")values with spaces between
sep=":"a colon between values instead
end="..."three dots instead of a new line
a missing quoteSyntaxError, and nothing runs

Try it yourself

Once your setup is done (see Set up PyCharm for Python), open hello.py and print your name and one line about yourself.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Python · 3 of 48

Previous
Thinking Like a Python Architect in an AI-First World
Next post
Set Up PyCharm for Python: Install, First Project and First Run

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Related posts

Python for AI: The Five Tools You Actually Need

The small part of Python that carries most AI code: dicts and JSON, typed functions with a dataclass, comprehensions and f-strings, environment variables for keys, and try/except for replies that are not JSON. Three standard-library scripts on four support tickets.

Thinking Like a Python Architect in an AI-First World

Coding is laying bricks; architecting is deciding how the pieces fit. A two-line average function shows why someone still has to understand the code an AI tool writes.

Set Up PyCharm for Python: Install, First Project and First Run

Install PyCharm, create a Pure Python project, and understand the two words that confuse beginners: the interpreter (the cook) and .venv (the project's own shelf). Then run a file and read the exit code.

Run a Python File and Read the Error: Tracebacks in Three Steps

Run a file two ways, then break it on purpose. A NameError, an IndentationError, a TypeError and a three-frame traceback across two files, all read the same way: last line, line number, fix.

On this page

  • Your first print
  • Python reads from top to bottom
  • Comments: notes Python skips
  • Several values, sep and end
  • One missing quote
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.