NAME : ASMITA PANWAR PAGE NO.
:
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
PROBLEM STATEMENT 1 : Write python program to demonstrate basic data
types of python and the concept of object identity.
OBJECTIVE : To understand the implementation of various types of data types
available in python.
EXPLANATION : It determines the storage allocations for that object and the
interpretation of the values during subsequent access.
SOURCE CODE :
#integer
a=10
print("Value of a is = ", a)
print("Class of variable a is", type(a))
print("ID of variable a is = ", id(a))
#float
b=10.2
print("Value of b is = ", b)
print("Class of variable b is", type(b))
print("ID of variable b is", id(b))
#string
c="Python"
print("Value of c is =", c)
print("Class of variable c is", type(c))
print("ID of variable c is = ", id(c))
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
#boolean
d=True
print("Value of d is = ", d)
print("Class of variable d is =", type(d))
print(" ID of variable d is = ", id(d))
#complex
e=2+3j
print("Value of e is = ", e)
print("Class of variable e is = ", type(e))
print(" ID of variable e is = ", id(e))
#list
L1=["red", "yellow","green","blue"]
print("Value of L1 is = ", L1)
print("Class of variable L1 is = ", type(L1))
print("ID of variable LI is = ", id(L1))
#tuple
T1=("maths", "science", "english", "hindi")
print("Value of T1 is =", T1)
print("Class of variable T1 is = ", type(T1))
print("ID of variable T1 is = ", id(T1))
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
#set
S1={1,2,3,4}
print("Value of S1 is = ", S1)
print("Class of variable S1 is = ", type(S1))
print("ID of variable S1 is = ", id(S1))
#dictionary
D1={"Name":"ram", "Age":18}
print("Value of D1 is = ", D1)
print("Class of variable D1 is = ", type(D1))
print("ID of variable D1 is = ", id(D1))
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
OUTPUT :
Value of a is = 10
Class of variable a is <class 'int'>
ID of variable a is = 140709940497112
Value of b is = 10.2
Class of variable b is <class 'float'>
ID of variable b is 3114757648944
Value of c is = Python
Class of variable c is <class 'str'>
ID of variable c is = 140709939384592
Value of d is = True
Class of variable d is = <class 'bool'>
ID of variable d is = 140709939696208
Value of e is = (2+3j)
Class of variable e is = <class 'complex'>
ID of variable e is = 3114757649008
Value of L1 is = ['red', 'yellow', 'green', 'blue']
Class of variable L1 is = <class 'list'>
ID of variable LI is = 3114762967488
Value of T1 is = ('maths', 'science', 'english', 'hindi')
Class of variable T1 is = <class 'tuple'>
ID of variable T1 is = 3114762987744
Value of S1 is = {1, 2, 3, 4}
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
Class of variable S1 is = <class 'set'>
ID of variable S1 is = 3114757940928
Value of D1 is = {'Name': 'ram', 'Age': 18}
Class of variable D1 is = <class 'dict'>
ID of variable D1 is = 3114762969984
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
PROBLEM STATEMENT 2 : Write a python program to write a python
keywords.
OBJECTIVE : To demonstrate the implementation of various keyword of python.
EXPLANATION : Determining an object’s exact class and dynamically creating
new classes at runtime.
SOURCE CODE :
import keyword
print(keyword.kwlist)
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
OUTPUT :
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue',
'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
PROBLEM STATEMENT 3 : Write a python program to implement set operation.
OBJECTIVE : To implement various set operations in python, such as union,
intersection, differnce and symmetric differnce.
EXPLANATION : Sets are fundamental data structures in python that stores
unique elements.
SOURCE CODE :
a={0,2,4,6,8}
b={1,2,3,4,5}
print("Union : ", a|b)
print("Intersection : ", a&b)
print("Difference : " ,a-b)
print("Symmetric Differnce : ", a^b)
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
OUTPUT :
Union : {0, 1, 2, 3, 4, 5, 6, 8}
Intersection : {2, 4}
Difference : {0, 8, 6}
Symmetric Differnce : {0, 1, 3, 5, 6, 8}
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
PROBLEM STATEMENT 4: Write a python program to implement arithmetic
operation ?
OBJECTIVE : To understand the implement of arithmetic operation.
EXPLANATION: It is used to perform mathematical calculation. It performs on
two operands.
SOURCE CODE :
#creating a arithmetic operation
num1=int(input("Enter the number:"))
num2=int(input("Enter the number:"))
addition=num1+num2 print(addition)
subtraction=num1-num2 print(subtraction)
multiplication=num1*num2 print(multiplication)
division=num1/num2 print(division)
floor_division=num1//num2 print(floor_division)
modulus=num1%num2 print(modulus)
exponentiation=num1**num2 print(exponentiation)
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
OUTPUT :
Enter the number:21
Enter the number:7
28
14
147
3.0
3
0
1801088541
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
PROBLEM STATEMENT 5 : Write a python program to take input from user and
demonstrate type casting ?
OBJECTIVE : To understand the implement of type casting.
EXPLANATION : To convert a specified value or an object into an integer value
or an integer object.
SOURCE CODE :
#Program to take input and demonstrate type casting
#Taking input
value = input("Enter a number: ")
print("\nOriginal input:", value, "Type:", type(value))
#Casting to integer
int_val = int(value)
print("As Integer:", int_val, "Type:",
type(int_val))
#Casting to float
float_val = float(value)
print("As Float:", float_val, "Type:",
str_val = str(int_val)
#Casting back to string
str_val = str(int_val)
print("As String:", str_val, "Type:",
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
type(str_val))
#Casting to boolean
bool_val = bool(int_val)
print("As Boolean:", bool_val, "Type:",
type(bool_val))
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
OUTPUT :
Enter a number: 65
Original input: 65 Type: <class 'str'>
As Integer: 65 Type: <class 'int'>
As Float: 65.0 Type: <class 'float'>
As String: 65 Type: <class 'str'>
As Boolean: True Type: <class 'bool'>
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
PROBLEM STATEMENT 6 : Write a python program to check the type of entered
character from the user ?
OBJECTIVE : To understand the implement of various type of characters.
EXPLANATION : To determine the type of an entered character in python, we use
built-in functions that check what kind of character it is.
SOURCE CODE :
ch=input("enter a character:")
if ch.isalpha():
print("It's a letter:")
elif ch.isdigit():
print("It's a digit:")
elif ch.isspace():
print("It's a whitespace character:")
else:
print("It's a special character:")
NAME : ASMITA PANWAR PAGE NO. :
ROLL NO. : 19 DATE :
COURSE : BCA AI & DS
OUTPUT :
enter a character:Python
It's a letter:
enter a character:21
It's a digit:
enter a character:"Hello World"
It's a special character:
enter a character:
It's a whitespace character: