Skip to content
Vista Academy
  • Home
  • About Us
  • Course
    • Master Program in Data Analytics Course
    • Master Program in Data Science Course
    • Master Program Business Analytics Course
    • 3‑Month Machine Learning Course
    • Human Intelligence Internship in the Age of AI | Vista Academy
  • Explore Our Courses
  • Gallery & Achievements
  • Blog
    • Data Analytics
    • artificial intelligence
    • Career & Salary
    • Data Dashboards – Uttarakhand Insights
    • informationTechnology
    • Power BI
    • python
    • SQL
    • Projects
  • Free Data Analytics Tools for Students
    • Free Dataset Finder
    • Data Analyst Resume Builder
    • Data Analytics Jobs
    • Data Analytics Roadmap 2026
  • Contact Us
  • Home
  • Explore Our Courses
  • Written Edition English Tutorial

Python Written Edition English Tutorial

Curriculum

  • 15 Sections
  • 167 Lessons
  • 10 Weeks
Expand all sectionsCollapse all sections
  • Python Basics
    54
    • 1.1
      Introduction to Python Programming
    • 1.2
      Python Overview: Features, Applications & Why It’s So Popular
    • 1.3
      MCQ Python – Overview
      10 Minutes4 Questions
    • 1.4
      Python History & Versions Explained: Evolution of the Language
    • 1.5
      MCQ History and Versions of Python
      10 Minutes4 Questions
    • 1.6
      Top Python Features: Why Python is So Popular
    • 1.7
      MCQ Python features
      10 Minutes4 Questions
    • 1.8
      Python vs C++: Key Differences for Beginners & Developers
    • 1.9
      MCQ Python vs C++
      10 Minutes4 Questions
    • 1.10
      Python Hello World Program – Your First Step in Coding
    • 1.11
      MCQ Hello World program in Python
      10 Minutes2 Questions
    • 1.12
      Top Applications of Python in Real Life | Python Career Scope
    • 1.13
      Python Interpreter & Modes Explained | Interactive vs Script Mode
    • 1.14
      MCQ Python Interpreter and Its Modes
      10 Minutes4 Questions
    • 1.15
      Python Environment Setup | Install Python, IDEs & Configure Path
    • 1.16
      MCQ Python Environment Setup: A Complete Guide
      10 Minutes4 Questions
    • 1.17
      Python Syntax Basics | Learn How Python Code is Written
    • 1.18
      MCQ Python – Syntax
      10 Minutes4 Questions
    • 1.19
      Python Variables Explained | Learn to Store and Use Data in Python
    • 1.20
      MCQ Python – Variables
      10 Minutes4 Questions
    • 1.21
      Assign Multiple Values to Python Variables | Python Tutorial for Beginners
    • 1.22
      MCQ Python Variables – Assign Multiple Values
      10 Minutes4 Questions
    • 1.23
      Python Data Types Explained | Built-in Data Types in Python
    • 1.24
      MCQ PYTHON DATA TYPE
      10 Minutes5 Questions
    • 1.25
      Python Type Casting | Convert Data Types in Python
    • 1.26
      MCQ Python – Type Casting
      10 Minutes4 Questions
    • 1.27
      Python Unicode System | Handle Multilingual Text in Python
    • 1.28
      MCQ Python Unicode System
      10 Minutes4 Questions
    • 1.29
      Python Literals Explained | Types, Examples & Use Cases
    • 1.30
      MCQ Python Literals: A Comprehensive Guide
      15 Minutes5 Questions
    • 1.31
      Python Operators Explained | Types, Syntax & Examples
    • 1.32
      MCQ Python – Operators
      15 Minutes5 Questions
    • 1.33
      Mastering Python Arithmetic Operators with Examples
    • 1.34
      MCQ Python arithmetical operator
      20 Minutes15 Questions
    • 1.35
      Python Comparison Operators Explained with Examples
    • 1.36
      MCQ Python – Comparison Operators
      10 Minutes4 Questions
    • 1.37
      Mastering Python Assignment Operators with Examples
    • 1.38
      MCQ Python Assignment Operators:
      10 Minutes4 Questions
    • 1.39
      Python Logical Operators Explained with Examples
    • 1.40
      MCQ Python Logical Operators
      10 Minutes4 Questions
    • 1.41
      Python Bitwise Operators Explained with Examples
    • 1.42
      Python Membership Operators Explained with Examples
    • 1.43
      MCQ Python – Membership Operators
      10 Minutes4 Questions
    • 1.44
      Python Identity Operators: is and is not Explained
    • 1.45
      MCQ Python Identity Operators
      10 Minutes4 Questions
    • 1.46
      Understanding Python Identity Operators with Examples
    • 1.47
      MCQ PYTHON IDENTITY OPERATOR
      10 Minutes4 Questions
    • 1.48
      Python Comments: Single-line and Multi-line Explained
    • 1.49
      Taking User Input in Python with input() Function
    • 1.50
      MCQ Provide User Input in Python
      10 Minutes2 Questions
    • 1.51
      Python Numbers: int, float, and complex Explained
    • 1.52
      MCQ Python – Numbers
      10 Minutes2 Questions
    • 1.53
      Python Booleans (bool): True and False Explained with Examples
    • 1.54
      MCQ Python Booleans (bool)
      10 Minutes4 Questions
  • Python Control Statements
    25
    • 2.1
      Python Control Flow: Master if, else, elif Statements with Examples
    • 2.2
      Python Decision Making: if, elif, else Explained with Examples
    • 2.3
      MCQ Python – Decision Making
      10 Minutes4 Questions
    • 2.4
      Python if Statement: Basic Conditional Execution in Python
    • 2.5
      MCQ Python – if Statement
      10 Minutes4 Questions
    • 2.6
      Python if-else Statement: Make Conditional Decisions in Python
    • 2.7
      Python Nested if Statement: Master Conditional Logic in Depth
    • 2.8
      MCQ Python – Nested if Statement Python if-else Statement
      10 Minutes4 Questions
    • 2.9
      Python Match-Case Statement: Simplify Multiple Conditions Easily
    • 2.10
      (MCQs) based on the Python Match-Case Statement
      10 Minutes4 Questions
    • 2.11
      Python Loops Explained: Master for, while, and nested loops
    • 2.12
      Python For Loops Tutorial: Syntax, Range, and Examples
    • 2.13
      MCQ Python – For Loops
      10 Minutes2 Questions
    • 2.14
      Python For Else Loop Explained with Examples
    • 2.15
      MCQ Python – For Else Loop
      10 Minutes4 Questions
    • 2.16
      Python While Loops with Syntax and Real Examples
    • 2.17
      MCQ Python – While Loops
      10 Minutes4 Questions
    • 2.18
      Python break Statement with Syntax, Flowchart & Examples
    • 2.19
      MCQ Python – break Statement
      10 Minutes4 Questions
    • 2.20
      Python continue Statement Explained with Syntax and Practical Examples
    • 2.21
      MCQ Python – Continue Statement
      10 Minutes4 Questions
    • 2.22
      Python pass Statement: Usage, Syntax, and Examples
    • 2.23
      MCQ Python – pass Statement
      10 Minutes4 Questions
    • 2.24
      Python Nested Loops: Complete Guide with Syntax and Examples
    • 2.25
      Mcq Python – Nested Loops
      10 Minutes4 Questions
  • Python Functions & Modules
    16
    • 3.1
      Python Functions: A Complete Guide with Syntax and Examples
    • 3.2
      MCQ Python – Functions
      10 Minutes4 Questions
    • 3.3
      Python Default Arguments Explained with Syntax and Real Examples
    • 3.4
      mcq Python – Default Arguments
      10 Minutes2 Questions
    • 3.5
      Python Keyword Arguments Explained with Syntax and Practical Examples
    • 3.6
      MCQ Python Keyword Arguments Explained
      10 Minutes4 Questions
    • 3.7
      Python Keyword-Only Arguments: Syntax, Examples, and Use Cases
    • 3.8
      Python Positional Arguments: A Beginner-Friendly Guide with Examples
    • 3.9
      MCQ Positional Arguments Keyword-Only Arguments
      10 Minutes4 Questions
    • 3.10
      Python Arbitrary (Variable-Length) Arguments Explained with Examples
    • 3.11
      MCQ Python – Arbitrary or, Variable-length Arguments
      10 Minutes4 Questions
    • 3.12
      Python Variable Scope Explained: Local, Global, and Nonlocal with Examples
    • 3.13
      MCQ Python Variable Scope
      10 Minutes4 Questions
    • 3.14
      Python Function Annotations: Add Meaning to Function Parameters and Return Types
    • 3.15
      MCQ Python – Function Annotations
      10 Minutes5 Questions
    • 3.16
      Python Modules: Create, Import, and Use Python Code Reusably
  • Python Strings
    14
    • 4.1
      Python Strings: Learn String Creation, Methods & Manipulation
    • 4.2
      MCQ Python – Strings
      10 Minutes4 Questions
    • 4.3
      Python Slicing Strings: Learn Indexing & Substring Extraction Easily
    • 4.4
      MCQ Python Slicing Strings
      10 Minutes4 Questions
    • 4.5
      Python Modify Strings: Learn How to Change and Update Strings
    • 4.6
      MCQ Python – Modify Strings
      10 Minutes4 Questions
    • 4.7
      Python String Concatenation: Combine Strings Easily
    • 4.8
      MCQ Python – String Concatenation
      10 Minutes4 Questions
    • 4.9
      Python String Formatting: Format Strings with Style
    • 4.10
      MCQ Python – String Formatting
      10 Minutes4 Questions
    • 4.11
      Python Escape Characters: Handle Special Characters in Strings
    • 4.12
      MCQ Python – Escape Characters
      10 Minutes4 Questions
    • 4.13
      Python String Methods: Essential Functions for String Handling
    • 4.14
      MCQ Python – String Methods
      10 Minutes4 Questions
  • Python Lists
    22
    • 5.1
      Python Lists Tutorial: Creating, Accessing, and Modifying Lists
    • 5.2
      MCQ Python – Lists
      10 Minutes4 Questions
    • 5.3
      Accessing List Items in Python with Indexing and Slicing
    • 5.4
      MCQ Python – Access List Items
      10 Minutes4 Questions
    • 5.5
      How to Change List Items in Python with Examples
    • 5.6
      MCQ Python – Change List Items
      10 Minutes4 Questions
    • 5.7
      How to Add Items to a List in Python with Examples
    • 5.8
      MCQ Python – Add List Items
      10 Minutes4 Questions
    • 5.9
      How to Remove Items from a List in Python with Examples
    • 5.10
      MCQ Python – Remove List Items
      10 Minutes4 Questions
    • 5.11
      Loop Through Lists in Python with For and While Loops
    • 5.12
      MCQ Python – Loop Lists
      10 Minutes4 Questions
    • 5.13
      Master Python List Comprehension with Simple Examples
    • 5.14
      MCQ Python – List Comprehension
      10 Minutes4 Questions
    • 5.15
      How to Sort Lists in Python with Examples
    • 5.16
      MCQ Python – Sort Lists
      10 Minutes4 Questions
    • 5.17
      Different Ways to Copy Lists in Python with Examples
    • 5.18
      MCQ Python – Copy Lists
      10 Minutes4 Questions
    • 5.19
      Python – Join Lists
    • 5.20
      MCQ Python – Join Lists
      10 Minutes4 Questions
    • 5.21
      Essential Python List Methods with Examples
    • 5.22
      MCQ List Methods
      10 Minutes4 Questions
  • Python Tuples
    14
    • 6.1
      Understanding Tuples in Python with Practical Examples
    • 6.2
      MCQ Python – Tuples
      10 Minutes4 Questions
    • 6.3
      Python – Access Tuple Items
    • 6.4
      MCQ Access Tuple Items
      10 Minutes4 Questions
    • 6.5
      How to Update Tuples in Python with Smart Workarounds
    • 6.6
      MCQ Update Tuples
      10 Minutes4 Questions
    • 6.7
      Python – Unpack Tuple Items
    • 6.8
      MCQ Unpack Tuple Items
      10 Minutes4 Questions
    • 6.9
      Python – Loop Tuples
    • 6.10
      MCQ Loop Tuples
      10 Minutes4 Questions
    • 6.11
      Python – Join Tuples
    • 6.12
      MCQ Join Tuples
      10 Minutes4 Questions
    • 6.13
      Python – Tuple Methods
    • 6.14
      MCQ Tuple Methods
      10 Minutes4 Questions
  • Python Sets
    18
    • 7.1
      Python Sets Tutorial with Examples for Beginners
    • 7.2
      MCQ Sets
      10 Minutes4 Questions
    • 7.3
      Accessing Items in Python Sets with Examples
    • 7.4
      MCQ Access Set Items
      10 Minutes4 Questions
    • 7.5
      Python – Add Set Items
    • 7.6
      MCQ Add Set Items
      10 Minutes4 Questions
    • 7.7
      Python – Remove Set Items
    • 7.8
      MCQ Remove Set Items
      10 Minutes4 Questions
    • 7.9
      Python – Loop Sets
    • 7.10
      MCQ Loop Sets
      10 Minutes4 Questions
    • 7.11
      Python – Join Sets
    • 7.12
      MCQ Join Sets
      10 Minutes4 Questions
    • 7.13
      Python – Copy Sets
    • 7.14
      MCQ Copy Sets
      10 Minutes4 Questions
    • 7.15
      Python – Set Operators
    • 7.16
      MCQ Set Operators
      10 Minutes4 Questions
    • 7.17
      Python – Set Methods
    • 7.18
      MCQ Set Methods
      10 Minutes4 Questions
  • Python Dictionaries
    20
    • 8.1
      Python – Dictionaries
    • 8.2
      MCQ Dictionaries
      10 Minutes4 Questions
    • 8.3
      Python – Access Dictionary Items
    • 8.4
      MCQ Access Dictionary Items
      10 Minutes4 Questions
    • 8.5
      Python – Change Dictionary Items
    • 8.6
      MCQ Change Dictionary Items
      10 Minutes4 Questions
    • 8.7
      Python – Add Dictionary Items
    • 8.8
      MCQ Add Dictionary Items
      10 Minutes4 Questions
    • 8.9
      Python – Remove Dictionary Items
    • 8.10
      MCQ Remove Dictionary Items
      10 Minutes4 Questions
    • 8.11
      Python – Dictionary View Objects
    • 8.12
      MCQs for “Python Dictionary View Objects
      10 Minutes4 Questions
    • 8.13
      Python – Loop Dictionaries
    • 8.14
      MCQs for “Python – Loop Dictionaries”
      10 Minutes4 Questions
    • 8.15
      Python – Copy Dictionaries
    • 8.16
      MCQs for “Python – Copy Dictionaries”
      10 Minutes4 Questions
    • 8.17
      Python – Nested Dictionaries
    • 8.18
      MCQs for “Python – Nested Dictionaries”
      10 Minutes4 Questions
    • 8.19
      Python – Dictionary Methods
    • 8.20
      MCQs for “Python – Dictionary Methods”
      10 Minutes4 Questions
  • Python Arrays
    20
    • 9.1
      Python – Arrays
    • 9.2
      MCQs for “Python – Arrays”
      10 Minutes4 Questions
    • 9.3
      Python – Access Array Items
    • 9.4
      MCQs for “Python – Access Array Items
      10 Minutes4 Questions
    • 9.5
      Python – Add Array Items
    • 9.6
      MCQs for “Python – Add Array Items”
      10 Minutes4 Questions
    • 9.7
      Python – Remove Array Items
    • 9.8
      MCQs for “Python – Remove Array Items”
      10 Minutes4 Questions
    • 9.10
      Python – Loop Arrays
    • 9.11
      MCQs for “Python – Loop Arrays”
      10 Minutes4 Questions
    • 9.12
      Python – Copy Arrays
    • 9.13
      MCQs for “Python – Copy Arrays”
      10 Minutes5 Questions
    • 9.14
      Python – Reverse Arrays
    • 9.15
      MCQs for “Python – Reverse Arrays”
      10 Minutes4 Questions
    • 9.16
      Python – Sort Arrays
    • 9.17
      MCQs for “Python – Sort Arrays”
      10 Minutes4 Questions
    • 9.18
      Python – Join Arrays
    • 9.19
      MCQs for “Python – Join Arrays”
      10 Minutes4 Questions
    • 9.20
      Python – Array Methods
    • 9.21
      MCQs for “Python – Array Methods”
      10 Minutes4 Questions
  • Python File Handling
    16
    • 10.1
      Python – File Handling
    • 10.2
      MCQs for “Python – File Handling”
      10 Minutes4 Questions
    • 10.3
      Python – Write to File
    • 10.4
      MCQs for “Python – Write to File”
      10 Minutes4 Questions
    • 10.5
      Python – Read Files
    • 10.6
      MCQs for “Python – Read Files”
      10 Minutes4 Questions
    • 10.7
      Python – Renaming and Deleting Files
    • 10.8
      MCQs for “Python – Renaming and Deleting Files”
      10 Minutes4 Questions
    • 10.9
      Python – Directories
    • 10.10
      MCQs for “Python – Directories”
      10 Minutes4 Questions
    • 10.11
      Python – File Methods
    • 10.12
      MCQs for “Python – File Methods”
      10 Minutes4 Questions
    • 10.13
      Python OS File/Directory Methods
    • 10.14
      MCQs for “Python OS File/Directory Methods”
      10 Minutes4 Questions
    • 10.15
      Python OS.Path Methods
    • 10.16
      MCQs for “Python OS.Path Methods”
      10 Minutes4 Questions
  • Object Oriented Programming
    46
    • 11.1
      Python – OOPs Concepts
    • 11.2
      MCQs for “Python – OOP Concepts”
      10 Minutes4 Questions
    • 11.3
      Python – Classes and Objects
    • 11.4
      MCQs for “Python – Classes and Objects”
      10 Minutes4 Questions
    • 11.5
      Python – Class Attributes
    • 11.6
      MCQs for “Python – Class Attributes”
      10 Minutes4 Questions
    • 11.7
      Python – Class Methods
    • 11.8
      MCQs for “Python – Class Methods”
      10 Minutes4 Questions
    • 11.9
      Python – Static Methods
    • 11.10
      MCQs for “Python – Static Methods”
      10 Minutes4 Questions
    • 11.11
      Python – Constructors
    • 11.12
      MCQs for “Python – Constructors”
      10 Minutes4 Questions
    • 11.13
      Python – Access Modifiers
    • 11.14
      MCQs for “Python – Access Modifiers”
      10 Minutes4 Questions
    • 11.15
      Python – Inheritance
    • 11.16
      MCQs for “Python – Inheritance”
      10 Minutes4 Questions
    • 11.17
      Python – Polymorphism
    • 11.18
      MCQs for “Python – Polymorphism”
      10 Minutes4 Questions
    • 11.19
      Python – Method Overriding
    • 11.20
      MCQs for “Python – Method Overriding”
      10 Minutes4 Questions
    • 11.21
      Python – Method Overloading
    • 11.22
      MCQs for “Python – Method Overloading”
      10 Minutes4 Questions
    • 11.23
      Python – Dynamic Binding
    • 11.24
      MCQs for “Python – Dynamic Binding”
      10 Minutes4 Questions
    • 11.25
      Python – Dynamic Typing
    • 11.26
      MCQs for “Python – Dynamic Typing”
      10 Minutes4 Questions
    • 11.27
      Python – Abstraction
    • 11.28
      MCQs for “Python – Abstraction”
      10 Minutes4 Questions
    • 11.29
      Python – Encapsulation
    • 11.30
      MCQs for “Python – Encapsulation”
      10 Minutes4 Questions
    • 11.31
      Python – Interfaces
    • 11.32
      MCQs for “Python – Interfaces”
      10 Minutes4 Questions
    • 11.33
      Python – Packages
    • 11.34
      MCQs for “Python – Packages”
      10 Minutes4 Questions
    • 11.35
      Python – Inner Classes
    • 11.36
      MCQs for “Python – Inner Classes”
      10 Minutes4 Questions
    • 11.37
      Python – Anonymous Class and Objects
    • 11.38
      MCQs for “Python – Anonymous Class and Objects”
      10 Minutes4 Questions
    • 11.39
      Python – Singleton Class
    • 11.40
      MCQs for “Python – Singleton Class”
      10 Minutes4 Questions
    • 11.41
      Python – Wrapper Classes
    • 11.42
      MCQs for “Python – Wrapper Classes”
      10 Minutes4 Questions
    • 11.43
      Python – Enums
    • 11.44
      MCQs for “Python – Enums”
      10 Minutes4 Questions
    • 11.45
      Python – Reflection
    • 11.46
      MCQs for “Python – Reflection”
      10 Minutes4 Questions
  • Python Errors & Exceptions
    22
    • 12.1
      Python – Syntax Errors
    • 12.2
      MCQs for “Python – Syntax Errors”
      10 Minutes4 Questions
    • 12.3
      Python – Exceptions
    • 12.4
      MCQs for “Python – Exceptions Handling”
      10 Minutes4 Questions
    • 12.5
      Python – The try-except Block
    • 12.6
      MCQs for “Python Try-Except Block”
      10 Minutes4 Questions
    • 12.7
      Python – The try-finally Block
    • 12.8
      MCQs for “Python Try-Finally Block”
      10 Minutes4 Questions
    • 12.9
      Python – Raising Exceptions
    • 12.10
      MCQs for “Raising Exceptions in Python”
      10 Minutes4 Questions
    • 12.11
      Python – Exception Chaining
    • 12.12
      MCQs for “Exception Chaining”
      10 Minutes4 Questions
    • 12.13
      Python – Nested try Block
    • 12.14
      MCQs for “Nested try Block in Python”
      10 Minutes4 Questions
    • 12.15
      Python – User-Defined Exceptions
    • 12.16
      MCQs for “User-Defined Exceptions in Python”
      10 Minutes4 Questions
    • 12.17
      Python – Logging
    • 12.18
      MCQs for “Logging in Python”
      10 Minutes4 Questions
    • 12.19
      Python – Assertions
    • 12.20
      MCQs for “Assertions in Python”
      10 Minutes4 Questions
    • 12.21
      Python – Built-in Exceptions
    • 12.22
      MCQs for “Python – Built-in Exceptions”
      10 Minutes4 Questions
  • Python Multithreading
    24
    • 13.1
      Python – Multithreading
    • 13.2
      MCQs for “Multithreading in Python”
      10 Minutes4 Questions
    • 13.3
      Python – Thread Life cycle
    • 13.4
      MCQs for “Thread Life Cycle in Python”
      10 Minutes4 Questions
    • 13.5
      Python – Creating a Thread
    • 13.6
      MCQs for “Creating Threads in Python”
      10 Minutes4 Questions
    • 13.7
      Python – Starting a Thread
    • 13.8
      MCQs for “Starting a Thread in Python”
      10 Minutes4 Questions
    • 13.9
      Python – Joining the Threads
    • 13.10
      MCQs for “Joining the Threads in Python”
      10 Minutes4 Questions
    • 13.11
      Python – Naming the Threads
    • 13.12
      MCQs for “Naming the Threads in Python”
      10 Minutes4 Questions
    • 13.13
      Python – Thread Scheduling
    • 13.14
      MCQs for “Thread Scheduling in Python”
      10 Minutes4 Questions
    • 13.15
      Python – Thread Pools
    • 13.16
      MCQs for “Thread Pool in Python”
      10 Minutes4 Questions
    • 13.17
      Python – Main Thread
    • 13.18
      MCQs for “Main Thread in Python”
      10 Minutes4 Questions
    • 13.19
      Python – Thread Priority
    • 13.20
      MCQs for “Thread Priority in Python”
      10 Minutes4 Questions
    • 13.21
      Python – Daemon Threads
    • 13.22
      MCQs for “Daemon Threads in Python”
      10 Minutes4 Questions
    • 13.23
      Python – Synchronizing Threads
    • 13.24
      MCQs for “Synchronizing Threads in Python”
      10 Minutes4 Questions
  • Python Synchronization
    6
    • 14.1
      Python – Inter-Thread Communication
    • 14.2
      MCQs for “Inter-Thread Communication in Python”
      10 Minutes4 Questions
    • 14.3
      Python – Thread Deadlock
    • 14.4
      MCQs for “Deadlock in Python”
      10 Minutes4 Questions
    • 14.5
      Python – Interrupting a Thread
    • 14.6
      MCQs for “Interrupting a Thread in Python”
      10 Minutes4 Questions
  • Python Networking
    8
    • 15.1
      Python – Network Programming
    • 15.2
      MCQs for “Networking and Interprocess Communication in Python”
      10 Minutes4 Questions
    • 15.3
      Python – Socket Programming
    • 15.4
      MCQs for “Python Socket Programming”
      10 Minutes4 Questions
    • 15.5
      Python – URL Processing
    • 15.6
      MCQs for “Working with URLs in Python using urllib”
      10 Minutes4 Questions
    • 15.7
      Python – Generics
    • 15.8
      MCQs for “Generics in Python”
      10 Minutes4 Questions

Accessing List Items in Python with Indexing and Slicing



Accessing List Items in Python: A Comprehensive Guide

Table of Contents

Toggle
  • Accessing List Items in Python: A Comprehensive Guide
    • 1. Accessing List Items with Indexing
    • 2. Accessing List Items with Negative Indexing
    • 3. Accessing List Items with Slice Operator
    • 4. Accessing Sublists from a List

In Python, a list is an ordered collection of elements. Each element in a list corresponds to an index, starting from 0. This guide explains how to access list items using indexing, negative indexing, slicing, and extracting sublists.

1. Accessing List Items with Indexing

To access an item in a list, use square brackets [] and specify the index of the element. The index starts at 0 for the first element and increments by 1 for each subsequent element.

Example: Accessing List Items with Indexing

list1 = ["Rohan", "Physics", 21, 69.75]
list2 = [1, 2, 3, 4, 5]

print("Item at 0th index in list1:", list1[0])  # Output: Rohan
print("Item at index 2 in list2:", list2[2])  # Output: 3

2. Accessing List Items with Negative Indexing

Negative indexing allows you to access elements from the end of the list. The index -1 refers to the last element, -2 to the second last, and so on.

Example: Accessing List Items with Negative Indexing

list1 = ["a", "b", "c", "d"]
list2 = [25.50, True, -55, 1+2j]

print("Item at -1 index in list1:", list1[-1])  # Output: d
print("Item at -3 index in list2:", list2[-3])  # Output: True

3. Accessing List Items with Slice Operator

The slice operator [start:stop] is used to fetch a range of elements from a list. The start index is inclusive, and the stop index is exclusive. If no indices are provided, it defaults to the entire list.

Example: Accessing List Items with Slice Operator

list1 = ["a", "b", "c", "d"]
list2 = [25.50, True, -55, 1+2j]
list3 = ["Rohan", "Physics", 21, 69.75]

print("Items from index 1 to last in list1:", list1[1:])  # Output: ['b', 'c', 'd']
print("Items from index 0 to 1 in list2:", list2[:2])  # Output: [25.5, True]
print("All items in list3:", list3[:])  # Output: ['Rohan', 'Physics', 21, 69.75]

4. Accessing Sublists from a List

A sublist is a consecutive sequence of elements from the original list. You can extract a sublist using the slice operator with appropriate start and stop indices.

Example: Accessing Sublists

list1 = ["a", "b", "c", "d"]
list2 = [25.50, True, -55, 1+2j]

print("Items from index 1 to 2 in list1:", list1[1:3])  # Output: ['b', 'c']
print("Items from index 0 to 1 in list2:", list2[0:2])  # Output: [25.5, True]

Learn Python In-Depth with Real-World Projects

Enroll in our Python certification course at Vista Academy and become a certified expert to boost your career.

Enroll Now