TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

TN State Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 1.
What is known as Nested list?
Answer:
A list contains within another list as an element. This type of list is known as Nested list.

Question 2.
What is known as index value in python?
Answer:
(i) In python, index value is an integer number which can be positive or negative.
(ii) Positive value of index counts from the beginning of the list and negative value means counting backward from end of the list.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 3.
What is the output?
Answer:
>>>marks = [10, 20, 30, 40]
>>> marks 1 = [100, 200, 300,400]
>>> print (marks [0])
>>> print (marks 1 [-1])
Output:
10
400

Question 4.
What is the output?
Answer:
>>> Name = [‘Anand’, ‘Arul’, ‘Nithya’,
‘Vani’]
>>> print (Name [1])
>>> print (Name [-2])
Output:
Arul
Nithya

Question 5.
What is the use of index from and index to?
Answer:

  • Index from is the beginning index of the range.
  • Index to is the upper limit of the range which is excluded in the range.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 6.
What is difference between append ( ) and extend ( )?
Answer:

  • append ( ) function is used to add single element in a list.
  • extend ( ) function is used to add more than one element to an existing list.

Question 7.
What is difference between append ( ) and insert ()?
Answer:

  • Append () function is used to add more elements, but it includes elements at the end of list.
  • Insert ( ) function is used to insert an element at any position of a list.

Question 8.
What is the use of pop ( ) and clear ( ) function?
Answer:
pop ( ) function deletes and returns the last element of a list if the index is not given.
Clear ( ) function is used to delete all the elements in list, it delete only the elements and retains the list.

Question 9.
What is the output?
Answer:
for x in range (3, 12, 3)
print, (x)
Output:
3
6
9

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 10.
What is Tuples in python?
Answer:

  • Tuples is similar to list, tuples consists of a number of values separated by comma and enclosed within parenthesis.
  • In a tuple values cannot be changed in the lists.

Question 11.
What is tuple () function?
Answer:
The tuple () function is used to create Tuples from a list. When you create a tuple, from a list, the elements should be enclosed within square brackets.

Question 12. What is called singleton tuple?
Answer:
(i) While creating a tuple with a single element, add a comma (,) at the end of the element.
(ii) In the absence of a comma, python will consider the element as an ordinary data type. Creating a Tuple with one element is called singleton Tuple.

Question 13.
What is Tuple assignment?
Answer:

  • Tuple assignment is a powerful feature in python.
  • It allows a tuple variable on the left of the assignment operator to be assigned to the values on the right side of the assignment operator.
  • Each value is assigned to its respective variable.

Question 14.
How can you creating a set?
Answer:

  • A set is created by placing all the element separated by comma within pair of curly brackets.
  • The set ( ) function can also used to create sets in python.

Question 15.
What are the set operator supports in python?
Answer:
There are four types of set operations supports in python.

They are union (|), Intersection (&), Difference(-) and symmetric difference (A).

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 16.
What is known as Dictionaries?
Answer:
A dictionary is a mixed collection of elements. The keys in a python dictionary is separated by a colon (:) while the commas work as a separator for the elements. The key value pairs are enclosed with curly braces {}.

Question 17.
What is output?
Answer:
Diet = {x:3*x for x in range (2,3)}
print (Diet)
Output:
{2:9,3:9}

Question 18.
What is mean by modification of a value in dictionary?
Answer:
(i) Modification of a value in dictionary is very similar as adding elements.
(ii) When you assign a value to a key, it will simply overwrite the old value.

Question 19.
What is output?
Answer:
Marks = {10, 23, 41, 75}
i=-1
while i> = -4:
print (marks[i])
i = i + -1
Output:
75
41
23
10

Question 20.
What is output?
Answer:
>>>Name = [“Arun”, “Senthil”, “Kumar”]
>>> len(Name)
Output:
3

Question 21.
What is output?
Answer:
for x in range (2,11,2)
print (x)
Output:
2
4
6
8
10

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 22.
What is output?
Answer:
>>> sQuestion = [x**2 for x in range (1,6)]
>>> print (sq)
Output:
[1, 4, 9, 16, 25]

Question 23.
What is output?
Answer:
>> (x, y, z, p) = (2**2, 5/3+4,15%2, 34>65)
>>> print (x,y,z,p)
Output:
45.666666666666667 1 False

Question 24.
How can you create a list in python?
Answer:
Python, a list is simply created by using square bracket.
The element of list should be specified within square brackets.
The syntax is variable = [element-1, element-2, element-3 element -n]
Eg: class = [“RAJA”, “RANI”, 50,100]

Question 25.
Write a python program to print reverse indexing.
Answer:
Marks = [5, 25, 10, 50, 35]
i = -1
while i >= -5
print (marks [i])
i=i+-1
Output:
35
50
10
25
5

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 26.
Write a short note on List Length in python?
Answer:
The len ( ) function in python is used to find the length of a list. The len ( ) function is used to set the upper limit in a loop to read all the elements of a list. If a list contains another list as an element, len ( ) function returns that inner list as a single element.
Eg; . s .
>>>Item = [“soap”, “pen”, “INK”]
>>>len (Item)
Output is 3.

Question 27.
Write short note on list comprehensions.
Answer:
List comprehensions is a simplest way of creating sequence of elements that satisfy a certain condition.
The syntax is List = [expression for variable in range]
Eg:
>>>cubes = [x**3 for x in range (1,6)]
>>>print(cubes)
Output:
1 8 16 32 64
In this example x**3 in the expression is evaluated each time it is iterated. This is the shortcut method of generating series of values.

Question 28.
Write a program to define a list of cities that are metro in India or not.
Answer:
# program for metro city or not
city = [“CHENNAI”, “DELHI”, “MUMBAI”, “KOLKATTA”]
Metro_city = input “Type name of the city”) if metro_city in city:
print (metro_city, “is the metro city in India”) else: ‘
print (metro_city,“is no the *metro city in India”)

Question 29.
Write a program to find the area and circumference of the circle using function with tuple assignment.
Answer:
pi = 22/7
def circle (r):
return (pi * r*r, 2*pi*r)
radius = float (input (“Type radius”))
(area, circum) = circle (radius)
print (“Area of the circle =”, area)
print (“Circumference of the circle-’, circum)

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 30.
Write a program to swap two values using tuples assignment.
Answer:
a = int(input(“Enter value of A:”))
b = int (input(“Enter value of B:”))
print(“Value of A =”, a, “\n Value of B=”,b) (a,b) = (b,a)
print(“Value of A =”,a,”\n value of B =”,b)
Output:
Enter value of A: 54
Enter value of B: 38
Value of A= 54
Value of B = 38
Value of A= 38
Value of B = 54

Question 31.
Write a program to print positive numbers from the list.
Answer:
Numbers = (5,-8,6,8,-4, 3, 1)
Positive = ( )
for i in Numbers:
if i > 0:
positive +=(i,)
print(“Positive Numbers: “, Positive)
Output:
Positive Numbers: (5, 6, 8, 3, 1)

Question 32.
What is output?
Answer:
set_A = {‘A’, 2,4/D’}
set_ B = {‘A’/B’/C’/D’}
print (set A A set B)
output:
{2, 4,’B’, C’}

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 33.
Explain copy (), count (), sum () functions.
Answer:
(i) Copy ( ) – is used returns the copy of the list.
The syntax is list.copy ()
Eg: orilist = [10,20, 30]
x = orilist. copy ()
print (x)
Output [10,20, 30]

(ii) Count () – is used to returns the number of similar elements present in last.
The syntax is list count (value)
Eg: orilist = [10, 20, 30]
x = orilist.count (30)
Output 2

(iii) Sum ( ) – is used returns the sum of values in a list
The syntax is sum (list)
Eg:
orilist = [10, 20, 30]
print (sum(orilist))
Output 60

Question 34.
Write a program that create a list of numbers upto 50 that are divisible by 5.
Answer:
# program for divisible by 5
divby5 = [ ]
for i in range (51):
if (i % 5 =0):
divby5.append (i)
print (divby5)
output [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]

Question 35.
Write a program to read six subject marks and print the total marks.
Answer:
# program for six subjects with Total marks
marks = [ ]
subjects = [“Tamil”, “English”, “physics”, “chemistry”, “maths”, “comp.Science”]
for i in range (6):
m = int (input(“Type mark”))
marks.append (m)
for j in range (len(marks)):
print (“{}.{} mark ={}”. format (j1+, subjects!]], marks[j]))
print (“Total marks”, sum (marks))

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 36.
Write a program to delete all the even numbers from the list.
Answer:
# program for delete all the even numbers
Num=[ ]
for x in range (1, 11):
Num.append (x)
print (“the numbers from 1 to 10 =”, Num)
for index, i in enumerate (Num):
if (i %2 = = 0):
delNum [index]
print (“The list after deletingeven numbers”,
Num)

Question 37.
Write a program that generate a set of prime numbers another set of even numbers.
Answer:
Demonstrate the result of union, intersection, difference and symmetric difference operations.
even=set([x*2 for x in range(l, 11)])
primes=set( )
for i in range(2, 20):
j=2
f=0
while j<i/2:
if i%j==0
f=1
j+=1
if f==0
primes.add(i)
print(“Even Numbers: even)
print(“Prime Numbers: “, primes)
print(“Union: even.union(primes))
print(“Intersection:”, even. intersection(primes))
print(“Difference: even.difference(primes))
print(“Symmetric Difference: even.
symmetric_difference(primes))
Output:
Even Numbers: {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
Prime Numbers: {2, 3, 4, 5, 7, 11, 13, 17, 19}
Union: {2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20}
Intersection: {2, 4}
Difference: {6, 8,10, 12, 14, 16, 18, 20}
Symmetric Difference: {3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20}

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 38.
What is List in Python?
Answer:
List is an ordered collection of values enclosed within square brackets [ ]. A list in python is known as a sequence data types like string. Each value of a list is called as element. It can be of any type such as numbers, characters, strings and even the nested lists.

Question 39.
How will you access the list elements in reverse order?
Answer:
Python enables reverse or negative indexing for the list elements.The python sets -1 as the index value for the last element in list and -2 for the preceding element and so on. This is called as Reverse order.

Question 40.
What will be the value of x in following python code?
List1=[2,4,6[l,3,5]] x=len( List1)
Answer:
The output will be printed as
4
Note: Inner list considered as single element in python.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 41.
Differentiate del with remove( ) function of List.
Answer:

Del

remove ()

del statement is used to delete known element. remove () function is used to remove elements of a list if its index is unknown.
The del statement can also be used to delete entire list. The remove () function can also be used to delete one or

more elements.

Question 42.
Write the syntax of creating a Tuple with n number of elements.
Answer:
Tuple_Name = tuple ([list of element])
Eg: Prime_Num = tuple ([2, 3, 5, 7, 11])

Question 6.
What is set in Python?
Answer:
A set is created by placing all the elements separated by comma within a pair of curly brackets.
The set ( ) function can also used to create sets in python.
Eg: >>>s = {1, 2, 3, ‘M’, 56, 100}

Question 43.
What are the advantages of Tuples over a list?
Answer:
(i) The elements of a list are changeable (mutable) whereas the elements of a tuple are unchangeable (immutable), this is the key difference between tuples and list.
(ii) The elements of a list are enclosed within square brackets. But, the elements of a tuple are enclosed by paranthesis.
(iii) Iterating tuples is faster than list.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 44.
Write a shot note about sort( ).
Answer:
Sort( ) function sorts the elements in list.
The syntax is
List.sort(reverse= True|False, key = my func)
• Both arguments are optional.
• Ascending is default.
• If reverse is set as True, list sorting is in descending order.

Question 45.
What will be the output of the following code?
Answer:
list = [2**x for x in range(5)]
print(list)
1 2 4 8 16

Question 46.
Explain the difference between del( ) and clear( ) in dictionary with an example.
Answer:

Del

clear ( )

Del statement is used to delete known element. The Clear () function is used to delete all the elements in a dictionary.
The del statement can also be used to delete entire list. It deletes only the elements and retains the list.
Eg:>>> del name [1] deletes an element whose index value is 1. Eg;»>Name_list. clear () This example removes only the elements and retain the list in Name_list.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 47.
List out the set operations supported by python.
Answer:
In python is supports the set operations such as union, intersection, difference and symmetric difference.
(i) Union – It includes all element from two or more sets. The operator is used to union of two sets.
(ii) Intersection – It includes the common elements in two sets. The operator & is used to intersect two sets in python.
(iii) Difference – It includes all elements that are in first set (set A) but not in the second set (set B). The – (minus) operator is used to difference set operation in python.
(iv) Symmetric difference – It includes all the elements that are in two sets (set A and B) but not the one that are common to two sets. The caret (A) operator is used to symmetric difference set operation in python.

Question 48.
What are the difference between List and Dictionary?
Answer:

List

 Dictionary

List is an ordered set of elements.  Dictionary is a data structure that is used for matching one element with another.
The index value can be used to access a particular element.  In dictionary key represents index.
Lists are used to look up a value.  Dictionary is used to take one value and look up another value.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 49.
What the different ways to insert an element in a list. Explain with suitable example.
Answer:
In python, to insert an element in a list for different ways, that are append ( ), extend ( ) and insert ( ) functions.

(i) append ( ) – is used to add a single element. The syntax is
List.append (element to be added)
Eg:
>>> Mark list = [90, 95, 98]
>>> Marklist.append (99)
>>> Print (marklist)
The output is [90, 95, 98, 99]
In this example, marklist is created with three elements.
Through >>>marklist.append (99) is that additional value (99) is included with the existing list as last element.

(ii) extend ( ) is used to add more than one element to an existing list.
The syntax is List.extend ([elements to be added])
Eg:
>>>Namelist.extend ([50,60,70])
>>> print (Namelist)
The output is [90, 95, 98, 99, 50, 60, 70]
In this example, extend ( ) function is used to include multiple elements, it shows all the elements of list after the inclusion of additional elements.

(iii) Insert () – is used to insert an element at any position of a list.
The syntax is:
List.insert (position index, element)
Eg:
>>>Namelist = [50, 60, ‘RAJA’, 4OUNA’, ‘YUVA’] *
>>>Namelist.insert (4, ‘SEKAR’)
>>> Print(Namelist)
The output is
[50, 60, ‘RAJA’, ‘GUNA’, ‘SEKAR’, ‘YUVA’]
In this example insert ( ) function a new element ‘sekar’ at the index value.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 50.
What is the purpose of range( )? Explain with an example.
Answer:
The range () is a function used to generate a series of values in python.
Using range () function, you can create list with series of values. The range () function has three arguments.
The syntax is
range (start value, end value, step value) Where
start value – beginning value of series. Zero is the default beginning value.
end value – upper limit of series. Python takes the ending value as upper limit -1.
step value – It is optional argument, which is used to generate different interval of values. Eg:
for m in range (5, 50, 5)
print (m)
The output will be printed as 5
10
15 „
20
25
30
35
40
45
In this example, start value 5 and end value is 50 with step size is 5, so it will be printed 5, 10, 15….

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 51.
What is nested tuple? Explain with an example.
Answer:
(i) A tuple can be defined inside another tuple is called Nested tuple.
(ii) In a nested tuple, each tuple is considered as an element.
(iii) The for loop will be useful to access all the elements in a nested tuple.
(iv All the functions used in list can be applicable even for tuples.
(v) Tuple is similar to list, values in a list can be changed but not in a tuple.
Eg:
Rankers = ((“ RAJA”, “I”), (“RANI”, “II”), (“LATHA”, “HI”), (“MANI”, “IV”))
for m in Rankers:
print (m)
The output will be printed as
(“RAJA”, “I”)
(“RANI”, “II”)
(“LATHA”, “III”)
(“MANI”, “IV”)

Question 52.
Explain the different set operations supported by python with suitable example.
Answer:
The python is supports the set operations such as union, intersection, difference and symmetric difference.

(i) Union:
It includes all elements from two or more sets.
The operator | is used to union of two sets. The function union ( ) is also used to join two sets in python.

TN State Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary 1

Eg:
set_A={ 10,20}
set_B={‘M’,‘N’}
U set = set _A | set_B
print (U_set)
Output
{10,20,‘M’,‘N’}

(ii) Intersection:
It includes the common elements in two sets.
The operator & is used to intersect two sets in python.
The function intersection ( ) is also used to intersect two sets on python.

TN State Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary 2

Eg:
set_A={5,10, ‘Y’}
set_B={‘X’,‘Y’}
print (set_A&set_B)
Output:
{‘Y’}

(iii) Difference:
It includes all elements that are in first set (set A) but not in the second set (set B)
The minus (-) operator is used to difference set operation. The function difference () is used to difference operation.

TN State Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary 3

Eg:
set_A={‘A’,2,4,’D’}
set_B={‘A\ ‘B\ ‘C’, ‘D’}
print (set_A-set_B}
Output:
{2,4}

(iv) Symmetric difference:
It includes all the elements that are in two sets (set A and B) but not the one that are common to two sets.
The caret (^) operator is used to symmetric difference set operation. The function symmetric difference () is also used to do the same operation.

TN State Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary 4

Eg:
set_A= {‘ A’ ,2,4, ‘ D ’}
print (set_A A set_B)
output:
{2,4,‘B’, ‘C’}

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 53.
Write a program to remove duplicates from a list.
Answer:
# program to remove duplicates from a list,
n = [10,20,30,20,10,50,60,40,80,50,40]
dupnumber = set ()
uniq_number=[ ]
for x in n:
if x not in dupnumber:
uniq_number.append (x)
dup number.add (x)
print (dup number)

Question 54.
Write a program that prints the maximum value in a Tuple.
Answer:
# program that prints maximum value in tuple.
tuple l,tuple2 = (‘TAMIL’, ‘ENGLISH’,’ ‘MATHEMATICS’, ‘COMPUTER SCIENCE’), (256, 500, 2720)
print (“The maximum value element”, max (tuple 1))
print (“The maximum value element”, max (tuple2))
The output is
The maximum value element COMPUTER SCIENCE
The maximum value element 2720.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 55.
Write a program that finds the sum of all the numbers in a Tuples using while loop.
Answer:
# program for sum of all the numbers in tuples using while loop.
n= int (input (“Type maximum number”))
sum = 0
while (n>0):
sum+=n
n-=1
print (“The sum is”, sum)

Question 56.
Write a program that finds sum of all even numbers in a list.
Answer:
# program for sum of all even numbers in a list
m = int (input (“Type the maximum value”))
T= 0
for n in range (1, m+1):
if (n % 2 =0):
print (“{0}’’.format (n)/format (n))
T =T+N
print (“The sum Even numbers from 1 to {0}
= {1}”.format (n,t))

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 57.
Write a program that reverse a list using a loop.
Answer:
# program that reverse a list using loop.
word_list= [‘RAM’, ‘MAN’, ‘RAJ’,’SUN’]
i = len (word_list)-1
while i>=0:
print (word list [i])
i-=l
Word_list[‘RAM’,(or)‘MAN’, ‘RAJ’, ‘SUN’]
for i in range (len(word_list)-1,-1,-1)
print (wordlist[i])

Question 58.
Write a program to insert a value in a list at the specified location.
Answer:
# program to insert a value in a list at the specified location
defmain( )
Listl= [‘RAM’, ‘BALU’, ‘CHAN’, ‘WHAT’,‘THAT’]
print (List 1)
list1.insert (3, ‘WHY’)
print(list1)
Listl.insert (0, ‘city’)
print (list1)
List2 = [3, 5, 7,1]
for elem in reversed (list2): //insert all the elements
list1.insert (3, elem)
print (list1)
List1 = list1 [:3]+list2 +listl[3:]
print (list+1)
if name —‘main’ main()
Output:
l.[‘RAM’, ‘BALU’,’CHAN’, ‘WHAT’, ‘THAT’]
2.[‘RAM’, ‘BALU’, ‘CHAN’, ‘WHY’, ‘WHAT’, ‘THAT’]
3.[‘CITY’, ‘RAM’, ‘BALU’, ‘CHAN’, ‘WHY’, ‘WHAT, ‘THAT’]
4.[‘CITY’, ‘RAM’, ‘BALU’, 3,5,7,1, ‘CHAN’, ‘WHAT’, ‘THAT’].
5.[‘RAM’ ‘BALU’, ‘CHAN’, 3,5,7,1, ‘WHAT’, ‘THAT’]

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 59.
Write a program that creates a list of numbers from 1 to 50 that are either divisible by 3 or divisible by 6.
Answer:
# program for list of numbers from 1 to 50
that are either divisible by 3 or divisible by 6.
for i in range (1, 50+1):
if (i % 3 =0 or i % 6==0):
print (i)

Question 60.
Write a program to create a list of numbers in the range 1 to 20. Then delete all the numbers from the list that are divisible by 3.
Answer:
# program list numbers from 1 to 20 and delete all from divisible by 3
number_list – (1:20)
print (numberlist)
for i in range (1,20+1):
if (i %3 =0):
del (i)

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 61.
Write a program that counts the number of times a value appears in the list. Use a loop to do the same.
Answer:
# program counts the number of times a
value appears in the list
1st = [2, 1, 5, 10, 5, 3, 4, 9, 12, 5, 5, 4]
def count (1st, x):
count = 0
for i in 1st:
if (i =x)
count = count+1
return count
x=5
print (countx (1 st, x))
Output: 4

Question 62.
Write a program that prints the maximum and minimum value in a dictionary.
Answer:
# program maximum and minimum value in a dietionary.
my_dict = {‘x’:500, ‘y’:5000, ‘z’: 8000}.
key_max = max (my_dict.keys( ), key = (lambda k: my_dict[k]))
keyjnin =? min (my_dict.keys( ), key = (lambda k: my dict[k]))
print (‘maximum value’,my_dict [key_max])
print (‘minimum value’ ,my_dict[key_min])
output
maximum value 8000
minimum value 500.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Choose the best answer:

Question 1.
What is a position of an element is indexed with starting number?
(a) 0
(b) 1
(c) -1
(d) None
Answer:
(a) 0

Question 2.
What is used, a list is simply created in python?
(a) ( )
(b) [ ]
(c) {}
(d) All of them
Answer:
(b) [ ]

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 3.
Which value of index counts from the beginning of the list elements?
(a) Positive
(b) Negative
(c) Both (a) and (b)
(d) None of these
Answer:
(a) Positive

Question 4.
Which value of index counts backward from end of the list?
(a) Positive
(b) Negative
(c) Both (a) and (b)
(d) None of these
Answer:
(b) Negative

Question 5.
Which are used to access all elements from a list?
(a) loop
(b) statements
(c) function
(d) none of these
Answer:
(a) loop

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 6.
What is the range [0 : 5] in python?
(a) 0 to 5
(b) 0 to 4
(c) 1 to 5
(d) 1 to 4
Answer:
(b) 0 to 4

Question 7.
Which function is used to add a single element to an existing list?
(a) append ( )
(b) extend( )
(c) Add ( )
(d) more( )
Answer:
(a) append ( )

Question 8.
What happen in the following statement? marks.append (99)
(a) 99 is included with the existing list in mark list.
(b) 99 is added to existing values in mark list.
(c) 99 is removed from existing list in mark list.
(d) 99 is added to the first value of existing list.
Answer:
(a) 99 is included with the existing list in mark list.

Question 9.
Which function is used to deletes only element and retains the list?
(a) del ( )
(b) clear ( )
(c) remove ( )
(d) erase ( )
Answer:
(b) clear ( )

Question 10.
Which function can be used to delete an element using the given index value?
(a) del ( )
(b) clear ( )
(c) pop ( )
(d) remove ( )
Answer:
(c) pop ( )

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 11.
Which function can be used to delete the elements if the index value is not known?
(a) del ( )
(b) clear ()
(c) pop ( )
(d) remove ( )
Answer:
(d) remove ( )

Question 12.
Which function is used to generate a series of values in Python?
(a) pop ( )
(b) range ( )
(c) len ( )
(d) count ( )
Answer:
(b) range ( )

Question 13.
What is the output?
>>> n= [for x in range (1,10):
>>> print (n)
(a) [1, 2, 3, 4, 5, 6, 7, 8, 9]
(b) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(c) both (a) and (b)
(d) [2, 3, 4, 5, 6, 7, 8]
Answer:
(a) [1, 2, 3, 4, 5, 6, 7, 8, 9]

Question 14.
What is the output.
>>> m = [4,3,4,2,4]
>>> n = m.count (4)
>>> print (n)
(a) 4
(b) 3
(c) 2
(d) 5
Answer:
(b) 3

Question 15.
Choose the incorrect pair:
(a) Positive index – Beginning onwards
(b) Negative index – Reverse order
(c) List – Initial value 1
(d) Tuples – Similar to list
Answer:
(c) List – Initial value 1

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 16.
Choose the incorrect pair:
(a) Set – Data type
(b) Index from – Beginning index
(c) Index to – Upper limit
(d) Dictionary – Numeric constant
Answer:
(d) Dictionary – Numeric constant

Question 17.
Choose the incorrect pair:
(a) List – data type
(b) Tuples – numeric constant
(c) Set – floating constant
(d) Dictionary – exponent
Answer:
(a) List – data type

Question 18.
Choose the incorrect pair:
(a) remove ( ) – delete element
(b) pop ( ) – delete index value
(c) clear ( ) – delete all element
(d) del ( ) – delete single element
Answer:
(d) del ( ) – delete single element

Question 19.
Choose the correct pair:
(a) list – immutable
(b) Tuple – mutable
(c) dictionary – mixed
(d) group – single
Answer:
(c) dictionary – mixed

Question 20.
Choose the correct pair:
(a) union – more sets
(b) intersection – two but not one
(c) difference – common sets
(d) symmetric – first set
Answer:
(a) union – more sets

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 21.
Choose the incorrect statement:
(a) Python has four collection of data types.
(b) A list is a numeric constant.
(c) Each value list is called as element
(d) The elements can be modified or replaced.
Answer:
(b) A list is a numeric constant.

Question 22.
Choose the incorrect statement:
(a) A list is simply created by using curly brackets.
(b) Nested list containing another list as an element.
(c) Python assigns automatic in^ex value.
(d) Index value of a list begins with zero.
Answer:
(a) A list is simply created by using curly brackets.

Question 23.
Choose the incorrect statement:
(a) Python enables reverse or negative indexing list.
(b) Python negative lists index in sequence order.
(c) Python sets -1 as the index value for the last element.
(d) Loops are used to access all elements.
Answer:
(b) Python negative lists index in sequence order.

Question 24.
Choose the correct statement:
(a) In python, the lists are mutable.
(b) Append ( ) function is used to add more element.
(c) Extend ( ) function is used to add single element
(d) Insert ( ) function is used to insert at last element only.
Answer:
(a) In python, the lists are mutable.

Question 25.
Choose the correct statement:
(a) del statement is used to delete unknown elements.
(b) remove ( ) is used to delete known elements.
(c) clear () is used to delete all the elements in list.
(d) pop () is used to delete single element and not returns the any element.
Answer:
(c) clear () is used to delete all the elements in list.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 26.
Match the following:

(i) Union  (A) —
(ii) intersection  (B) |
(iii) difference  (C) ^
(iv) symmetric  (D) &

(a) (i) – B, (ii) – D, (iii) – A, (iv) – C
(b) (i) – B, (ii) – A, (iii) – C, (iv) – D
(c) (i) – C, (ii) – D, (iii) – A, (iv) – B
(d) (i) – C, (ii) – A, (iii) – B, (iv) – D
Answer:
(a) (i) – B, (ii) – D, (iii) – A, (iv) – C

Question 27.
Match the following:

(i) del ( )  (A) delete unknown element
(ii) remove ( )  (B) delete known element
(iii) Pop( )  (C) delete only elements
(iv) clear ( )  (D) delete and returns

(a) (i) – B, (ii) – C, (iii) – D, (iv) – A
(b) (i) – B, (ii) – A, (iii) – D, (iv) – C
(c) (i) – D, (ii) – A, (iii) – B, (iv) – C
(d) (i) – D, (ii) – C, (iii) – B, (iv) – A
Answer:
(b) (i) – B, (ii) – A, (iii) – D, (iv) – C

Question 28.
Match the following:

(i) index from  (A) Upper limit
(ii) index to  (B) Add single
(iii) append ( )  (C) Add more
(iv) extend ( )  (D) Lower limit

(a) (i) – B, (ii) – D, (iii) – C, (iv) – A
(b) (i) – B, (ii) – C, (iii) – A, (iv) – D
(c) (i) – D, (ii) – C, (iii) – A, (iv) – B
(d) (i) – D, (ii) – A, (iii) – B, (iv) – C
Answer:
(d) (i) – D, (ii) – A, (iii) – B, (iv) – C

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 29.
Match the following:

(i) list (A) from list
(ii) Tuple (B) mixed
(iii) set (C) element
(iv) dictionary (D) unordered

(a) (i) – C, (ii) – A, (iii) – B, (iv) – D
(b) (i) – C, (ii) – A, (iii) – D, (iv) – B
(c) (i) – B, (ii) – D, (iii) – A, (iv) – C
(d) (i) – B, (ii) – C, (iii) – A, (iv) – D
Answer:
(b) (i) – C, (ii) – A, (iii) – D, (iv) – B

Question 30.
Match the following:

(i) range (1)  (A) 5
(ii) range (5, 6)  (B) 3
(iii) range (1, 4, 2)  (C) 1
(iv) range (1, 1 + 1)  (D) 0

(a) (i) – D, (ii) – A, (iii) – B, (iv) – C
(b) (i) – D, (ii) – B, (iii) – C, (iv) – A
(c) (i) – B, (ii) – D, (iii) – C, (iv) – A
(d) (i) – B, (ii) – C, (iii) – A, (iv) – D
Answer:
(a) (i) – D, (ii) – A, (iii) – B, (iv) – C

Question 31. Assertion (A):
In python, each value of a list is called as element.
Reason (R):
It can be of any type such as numbers, characters, strings and even the nested lists.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true, but R is falset
(d) A is false, but R is true.
Answer:
(a) Both A and R are true and R is the correct explanation for A.

Question 32.
Assertion (A):
Python assign an automatic index value for each element of list begin with zero.
Reason (R):
Positive value of index counts from the end of the list.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(c) A is true, but R is false.

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 33.
Assertion (A):
Index to is the lower limit of the range.
Reason (R):
Index from is the upper limit of the range.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(d) A is false, but R is true.

Question 34.
Assertion (A):
The Insert ( ) is used to insert an element at any position of a list.
Reason (R):
Python is used to add more elements in a list. .
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(a) Both A and R are true and R is the correct explanation for A.

Question 35.
Assertion (A):
The Tuple ( ) function is used to create Tuples from a list.
Reason (R):
When you create a tuple, from a list, the elements should be enclosed curlly brackets.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(c) A is true, but R is false.

Question 36.
Pick the odd one out:
(a) Tuples
(b) Set
(c) Dictionary
(d) For
Answer:
(d) For

Question 37.
Pick the odd one out:
(a) append ( )
(b) count ( )
(c) extend ( )
(d) insert ( )
Answer:
(b) count ( )

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 38.
Pick the odd one out:
(a) remove ( )
(b) clear ( )
(c) index ( )
(d) pop ( )
Answer:
(c) index ( )

Question 39.
Pick the odd one out:
(a) Dictionary
(b) Union
(c) Intersection
(d) Symmetric
Answer:
(a) Dictionary

Question 40.
Pick the odd one out:
(a) copy ( )
(b) count ( )
(c) index ( )
(d) tuple ( )
Answer:
(d) tuple ( )

Question 41.
Which function is used to add a single element to an existing list?
(a) append ( )
(b) add ( )
(c) extend ( )
(d) insert ( )
Answer:
(a) append ( )

Question 42.
Which function is used to add more than one element in an existing list?
(a) append ( )
(b) add ()
(c) extend ( )
(d) insert ( )
Answer:
(c) extend ( )

Question 43.
How many ways to delete element from a list?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 44.
What is output?
m = list(range(0, 5, 2))
(a) [2, 4]
(b) [0, 2, 4]
(c) [1, 3, 5]
(d) [0, 3, 5]
Answer:
(b) [0, 2, 4]

Question 45.
When using sort ( ) function, the default sorting is:
(a) Ascending
(b) Descending
(c) No sorting
(d) Multiple sorting
Answer:
(a) Ascending

Question 46.
Which of the following can be used to access a particular element in a dictionary?
(a) [ ]
(b) {}
(c) ( )
(d) < >
Answer:
(a) [ ]

Question 47.
What is a powerful feature in python assignment?
(a) Tuple Assignment
(b) List Assignment
(c) Pair Assignment
(d) Assignment statement
Answer:
(a) Tuple Assignment

Question 48.
Which key is separated by python dictionary?
(a) ,
(b) :
(c) ::
(d) .
Answer:
(b) :

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 49.
What is output?
>>> marks = [10, 23, 41, 75]
>>> print (marks[-l])
(a) 10
(b) 23
(c) 75
(d) 41
Answer:
(c) 75

Question 50.
The key value pair are enclosed with:
(a) [ ]
(b) { }
(c) ( )
(d) All of these
Answer:
(b) { }

Question 51.
What is the acronym of DBMS?
(a) DataBase Management Symbol
(b) Database Managing System
(c) DataBase Management System
(d) DataBasic Management System
Answer:
(c) DataBase Management System

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 52.
A table is known as:
(a) tuple
(b) attribute
(c) relation
(d) identity
Answer:
(c) relation

Question 53.
Which database model represents parent- child relationship?
(a) Relational
(b) Network
(c) Hierarchical
(d) Object
Answer:
(c) Hierarchical

Question 54.
Relational database model was first proposed by:
(a) E F Codd
(b) E E Codd
(c) E F Cadd
(d) E F Codder
Answer:
(a) E F Codd

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 55.
What type of relationship does hierarchical model represents?
(a) one-to-one
(b) one-to-many
(c) many-to-one
(d) many-to-many
Answer:
(b) one-to-many

Question 56.
Who is called Father of Relational Database from the following?
(a) Chris Date
(b) Hugh Darween
(c) Edgar Frank Codd
(d) Edgar Frank Cadd
Answer:
(c) Edgar Frank Codd

Question 57.
Which of the following is an RDBMS?
(a) Dbase
(b) Foxpro
(c) Microsoft Access
(d) SQLite
Answer:
(d) SQLite

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 58.
What symbol is used for SELECT statement?
(a) σ
(b) Π
(c) X
(d) Ω
Answer:
(a) σ

Question 59.
A tuple is also known as:
(a) table
(b) row
(c) attribute
(d) field
Answer:
(b) row

TN Board 12th Computer Science Important Questions Chapter 9 Lists, Tuples, Sets and Dictionary

Question 60.
Who developed ER model?
(a) Chen
(b) EF Codd
(c) Chend
(d) Chand
Answer:
(a) Chen

TN Board 12th Computer Science Important Questions