1. What is Python?
Python is a high-level, interpreted programming language known for its clear syntax and readability. Unlike low-level languages like C++ or Assembly, Python code is compiled at runtime by an interpreter, which reads and executes instructions line by line. This makes the language highly portable and easy to debug, but slightly slower for raw execution. Python is widely used in web development, data analysis, scripting, artificial intelligence, and automation.
2. How Python Runs Code
To run Python on your computer, you need to download and install the Python runtime from the official python.org website. Python can be executed in two main ways:
- Interactive REPL (Read-Eval-Print Loop): By typing
pythonorpython3in your command terminal, you open a live environment where every line of code you write is executed immediately. This is great for testing and quick experimentation. - Script Mode: For real applications, you write your code in text files ending with the
.pyextension (e.g.,hello.py), and then run the whole script from your terminal using:python hello.py.
3. Syntax and Your First Script
Python values simplicity. To display output to the screen, we use the built-in print() function. Strings (text) must be enclosed inside double or single quotes. Multi-line comments or descriptions can be written, but for single-line notes, Python uses the # symbol.
# This is a comment. The interpreter ignores it.
print("Hello, Infotris!") # Prints text to console
# Multiple arguments can be separated by commas
print("Welcome to", "Python", 3.12)
4. Common Beginner Mistakes
⚠️ Watch out for these mistakes:
- Case Sensitivity:
Print("Hello")will fail with aNameError. Python functions are case-sensitive. Use lowercase:print(). - Missing Quotes:
print(Hello)will try to look for a variable namedHellorather than printing the word, causing an error. - Unmatched Quotes: Mixing quotes like
"Hello'will cause aSyntaxError.
Mini Practice: Run Your First Code
Write a script locally, save it as intro.py, run it in your terminal, and confirm the steps. Copy the printed output to check it.
Practice complete!
Awesome. You can run Python files. Take the quiz below to unlock the next lesson.
Test Your Understanding
1. What kind of language is Python primarily considered?
2. How is a comment written in Python?
🚀 Progression
By completing this introduction, you have unlocked the fundamentals. Next, you'll learn how to store information and compute numbers using **Variables and Data Types**.