πŸ“Š Problem Solving and Python Programming
Q. What are the two main types of functions?
  • (A) custom function
  • (B) built-in function & user defined function
  • (C) user function
  • (D) system function
πŸ’¬ Discuss
βœ… Correct Answer: (B) built-in function & user defined function

Explanation: built-in functions and user defined ones. the built-in functions are part of the python language. examples are: dir(), len() or abs(). the user defined functions are functions created with the def keyword.

πŸ“Š Problem Solving and Python Programming
Q. Where is function defined?
  • (A) module
  • (B) class
  • (C) another function
  • (D) all of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) all of the mentioned

Explanation: functions can be defined inside a module, a class or another function.

πŸ“Š Problem Solving and Python Programming
Q. Which of the following is the use of id() function in python?
  • (A) id returns the identity of the object
  • (B) every object doesn’t have a unique id
  • (C) all of the mentioned
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) id returns the identity of the object

Explanation: each object in python has a unique id. the id() function returns the object’s id.

πŸ“Š Problem Solving and Python Programming
Q. Which of the following refers to mathematical function?
  • (A) sqrt
  • (B) rhombus
  • (C) add
  • (D) rhombus
πŸ’¬ Discuss
βœ… Correct Answer: (A) sqrt

Explanation: functions that are always available for usage, functions that are contained within external modules, which must be imported and functions defined by a programmer with the def keyword.

πŸ“Š Problem Solving and Python Programming
Q. Python supports the creation of anonymous functions at runtime, using a construct called
  • (A) lambda
  • (B) pi
  • (C) anonymous
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) lambda

Explanation: python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called lambda. lambda functions are restricted to a single expression. they can be used wherever normal functions can be used.

πŸ“Š Problem Solving and Python Programming
Q. print z(8)
  • (A) 48
  • (B) 14
  • (C) 64
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) 48

Explanation: the lambda keyword creates an anonymous function. the x is a parameter, that is passed to the lambda function. the parameter is followed by a colon character.

πŸ“Š Problem Solving and Python Programming
Q. Does Lambda contains return statements?
  • (A) true
  • (B) false
  • (C) ---
  • (D) ---
πŸ’¬ Discuss
βœ… Correct Answer: (B) false

Explanation: lambda definition does not include a return statement. it always contains an expression which is returned. also note that we can put a lambda definition anywhere a function is expected. we don’t have to assign it to a variable at all.

πŸ“Š Problem Solving and Python Programming
Q. What is a variable defined outside a function referred to as?
  • (A) a static variable
  • (B) a global variable
  • (C) a local variable
  • (D) an automatic variable
πŸ’¬ Discuss
βœ… Correct Answer: (B) a global variable

Explanation: the value of a variable defined outside all function definitions is referred to as a global variable and can be used by multiple functions of the program.

Jump to