Code Tutorials Visual Tools
1. Python Installation

Here's a comprehensive Python introduction study material that covers all the key foundational topics, complete with explanations, examples, and practice exercises:


Python Introduction: Study Material


1. What is Python?

  • High-level, interpreted, general-purpose programming language.
  • Designed for readability, simplicity, and versatility.
  • Created by Guido van Rossum in 1991.
  • Widely used in web development, data science, automation, AI/ML, etc.

2. Installing Python

  • Download from python.org
  • Check installation: python --version
  • Use IDEs like:
    • VSCode
    • PyCharm
    • Jupyter Notebook (for data science)

3. Python Syntax Basics

Printing Output

print("Hello, World!")

Comments

# This is a comment

Variables

x = 5
name = "Alice"

Data Types

  • int, float, str, bool, list, tuple, dict, set, None

4. Data Types & Type Conversion

Built-in Types:

x = 10            # int
pi = 3.14         # float
name = "Alice"    # str
flag = True       # bool

Type Conversion

int("5")         # 5
str(100)         # "100"
float("3.14")    # 3.14

5. Operators

Arithmetic

+ - * / % // **

Comparison

== != > < >= <=

Logical

and or not

Assignment

= += -= *=


6. Control Structures

If Statements

if x > 0:
    print("Positive")
elif x == 0:
    print("Zero")
else:
    print("Negative")

Loops

For Loop

for i in range(5):
    print(i)

While Loop

while x < 5:
    x += 1

7. Data Structures

Lists

fruits = ["apple", "banana"]
fruits.append("orange")

Tuples

point = (1, 2)

Sets

unique_nums = {1, 2, 3}

Dictionaries

person = {"name": "Alice", "age": 25}

8. Functions

def greet(name):
    return f"Hello, {name}"

Built-in Functions

len(), type(), range(), input(), print()


9. Modules and Packages

import math
print(math.sqrt(16))

Custom Modules

Save your code as mymodule.py and import:

import mymodule

10. Exception Handling

try:
    x = 1 / 0
except ZeroDivisionError:
    print("Cannot divide by zero")
finally:
    print("Done")

11. File Handling

# Writing
with open("file.txt", "w") as f:
    f.write("Hello")

# Reading
with open("file.txt", "r") as f:
    content = f.read()

12. Object-Oriented Programming (OOP)

Class and Object

class Person:
    def __init__(self, name):
        self.name = name

    def greet(self):
        print(f"Hi, I'm {self.name}")

p = Person("Alice")
p.greet()

Concepts:

  • Encapsulation
  • Inheritance
  • Polymorphism

Practice Exercises

Basic

  1. Print your name and age.
  2. Convert temperature from Celsius to Fahrenheit.
  3. Swap two variables.

Intermediate

  1. Count vowels in a string.
  2. Check if a number is prime.
  3. Create a simple calculator.

Advanced

  1. Build a contact book using dictionaries.
  2. Simulate a banking system with OOP.
  3. Create a mini file-reader tool.

Additional Resources