Python Programming Quiz

Python Programming

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is the modulo operator?

  1. *
  2. %
  3. \
  4. #
Question 2 Multiple Choice (Single Answer)

How would you call the sqrt function from the math module using a generic import?

  1. sqrt(16)
  2. module.sqrt(16)
  3. call.sqrt(16)
  4. math.sqrt(16)
Question 3 Multiple Choice (Single Answer)

What would this function output? def value(a, b): return a[:b] print value("Notebook",5)

  1. ook
  2. Noteb
  3. book
  4. noteb
Question 4 Multiple Choice (Single Answer)

What is this equal to? min(343, 74, 334, 93)

  1. 334
  2. 93
  3. 74
  4. 343
Question 5 Multiple Choice (Single Answer)

What are functions?

  1. Code that can only be used once in the application
  2. Reusable pieces of code that can be called on repeatedly.
  3. A special type of variable
  4. Indefinite arrays
Question 6 Multiple Choice (Single Answer)

What is the expression after an if statement always followed by? A...

  1. semicolon and curly braces
  2. semicolon and four white spaces on the next code block
  3. colon and four spaces of white space on the next code block
  4. colon and two spaces of white space on the next code block
Question 7 Multiple Choice (Single Answer)

Which of the following statements is true?

  1. True and False
  2. False and 5 <= 2 ** 3
  3. 10 ** 2 > 8 % 1 + 95 and 5 % 3 != 5 / 3
  4. True and 5 – (10 % 3) <= (2 - 3) * 5
Question 8 Multiple Choice (Single Answer)

In Python, what data type do comparisons generate?

  1. Integers
  2. Floats
  3. Numbers
  4. Booleans
Question 9 Multiple Choice (Single Answer)

Which of the following is true?

  1. 5*5 > 4+3
  2. 6-5 < 3-6
  3. 49 >= 313
  4. 42 >= 4*10
Question 10 Multiple Choice (Single Answer)

What correctly imports the datetime library?

  1. import datetime from datetime
  2. import from datetime
  3. from datetime import datetime
  4. import datetime
Question 11 Multiple Choice (Single Answer)

If my_variable = "food", what is the data type of my_variable?

  1. Integer
  2. Word
  3. String
  4. Boolean
Question 12 Multiple Choice (Single Answer)

What is a correct way of printing the "T" in the string "PYTHON"?

  1. Print "PYTHON"[2]
  2. Print "PYTHON"(2)
  3. Print "PYTHON"[3]
  4. Print "PYTHON"(3)
Question 13 Multiple Choice (Single Answer)

Which of the following is the exponent operator?

  1. $
  2. ^
  3. **
  4. %
Question 14 Multiple Choice (Single Answer)

What is this variable equal to: addition = 72 + 23

  1. 85
  2. 96
  3. 95
  4. 97
Question 15 Multiple Choice (Single Answer)

What is the correct syntax for a multiline comment?

  1. """This is a multiline comment""""
  2. #This is a multiline comment""
  3. <!--This is a multiline comment-->""
  4. //This is a multiline comment//"