Lab Python Program
Lab Python Program
2023)
EXERCISE NO: 02A: OPERATIONS IN TUPLE:
1. CREATING TUPLE:
MyTup4 = (10)
print (type(MyTup4))
MyTup5 = (10,)
print (type(MyTup5))
print(Tup1)
print(Tup1[2:5])
print(Tup1[:5])
print(Tup1[4:])
print(Tup1[:])
Tup1 = (2,4,6,8,10)
Tup2 = (1,3,5,7,9)
Tup3 = Tup1 + Tup2
print(Tup3) # JOINING TWO TUPLES
del Tup3 # DELETING THE TUPLE
print (Tup3) # SINCE IT IS DELETED TUPLE BECOMES UN-
DEFINED
6. TUPLE ASSIGNMENT:
def Min_Max(n):
a = max(n)
b = min(n)
return(a, b)
Num = (12, 65, 84, 1, 18, 85, 99)
(Max_Num, Min_Num) = Min_Max(Num)
print("Maximum value = ", Max_Num)
print("Minimum value = ", Min_Num)
8. NESTED TUPLES:
BASIC PROGRAMS:
pi = 3.14
def Circle(r):
return (pi*r*r, 2*pi*r)
radius = float(input("Enter the Radius: "))
(area, circum) = Circle(radius)
print ("Area of the circle = ", area)
print ("Circumference of the circle = ", circum)
# Creating tuples
Tuple = ( 1, 3, 4, 2, 5, 6 )
res = max(Tuple)
print('Maximum of Tuple is', res)
MyList = [1, 3, 5, 7, 9]
print ("List Odd numbers... ")
for x in MyList:
print (x)
MyList[0:5] = 2,4,6,8,10
print ("List Even numbers... ")
for y in MyList:
print (y)
del MyList
print(MyList)
BASIC PROGRAMS:
1. GIVEN COUNTRY IS PART OF BRICS OR NOT: