Class 11 CBSE - Python Tuple Programs

Python is designed to understand the user’s responsibility, the protocol, and the ethical issues related to the field of computing.
Python in class 11 for cbse is very handy when it comes to practice on computers but for the beginers there might be some errors and problems such as exception. But it's always advisable to practice program on computer than writing it on paper because it cherishes your practical skills , knowledge and typing speed and you'll come to know new things and if you want to be a software developer someday then its a must call for you.
Program 1: Write a Python program to find the sum and average of marks in 5 subjects.
Solution:
T1=(78,98,85,57,69)
sum = T1[0]+T1[1]+T1[2]+T1[3]+T1[4]
avg = sum/5
print("Average=", avg)
print("Sum=",sum)


                        

Program 2: Write a python program to find the maximum element in the tuple entered by the user.
Solution:
tup= tuple()
num= int(input("How many numbers:"))
for n in range(0,num):
    numbers= int(input("Enter the number="))
    tup = tup +(numbers,)

print(tup)
print("Maximum number is:", max(tup))


                        

Program 3: Write a Python program that has a tuple of numbers (both positive as well as negative). Make a new tuple that has only positive values from that tuple.
Solution:
# frequency of an element in the list
L= [3,21,5,6,3,8,21,6]
print(L)
L1=[]
L2=[]
for i in L:
    if i not in L2:
        L2.append(i)
        x=L.count(i)
        L1.append(x)


print("Elememts" ,'\t\t\t',"Frequency")
for i in range(len(L1)):
    print(L2[i], '\t\t\t\t', L1[i])
    

                        

Program 4: Write a Python program that has a tuple of numbers (both positive as well as negative). Find the sum and product of only negative numbers from that tuple.
Solution:
# Python program to find positive numbers from a list
L1 = []
length = int(input("Enter number of elements : "))
for i in range(0, length):
    value = int(input())
    L1.append(value)

# printing all positive values of the list 
print("All positive numbers of the list : ")
for i in L1:
    if i >0:
        print(i , end = " ")
    




                        

Program 5: Write a python program remove duplicate elements from the tuple.
Solution:
# declare list 
list1 = [10, 20, 10, 20, 30, 40, 30, 50]
# declare another list 
list2 = []

# appending elements 
for n in list1:
	if n not in list2:
		list2.append(n)

# printing the lists 
print ("Original list")
print ("list1: ", list1)
print ("List after removing duplicate elements")
print ("list2: ", list2)

                        

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com