Professional Documents
Culture Documents
PWP Practical Ans
PWP Practical Ans
PWP Practical Ans
sr=s**0.5
area=l*b
print("Area of rectangle:",area)
area=side*side
peri=side*4
print("Area of square:",area)
print("Perimeter of square:",peri)
# 4. Write a program to check whether a number is even or odd.
if(n%2)==0:
else:
# 5.Write a program to check the largest number among the three numbers.
else:
n1=0
n2=1
c=0
nt=n1+n2
n1=n2
n2=nt
c+=1
f=1
print("factorial of :",n)
while n>=1:
f=f*n
n=n-1
print(f)
l=[1,2,3,4,5]
OR
l=[1,2,3,4,5]
max_num=0
for i in l:
max_num=i
s=set()
s.add("apple")
s.add("banana")
s.add("cherry")
s.remove("banana")
dic3 = {5:50,6:60}
dic={}
for x in (dic1,dic2,dic3):
dic.update(x)
print(dic)
"""11 Write a Python function that accepts a string and calculate the number
of upper case letters and lower case letters"""
def uplo(s):
u=0
l=0
for n in s:
if(n.islower()):
l=l+1
elif(n.isupper()):
u=u+1
uplo(s)
"""12 Write a Python function that takes a number as a parameter and check
the number is prime or not"""
def prime(no):
if(no%2==0):
else:
print("Number is prime")
no=int(input("Enter a number:"))
prime(no)
"""13 Write a Python program that will calculate area and circumference
of circle using inbuilt Math Module"""
import math
def cp(radius):
area=math.pi*radius**2
circumference=2*math.pi*radius
return area,circumference
area,circumference=cp(radius)
print("Area of circle:",area)
print("Circumference of circle:",circumference)
import numpy
random_int=numpy.random.randint(low=10,high=30,size=6)
print(random_int)
“””IN 14 IF IT SHOW ERROR MODULE NOT FOUND THEN OPEN CMD AND TYPE
Pip install numpy AND PRESS ENTER THEN INSTALLATION COMPLETE AND RUN
THE CODE”””
"""15 Create a class Employee with data members: name, department and
salary.
class Employee:
def get(self):
self.name=input("Enter name:")
self.dept=input("Enter department:")
self.salary=int(input("Enter salary:"))
def put(self):
print("Name:",self.name)
print("Department:",self.dept)
print("Salary:",self.salary)
obj=Employee()
obj.get()
obj.put()
a=int(input("Enter a number:"))
b=int(input("Enter a number:"))
try:
c=a/b
except:
else:
print("Division =",c)