Python Tutorial - Modules

Unlock Premium Features: AI explanations (Hinglish), Indian voice & Videos
Sign Up Free

๐Ÿ“ฆ Modules - Ready-Made Tools

๐ŸŒŸ Real Life Mein:

Tools jo already available hain:

๐Ÿ”ง "Toolkit box" - Har tool already ready
๐Ÿ“š "Library" - Books already likhi hui
๐Ÿฝ๏ธ "Ready-to-eat food" - Khud banana nahi padta
๐Ÿ“ฑ "Apps" - Download aur use karo

Python Modules = Pre-written code import karo!

๐Ÿ“š Module Kya Hai?

Module ek Python file hai jisme:

  • Ready-made functions
  • Useful variables
  • Pre-written code

Faada: Wheel reinvent nahi karna padta!

Module Import Karna
import math

# Math functions available
print(math.sqrt(16))    # 4.0
print(math.pi)          # 3.14159...
print(math.pow(2, 3))   # 8.0

๐ŸŽฒ Popular Built-in Modules

ModuleUseExample
randomRandom valuesrandom.randint(1,6)
mathMath operationsmath.sqrt(25)
datetimeDate/Timedatetime.now()
osOperating Systemos.getcwd()
๐ŸŽฒ Dice Game
import random

# 1 se 6 beech random number
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)

print(f"Dice 1: {dice1}")
print(f"Dice 2: {dice2}")
print(f"Total: {dice1 + dice2}")
๐Ÿ“… Current Date/Time
import datetime

# Aaj ka date/time
now = datetime.datetime.now()

print("Today:", now.date())
print("Time:", now.time())
print("Year:", now.year)
Install External Modules:
pip install module_name command se naye modules install kar sakte ho!

๐Ÿค– AI Tutor Unlock Karo!

Apni language mein coding seekho - Hindi, Marathi, Gujarati aur 10+ Indian languages mein!

  • Hinglish mein explanations
  • Real-life examples
  • Beginner-friendly
Free Signup Karo

Example

import random
x = random.randint(1, 100)
print(x)