Practical 1
Practical 1
<class 'int'>
<class 'float'>
<class 'str'>
Q1 (B) WAP to accept 3 numbers from the user and display
the sum of squares of those numbers.
SOL:
a=int(input("Enter number: "))
b=int(input("Enter number: "))
c=int(input("Enter number: "))
x=a*a
y=b*b
Z=C*C
d=x+y+z
print("Sum of square is ",d)
OUTPUT:
Enter number: 45
Enter number: 54
Enter number: 65
Sum of square is 9166
Q1 (C) WAP to demonstrate:-
(i) If-else statement:
a=45
if a>0:
print(a,' is positive')
else:
print(a,' is negative')
OUTPUT:
45 is positive
OUTPUT:
I am studying Bsc IT
I am studying Bsc IT
I am studying Bsc IT
I am studying Bsc IT
I am studying Bsc IT
I am studying Bsc IT
Q1 (E) WAP to demonstrate local and global variables.
SOL:
a=101
print(a)
def display():
a="In function"
print(a)
display()
print(a)
OUTPUT:
101
In function
101
PRACTICAL 2.
Q2 (A) Create a user-defined parameterized function for
finding the area of a cylinder.
SOL:
def area(r,h):
a=3.14*r*r*h
print("Area of cylinder is ",a)
p=float(input("Enter radius: "))
s=float(input("Enter height: "))
area(p,s)
OUTPUT:
Enter radius: 3
Enter height: 3.2
Area of cylinder is 90.432
Q2 (B) WAP to demonstrate function with return types.
(Fruitful Function)
SOL:
def sum(a,b,c):
x=a*a*a+b*b*b+c*c*c
return x
d=sum(2,3,5)
print('Sum of cube of three numbers is ',d)
OUTPUT:
3 is Odd
Factorial of 8 is 40320