MCS-201 · Unit 10

Data Structures and Control Statements in Python

12 sections

Block 3 · Unit 10Data Structures and Control Statements in Python109 min · 12 sections

Unit 10Data Structures and Control Statements in Python

Follows IGNOU MCS-201, Unit 10

This unit teaches the everyday building blocks of Python. You will learn the rules for names, how statements and expressions work, Python’s operators and basic data types, and the four built-in collections (list, tuple, dictionary and set) that make Python so productive. You will then use them to build classic data structures (arrays, linked lists, stacks and queues), and finish with the statements that control the order of execution: decisions, loops and recursion. Much of it will feel familiar from C, so the notes point out where Python behaves differently.

In this unit you will learn to

  • Write valid identifiers and recognise Python’s keywords, statements and expressions.
  • Create variables and use Python’s arithmetic, assignment, comparison, logical and bitwise operators correctly.
  • Work with numbers, strings and None, including indexing and slicing.
  • Choose between lists, tuples, dictionaries and sets, and use their main operations and methods.
  • Implement arrays, linked lists, stacks and queues in Python.
  • Control program flow with if, elif, else, while, for, break and continue.
  • Write recursive functions and trace how they run.

Sections in this unit

  1. 10.1Identifiers, Keywords, Statements and ExpressionsThe rules for naming things in Python, the reserved keywords, and the difference between a statement and an expression.9 min
  2. 10.2Variables and AssignmentHow Python variables work as names bound to objects, how assignment, multiple assignment and reassignment behave, and the NameError.8 min
  3. 10.3Operators and PrecedencePython's arithmetic, assignment, comparison, logical and bitwise operators, how they differ from C, and the order in which they are evaluated.9 min
  4. 10.4Numbers, Strings and NonePython's numeric types int, float, complex and bool, strings with indexing, slicing and immutability, the None value, and type conversion.8 min
  5. 10.5ListsCreating, indexing, slicing, changing and traversing Python lists, list methods and built-in functions, aliasing versus copying, and nested lists.11 min
  6. 10.6TuplesCreating immutable tuples, the single-item comma rule, indexing and operators, tuple assignment and swapping, and when to use tuples instead of lists.5 min
  7. 10.7DictionariesStoring key-value pairs in Python dictionaries: creating, looking up, adding, updating and deleting entries, methods, iteration and key rules.11 min
  8. 10.8Sets and FrozensetsUnordered collections of unique items: creating sets, membership tests, union, intersection, difference, set methods and immutable frozensets.9 min
  9. 10.9Arrays, Linked Lists, Stacks and QueuesHow the classic data structures (array, linked list, stack, queue) are implemented in Python with lists, the array module, classes and deque.11 min
  10. 10.10Decision Control StatementsSequential flow and decisions in Python: if, if-else, if-elif-else, nested if, the conditional expression and indentation rules, with corrected programs.11 min
  11. 10.11Loops: while, for, break and continueRepeating code with while and for loops, the range() function, break, continue and the loop else clause, with corrected loop programs.9 min
  12. 10.12RecursionFunctions that call themselves: base case and recursive case, tracing factorial and Fibonacci, the call stack, recursion limits and recursion versus loops.8 min
↑ ↓ move↵ openTab switch type