Pps Lab Manual Programs
Pps Lab Manual Programs
PREREQUISITES:
1. Knowledge of python programming
COURSE OBJECTIVE:
2. Understand basic concepts of programming language
THEORY:
Momentum is the quantity of motion of a moving body. In a
basic sense, the more momentum a
moving object has, the harder it is to stop. In this assignment,
user has to accept mass ofobject in Kg
and velocity in M/Sec to display its momentum.
ALGORITHM:
1. Accept mass of object in Kg from user
2. Accept velocity in M/Sec from user
3. Calculate e=mc2
4. Print momentum
FAQ’s:
1. Why Python is versatile?
2. Which operator in python is use to print power of a number ?
THEORY:
print (sample_str[-1])
print (sample_str[-2]) # return last second character
# output: n
2. String Reversal
def reverse(s):
str = ""
for i in s:
str = i + str
return str
4. Check Palindrome
# Python program to check if a string is palindrome or not
x = "malayalam"
w = ""
for i in x:
w=i+w
if (x==w):
print("YES")
5. Check Substring
# function to check if small string is there in big string
def check(string, sub_str):
if (string.find(sub_str) == -1):
print("NO")
else:
print("YES")
# driver code
string = "First Y ear Engineering"
sub_str ="First"
check(string, sub_str)
FAQ’s:
1. Write a short note on format operator.
2. What is slice operation? Explain with an example.
3. How to concatenate , append and multiplication in strings?