google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 class 11 chapter 10 tuples and dictionaries in python mcq - 2nd puc computer science

class 11 chapter 10 tuples and dictionaries in python mcq

class 11 computer chapter 10 mcq,tuples and dictionaries in python class 11 mcq,tuples mcq class 11,class 11 computer science dictionary mcq,tuple mcq in python,mcq on tuples in python,mcq on tuples in python class 11,Mcq on tuples in python class 11 with answers,Mcq on tuples in python class 11 with answers pdf,Mcq on tuples in python class 11 pdf,Mcq on tuples in python class 11 pdf download,Dictionary MCQ in Python Class 11,MCQ on dictionary in Python,Dictionary mcq in python class 11 with answers,Dictionary mcq in python class 11 with answers pdf,Dictionary mcq in python class 11 pdf,Dictionary mcq in python class 11 pdf download

1. What is a tuple in Python?





ANSWER= A) An immutable ordered sequence of elements of different data types

2. How are elements of a tuple accessed?





ANSWER= B) Using indexing and slicing

3. What will be the output of the following code? Python Code: tuple1 = (2, 4, 6, 8, 10) print(tuple1[3])





ANSWER= B) 8

4. What is the result of trying to change an element in a tuple?





ANSWER= B) It raises a TypeError

5. How can you create a tuple with a single element?





ANSWER= A) `(element,)`

6. What is the correct way to create an empty tuple?





ANSWER= C) `tuple = ()`

7. Which method is used to concatenate two tuples?





ANSWER= A) `+`

8. What will be the output of the following code? Python Code: tuple1 = (1, 3, 5) tuple2 = (2, 4, 6) print(tuple1 + tuple2)





ANSWER= A) `(1, 3, 5, 2, 4, 6)`

9. What operator is used to repeat elements of a tuple?





ANSWER= B) `*`

10. How can you check if an element is present in a tuple?





ANSWER= A) Using the `in` operator

11. What will be the output of the following code? Python Code: tuple1 = ('Hello',) * 3 print(tuple1)





ANSWER= A) `('Hello', 'Hello', 'Hello')`

12. Which function returns the length of a tuple?





ANSWER= A) `len()`

13. Which method returns the number of times an element appears in a tuple?





ANSWER= C) `count()`

14. How do you create a tuple from a list?





ANSWER= B) `tuple(list)`

15. What is the result of the following operation? Python Code: tuple1 = (1, 2, 3) tuple2 = (4, 5, 6) result = tuple1 * 2 + tuple2 print(result)





ANSWER= A) `(1, 2, 3, 1, 2, 3, 4, 5, 6)`

16. What will be the output of the following slicing operation? Python Code: tuple1 = (10, 20, 30, 40, 50, 60, 70, 80) print(tuple1[2:5])





ANSWER= B) `(30, 40, 50)`

17. Which function returns a tuple?





ANSWER= D) `tuple()`

18. What will be the output of the following code? Python Code: tuple1 = (1, 2, 3, 4, 5) print(tuple1[-1])





ANSWER= C) `5`

19. How can you iterate through a tuple?





ANSWER= D) All of the above

20. What is the purpose of the `index()` method in tuples?





ANSWER= B) To find the position of the first occurrence of an element

21. Which method returns the index of the first occurrence of an element in a tuple?





ANSWER= C) `index()`

22. How can you reverse a tuple?





ANSWER= B) Using slicing with a step of -1

23. What is the result of the following slicing operation? Python Code: tuple1 = (1, 2, 3, 4, 5, 6, 7, 8) print(tuple1[::2])





ANSWER= B) `(1, 3, 5, 7)`

24. Which operator is used to check if an element is not present in a tuple?





ANSWER= B) `not in`

25. What will be the output of the following code? Python Code: tuple1 = ('Red', 'Green', 'Blue') print('Yellow' in tuple1)





ANSWER= B) `False`

26. How do you create a tuple with the numbers 1 to 5?





ANSWER= A) `tuple(range(1, 6))`

27. What is the output of the following code? Python Code: tuple1 = (1, 2, (3, 4), 5) print(tuple1[2])





ANSWER= A) `(3, 4)`

28. What is the correct way to concatenate two tuples?





ANSWER= B) `tuple1 + tuple2`

29. What will be the output of the following code? Python Code: tuple1 = ('a', 'b', 'c', 'd') print(tuple1[:2])





ANSWER= A) `('a', 'b')`

30. What is the output of the following code? Python Code: tuple1 = ('x', 'y', 'z') tuple2 = ('a', 'b') tuple3 = tuple1 + tuple2 print(len(tuple3))





ANSWER= B) `5`

31. What is a dictionary in Python?





ANSWER= B) An unordered collection of key-value pairs

32. How are elements in a dictionary accessed?





ANSWER= B) Using keys

33. Which of the following is the correct syntax for creating a dictionary?





ANSWER= A) `{key1: value1, key2: value2}`

34. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} print(dict1['b'])





ANSWER= B) `2`

35. How can you add an element to a dictionary?





ANSWER= B) `dict1[key] = value`

36. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} dict1['d'] = 4 print(dict1)





ANSWER= A) `{'a': 1, 'b': 2, 'c': 3, 'd': 4}`

37. How can you remove an element from a dictionary?





ANSWER= D) Both a and c

38. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} del dict1['b'] print(dict1)





ANSWER= B) `{'a': 1, 'c': 3}`

39. How can you access all keys in a dictionary?





ANSWER= A) `dict1.keys()`

40. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} keys = list(dict1.keys()) print(keys)





ANSWER= A) `['a', 'b', 'c']`

41. How can you access all values in a dictionary?





ANSWER= B) `dict1.values()`

42. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} values = list(dict1.values()) print(values)





ANSWER= B) `[1, 2, 3]`

43. How can you access all key-value pairs in a dictionary?





ANSWER= C) `dict1.items()`

44. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} items = list(dict1.items()) print(items)





ANSWER= D) `[('a', 1), ('b', 2), ('c', 3)]`

45. How can you check if a key exists in a dictionary?





ANSWER= A) `key in dict1`

46. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2, 'c': 3} print('b' in dict1)





ANSWER= A) `True`

47. How can you update a dictionary with another dictionary?





ANSWER= B) `dict1.update(dict2)`

48. What will be the output of the following code? Python Code: dict1 = {'a': 1, 'b': 2} dict2 = {'b': 3, 'c': 4} dict1.update(dict2) print(dict1)

     A) 



ANSWER= B) `{'a': 1, 'b': 3, 'c': 4}`

1st puc computer science chapter 10 tuples and dictionaries mcq
class 11 chapter 10 tuples and dictionaries in python mcq class 11 chapter 10 tuples and dictionaries in python mcq Reviewed by Vision Academy on September 25, 2024 Rating: 5

No comments:

CheckOut

Powered by Blogger.