Computational Thinking and Programming

Lesson Organising information: ordered structures

How To Import Modules

  • In this lesson, you'll learn how to use Python's built-in functions and enhance your programs by importing external modules. The lesson covers how to check, install, and import modules, demonstrating the use of common built-in functions (print(), abs(), int(), len()) and external modules like random and math. You'll explore different ways to import functions, use dot notation, apply the from ... import syntax, and create aliases for modules to make coding more efficient. By understanding modules, you can extend Python’s functionality, build more powerful programs, and reuse code effectively.
  • Recommended reading:
  • Built-in Functions: Basic functions in Python like print(), abs(), int(), and len().
  • Modules: Python files containing reusable code that can be imported.
  • Importing Modules: Using the import statement to access external modules in Python programs.
  • From Import: Selective importing of specific functions from a module to use them directly.
  • Aliasing: Renaming modules or functions using the as keyword for convenience.

Understanding Lists

  • In this lesson, you will explore the flexibility and functionality of lists in Python, which are ordered, mutable sequences of elements. You’ll learn how to define lists, access their elements using indexing, modify them, and perform operations like concatenation, slicing, and replication. Additionally, the lesson covers using operators to alter lists, removing elements, and working with nested lists. By understanding these concepts, you’ll gain control over how to manage collections of data efficiently in Python, allowing for more dynamic and interactive programs.
  • Recommended reading:
  • Lists: Mutable, ordered sequences of elements enclosed in square brackets.
  • Indexing: Accessing individual elements of a list using their index positions.
  • Negative Indexing: Accessing elements from the end of the list using negative indices.
  • Slicing: Extracting a sublist by specifying a range of indices, with optional stride.
  • Concatenation: Combining two or more lists using the '+' operator.
  • Replication: Multiplying lists using the '*' operator to duplicate their elements.
  • Modification: Changing list elements by assigning new values to specific indices.
  • Deletion: Removing elements from a list using the 'del' statement.
  • Nested Lists: Lists containing other lists as elements, requiring multiple indices for access.

Understanding Boolean Logic

How To Write Comments

  • This lesson covers the importance of comments in Python programming, explaining how they improve code readability and collaboration. Key topics include:
  • Recommended reading:
  • Purpose of Comments: Enhance code readability and provide explanations for code functionality.
  • Comment Syntax: Comments begin with a hash mark (#) and are ignored by the interpreter.
  • Types of Comments: Different types include inline comments, block comments, and commented-out code for testing purposes.
  • Best Practices: Guidelines on when and where to use comments effectively.
  • Practical Examples: Real-life code samples demonstrating comments in loops, functions, and conditional statements.