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

Explanation: the variable inside a function is called as local variable and the variable definition is confined only to that function.

πŸ“Š Problem Solving and Python Programming
Q. , i = 2)
  • (A) an exception is thrown because of conflicting values
  • (B) 1 2
  • (C) 3 3
  • (D) 3 2
πŸ’¬ Discuss
βœ… Correct Answer: (D) 3 2

Explanation: the values given during function call is taken into consideration, that is, i=2 and j=1.

πŸ“Š Problem Solving and Python Programming
Q. ,2,3,4)
  • (A) integer
  • (B) tuple
  • (C) dictionary
  • (D) an exception is thrown
πŸ’¬ Discuss
βœ… Correct Answer: (B) tuple

Explanation: the parameter two is a variable parameter and consists of (2,3,4). hence the data type is tuple.

πŸ“Š Problem Solving and Python Programming
Q. If a function doesn’t have a return statement, which of the following does the function return?
  • (A) int
  • (B) null
  • (C) none
  • (D) an exception is thrown without the return statement
πŸ’¬ Discuss
βœ… Correct Answer: (C) none

Explanation: a function can exist without a return statement and returns none if the function doesn’t have a return statement.

πŸ“Š Problem Solving and Python Programming
Q. What is the length of sys.argv?
  • (A) number of arguments
  • (B) number of arguments + 1
  • (C) number of arguments – 1
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) number of arguments + 1

Explanation: the first argument is the name of the program itself. therefore the length of sys.argv is one more than the number arguments.

πŸ“Š Problem Solving and Python Programming
Q. How many keyword arguments can be passed to a function in a single function call?
  • (A) zero
  • (B) one
  • (C) zero or more
  • (D) one or more
πŸ’¬ Discuss
βœ… Correct Answer: (C) zero or more

Explanation: zero keyword arguments may be passed if all the arguments have default values.

πŸ“Š Problem Solving and Python Programming
Q. ): print(foo(i))
  • (A) [0] [1] [2]
  • (B) [0] [0, 1] [0, 1, 2]
  • (C) [1] [2] [3]
  • (D) [1] [1, 2] [1, 2, 3]
πŸ’¬ Discuss
βœ… Correct Answer: (B) [0] [0, 1] [0, 1, 2]

Explanation: when a list is a default value, the same list will be reused.

Jump to