Python Revision Tour - Part 1
• Welcome to Python Revision Tour - Class 12
• Topics Covered:
• - Python Basics
• - Tokens
• - Data Types
• - Operators
• - Flow of Control
• - Functions and more
Introduction to Python
• Python is an interpreted, high-level, general-
purpose programming language.
• It is known for its simplicity and readability.
• Python supports object-oriented, procedural,
and functional programming.
Tokens in Python
• Tokens are the smallest units of a Python
program.
• Types:
• - Keywords
• - Identifiers
• - Literals
• - Operators
• - Punctuators
Keywords
• Keywords are reserved words that have
special meaning in Python.
• Examples: if, else, elif, import, def, return,
class
Identifiers
• Identifiers are names used to identify
variables, functions, classes, etc.
• They must start with a letter (A-Z or a-z) or an
underscore (_).
Literals
• Literals represent constant values in Python
code.
• Examples:
• - Numeric: 123, 3.14
• - String: "Hello"
• - Boolean: True, False
Operators
• Operators perform operations on variables
and values.
• Types:
• - Arithmetic
• - Relational
• - Logical
• - Assignment
• - Bitwise
Variables and Data Types
• Variables store data values.
• Data types include:
• - int, float, str, bool
• - list, tuple, dict, set
Input and Output Functions
• Use input() to take user input.
• Use print() to display output.
• Example:
• name = input("Enter your name: ")
• print("Hello", name)
Type Casting
• Type casting is converting one data type to
another.
• Examples:
• int("7") -> 7
• float(3) -> 3.0
• str(10) -> "10"