Tag: Python

  • Python Questions and Answers – Matrix List Comprehension

    Python Questions and Answers – Matrix List Comprehension

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Matrix List Comprehension”. Q 1. Which of the following matrices will throw an error in Python?A. A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B. B = [[3, 3, 3] [4, 4, 4] [5, 5, 5]] C. C = [(1, 2, 4), (5,…

  • Python Multiple Choice Questions – List Comprehension

    Python Multiple Choice Questions – List Comprehension

     Python Multiple Choice Questions & Answers (MCQs) focuses on “List Comprehension”. Q 1. What will be the output of the following Python code snippet? k = [print(i) for i in my_string if i not in “aeiou”] A. prints all characters of my_string that aren’t vowelsB. prints all the consonants in my_stringC. prints all the vowels…

  • Python Questions and Answers – Lists – 6

    Python Questions and Answers – Lists – 6

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Lists-6”. Python Multiple Choice Questions & Answers (MCQs) focuses on “Lists-6”. Q 1. What will be the output of the following Python code? a=[10,23,56,[78]] b=list(a) a[3][0]=95 a[1]=34 print(b) A. [10,34,56,[78]] B. [10,23,56,[95]] C. [10,23,56,[78]] D. [10,34,56,[95]] Show Answer Answer:-B. [10,23,56,[95]] Explanation The above copy is a…

  • Python Questions and Answers – Lists – 5

    Python Questions and Answers – Lists – 5

    Python Questions and Answers – Lists – 5 Python Question Paper focuses on “Lists”. Q 1. What will be the output of the following Python code? print(“Hello, World!”[7:]) values = [[3, 4, 5, 1], [33, 6, 1, 2]]   v = values[0][0] for lst in values: for element in lst: if v > element: v…

  • Python Questions and Answers – Lists – 4

    Python Questions and Answers – Lists – 4

    Python Programming Questions & Answers focuses on “Lists”. Q 1. What will be the output of the following Python code? def f(i, values = []): values.append(i) return values f(1)f(2)v = f(3)print(v) A. [1] [2] [3]B. [1] [1, 2] [1, 2, 3]C. [1, 2, 3]D. 1 2 3 Show Answer Answer:-C. [1, 2, 3] Explanation Execute in…

  • Python Questions and Answers – Lists – 3

    Python Questions and Answers – Lists – 3

    Python Programming Questions & Answers focuses on “Lists”. Q 1. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?A. [3, 4, 5, 20, 5, 25, 1, 3]B. [1, 3, 3, 4, 5, 5, 20, 25]C. [25, 20, 5, 5, 4, 3, 3, 1]D. [3, 1, 25, 5, 20,…

  • Python Multiple Choice Quizs Question– String

    Q 1. The output of executing string.ascii_letters can also be achieved by:A. string.ascii_lowercase_string.digitsB. string.lowercase_string.uppercaseC. string.lettersD. string.ascii_lowercase+string.ascii_uppercase Show Answer Answer:-D. string.ascii_lowercase+string.ascii_uppercase Explanation Execute in shell and check. Q 2 . What will be the output of the following Python code? A. ollehB. helloC. hD. o Show Answer Answer:-D. o Explanation 1 corresponds to the last index.…

  • Python Quizs Question and Answers – Formatting – 2

    Q 1. The output of which of the codes shown below will be: “There are 4 blue birds.”?A. ‘There are %g %d birds.’ %4 %blueB. ‘There are %d %s birds.’ %(4, blue)C. ‘There are %s %d birds.’ %[4, blue]D. ‘There are %d %s birds.’ 4, blue Show Answer Answer:-B. ‘There are %d %s birds.’ %(4,…

  • Python Quizs Question and Answers – Decorators

    Q 1. In the following Python code, which function is the decorator? def mk(x): def mk1(): print(“Decorated”) x() return mk1 def mk2(): print(“Ordinary”) p = mk(mk2) p() A. p()B. mk()C. mk1()D. mk2() Show Answer Answer:-B. mk() Explanation In the code shown above, the function mk() is the decorator. The function which is getting decorated is…

  • Python Quizs Question and Answers – Bitwise – 2

    Q 1. It is not possible for the two’s complement value to be equal to the original value in any case.A. TrueB. False Show Answer Answer:-B. False Explanation In most cases the value of two’s complement is different from the original value. However, there are cases in which the two’s complement value may be equal…

You cannot copy content of this page