

InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
1. |
Python supports the creation of anonymous functions at runtime, using a construct called __________(a) lambda(b) pi(c) anonymous(d) none of the mentionedI got this question during an internship interview.My question is from Function topic in portion Dictionary, Functions and Built-in Functions of Python |
Answer» The correct option is (a) LAMBDA |
|
2. |
The function pow(x,y,z) is evaluated as:(a) (x**y)**z(b) (x**y) / z(c) (x**y) % z(d) (x**y)*zThis question was posed to me by my school teacher while I was bunking the class.I would like to ask this question from Built-in Functions topic in section Dictionary, Functions and Built-in Functions of Python |
Answer» Correct OPTION is (c) (x**y) % z |
|
3. |
Which of the following functions is a built-in function in python?(a) seed()(b) sqrt()(c) factorial()(d) print()This question was posed to me during an online interview.This key question is from Built-in Functions topic in division Dictionary, Functions and Built-in Functions of Python |
Answer» RIGHT option is (d) print() Explanation: The function seed is a function which is PRESENT in the random MODULE. The functions sqrt and factorial are a part of the MATH module. The print function is a built-in function which prints a value directly to the system output. |
|
4. |
If b is a dictionary, what does any(b) do?(a) Returns True if any key of the dictionary is true(b) Returns False if dictionary is empty(c) Returns True if all keys of the dictionary are true(d) Method any() doesn’t exist for dictionaryThe question was asked in an interview.My query is from Dictionary in chapter Dictionary, Functions and Built-in Functions of Python |
Answer» RIGHT choice is (a) Returns True if any KEY of the dictionary is true The EXPLANATION is: Method any() returns True if any key of the dictionary is true and FALSE if the dictionary is empty. |
|
5. |
If a is a dictionary with some key-value pairs, what does a.popitem() do?(a) Removes an arbitrary element(b) Removes all the key-value pairs(c) Removes the key-value pair for the key given as an argument(d) Invalid method for dictionaryThe question was posed to me in an interview for job.My doubt is from Dictionary topic in section Dictionary, Functions and Built-in Functions of Python |
Answer» RIGHT option is (a) Removes an ARBITRARY element Explanation: The METHOD popitem() removes a random key-value PAIR. |
|
6. |
Which of the statements about dictionary values if false?(a) More than one key can have the same value(b) The values of the dictionary can be accessed as dict[key](c) Values of a dictionary must be unique(d) Values of a dictionary can be a mixture of letters and numbersI had been asked this question in exam.My query is from Dictionary in section Dictionary, Functions and Built-in Functions of Python |
Answer» The correct CHOICE is (c) Values of a DICTIONARY must be unique |
|
7. |
Which of the following isn’t true about dictionary keys?(a) More than one key isn’t allowed(b) Keys must be immutable(c) Keys must be integers(d) When duplicate keys encountered, the last assignment winsI have been asked this question in a job interview.My enquiry is from Dictionary topic in section Dictionary, Functions and Built-in Functions of Python |
Answer» CORRECT option is (c) Keys must be integers Easiest explanation - Keys of a DICTIONARY may be any DATA type that is IMMUTABLE. |
|
8. |
Which of the following is not a declaration of the dictionary?(a) {1: ‘A’, 2: ‘B’}(b) dict([[1,”A”],[2,”B”]])(c) {1,”A”,2”B”}(d) { }The question was asked in an online interview.Question is taken from Dictionary in portion Dictionary, Functions and Built-in Functions of Python |
Answer» The CORRECT CHOICE is (c) {1,”A”,2”B”} |
|
9. |
Which of these about a dictionary is false?(a) The values of a dictionary can be accessed using keys(b) The keys of a dictionary can be accessed using values(c) Dictionaries aren’t ordered(d) Dictionaries are mutableThe question was posed to me in final exam.The doubt is from Dictionary topic in division Dictionary, Functions and Built-in Functions of Python |
Answer» RIGHT CHOICE is (B) The keys of a DICTIONARY can be ACCESSED using values Best explanation: The values of a dictionary can be accessed using keys but the keys of a dictionary can’t be accessed using values. |
|
10. |
Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression d[“susan”]?(a) Since “susan” is not a value in the set, Python raises a KeyError exception(b) It is executed fine and no exception is raised, and it returns None(c) Since “susan” is not a key in the set, Python raises a KeyError exception(d) Since “susan” is not a key in the set, Python raises a syntax errorI had been asked this question during an online exam.My query is from Dictionary in chapter Dictionary, Functions and Built-in Functions of Python |
Answer» Correct CHOICE is (c) Since “SUSAN” is not a key in the set, Python RAISES a KeyError exception |
|
11. |
Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?(a) d.size()(b) len(d)(c) size(d)(d) d.len()I got this question by my school teacher while I was bunking the class.The question is from Dictionary topic in division Dictionary, Functions and Built-in Functions of Python |
Answer» The correct CHOICE is (b) LEN(d) |
|
12. |
Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?(a) d.delete(“john”:40)(b) d.delete(“john”)(c) del d[“john”](d) del d(“john”:40)This question was posed to me during an online exam.The above asked question is from Dictionary in chapter Dictionary, Functions and Built-in Functions of Python |
Answer» Right choice is (C) del d[“JOHN”] |
|
13. |
Which of the following statements create a dictionary?(a) d = {}(b) d = {“john”:40, “peter”:45}(c) d = {40:”john”, 45:”peter”}(d) All of the mentionedI had been asked this question by my school principal while I was bunking the class.Question is from Dictionary in division Dictionary, Functions and Built-in Functions of Python |
Answer» RIGHT answer is (d) All of the mentioned Explanation: DICTIONARIES are CREATED by specifying keys and VALUES. |
|