Sathvika
Sathvika
Given a list of tuples. Write a program to find tuples that have all
elements divisible by K from a list of tuples.
Example:
Input:
n: 3
6 24 12
60 12 6
12 8 21
K: 6
Output:
n=int(input("n: "))
lst = [ ]
for i in range(n):
a = tuple(map(int,input().split()))
lst.append(a)
k = int(input("K: "))
selectedTupList = [tup for tup in lst if all(values % k == 0 for values
in tup)]
print(selectedTupList)
1.3 Input & Output :
Text Case -
Output :
PROGRAM 2 :
For example, to find all primes less than 100, we would first mark [4, 6,
8, ...] (multiples of two). then [6, 9, 12, ...] (multiples of three), and so on.
Once we have done this for all primes less than 'N', the unmarked
numbers that remain will be prime.
Text Case -
Output :