1 - Python Environment Setup and Language Fundamentals — Topics & Learning Outcomes
Module Topics
Python Programming Environments
Covers the tools and interfaces used to write and run Python code, including IDEs and Jupyter notebooks. Learners will understand how to choose an appropriate environment for different tasks.
- What Is a Python Environment? — A Python programming environment is the combination of tools, interpreters, and interfaces that allow a developer to write, run, and debug Python code.
- Integrated Development Environments (IDEs) — An IDE is a software application that provides comprehensive tools for writing and debugging code, typically including a code editor, debugger, and project manager in one interface.
- Jupyter Notebooks — Jupyter Notebook is an open-source, browser-based environment that allows you to write and execute Python code in discrete, runnable cells alongside narrative text and visualizations.
- The Python Interpreter and REPL — The Python interpreter is the program that reads and executes Python code. When launched interactively, it provides a Read-Eval-Print Loop (REPL) where each line of code is executed immediately.
Package Management in Python
Explores how Python packages extend the language's capabilities and how to install, manage, and organize them using tools like pip and virtual environments.
- What Are Python Packages? — A Python package is a collection of modules that provide pre-written code for specific tasks, allowing developers to reuse functionality without writing it from scratch.
- Using pip to Install Packages — pip is the default package manager for Python and allows users to install, upgrade, and remove packages from the command line.
- Virtual Environments — A virtual environment is an isolated Python environment that allows different projects to have their own dependencies without conflicting with one another.
Interactive vs. Script Execution
Distinguishes between running Python code interactively in a REPL or notebook and executing standalone Python script files. Learners will understand when to use each approach.
- Interactive Execution — Interactive execution allows a programmer to type Python statements one at a time and see results immediately, making it ideal for learning, testing, and data exploration.
- Script Execution — A Python script is a plain-text file with a .py extension that contains a sequence of Python statements executed from top to bottom when the file is run.
- Choosing the Right Execution Mode — Selecting between interactive and script execution depends on the goal: interactive mode suits exploration and learning, while script mode suits repeatable, structured programs.
Variables and Assignment
Introduces how Python uses variables to store and reference data, covering naming conventions, assignment syntax, and how Python manages variable references in memory.
- What Is a Variable? — A variable is a named reference that points to a value stored in memory, allowing programmers to store, retrieve, and manipulate data throughout a program.
- Naming Rules and Conventions — Python enforces specific rules for variable names and follows community conventions documented in PEP 8 to promote readable, consistent code.
- Multiple Assignment and Unpacking — Python supports assigning multiple variables at once, either to the same value or to individual values from a sequence, using concise syntax.
Core Data Types
Covers Python's fundamental built-in data types including integers, floats, strings, and booleans, explaining their characteristics and appropriate use cases.
- Integers and Floating-Point Numbers — Python provides two primary numeric types: integers (int) for whole numbers and floating-point numbers (float) for decimals and numbers requiring fractional precision.
- Strings — A string (str) is an ordered, immutable sequence of characters used to represent text in Python, enclosed in single or double quotation marks.
- Booleans — The boolean (bool) type represents one of two truth values — True or False — and is fundamental to controlling program flow through conditionals and loops.
- The None Type — None is a special singleton value in Python that represents the absence of a value or a null result, commonly used as a default or placeholder.
- Checking Data Types with type() — The built-in type() function returns the type of any Python object, allowing programmers to inspect and verify the data type of a variable at runtime.
Operators in Python
Introduces the main categories of Python operators — arithmetic, comparison, logical, and assignment — explaining their syntax, behavior, and precedence rules.
- Arithmetic Operators — Arithmetic operators perform mathematical calculations on numeric values, including addition, subtraction, multiplication, division, and more specialized operations.
- Comparison Operators — Comparison operators evaluate the relationship between two values and return a boolean result, forming the basis of conditional logic in Python programs.
- Logical Operators — Logical operators — and, or, and not — combine or invert boolean expressions and are central to building complex conditional statements.
- Assignment Operators — Assignment operators store a value in a variable, with augmented assignment operators providing a shorthand for updating a variable's value in place.
- Operator Precedence — Python evaluates expressions according to a defined order of precedence, determining which operations are performed first when multiple operators appear in a single expression.
Type Conversion
Explains how Python handles conversion between data types, distinguishing between implicit coercion performed automatically by Python and explicit conversion performed by the programmer.
- Implicit Type Conversion — Implicit type conversion, or coercion, occurs automatically when Python converts one data type to another to complete an operation without requiring any action from the programmer.
- Explicit Type Conversion with Built-in Functions — Explicit type conversion, also called casting, uses built-in functions such as int(), float(), str(), and bool() to deliberately convert a value from one type to another.
- Common Conversion Errors and How to Avoid Them — Incorrect type conversion attempts raise exceptions in Python, so understanding which conversions are valid and how to handle failures is an essential programming skill.
Student Learning Outcomes
By the end of this module, students will be able to:
MO1
Select an appropriate Python execution environment — such as an IDE, Jupyter Notebook, or REPL — for a given programming task
Level: EvaluateType: CognitiveCourse mapping: CO3
MO2
Configure an isolated virtual environment and install required packages using pip
Level: ApplyType: BehavioralCourse mapping: CO3
MO3
Construct valid Python variable assignments that conform to PEP 8 naming conventions and utilize multiple assignment and unpacking syntax
Level: ApplyType: CognitiveCourse mapping: CO1
MO4
Differentiate among Python's core built-in data types — int, float, str, bool, and None — by using the type() function to inspect variable types in a running program
Level: AnalyzeType: CognitiveCourse mapping: CO1
MO5
Apply explicit type conversion functions to transform values between compatible data types while identifying conversions that raise exceptions
Level: ApplyType: CognitiveCourse mapping: CO1
Course Outcomes (reference)
CO1Use variables, arrays and object structures appropriate to solve engineering problems.
CO2Write computer functions to meet specific calculation needs.
CO3Write computer programs to solve mathematical expressions and engineering problems