0% found this document useful (0 votes)
136 views2 pages

MCA-Python Lab Manual

The document contains three Python programs demonstrating different functionalities. The first program showcases the use of bitwise operators, the second finds the largest and smallest of three numbers, and the third prints the Fibonacci series up to 'n' terms. Each program includes user input and outputs the results based on the calculations performed.

Uploaded by

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

MCA-Python Lab Manual

The document contains three Python programs demonstrating different functionalities. The first program showcases the use of bitwise operators, the second finds the largest and smallest of three numbers, and the third prints the Fibonacci series up to 'n' terms. Each program includes user input and outputs the results based on the calculations performed.

Uploaded by

Sekhar Anasani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. Write a python program to demonstrate the usage of bitwise operators.

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
print("a & b=",a&b)
print("a | b=",a|b)
print("~a=",~a)
print("a^b=",a^b)
print("a>>1=",a>>1)
print("a<<1=",a<<1)

Output:

Enter first number: 4

Enter second number: 2

a & b= 0

a | b= 6

~a= -5

a^b= 6

a>>1= 2

a<<1= 8

[Link] a python program to find largest and smallest of three numbers.

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
c = int(input("Enter second number: "))
if a>b and a>c:
print("largest value=",a)
elif b>c:
print("largest value=",b)
else:
print("largest value=",c)
if a<b and a<c:
print("smallest value=",a)
elif b<c:
print("smallest value=",b)
else:
print("smallest value=",c)
#largest=max(a,b,c)
#smallest=min(a,b,c)
#print("bigger value =",largest)
#print("smaller value =",smallest)

Output:

Enter first number: 2

Enter second number: 3

Enter second number: 4

largest value= 4

small value= 2

3. Write a python program to print ‘n' terms of Fibonacci series of numbers

a=0
b=1
n=int(input("enter the n value"))
print(a)
print(b)
for i in range(n-2):
c=a+b
print(c)
a=b
b=c

Output:

enter the n value5

You might also like