Computer Science
Write a program that inputs two tuples seq_a and seq_b and prints True if every element in seq_a is also an element of seq_b, else prints False.
Python
Python Tuples
7 Likes
Answer
seq_a = eval(input("Enter the first tuple: "))
seq_b = eval(input("Enter the second tuple: "))
for i in seq_a:
if i not in seq_b:
print("False")
break
else:
print("True")
Output
Enter the first tuple: 1,3,5
Enter the second tuple: 4,5,1,3
True
Answered By
4 Likes
Related Questions
Create a tuple ('a', 'bb', 'ccc', 'dddd', … ) that ends with 26 copies of the letter z using a for loop.
Given a tuple pairs = ((2, 5), (4, 2), (9, 8), (12, 10)), count the number of pairs (a, b) such that both a and b are even.
Computing Mean. Computing the mean of values stored in a tuple is relatively simple. The mean is the sum of the values divided by the number of values in the tuple. That is,
Write a program that calculates and displays the mean of a tuple with numeric elements.
Write a program to check the mode of a tuple is actually an element with maximum occurrences.