πŸ“Š Problem Solving and Python Programming
Q. [0]} and {0[1]}".format(( 'foo', 'bin')))
  • (A) hello foo and bin
  • (B) hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
  • (C) error
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) hello foo and bin

Explanation: the elements of the tuple are accessed by their indices.

πŸ“Š Problem Solving and Python Programming
Q. , 10, 12))
  • (A) the sum of 2 and 10 is 12
  • (B) error
  • (C) the sum of 0 and 1 is 2
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) the sum of 2 and 10 is 12

Explanation: the arguments passed to the function format can be integers also.

πŸ“Š Problem Solving and Python Programming
Q. , 10, 12))
  • (A) the sum of 2 and 10 is 12
  • (B) the sum of 10 and a is 14
  • (C) the sum of 10 and a is c
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (B) the sum of 10 and a is 14

Explanation: 2 is converted to binary, 10 to hexadecimal and 12 to octal.

πŸ“Š Problem Solving and Python Programming
Q. Which of the following functions will not result in an error when no arguments are passed to it?
  • (A) min()
  • (B) divmod()
  • (C) all()
  • (D) float()
πŸ’¬ Discuss
βœ… Correct Answer: (D) float()

Explanation: the built-in functions min(), max(), divmod(), ord(), any(), all() etc throw an error when no arguments are passed to them. however there are some built-in functions like float(), complex() etc which do not throw an error when no arguments are passed to them. the output of float() is 0.0.

πŸ“Š Problem Solving and Python Programming
Q. Which of the following functions does not throw an error?
  • (A) ord()
  • (B) ord(‘ ‘)
  • (C) ord(”)
  • (D) ord(“”)
πŸ’¬ Discuss
βœ… Correct Answer: (B) ord(‘ ‘)

Explanation: the function ord() accepts a character. hence ord(), ord(”) and ord(“”)

πŸ“Š Problem Solving and Python Programming
Q. Which of the following is the use of function in python?
  • (A) functions are reusable pieces of programs
  • (B) functions don’t provide better modularity for your application
  • (C) you can’t also create your own functions
  • (D) all of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) functions are reusable pieces of programs

Explanation: functions are reusable pieces of programs. they allow you to give a name to a block of statements, allowing you to run that block using the specified name anywhere in your program and any number of times.

πŸ“Š Problem Solving and Python Programming
Q. printMax(3, 4)
  • (A) 3
  • (B) 4
  • (C) 4 is maximum
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) 4 is maximum

Explanation: here, we define a function called printmax that uses two parameters called a and b. we find out the greater number using a simple if..else statement and then print the bigger number.

πŸ“Š Problem Solving and Python Programming
Q. print(maximum(2, 3))
  • (A) 2
  • (B) 3
  • (C) the numbers are equal
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) 3

Explanation: the maximum function returns the maximum of the parameters, in this case the numbers supplied to the function. it uses a simple if..else statement to find the greater value and then returns that value.

πŸ“Š Problem Solving and Python Programming
Q. Which of the following is a feature of DocString?
  • (A) provide a convenient way of associating documentation with python modules, functions, classes, and methods
  • (B) all functions should have a docstring
  • (C) docstrings can be accessed by the doc attribute on objects
  • (D) all of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) all of the mentioned

Explanation: python has a nifty feature called documentation strings, usually referred to by its shorter name docstrings. docstrings

Jump to