Python Fundamentals

1.What is the output of: print(type(5))?
  • A. <class 'int'>
  • B. <type 'int'>
  • C. int
  • D. Integer

<class 'int'>

<class 'int'>

2.Which of the following is a valid variable name in Python?
  • A. 2var
  • B. var_2
  • C. var-2
  • D. var 2

var_2

var_2

3.What does the len() function do?
  • A. Returns last index
  • B. Returns first index
  • C. Returns number of items
  • D. Returns total memory used

Returns number of items

Returns number of items

4. Which of the following is used to define a block of code in Python?
  • A. Curly braces {}
  • B. Parentheses ()
  • C. Indentation
  • D. Square brackets []

Indentation

Indentation

5. What will be the output of print(3 * 'ab')?
  • A. abab
  • B. ab3
  • C. ababab
  • D. ab ab ab

ababab

ababab