Python Programs for BCA Course Tasks
Python Programs for BCA Course Tasks
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
DESCRIPTION: A data type in programming refers to the kind of data that a variable can
hold.
SOURCE CODE:
a=10
x="tiya"
y=2.4
z=3+2j
print("value of l1=",l1)
print("ID of l1=",id(l1))
t1=("ginni","rashi")
print("value of t1=",t1)
r1=(1,2,3,4)
print("value of r1=",r1)
print("ID of r1=",id(r1))
m1={"name":"John","age":23}
print("value of m1=",m1)
print("ID of m1=",id(m1))
b1=True
print("value of b1=",b1)
print("ID of b1=",id(b1))
OUT PUT
value of variable a= 10
ID of variable a= 140703357629640
ID of variable a= 2269711611344
ID of variable y= 2269708792208
ID of variable z= 2269711554736
ID of l1= 2269709705856
ID of r1= 2269709497056
ID of m1= 2269711690240
ID of b1= 140703356744112
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
operator only.
OBJECTIVE-To write a Python program that swaps the values of two variables without
using a
third variable or built-in swap methods, but instead using arithmetic operators.
variables using addition and subtraction (or alternatively, multiplication and division).
SOURCE CODE
print("Before swapping:")
print("a =", a)
print(“b=”,b)
a=a+b
b=a-b
a=a-b
print("After swapping:")
print("a =", a)
print("b =", b)
OUTPUT
Before swapping:
a = 10 , b = 5
After swapping:
a=5,b=1
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 3 Write a Python program to find the greatest of three numbers
and
OBJECTIVE-To find the greatest of three numbers and display the numbers in ascending
order.
greatest number, and then arranges all three numbers in ascending order using simple
[Link] or sorting
SOURCE CODE-
greatest = a
greatest = b
else:
greatest = c
numbers = [a, b, c]
[Link]()
OUTPUT
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 4 Write a python program to print whether a given year is leap
year
or not.
DESCRIPTION-This program takes a year as input and determines if it’s a leap year.
It is divisible by 4,
SOURCE CODE:
year=int(input("Enter a year:"))
else:
OUTPUT:
Enter a year:2024
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 5: Write a program to check whether the number is even or odd.
SOURCE CODE:
num=int(input("Enter a number:"))
if num%2==0:
else:
OUTPUT:
Enter a number:5
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
EXPLAINATION: This program takes an integer as input and finds its factorial.
The factorial of a number n (written as n!) is the product of all positive integer from 1 to
n.
SOURCE CODE:
prod = 1
prod = prod * i
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
OBJECTIVE: To print the Fibonacci series up to a given number ‘n’ using Python.
EXPLAINATION: The Fibonacci series is a sequence where each number is the sum of
the two
preceding ones, starting from 0 and 1. This program takes an integer input ‘n’ and prints
all
SOURCE CODE:
a,b =0,1
while a<=n:
print(a,end=" ")
a,b =b,a+b
OUTPUT:
0 1 1 2 3 5 8 13
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
EXPLAINATION: A prime number is a number greater than 1 that has no divisors other
than 1
and itself.
SOURCE CODE:
num=int(input("Enter a number:"))
if num>1:
for i in range(2,int(num**0.5)+1):
if num%i==0:
else:
print(num,"is prime")
OUTPUT:
Enter a number:7
7 is prime
NAME KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
EXPLAINATION: This program takes an integer as input and reverse its digits by
repeatedly
extracting the last digit using the modulus operator (%) and building the reverse number
step by
SOURCE CODE:
num=int(input("Enter a number:"))
rev=0
while num>0:
rev=(rev*10)+(num%10)
num=num//10
OUTPUT:
Enter a number:1234
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
palindrome or not.
EXPLAINATION: A palindrome number is one of that remains the same when its digits
are
reversed. This program reversed a given number using a while loop and compares it with
the
original number.
SOURCE CODE:
num=int(input("Enter a number:"))
original=num
reverse=0
while num>0:
digit=num%10
reverse=reverse*10+digit
num=num//10
if original==reverse:
print("Palindrome number.")
else:
print("Not a palindrome.")
OUTPUT:
Enter a number:141
Palindrome number.
NAME KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
EXPLAINATION: An Armstrong number is a number that is equal to the sum of the cubes
of its
SOURCE CODE:
num=int(input("Enter a number:"))
temp=num
sum=0
while num>0:
digit=num%10
sum+=digit**3
num//=10
if temp==sum:
else:
OUTPUT:
Enter a number:143
.
NAME: KRISHNA SINGH
ROLL NO: 22
SECTION: B2
DATE:17/11/2025
PROBLEM STATEMENT 12: Write a Python program to print the digit sum of a number.
EXPLAINATION: This program takes an integer as input and repeatedly extends each
digit
using the modulus (%) operators, adds them together, and removes the last digit using
integer
division (//).
SOURCE CODE:
num=int(input("Enter a number:"))
original_num=num
sum_digit=0
digit = num % 10
sum_digit += digit
num = num // 10
OUTPUT:
Enter a number:12345
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 13: Write a function to find whether a given number is prime or
not.
OBJECTIVE: To define a function that checks whether a given number is prime or not.
EXPLAINATION: A prime number is a number greater than 1 that has no divisors other
than 1
and itself. This program defines a function is prime(num) that returns whether a number
is prime
SOURCE CODE:
num=int(input("Enter a number:"))
if num>1:
for i in range(2,int(num**0.5)+1):
if num%i==0:
else:
print(num,"is prime")
OUTPUT:
Enter a number:8
8 is not prime
NAME KRISHNA SINGH
ROLL NO: 22
SECTION: B2
DATE:17/11/2025
PROBLEM STATEMENT 14: Write a recursive function to find the factorial of a number.
up to n. In recursion, a function calls itself until a base condition is met -here, when n
becomes 1.
SOURCE CODE:
def fact(n):
if n == 0:
return 1
else:
return n * fact(n - 1)
num=int(input("Enter a number:"))
OUTPUT:
Enter a number:5
ROLL NO: 22
SECTION: B2
DATE:17/11/2025
PROBLEM STATEMENT 15: Write a function that returns the sum of digits of a number
using
recursion.
EXPLANIATION-This program defines a recursive function that breaks down the number
into
its digits. At each recursive call, it adds the last digit (n % 10) to the sum of the
remaining digits
SOURCE CODE-
def sum_digits(n):
if n==0:
return 0
num=int(input("Enter a number:"))
OUTPUT:
Enter a number:1234
Sum of digits: 10
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 16- Write a Python program to find all prime numbers in a given
OBJECTIVE-To find and display all prime numbers within a given range using a function
greater than 1 that has no divisors other than 1 and itself. The function returns a list of
all such
prime numbers.
SOURCE CODE-
primes = []
if num > 1:
if num % i == 0:
break
else:
[Link](num)
return primes
OUTPUT
Prime numbers between 10 and 50 are: [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 17: Write a function to find the LCM and GCD of two numbers
OBJECTIVE: To find the LCM (Least Common Multiple) and GCD (Greatest Common
Divisor)
EXPLAINATION: This program defines two functions: - find_gcd (a ,b) finds the greatest
number that divides both a and b. - find_lcm (a, b) uses the relation LCM*GCD=a*b to
compute the least common multiple.
SOURCE CODE:
gcd = 1
i=1
gcd = i
i+=1
return gcd
def find_lcm(a, b):
gcd = find_gcd(a,b)
lcm = (a * b) // gcd
return lcm
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
EXPLAINATION: This program uses a lambda function to define a one-line formula for
finding
SOURCE CODE:
area=lambda r:3.14159*r*r
OUTPUT:
ROLL NO: 22
SECTION: B2
DATE:17/11/2025
PROBLEM STATEMENT 19: Write a python program to count vowels and consonants in a
given string.
EXPLAINATION: This program takes a string input from the user and checks each
character. If
SOURCE CODE:
vowels = 0
consonants = 0
for ch in string:
if [Link]():
if ch in 'aeiou':
vowels+= 1
else:
consonants+=1
print("Number of vowels:",vowels)
print("Number of consonants:",consonants)
OUTPUT:
Number of vowels: 3
Number of consonants: 7
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
EXPLAINATION: A palindrome string is one that reads the same backward and forward.
This
program compares the original string with its reverse to determine if it’s a palindrome.
SOURCE CODE:
text =[Link]()
if text==text[::-1]:
else:
OUTPUT:
Enter a string:hello
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 21: Write a python function to count the frequency of each
character
in a string.
OBJECTIVE: To count the frequency of each character in a given string using a function.
EXPLAINATION: This program defines a function that takes a string as input and uses a
loop to
count how many times each character appears. The results are stored in a dictionary,
where each
SOURCE CODE:
def char_frequency(text):
freq = {}
for ch in text:
if ch in freq:
freq[ch]+=1
else:
freq[ch]=1
return freq
print("Character frequencies:")
print(key,":",value)
OUTPUT:
Enter a string:hello
Character frequencies:
h:1
e:1
l:2
o:1
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 22: Write a program to remove all punctuation marks and spaces
from
OBJECTIVE: To remove punctuation marks and spaces from a string and check whether
it is a
palindrome.
EXPLIANATION: This program removes all punctuation and spaces using a loop and
string
filtering.
SOURCE CODE:
import string
cleaned =""
for ch in [Link]():
cleaned+=ch
if cleaned == cleaned[::-1]:
else:
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 23: Write a program to find longest and shortest word in a
sentence.
EXPLAINATION: This program takes a sentence as input, splits it into individual words,
and
then uses the min () and max () function to find the words with the smallest and largest
lengths.
SOURCE CODE:
words =[Link]()
longest =max(words,key=len)
shortest =min(words,key=len)
print("Longest word:",longest)
print("Shortest word:",shortest)
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
The output should be displayed in a dictionary format where each unique word will be
the key
OBJECTIVE: To count the frequency of each word in a sentence and display the result in
a
dictionary format.
EXPLAINATION: This program takes a sentence as input, splits it into words, and counts
how
Each unique word is used as a key, and its frequency is stored as the value in a
dictionary.
SOURCE CODE:
words = [Link]().split()
freq = {}
if word in freq:
freq[word] += 1
else:
freq[word] = 1
print(freq)
OUTPUT:
DATE:17/11/2025
ROLL NO: 80
SECTION: B2
PROBLEM STATEMENT 25: Write a Python program to create a list of numbers and print
their
OBJECTIVE: To create a list of numbers and calculate their sum and average.
EXPLAINATION: This program takes multiple numbers as input from the user, stores
them in a
list, and then uses the built-in sum() and len() functions to compute the total sum and
average of
the numbers.
SOURCE CODE:
total = sum(numbers)
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 26: Write a program to find the largest and the smallest element
in a
list.
EXPLAINATION: This program goes through each element in the list using a loop and
SOURCE CODE:
largest = numbers[0]
smallest = numbers[0]
largest = num
smallest = num
print("List:", numbers)
OUTPUT:
Largest element: 99
Smallest element: 2
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 27: Write a Python function to remove duplicates from a list
without
using set().
EXPLAINATION: This function iterates through the input list, adding each element to a
new list
SOURCE CODE:
def remove_duplicates(lst):
result = []
[Link](item)
return result
numbers = [1, 2, 2, 3, 4, 4, 5]
print(remove_duplicates(numbers))
OUTPUT:
[1, 2, 3, 4, 5]
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 28: Write a program to sort a list of tuples based on the second
OBJECTIVE: Sort a list of tuples based on the second element of each tuple.
EXPLAINATION: The program uses the 'sorted' function with a lambda key to sort tuples
by
SOURCE CODE:
def sort_by_second_element(tuple_list):
sorted_data = sort_by_second_element(data)
print(sorted_data)
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 29: Write a function that accepts a list of integers and returns a
new
EXPLAINATION: The function checks each number in the input list and returns a new list
SOURCE CODE:
def is_prime(n):
if n < 2:
return False
if n % i == 0:
return False
return True
def filter_primes(lst):
prime_numbers = filter_primes(numbers)
print(prime_numbers)
OUTPUT:
[2, 3, 5, 7]
NAME KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 30: Write a program to create and display a tuple containing
numbers
and string.
OBJECTIVE: Create a tuple containing numbers and strings, and display it.
EXPLAINATION: The program demonstrates how to define a tuple with mixed data types
and
SOURCE CODE:
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 31: Write a Python program to convert a list of tuples into
dictionary.
EXPLAINATION: Each tuple in the list contains a key-value pair, which is added to the
dictionary.
SOURCE CODE:
dict_result = {}
dict_result[key] = value
OUTPUT:
}
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 32: Write a program to count the frequency of each character in
a
EXPLAINATION: The program iterates through the string and updates a dictionary with
the
SOURCE CODE:
char_frequency = {}
if char in char_frequency:
char_frequency[char] += 1
else:
char_frequency[char] = 1
OUTPUT:
Character frequency: {'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1, 'w': 1, 'r': 1, 'd': 1}
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 33: Write a Python program to find the most frequent element in
a
tuple.
EXPLAINATION: The program iterates through the tuple and uses a dictionary to count
the
occurrences of each element. It then identifies the element with the highest frequency
and
displays it.
SOURCE CODE:
my_tuple = (1, 2, 3, 2, 4, 2, 5, 3, 1)
freq_dict = {}
if item in freq_dict:
freq_dict[item] += 1
else:
freq_dict[item] = 1
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 34: write a program to merge two dictionaries and sum values of
common keys.
OBJECTIVE: Merge two dictionaries, summing the values of keys that appear in both.
EXPLAINATION: The program iterates through both dictionaries. If a key exists in both, it
adds
SOURCE CODE:
merged_dict = [Link]()
if key in merged_dict:
merged_dict[key] += value
else:
merged_dict[key] += value
OUTPUT:
Merged dictionary: {'a': 100, 'b': 350, 'c': 400, 'd': 250}
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 35: Write a function to invert a dictionary, swap keys and values.
OBJECTIVE: Invert a dictionary so that its keys become values and its values become
keys.
EXPLAINATION: The function iterates through the original dictionary and creates a new
dictionary with keys and values swapped. Note: If the original dictionary has duplicate
values,
SOURCE CODE:
def invert_dictionary(d):
inverted = {}
inverted[value] = key
return inverted
inverted_dict = invert_dictionary(original_dict)
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 36: Write a Python program to demonstrate set creation and
basic set
OBJECTIVE: Demonstrate how to create sets and perform basic set operations: union,
EXPLAINATION: The program creates two sets and shows how to combine them (union),
find
common elements (intersection), and find elements present in one set but not the other
(difference).
SOURCE CODE:
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
print("Union:", union_set)
print("Intersection:", intersection_set)
OUTPUT:
Set 1: {1, 2, 3, 4, 5}
Set 2: {4, 5, 6, 7, 8}
Union: {1, 2, 3, 4, 5, 6, 7, 8}
Intersection: {4, 5}
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 37: Write a Python program to read the content of a text file and
OBJECTIVE: Read the contents of a text file and display them on the screen.
EXPLAINATION: The program opens a text file in read mode, reads its content, and
prints it. It
SOURCE CODE:
file_path = '[Link]'
try:
content = [Link]()
print("File content:\n")
print(content)
except FileNotFoundError:
OUTPUT:
File content:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 38: Write a Python program to count the total number of lines in
a
file.
EXPLAINATION: The program opens a file in read mode and iterates through each line,
SOURCE CODE:
file_path = '[Link]'
try:
line_count = 0
line_count += 1
except FileNotFoundError:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 39: Write a Python program to copy the content of one file to
another
file.
DESCRIPTION: The program opens the source file in read mode and the destination file
in write
mode. It reads the content from the source and writes it to the destination file.
SOURCE CODE:
source_file = '[Link]'
destination_file = '[Link]'
try:
content = [Link]()
[Link](content)
except FileNotFoundError:
OUTPUT
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
DESCRIPTION: The BankAccount class initializes with an account holder name and a
balance
(default 0). It provides methods to deposit money, withdraw money (with a check for
sufficient
SOURCE CODE:
class BankAccount:
[Link] = owner
[Link] = balance
if amount > 0:
[Link] += amount
else:
if amount > 0:
else:
print("Insufficient balance.")
else:
def display_balance(self):
account.display_balance()
[Link](500)
[Link](200)
account.display_balance()
Output:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 41-Write a class student that stores name, roll number, and
marks of
OBJECTIVE: Create a class to store student details, compute total marks, and
determine the
DESCRIPTION: The Student class stores a student’s name, roll number, and marks of
three
subjects. It has methods to calculate total marks and assign a grade based on the total
percentage.
SOURCE CODE:
class Student:
[Link] = name
self.roll_no = roll_no
[Link] = marks
def total_marks(self):
return sum([Link])
def grade(self):
total = self.total_marks()
percentage = total / 3
return 'A'
return 'C'
return 'D'
else:
return 'F'
def display(self):
print(f"Name: {[Link]}")
print(f"Marks: {[Link]}")
print(f"Total: {self.total_marks()}")
print(f"Grade: {[Link]()}")
[Link]()
OUTPUT:
Total: 255
Grade: B
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 42-Write a class Rectangle that computes Area and Perimeter.
OBJECTIVE: Create a class to represent a rectangle and calculate its area and
perimeter.
DESCRIPTION: The Rectangle class stores the length and width of a rectangle. It
provides
SOURCE CODE:
class Rectangle:
[Link] = length
[Link] = width
def area(self):
def perimeter(self):
def display(self):
print(f"Area: {[Link]()}")
print(f"Perimeter: {[Link]()}")
rect = Rectangle(5, 3)
[Link]()
OUTPUT:
Length: 5, Width: 3
Area: 15
Perimeter: 16
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 43-Write a simple tkinter program to create a window with the
label
OBJECTIVE: Create a basic GUI window in Python using Tkinter with a welcoming label.
DESCRIPTION: The program uses the Tkinter library to create a window, adds a Label
widget
with a message, and runs the main event loop to display the window.
SOURCE CODE:
window = Tk()
[Link]("Simple GUI")
[Link]("400x200")
[Link](pady=50)
[Link]()
OUTPUT-
A GUI window appears with the title “Simple GUI” and a centered label displaying:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
their sum.
OBJECTIVE: Create a GUI application to input two numbers and display their sum.
DESCRIPTION: The program uses Tkinter to create input fields for two numbers, a
button to
SOURCE CODE:
def calculate_sum():
try:
num1 = float([Link]())
num2 = float([Link]())
label_result.config(text=f"Sum: {result}")
except ValueError:
window = Tk()
[Link]("Sum Calculator")
[Link]("300x200")
entry1 = Entry(window)
[Link](pady=5)
Label(window, text="Enter second number:").pack(pady=5)
entry2 = Entry(window)
[Link](pady=5)
label_result.pack(pady=5)
[Link]()
OUTPUT:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
window.
OBJECTIVE: Create a GUI application that allows the user to change the window’s
background
color.
DESCRIPTION: The program uses Tkinter to create buttons that, when clicked, change
the
SOURCE CODE:
def change_bg(color):
[Link](bg=color)
window = Tk()
[Link]("400x200")
12)).pack(pady=10)
change_bg("green")).pack(pady=5)
change_bg("yellow")).pack(pady=5)
[Link]()
OUTPUT:
• Clicking a button changes the window’s background color to the selected color.
NAME KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
PROBLEM STATEMENT 46-Write a tkinter GUI application to take a name, input, and
display
OBJECTIVE: Create a GUI application that accepts a user’s name and displays a
personalized
greeting message.
DESCRIPTION: The program uses Tkinter to create an input field for the name, a button
to
SOURCE CODE:
def greet():
name = entry_name.get()
if [Link]():
else:
window = Tk()
[Link]("Greeting App")
[Link]("400x200")
entry_name.pack(pady=5)
label_greeting.pack(pady=10)
[Link]()
OUTPUT:
• A GUI window appears with a label “Enter your name:”, an entry box, and a “Greet Me”
button.
• When the user enters their name (e.g., Alice) and clicks the button, the label updates:
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
OBJECTIVE: Create a GUI application to input marks for three subjects and display the
total
DESCRIPTION: The program uses Tkinter to create input fields for three subjects, a
button to
calculate the total and grade, and labels to display the results. The grade is assigned
based on
percentage:
• ≥ 90: A
• ≥ 75: B
• ≥ 60: C
• ≥ 50: D
• < 50: F
SOURCE CODE:
def calculate():
try:
marks1 = float([Link]())
marks2 = float([Link]())
marks3 = float([Link]())
grade = 'A'
grade = 'B'
grade = 'C'
grade = 'D'
else:
grade = 'F'
except ValueError:
window = Tk()
[Link]("400x350")
[Link](pady=5)
[Link](pady=5)
[Link](pady=5)
label_result.pack(pady=10)
[Link]()
OUTPUT
• Total: 255
• Grade: B
NAME: KRISHNA SINGH
DATE:17/11/2025
ROLL NO: 22
SECTION: B2
OBJECTIVE: Create a GUI application that displays an image and allows the user to
zoom in
DESCRIPTION: The program uses Tkinter along with PIL (Python Imaging Library) to load
and
display an image. Buttons are provided to increase or decrease the size of the image
dynamically
SOURCE CODE:
def zoom_in():
zoom *= 1.2
tk_img = [Link](new_img)
[Link](image=tk_img)
def zoom_out():
zoom /= 1.2
tk_img = [Link](new_img)
[Link](image=tk_img)
root = Tk()
zoom = 1.0
tk_img = [Link](img)
[Link]()
[Link]()
OUTPUT-
+---------------------------------------+
| |
+---------------------------------------+
| [ Zoom In ]
[ Zoom Out ]
+---------------------------------------+