D. R.
Mane Mahavidyalaya, Kagal
B.C.A DEPARTMENT
Certificate
This is to certify that Miss Ballal Janhavi Ananda has satisfactorily carried out
the required practical work prescribed by the Shivaji University Kolhapur for BCA
Part –III course Python Programming subject this journal represents his bonafide work
during the academic year 2023-24
PRN No.
Exam Seat No.
Date:
Place: Kagal
External Examiner External Examiner
Prof. Arun Kumbhar
Teacher In charge
Mr. Sandhya Sawant Prin. Dr. P. N. Chougale
H. O. D. Principal
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
SR. PAGE SIGN
PROGRAM NUMBER
NO. NO.
1 Program to display name and address.
Program to Accept two number and display addition, subtraction,
2
multiplication, division and modules.
3 Program to calculate factorial of given number
Program to create a list of 100 numbers and separate those numbers in two
4
different list one includes odd number other even.
5 Program to display maximum number and minimum number from given list
6 Program to demonstrate slicing.
7 Program to demonstrate set operators(union ,intersection, minus)
8 Program to print current date and time.
9 Program to Today’s Year, Month, and Date
10 Program to convert Date to String
11 Program to display the Calendar of a given month.
12 Program to display calendar of the given year.
13 Program to demonstrate File input.
14 Program to demonstrate file output.
15 Program two add two numbers using GUI.
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
1.Program to display name and address.
Code:
name = input("Enter name : ")
address = input("Enter address : ")
number = input ("Enter number :")
print("Hi, my name is " + name + ", and I proper address " + address + ", content
number " + number)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
2.Program to Accept two number and display addition, subtraction, multiplication,
division and modules.
Code:
num1 = 20;
num2 = 30;
sum = num1+num2;
print("add this two value : ",sum);
sub = num1- num2
print("sub this value : ", sub);
mul = num1 * num2 ;
print("mul this two value : ",mul);
div = num1 / num2;
print("div this two value : ", div);
mod = num1 % num2;
print("mud this two value : ",mod)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
3.Program to calculate factorial of given number
Code:
n = int (input ("Enter a number:"))
fact = 1
if n >= 1:
fori in range (1, n+1):
fact = fact *i;
print ("Factorial of the given number is: ", fact)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
4.Program to create a list of 100 numbers and separate those numbers in two
different list one includes odd number other even.
Code:
list1 = [10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100]
listOdd = []
listEven = []
fornum in list1:
ifnum % 2 == 0:
listEven.append(num)
else:
listOdd.append(num)
print("list1: ", list1)
print("listEven: ", listEven)
print("listOdd: ", listOdd)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
5. Program to display maximum number and minimum number from given list
Code:
num = [12, 65, 54, 39, 102, 37, 72, 33, 5, -28, 0, 15]
print(min(num))
print(max (num))
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
6.Program to demonstrate slicing.
Code:
my_str = "Python_the_simple_language"
# Creating slice objects
slice1 = slice(0, 10, 3) # returns slice object
slice2 = slice(-1, 0, -3) # returns slice object
# We can use these slice objects to slice the string
result1 = my_str[slice1]
result2 = my_str[slice2] # returns elements in reverse order
# Displaying result
print("Result 1:", result1)
print("Result 2:", result2)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
7. Program to demonstrate set operators(union ,intersection, minus)
Code:
# define three sets
E = {0, 2, 4, 6, 8};
N = {1, 2, 3, 4, 5};
# set union
print("Union of E and N is",E | N)
# set intersection
print("Intersection of E and N is",E& N)
# set difference
print("Difference of E and N is",E - N)
# set symmetric difference
print("Symmetric difference of E and N is",E ^ N)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
8. Program to print current date and time.
Code:
#from datetime import datetime
fromdatetime import datetime
today = datetime.today()
print("Today's date:", today)
dt_string = today.strftime("%d/%m/%Y %H:%M:%S")
print("date and time",dt_string)
#from datetime import datetime
# datetime object containing current date and time
#now = datetime.now()
#print("now =", now)
# dd/mm/YY H:M:S
#dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
#print("date and time",dt_string)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
9. Program to Today’s Year, Month, and Date
Code:
fromdatetime import date
current_date = date.today()
print("Current date: ", current_date)
print("Current year:", current_date.year)
print("Current month:", current_date.month)
print("Current day:", current_date.day)
fromdatetime import date
current_date = date.today()
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
10. Program to convert Date to String
Code:
fromdatetime import datetime
now = datetime.now()
year = now.strftime("%Y")
print("year:", year)
month = now.strftime("%m")
print("month:", month)
#Full_month_name = now.strftime(("%B")
#print("Full_month_name :",Full_month_name)
day = now.strftime("%d")
print("day:", day)
time = now.strftime("%H:%M:%S")
print("time:", time)
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
print("date and time:",date_time)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
11. Program to display the Calendar of a given month.
Code:
import calendar
y = int(input("Input the year : "))
m = int(input("Input the month : "))
print(calendar.month(y, m))
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
12. Program to display calendar of the given year.
Code:
import calendar
y = int(input("Input the year : "))
m = int(input("Input the month : "))
print(calendar.month(y, m))
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
13. Program to demonstrate File input.
Code:
# open a file
file1 = open("lab.txt", "r")
# read the file
read_content = file1.read()
print(read_content)
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
14. Program to demonstrate file output.
Code:
# writing to file
# Opening a file
file1 = open('myfile.txt', 'w')
L = ["Pyhon is the Simple language \n", "This is object oriented language
\n", "This is easy learn \n"]
s = "PYHON:\n"
# Writing a string to file
file1.write(s)
# Writing multiple strings
# at a time
file1.writelines(L)
# Closing files
file1.close()
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
# Checking if the data is
# written to file or not
file1 = open('myfile.txt', 'r')
print(file1.read())
file1.close()
Output:
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
15.Program two add two numbers using GUI.
Code:
# Python GUI program to
# add two numbers
# Using Labels, Entry and Button
# widgets - Python 3 tkinter module
from tkinter import *
def add_numbers():
res = int(e1.get()) + int(e2.get())
label_text.set(res)
window = Tk()
label_text = StringVar();
Label(window, text="Enter First Number:").grid(row=0, sticky=W)
Label(window, text="Enter Second Number:").grid(row=1, sticky=W)
Label(window, text="Result of Addition:").grid(row=3, sticky=W)
result = Label(window, text="", textvariable=label_text).grid(row=3, column=1,
sticky=W)
e1 = Entry(window)
THE KAGAL EDUCATION SOCIETY’S
D. R. MANE MAHAVIDYALAYA, KAGAL
BACHELOR OF COMPUTER APPLICATION
PYTHON PROGRAMMING
e2 = Entry(window)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
b = Button(window, text="Calculate", command=add_numbers)
b.grid(row=0, column=2, columnspan=2, rowspan=2, sticky=W + E + N + S,
padx=5, pady=5)
mainloop()
Output: