Unit I: Introduction to Python

Table of Contents

1. Basic Elements of Python

Python is a high-level, interpreted programming language known for its readability and simple syntax. The basic elements include character sets and the use of comments to explain code.


2. Python Character Set & Tokens

A token is the smallest individual unit in a python program.


3. Variables, L-values, and R-values

Variables are reserved memory locations to store values.


4. Knowledge of Data Types

Python provides several built-in data types to handle different kinds of data:

Category Data Types
Number Integer, Floating point, Complex
Boolean True, False
Sequence String, List, Tuple
Mapping Dictionary
None Represents the absence of a value

5. Mutable vs Immutable Types

Understanding mutability is critical for managing data in Python.


6. Operators & Expressions

Operators are symbols used to perform computations.

Precedence of Operators: Determines the order in which operators are evaluated in an expression (e.g., multiplication before addition).

7. Input/Output & Type Conversion

Exam Tips & Warnings

Mnemonic for Tokens: KILOP (Keywords, Identifiers, Literals, Operators, Punctuators).

Frequently Asked Questions

Q: What is the difference between a list and a tuple?
A list is mutable (can be changed), while a tuple is immutable (cannot be changed).

Q: What is a complex number in Python?
It is a number with a real and imaginary part, represented as a + bj.