Q1. What will be the output of following code:
1 2 3 4 5 |
n = ["a", "b", "c"] for x in n: if x == "b": continue print(x, end=" ") |
- a b c
- a b
- a c
- a
Q2. What will be the output of following code:
1 2 3 4 5 6 7 |
def func(x, y=2, z=3): def in_fun(a, b): x = a+b return x return x+in_fun(y, z) print(func(3, 6)) |
- 18
- 12
- 9
- Error
Q3. What are the dunder(magic) methods in Python?
- Methods that start with single underscore.
- Methods that start with double underscore and ends with double underscore.
- Methods that start with double underscore.
- Methods that ends with single underscore.
Q4. Which of the following option gives the value of rating2 from the code?
1 2 3 4 5 6 7 8 9 10 11 |
dictionary = { "Company":{ "Employee":{ "name":"Virat", "Performance":{ "rating1":7/10, "rating2":8/10 } } } } |
- dictionary[“Company”][“Employee”][“Performance”][“rating2”]
- dictionary[“Company”][“Employee”][“Performance”][1]
- dictionary[“Company”][0][“Performance”][“rating2”]
- dictionary[0][“Employee”][“Performance”][“rating2”]
Q5. Which of the following are main component of JSON in Python?
- Arrays and Values
- DIctionary and Values
- Classes and Objects
- Keys and Values
Q6. Which of the following is not a correct statement regarding JSON in Python?
- Python has a built-in package called json, which can be used to work with JSON data.
- JSON is a syntax for storing and exchanging data.
- A Python object can be converted into JSON string using json.create()
- A Python object can be converted into JSON string using json.dumps()
Q7. Which of the following is not an iterable Object?
- List and tuples
- Int
- Set
- Dictionary
Q8. What will be the output of following code:
1 2 3 |
x={1,2,3,4} y={3,4,5,6} print(x^y) |
- {3, 4, 5, 6}
- {3, 4}
- {1, 2, 3, 4, 5, 6}
- {1, 2, 5, 6}