The Ultimate Python Programming MCQ Test

63 Questions | Total Attempts: 1902

SettingsSettingsSettings
The Ultimate Python Programming MCQ Test - Quiz

Python, you must know about this if you are related to Programming in any way. Here is the ultimate Python programming MCQ test for you that we have brought. Python is a high-level, interpreted, general-purpose programming language. The design philosophy of Python emphasizes code readability using significant indentation. Python is dynamically-typed as well as garbage-collected. Let's test your knowledge with these questions. We wish you the best of luck with this quiz.


Questions and Answers
  • 1. 
    In Python, strings are…
    • A. 

      Str objects

    • B. 

      Char arrays

    • C. 

      Changeable

    • D. 

      None

  • 2. 
    The minsplit parameter to split() specifies the minimum number of splits to make to the input string.
    • A. 

      False

    • B. 

      True

  • 3. 
    Python strings have a property called “immutability." What does this mean?
    • A. 

      You can update a string in Python with concatenation.

    • B. 

      Strings in Python can be represented as arrays of char.

    • C. 

      Strings can’t be divided by numbers.

    • D. 

      Strings in Python can’t be changed.

  • 4. 
    If you want to transform a list of strings input_list into a single string with a comma between each item, which of the following would you give as the input to join()?
    • A. 

      ','

    • B. 

      Input_list

    • C. 

      Str

    • D. 

      String

  • 5. 
    Which of the following mathematical operators can be used to concatenate strings:
    • A. 

      /

    • B. 

      *

    • C. 

      -

    • D. 

      =

  • 6. 
    Assume x and y are assigned as follows: x=5, y=-5. What is the effect of this statement: x, y = (y, x)[::-1]
    • A. 

      Both x and y are 5

    • B. 

      The values of x and y are swapped.

    • C. 

      The values of x and y are unchanged.

    • D. 

      Both x and y are -5

  • 7. 
    In regards to separated value files such as .csv and .tsv, what is the delimiter?
    • A. 

      Any character such as the comma (,) or tab (\t) that is used to separate the raw data

    • B. 

      Delimiters are not used in separated value files.

    • C. 

      Anywhere the comma (,) character is used in the file.

    • D. 

      Any character such as the comma (,) or tab (\t) that is used to separate the column data

  • 8. 
    In separated value files such as .csv and .tsv what does the first row in the file typically contain?
    • A. 

      The author of the table data

    • B. 

      The column names of the data

    • C. 

      The source of the data

    • D. 

      Notes about the table data

  • 9. 
    Consider this assignment statement: a,b,c = (1,2,3,4,5,6,7,8,9)[1::3]. Following execution of this statement, what is the value of b:
    • A. 

      2

    • B. 

      4

    • C. 

      5

    • D. 

      6

  • 10. 
    Which of the following is the correct way to open the CSV file hrdata.csv for reading using the pandas package? Assume that the pandas package has already been imported.
    • A. 

      Pandas.read_csv('hrdata.csv')

    • B. 

      Pandas.open('hrdata.csv', 'r')

    • C. 

      Pandas.read_table('hrdata.csv')

    • D. 

      Pandas.open_csv('hrdata.csv', 'r')

  • 11. 
    . What is a correct syntax to output “Hello World” in Python?
    • A. 

      P("Hello, World")

    • B. 

      Echo "Hello, World"

    • C. 

      Echo ("Hello, World")

    • D. 

      Print("Hello, World")

  • 12. 
    How do you insert COMMENTS in Python code?
    • A. 

      <--this is a comment-->

    • B. 

      /*this is a comment*/

    • C. 

      #this is a comment

    • D. 

      //this is a comment//

  • 13. 
    Which collection is ordered, changeable, and allows duplicate members?
    • A. 

      TUPLE

    • B. 

      SET

    • C. 

      LIST

    • D. 

      DICTIONARY

  • 14. 
    1. Which of the following are true about python lists?
    • A. 

       These represent the same list: ['a', 'b', 'c'] ['c', 'a', 'b']

    • B. 

      All elements in a list must be of the same type 

    • C. 

      A given object may appear in a list more than once

    • D. 

      There is no conceptual limit to the size of a list

  • 15. 
    1. Assume the following list definition:
    >>> a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge'] Several short REPL sessions are shown below. Which display correct output?
    • A. 

      · >>> print(a[4::-2]) ['quux', 'baz', 'foo']  

    • B. 

      · >>> a[:] is a True

    • C. 

      · >>> print(a[-5:-3]) ['bar', 'baz']

    • D. 

      · >>> max(a[2:4] + ['grault']) 'qux'

    • E. 

      · >>> print(a[-6]) Traceback (most recent call last):   File "<stdin>", line 1, in <module> IndexError: list index out of range

  • 16. 
    A collection which is unordered, changeable and does not allow duplicates.
    • A. 

      TUPLE

    • B. 

      SET

    • C. 

      LIST

    • D. 

      DICTIONARY

  • 17. 
    A collection which is ordered and unchangeable.
    • A. 

      TUPLE

    • B. 

      SET

    • C. 

      LIST

    • D. 

      DICTIONARY

  • 18. 
    How do you start writing a while loop in Python?
    • A. 

      While x > y:

    • B. 

      While (x > y)

    • C. 

      X > y while {

    • D. 

      While x>y {

  • 19. 
    Select the ones you like List a is defined as follows: a = [1, 2, 3, 4, 5] Select all of the following statements that remove the middle element 3 from a so that it equals [1, 2, 4, 5]:
    • A. 

      A[2]=[ ]

    • B. 

      A[2:3]=[ ]

    • C. 

      A.remove(3)

    • D. 

      A[2:2]=[ ]

    • E. 

      Del a[2]

  • 20. 
    Which statement is used to stop a loop?
    • A. 

      Break

    • B. 

      Exit

    • C. 

      Return

    • D. 

      Stop

  • 21. 
    List a is defined as follows: a = ['a', 'b', 'c'] Which of the following statements adds 'd' and 'e' to the end of a, so that it then equals ['a', 'b', 'c', 'd', 'e']:
    • A. 

      A.extend(['d','e'])

    • B. 

      A.append(['d','e'])

    • C. 

      A += ['d','e']

    • D. 

      A[len(a):] = ['d','e']

    • E. 

      A +=  'de'

    • F. 

      A[-1:] =  ['d','e']

  • 22. 
    Updates the dictionary with the specified key-value pairs
    • A. 

      Clear()

    • B. 

      Copy()

    • C. 

      Fromkeys()

    • D. 

      Update()

    • E. 

      Items()

  • 23. 
    Returns a list of all the values in the dictionary
    • A. 

      Clear()

    • B. 

      Copy()

    • C. 

      Fromkeys()

    • D. 

      Values()

    • E. 

      Items()

  • 24. 
    List is:
    • A. 

      Is a collection which is ordered and unchangeable. Allows duplicate members.

    • B. 

      Is a collection which is ordered and changeable. Allows duplicate members.

    • C. 

      Is a collection which is unordered and unindexed. No duplicate members.

    • D. 

      Is a collection which is unordered and changeable. No duplicate members.

  • 25. 
    Tuple is
    • A. 

      Is a collection which is ordered and unchangeable. Allows duplicate members.

    • B. 

      Is a collection which is ordered and changeable. Allows duplicate members.

    • C. 

      Is a collection which is unordered and unindexed. No duplicate members.

    • D. 

      Is a collection which is unordered and changeable. No duplicate members.

Related Topics
Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.