1. Write a python program to add a single element in to the tuples?
2. Write a python program to add a group of elements into the tuples?
3. Write a python program to add the elements into the particular index?
4. Write a python program to remove the given element into the typle?
5. Write a python program to delete the tuple?
6. Write a python program how to used (+, *) this operators in tuple?
7. Write a python program to unpack the tuple?
8. Write a python program to convert the list into tuple?
9. Write a python program to convert the string into tuple?
10. Write a python program to count the given element into the tuple?
11. Write a python program to find the index of the given element?
12. Write a python program to print the tuple of elements without using iteration?
13. Write a python program to find the length of the tuple?
14. Write a python program to the tuple in reverse?
15. Write a python program to use all the function and print the tuples?
1. Write a python program to create a even number tuple with using tuple comprehension?
Programe:
n=int(input("Enter how many element do you want to store in the tuple"))
t=tuple(i for i in range(1,n+n+1) if i%2==0)
print(t)
[Link] a python program to create a odd number tuple using comprehension?
Programe:
n=int(input("Enter how many element do you want to store in the tuple"))
t=tuple(i for i in range(1,n+n+1) if i%2!=0)
print(t)
3. Write a python program to create a tuple of elements whose factories of 100 using comprehension?
Programe:
t=tuple(x for x in range(1,101) if 100%x==0)
print(t)
4. Write a python program to convert the dictionary of keys into one tuple and values in another tuple?
Programe:
d={1:2,3:4,5:6,7:8}
t1=tuple()
t2=tuple()
for k,v in [Link]():
t1+=k,
t2+=v,
print("keys in dictionary",t1)
print("Values in dictionary",t2)
5. Write a python program to convert the takes the input of numbers from the user and store the
factories as nested tuples as another tuple?
Example: t1=2,3,4,5,6
Output: t2=((1,2),(1,3),(,1,2,4),(1,5),(1,2,3,6))
Program:
t=(2,3,4,5,6)
t2=tuple()
for i in t:
t3=tuple()
c=0
for j in range(1,i+1):
if(i%j==0):
t3+=(j,)
c=c+1
t2+=(t3,)
print(t2)
6. Write a python program to take the string from the user convert it into tuples and count the number
of character in the tuple except spaces?
Example: s=hello hi how are you
Output: total number of character without space: 16
Programe:
s=input("Enter the string")
t=tuple(s)
c=0
for i in t:
if i!=' ':
c+=1
print("The character in a given string except spaces",c)