๐Ÿ ๐Ÿ’ป โš™๏ธ ๐Ÿš€
๐Ÿ

Python Programming

๐Ÿ Code โ€ข Practice โ€ข Create โœจ

๐ŸŽ“ BCA โ€ข PYTHON PROGRAMMING

๐Ÿ Python Programming

Learn Python from the basics with simple explanations, examples, diagrams, important concepts and exam-friendly notes.

๐Ÿ“š Python Topics

๐Ÿ 1. Python Basics

Python is a high-level, interpreted and general-purpose programming language. It is known for its simple and readable syntax.

โญ First Python Program

print("Hello, World!")

๐Ÿš€ How Python Code Works

๐Ÿ‘จโ€๐Ÿ’ป Write Code
โ†’
๐Ÿ Python Interpreter
โ†’
๐Ÿ“ค Output
๐Ÿ’ก Why learn Python?

Python is beginner-friendly and is used in web development, automation, data analysis, AI, machine learning and many other areas.

๐Ÿ“ฆ 2. Variables

A variable is a name used to store a value. Python automatically determines the type of the value.

name = "Roshni" age = 20 marks = 85.5
๐Ÿ‘ค name
Stores text
๐Ÿ”ข age
Stores integer
๐Ÿ“Š marks
Stores decimal value
๐Ÿ’ก Python
No separate declaration needed

๐Ÿ”ข 3. Data Types

Data types define the kind of value stored in a variable.

๐Ÿ”ข int
Whole numbers
๐Ÿ’ง float
Decimal numbers
๐Ÿ”ค str
Text
โœ… bool
True / False
๐Ÿ“‹ list
Ordered collection
๐Ÿ”— tuple
Ordered immutable collection
๐Ÿ“– dict
Key-value collection
๐ŸŽฏ set
Unique unordered values
๐Ÿ’ป Check Data Type
age = 20 print(type(age))

โž• 4. Operators

Operators are symbols used to perform operations on values.

โž• Arithmetic

+   -   *   /   %   **   //

๐Ÿ” Comparison

==   !=   >   <   >=   <=

๐Ÿง  Logical

and   or   not

๐Ÿ“ Assignment

=   +=   -=   *=

a = 10 b = 5 print(a + b) print(a * b)

๐Ÿ”€ 5. Conditions

Conditional statements allow a program to make decisions.

โ–ถ๏ธ Start
โ†’
๐Ÿ” Condition
โ†’
โœ… True / โŒ False
๐Ÿ’ป if-else Example
age = 18 if age >= 18: print("Eligible") else: print("Not Eligible")

๐Ÿงฉ elif

marks = 75 if marks >= 90: print("A") elif marks >= 60: print("B") else: print("C")

๐Ÿ” 6. Loops

Loops are used to execute code repeatedly.

๐Ÿ” for Loop

Used to iterate over a sequence.

๐Ÿ”„ while Loop

Repeats while a condition is true.

๐Ÿ’ป for Loop
for i in range(1, 6): print(i)
๐Ÿ’ป while Loop
i = 1 while i <= 5: print(i) i +=1

โš™๏ธ 7. Functions

A function is a reusable block of code designed to perform a specific task.

๐Ÿ“ฅ Input
โ†’
โš™๏ธ Function
โ†’
๐Ÿ“ค Output
๐Ÿ’ป Function Example
def add(a, b): return a + b result = add(10, 20) print(result)

โœจ Advantages

๐Ÿ“‹ 8. Lists

A list is an ordered and mutable collection of elements.

[0] Apple
[1] Mango
[2] Banana
๐Ÿ’ป List Example
fruits = ["Apple", "Mango", "Banana"] print(fruits[0]) fruits.append("Orange") print(fruits)

๐Ÿงฐ Common List Methods

โž• append()
โŒ remove()
๐Ÿ”ข sort()
๐Ÿงน clear()

๐Ÿ”— 9. Tuples

A tuple is an ordered collection that cannot normally be changed after creation.

numbers = (10, 20, 30, 40) print(numbers[0])
๐Ÿ’ก Remember:

Lists are generally mutable, while tuples are generally immutable.

๐Ÿ“– 10. Dictionaries

A dictionary stores data in key : value pairs.

๐Ÿ”‘ name
โ†’
๐Ÿ‘ค Roshni
๐Ÿ”‘ age
โ†’
๐Ÿ”ข 20
๐Ÿ’ป Dictionary Example
student = { "name": "Roshni", "age": 20, "course": "BCA" } print(student["name"])

๐ŸŽฏ 11. Sets

A set is an unordered collection of unique elements.

numbers = {10, 20, 30, 20} print(numbers)
โญ Key Point:

Sets automatically remove duplicate values.

๐Ÿงฐ Common Set Methods

โž• add()
โŒ remove()
๐Ÿ”— union()
๐Ÿ” intersection()

๐Ÿ“ 12. File Handling

File handling allows Python programs to read and write data stored in files.

๐Ÿ’ป Python Program
โ†’
๐Ÿ“‚ File
โ†’
๐Ÿ’พ Data
โœ๏ธ Write to a File
file = open("data.txt", "w") file.write("Hello Python") file.close()
๐Ÿ“– Read from a File
file = open("data.txt", "r") data = file.read() print(data) file.close()
๐Ÿ’ก Common Modes:

r โ†’ Read
w โ†’ Write
a โ†’ Append

๐Ÿงฉ 13. Basic OOP

Object-Oriented Programming organizes programs using classes and objects.

๐Ÿ—๏ธ Class
โ†’
๐Ÿ“ฆ Object
โ†’
โš™๏ธ Methods
๐Ÿ’ป Basic Class Example
class Student: def __init__(self, name): self.name = name def display(self): print(self.name) student1 = Student("Roshni") student1.display()

๐Ÿง  Important OOP Concepts

๐Ÿ—๏ธ Class
๐Ÿ“ฆ Object
๐Ÿ”’ Encapsulation
๐Ÿงฌ Inheritance
๐Ÿ”„ Polymorphism
๐ŸŽฏ Abstraction

๐Ÿ“ Python Quick Revision

๐ŸŽฏ BCA Python Exam Checklist

Before your exam, revise these important Python topics:

โœ… Python Basics
โœ… Variables
โœ… Data Types
โœ… Operators
โœ… Conditions
โœ… Loops
โœ… Functions
โœ… Lists
โœ… Tuples
โœ… Dictionaries
โœ… Sets
โœ… File Handling
โœ… Basic OOP