You are on page 1of 7

Department of Computer Science &

Engineering
LAB FILE

SUBJECT: PROGRAMMING IN PYTHON LAB


(21CSP-259)

B.E. II Year – IV Semester


(CSE/IT)

Submitted By: Submitted To:


Sahil Arora Parvesh Kumar
21BCS-7498 Assistant Professor
21BCS-702 A
UNIT – 1

Experiment – 1.2

Name: Sahil Arora UID: 21BCS7498


Branch: CSE Section: 21 BCS 702-A
Semester: 4 Date of Performance: 15-02-2023
Subject: Programming in Python Subject Code: 21CSP-259

Aim: Writing python programs in various modes and printing and assigning values
assigned to the variables.

Program 1.2.1:

Python program to check whether a given number is a palindrome.

Program Code:

num=eval(input("Enter a number "));\


... rev=0;
dnum=num;
while(num>0):
... var=num%10;
... rev=rev*10+var;
... num=int(num/10);
...
>>> if(rev==dnum):
... print("Palindrom number");
... else:
... print("Not a palindrome number");
Output:

Program 1.2.2:

Python program to check whether entered number is Armstrong or Not?

Program Code:

num=eval(input("Enter a number to check for Armstrong "));\


... sum=0;\
... dnum=num;
count=0;\
...
>>> while(dnum>0):
... dnum=int(dnum/10);
... count+=1;
...
>>> dnum=num;
>>> while(num>0):
... var=num%10;
... sum=sum+var**count;
... num=int(num/10);
...
>>> if(sum==dnum):
... print(dnum, " is an Armstrong number");
... else:
... print(dnum, " is not an Armstrong number");
Output:

Program 1.2.3:

Python program to take three numbers from the user and print the greatest number.

Program Code:

n1=eval(input("Enter a number "));\


... n2=eval(input("Enter a number "));\
... n3=eval(input("Enter a number "));
if n1>n2 :
... if n1>n3 :
... print(n1 ," is the greatest number");
... else:
... print(n3 ," is the greatest number");
... else:
... if n2>n3:
... print(n2 ," is the greatest number");
... else:
... print(n3 ," is the greatest number");
Output:
Table of Contents

Sr. No. Name of the Experiments

UNIT-I

Writing python programs in various modes and printing and assigning


I. values assigned to the variables.

II. Program to demonstrate the use of if, if-else, while, for, break and continue.

Program to demonstrate the use of functions and passing different types of


III.
arguments to functions.
UNIT-II

IV. Program to demonstrate the various kind of operations that can be applied
to the string.

Program to demonstrate creation and accessing of lists and apply different


V.
kinds of operations on them.
Program to demonstrate creation and accessing of dictionary and apply
VI. different kinds of operations on them.

Program to demonstrate creation and accessing of tuples and apply


VII.
different kinds of operations on them.
UNIT-III

VIII. Program to implement various kinds of searching and sorting algorithms

Program to implement concepts of Object Oriented Programming such as


IX. classes, inheritance and polymorphism.

X Program to demonstrate read and write data to the file in various modes.
INDEX

Exp. Conduct Viva Record Total


Experiments Signature
No (12) (10) (8) (30)
Writing python programs in
various modes and printing and
1.
assigning values assigned to the
variables.
Program to demonstrate the use of
2. if, if-else, while, for, break and
continue.

Program to demonstrate the use of


3. functions and passing different
types of arguments to functions.

Program to demonstrate the


4. various kind of operations that can
be applied to the string.

Program to demonstrate creation


and accessing of lists and apply
5.
different kinds of operations on
them.
Program to demonstrate creation
and accessing of dictionary and
6.
apply different kinds of operations
on them.
Program to demonstrate creation
and accessing of tuples and apply
7.
different kinds of operations on
them.
Program to implement various
8. kinds of searching and sorting
algorithms

Program to implement concepts of


Object Oriented Programming
9.
such as classes, inheritance and
polymorphism.
Program to demonstrate read and
write data to the file in various
10. modes.

You might also like