0% found this document useful (0 votes)
10 views6 pages

Python Core Modules Notes Ok

This document provides detailed notes on four Python modules: Calendar, QR Code, Sys, and a complete overview of Python modules. Each module includes definitions, usage, important functions, syntax, examples, and outputs. The final summary outlines the purpose of each module, emphasizing their functionalities in date handling, QR code generation, system interaction, and code reusability.

Uploaded by

kumman2030
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Python Core Modules Notes Ok

This document provides detailed notes on four Python modules: Calendar, QR Code, Sys, and a complete overview of Python modules. Each module includes definitions, usage, important functions, syntax, examples, and outputs. The final summary outlines the purpose of each module, emphasizing their functionalities in date handling, QR code generation, system interaction, and code reusability.

Uploaded by

kumman2030
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Core Modules – Detailed Notes with

Outputs
This document explains the following Python modules in a very clear,
beginner-friendly, and detailed way:
1. Calendar Module
2. QR Code Module
3. Sys Module
4. Python Modules (Complete Overview)
Each topic includes: ✔ Definition ✔ Why it is used ✔ Important functions ✔
Syntax ✔ Examples ✔ Output of each example

1. Calendar Module
What is the Calendar Module?
The calendar module is a built-in Python module that allows you to work with
dates, months, and years. You can display calendars, check leap years, and
find which day a specific date falls on.

Why use the Calendar Module?


 To display month or year calendars
 To check leap years
 To find the day of the week
 To handle date-related operations

Importing the Calendar Module


Syntax:
import calendar

Example 1: Display a Month Calendar


import calendar
print([Link](2026, 1))
Output:
January 2026
Mo Tu We Th Fr Sa Su
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Example 2: Check Leap Year


import calendar
print([Link](2024))
print([Link](2025))

Output:
True
False

Example 3: Find the Day of the Week


import calendar
# 0 = Monday, 6 = Sunday
print([Link](2026, 1, 8))

Output:
3

👉 This means Thursday

2. QR Code Module
What is the QR Code Module?
The qrcode module is used to generate QR codes that store text, links, or
data which can be scanned using a mobile camera.

Installation
This is not a built-in module. Install it using:
pip install qrcode[pil]
Importing QR Code Module
import qrcode

Example 1: Create a Simple QR Code


import qrcode
img = [Link]("Hello Python")
[Link]("hello_qr.png")

Output:
A file named hello_qr.png will be created in your folder.

Example 2: QR Code for a Website


import qrcode
img = [Link]("[Link]
[Link]("google_qr.png")

Output:
A QR code image named google_qr.png is created.

3. Sys Module
What is the Sys Module?
The sys module provides access to system-specific parameters and functions
related to the Python interpreter.

Why use Sys Module?


 Read command-line arguments
 Exit a program
 Check Python version
 Access system paths

Importing Sys Module


import sys
Example 1: [Link] (Command-line Arguments)
import sys
print([Link])

Run from terminal:


python [Link] hello 10

Output:
['[Link]', 'hello', '10']

Example 2: Exit a Program


import sys
[Link]("Program stopped")

Output:
Program stopped

Example 3: Python Version


import sys
print([Link])

Output:
3.x.x (example)

4. Python Modules (Complete Overview)


What is a Python Module?
A Python module is a file containing Python code (functions, variables,
classes) that can be reused in other programs.

Types of Modules
1. Built-in Modules → math, sys, calendar
2. User-defined Modules → your own .py files
3. Third-party Modules → numpy, pandas, qrcode

Importing a Module
import module_name
from module_name import function_name

import module_name as alias

Example 1: Built-in Module (math)


import math
print([Link](25))

Output:
5.0

Example 2: User-Defined Module


[Link]
def add(a, b):
return a + b

[Link]
import mymath
print([Link](10, 20))

Output:
30

Example 3: Third-Party Module (numpy)


import numpy as np
arr = [Link]([1, 2, 3])
print(arr)

Output:
[1 2 3]

Final Summary
Module Purpose
calendar Work with dates & months
qrcode Generate QR codes
sys System interaction
modules Code reusability
If you want, I can now: ✅ Convert this into a Word file ✅ Add more examples ✅
Add interview questions ✅ Add diagrams
Just tell me what you want next 👍

You might also like