0% found this document useful (0 votes)
2 views

final-pps-program_FE-2023-24_MTJ (1)

The document outlines a series of practical programming exercises for a Programming and Problem Solving Laboratory course, covering topics such as salary calculation, momentum computation, statistical analysis of numbers, student grading, Armstrong number verification, basic calculator functions, GCD computation, number reversal, binary to decimal conversion, Fibonacci series generation, and string manipulation. Each practical includes a title, input requirements, program code, and example outputs. The exercises are designed to enhance programming skills and problem-solving abilities in Python.

Uploaded by

sneha bose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

final-pps-program_FE-2023-24_MTJ (1)

The document outlines a series of practical programming exercises for a Programming and Problem Solving Laboratory course, covering topics such as salary calculation, momentum computation, statistical analysis of numbers, student grading, Armstrong number verification, basic calculator functions, GCD computation, number reversal, binary to decimal conversion, Fibonacci series generation, and string manipulation. Each practical includes a title, input requirements, program code, and example outputs. The exercises are designed to enhance programming skills and problem-solving abilities in Python.

Uploaded by

sneha bose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO - 01
Title : To calculate salary of an employee given his basic pay (take as input from
user). Calculate gross salary of employee. Let HRA be 10 % of basic pay and TA be
5% of basic pay. Let employee pay professional tax as 2% of total salary. Calculate
net salary payable after deductions.

Program :

Input :
basic = int(input("ACCEPT BASIC SALARY OF EMPLYOEE : ")) //30000 as input

gross = basic+10/100 * basic+5/100*basic

net = gross-2/100 * gross

print('NET SALARY AFTER DEDUCTION:',net)

Output :

30810.0

PRACTICAL NO - 02
Title : To accept an object mass in kilograms and velocity in meters per second and
display its momentum. Momentum is calculated as e=mc2 where m is the mass of
the object and c is its velocity.

Program :

Input :
mass = float(input("ENTER MASS(in Kg) : "))

velocity = float(input("ENTER VELOCITY(in m/s) : "))

momentum = mass * velocity ** 2

print('MOMENTUM IS :',momentum)

Output :
ENTER MASS(in Kg) : 12

ENTER VELOCITY(in m/s) : 34

MOMENTUM IS : 13872.0

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO - 03
Title : To accept N numbers from user. Compute and display maximum in list,
minimum in list, sum and average of numbers.

Program :

Input :
N = int(input("Do you want how many number of Input Element : "))

data=[ ]

for i in range(N):

n = int(input("ENTER ELEMENT : "))

data.append(n)

print("Maximum :", max(data))

print("Minimum :", min(data))

print("Sum :", sum(data))

print("Average : ",sum(data)/N)

Output :

Do you want how many number of Input Element : 3

ENTER ELEMENT : 55

ENTER ELEMENT : 22

ENTER ELEMENT : 88

Maximum : 88

Minimum : 22

Sum : 165

Average : 55.0

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO - 04
Title : To accept student’s five courses marks and compute his/her result. Student
is passing if he/she scores marks equal to and above 40 in each course. If student
scores aggregate greater than 75%, then the grade is distinction. If aggregate is
60>= and <75 then the grade if first division. If aggregate is 50>= and <60, then the
grade is second division. If aggregate is 40>= and <50, then the grade is third
division.

Program :

Input :
m1 = int(input("ENTER THE FIRST SUBJECT MARKS : "))
m2 = int(input("ENTER THE SECOND SUBJECT MARKS : "))
m3 = int(input("ENTER THE THIRD SUBJECT MARKS : "))
m4 = int(input("ENTER THE FOURTH SUBJECT MARKS : "))
m5 = int(input("ENTER THE FIFTH SUBJECT MARKS : "))

per = int((m1+m2+m3+m4+m5))/5
print("PERCENTAGE IS :", int(per))

if m1>40 and m2 > 40 and m3>40 and m4>40 and m5>40:


if per >= 75:

print("DISTICTION!!!")

elif per >=60 and per <75:


print("FIRST CLASS")

elif per >=50 and per <= 60:


print("SECOND CLASS")

elif per >=40 and per<=50:


print("THIRD CLASS")

else:
print("FAILED. .... !!!!")

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

Output1 :

ENTER THE FIRST SUBJECT MARKS : 44

ENTER THE SECOND SUBJECT MARKS : 22

ENTER THE THIRD SUBJECT MARKS : 44

ENTER THE FOURTH SUBJECT MARKS : 22

ENTER THE FIFTH SUBJECT MARKS : 33

PERCENTAGE IS : 33

FAILED ..... !!!!

Output2 :

ENTER THE FIRST SUBJECT MARKS : 88

ENTER THE SECOND SUBJECT MARKS : 78

ENTER THE THIRD SUBJECT MARKS : 66

ENTER THE FOURTH SUBJECT MARKS : 58

ENTER THE FIFTH SUBJECT MARKS : 98

PERCENTAGE IS : 77

DISTICTION!!!

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 05(A)
Title : To check whether input number is Armstrong number or not. An
Armstrong number is an integer with three digits such that the sum of the cubes of
its digits is equal to the number itself. Ex. 371.

Program(Basic) :

Input :
num = int(input("ENTER THE 3 DIGIT ELEMENT :"))

num_original = num

rem1 = num%10

num = num // 10

rem2 = num%10

rem3 = num // 10

result = (rem1**3 + rem2**3 + rem3**3)

if result == num_original:

print("\nIT IS ARMSTRONG NUMBER")

else:

print('\nIT IS NOT ARMSTRONG NUMBER')

Output-1 :
ENTER THE 3 DIGIT ELEMENT :371

IT IS ARMSTRONG NUMBER

Output-2 :
ENTER THE 3 DIGIT ELEMENT :534

IT IS NOT ARMSTRONG NUMBER

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 05(B)
Title : To check whether input number is Armstrong number or not. An
Armstrong number is an integer with three digits such that the sum of the cubes of
its digits is equal to the number itself. Ex. 371.

Program(Modified) :

Input :

num = int(input("ENTER THE 3 DIGIT ELEMENT :"))

num_original = num

rem1 = num%10

num = num // 10

rem2 = num%10

rem3 = num // 10

result = (rem1**3 + rem2**3 + rem3**3)

if result == num_original:

print("\nIT IS ARMSTRONG NUMBER")

else:

print('\nIT IS NOT ARMSTRONG NUMBER')

print("\nCUBE OF FIRST DIGIT",rem1,"IS",rem1**3)

print("CUBE OF FIRST DIGIT",rem2,"IS",rem2**3)

print("CUBE OF FIRST DIGIT",rem3,"IS",rem3**3)

print("\nSUMMATION OF CUBE OF NUMBER IS :",result)

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

Output1 :
ENTER THE 3 DIGIT ELEMENT :371

IT IS ARMSTRONG NUMBER

CUBE OF FIRST DIGIT 1 IS 1

CUBE OF FIRST DIGIT 7 IS 343

CUBE OF FIRST DIGIT 3 IS 27

SUMMATION OF CUBE OF NUMBER IS : 371

Output2 :
ENTER THE 3 DIGIT ELEMENT :534

IT IS NOT ARMSTRONG NUMBER

CUBE OF FIRST DIGIT 4 IS 64

CUBE OF FIRST DIGIT 3 IS 27

CUBE OF FIRST DIGIT 5 IS 125

SUMMATION OF CUBE OF NUMBER IS : 216

SCOE, Nashik Dr. Jagtap


Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 06
Title : To simulate simple calculator that performs basic tasks such as addition,
subtraction, multiplication and division with special operations like computing xy
and x!.

Program :

Input :
x = int(input("ENTER VALUE OF X :"))
y = int(input("ENTER VALUE OF Y :"))

print("THE ADDITION IS:",x+y)

print("THE SUBSTRACTION IS:",x-y)

print("THE MULTIPLICATION IS:",x*y)

print("THE DIVISION IS:",x/y)

result=1

for n in range(y):

result = result * x

print("THE X^Y IS :", result)

result=1

for n in range(1, x + 1):

result = result * n

print("THE X! =",result)

Output :
ENTER VALUE OF X :5
ENTER VALUE OF Y :3
THE ADDITION IS: 8

THE SUBSTRACTION IS: 2


THE MULTIPLICATION IS: 15
THE DIVISION IS: 1.6666666666666667
THE X^Y IS : 125
THE X! = 120

SCOE Nashik
Programming and Problem Solving Laboratory (PPSL) FE- 2019 Pattern

PRACTICAL NO – 08
Title : To accept two numbers from user and compute smallest divisor and
Greatest Common Divisor of these two numbers.

Program :

Input :

x = int(input("ENTER VALUE OF X :"))

y = int(input("ENTER VALUE OF Y :"))

while y!=0:

(x,y)=(y, x%y)

print("GCD IS :",x)

print("SCD 1")

Output-1 :
ENTER VALUE OF X :12

ENTER VALUE OF Y :3

GCD IS : 3

SCD 1

Output-2 :

ENTER VALUE OF X :67

ENTER VALUE OF Y :5

GCD IS : 1

SCD 1

SCOE, Nashik
Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 09
Title : To accept a number from user and print digits of number in a reverse order.
Program :

Input :

num = int(input("ENTER THE NUMBER :"))

print("THE REVERSE OF NUMBER IS : ",end="")

while num!=0:
print(num%10, end="")
num = num // 10
print()

Output :
ENTER THE NUMBER :123
THE REVERSE OF NUMBER IS : 321
Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 10
Title : To input binary number from user and convert it into decimal number.
Program :

Input :

bin = input("ENTER THE BINARY NUMBER :")

dec = 0

for digit in bin:


dec = dec*2 + int(digit)

print("DECIMAL NUMBER IS :",dec)

Output-1:
ENTER THE BINARY NUMBER :1111
DECIMAL NUMBER IS : 15

Output-2:
ENTER THE BINARY NUMBER :1010
DECIMAL NUMBER IS : 10
Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 14
Title : To accept from user the number of Fibonacci numbers to be generated and
print the Fibonacci series.Program :

Input :

term = int(input("HOW MANY TERMS :"))

n1 = 0
n2 = 1
count = 0

print("FIBONAACI SEQUENCE UPTO TERM",term,":")

while count < term:


print(n1,end=",")
nth = n1+n2
n1 = n2
n2 = nth
count +=1

Output :
HOW MANY TERMS :10
FIBONAACI SEQUENCE UPTO TERM 10 :
0,1,1,2,3,5,8,13,21,34,
Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 15
Title : Write a python program that accepts a string from user and perform
following string operations- i. Calculate length of string ii. String reversal iii.
Equality check of two strings iii. Check palindrome ii. Check substring

Input :
s = input("ENTER FIRST STRING :")
print("Length is :",len(s))
print("Reverse is :",s[::-1])
print("Palindrome is :",s == s[::-1])
t = input("\nENTER SECOND STRING :")
print("String Equal is :",s==t)
print("Substring present from :",s.find(t))

Output :
ENTER FIRST STRING :madam
Length is : 5
Reverse is : madam
Palindrome is : True

ENTER SECOND STRING :;madam


String Equal is : False
Substring present from : -1
Programming and Problem Solving Laboratory (PPSL) FE -2019 Pattern

PRACTICAL NO – 16
Title : Write a python program that accepts a string from user and perform
following string operations- i. Calculate length of string ii. String reversal iii.
Equality check of two strings iii. Check palindrome ii. Check substring

Program :

Input :

file1 = open("myfile.txt")

data = file1.read()

data = data.replace(".",".")

data = data.swapcase()

file2 = open("myfile.txt","w")

file2.write(data)

file1.close()

file2.close()

print("Task Completed")

Output :
Hi, welcome to SCOE, Nashik.

*******************BEST OF LUCK***************

You might also like