Python Practical File GIRI
Python Practical File GIRI
Roll No:-1916849
PYTHON PRACTICAL FILE
B.TECH CSE 5TH SEMESTER
Output:
Output:
Output:
Output:
Output:
Output:
Output:
Output:
Output:
Output:
False
True
True
False
False
True
Output:
Output:
Output:
Output:
-100
10
Output:
# program to typecast
x = int(1)
y = int(2.8)
z = int("3")
print(x)
print(y)
print(z)
Output:
Output:
Output:
Output:
elif n == 2:
length = int(input('Enter length of rectangle : '))
breadth = int(input('Enter breadth of rectangle : '))
print(length * breadth)
elif n == 3:
radius = int(input('Enter radius of circle : '))
print(3.14 * radius * radius)
elif n == 4:
radius = int(input('Enter radius of cylinder : '))
height = int(input('Enter height of cylinder : '))
area = (2 * 3.14 * radius * height) + (2 * 3.14 * radius * radius)
print(area)
else:
print('Invalid Input!')
Output:
# program for menu driven arithmetic operation
a=int(input('Enter number 1: '))
b=int(input('Enter number 2: '))
print('Enter + for Addition, - for Subtraction, * for Multiplication and /
for Division.')
ch=input('Enter your choice: ')
if ch=='+':
print("Sum = ",a + b)
if ch=='-':
print("Difference = ",a - b)
if ch=='*':
print("Product = ",a * b)
if ch=='/':
print("Division = ",a / b)
Output:
print(id(a))
print(id(b))
print(id(c))
print(a is c)
print(a is b)
Output:
1633999585808
1633999585648
1633999585808
True
False
# program to print first five numbers without range function using for
loop
for i in [1,2,3,4,5]:
print(i)
Output:
1
2
3
4
5
# program to print first five numbers with range function using for loop
for i in range(1,6):
print(i)
Output:
1
2
3
4
5
Output:
55
Output:
Enter value of n: 15
120
Output:
Enter value of n: 22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
for a in range(1,a+1):
b=b*a
Output:
Enter number: 24
Factorial of number is: 620448401733239439360000
while a != 0:
c = a % 10
b = b * 10 + c
a //= 10
if d==b:
print('\nIt is a Palindrome.')
else:
print('\nIt is not a Palindrome.')
Output:
Enter number to check: 123321
It is a Palindrome.
Output:
Output:
Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
while a != 0:
a //= 10
count=count+1