Back to Python Notes
Topic #211

Getting Started with Python

By the end of this lesson, you will be able to install Python on your computer and execute a simple script from the command line.

What it is

Python is an interpreted, high-level programming language. Unlike compiled languages like C++ or Java, you do not need to compile Python code into machine code before running it. Instead, the Python interpreter reads your source code line by line and executes it immediately. This makes Python ideal for rapid development, scripting, and learning programming concepts.

The core components are:

  • Interpreter: The program that runs your Python code (e.g., python.exe).
  • Script: A text file containing Python commands, typically ending with the .py extension.
  • REPL: Read-Eval-Print Loop, an interactive mode where you type commands one at a time.

Why it matters

  • Immediate Feedback: You can test small pieces of logic instantly without complex build steps.
  • Cross-Platform: The same script usually runs on Windows, macOS, and Linux.
  • Industry Standard: Used heavily in data science, web development, automation, and AI.
  • Simplicity: The syntax resembles plain English, reducing the barrier to entry for new programmers.

Syntax or steps

To run a Python program, follow these general steps:

  1. Install Python: Download the installer from python.org. On Windows, check "Add Python to PATH" during installation.
  2. Create a File: Open a text editor (like VS Code, Notepad++, or Sublime Text) and save a file with a .py extension.
  3. Write Code: Enter valid Python statements.
  4. Run via Terminal: Open your command prompt or terminal, navigate to the file's directory, and execute the interpreter.

Example

Here is a complete workflow for creating and running a basic script.

# Step 1: Create a file named hello.py
# Content of hello.py:
print("Hello, World!")
name = input("Enter your name: ")
print(f"Nice to meet you, {name}")

To run this file, open your terminal or command prompt and type:

python hello.py

Explanation:

  • print(): Outputs text to the console.
  • input(): Pauses execution and waits for the user to type something, storing it in the variable name.
  • f-string: The f prefix allows embedding variables directly inside strings using curly braces {}.
  • python hello.py: Tells the operating system to launch the Python interpreter and pass hello.py as the script to execute.

Common mistakes

  • "Command not found": Python is not installed or not added to the system PATH. Fix: Reinstall Python and ensure "Add to PATH" is checked, or use the full path to the executable.
  • Indentation Errors: Python uses whitespace to define blocks of code. Mixing tabs and spaces causes errors. Fix: Configure your editor to insert spaces instead of tabs.
  • File Extension: Saving the file as hello.txt instead of hello.py. Fix: Ensure the file ends with .py.
  • Version Confusion: Using python when only python3 is installed (common on macOS/Linux). Fix: Try running python3 hello.py.

When to use it

Compare running scripts via the command line versus using an Integrated Development Environment (IDE).

Method Best For Pros Cons
Command Line (python script.py) Automation, servers, quick tests Lightweight, universal, fast startup No visual debugging tools built-in
IDE (VS Code, PyCharm) Large projects, learning Auto-completion, error highlighting, debuggers Heavier resource usage, setup required

Practice

Guided Exercise: Write a script called math_test.py that asks the user for two numbers and prints their sum.

Hint: Use float(input()) to convert the string input into a number.

Challenge: Modify the script to also print the product of the two numbers.

Expected Output:

Enter first number: 5
Enter second number: 4
Sum: 9.0
Product: 20.0

Quick check

Question: Why must you include the .py extension when saving your Python file?

Answer: While the interpreter can technically read any text file, the .py extension signals to your operating system and editors that the file contains Python code, enabling proper syntax highlighting and default execution associations.

Summary

Getting started with Python involves installing the interpreter, writing code in a text file with a .py extension, and executing it via the command line. Mastering this basic workflow provides the foundation for all future Python development, whether you move toward web apps, data analysis, or automation.

Want to go beyond the notes?

Join Coding Now Tech Institute's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Getting Started with Python – FAQs

Quick answers about learning Getting Started with Python in Python.

This free note from Coding Now Tech Institute explains Getting Started with Python in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on Coding Now Tech Institute, including Getting Started with Python, is 100% free with no signup required.
With focused practice, most students grasp Getting Started with Python in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now