Home > Articles > Open Source > Python

  • Print
  • + Share This
This chapter is from the book

Workshop

Quiz

  1. The print function is part of the Python standard library and is considered a built-in function. True or false?
  2. When is a variable created and assigned a data type?
  3. A(n) __________ sequence enables a Python statement to “escape” from its normal behavior.
  4. Which of the following is a valid Python escape sequence?

    1. //
    2. \'
    3. ESC
  5. Which Python escape sequence will insert a linefeed in output?
  6. A comment in a Python script should begin with which character?
  7. Which of the following is a valid Python data type?

    1. int
    2. input
    3. print
  8. Which function enables you to view a variable’s data type?
  9. If a variable is assigned the number 3.14, which data type will it be assigned?
  10. The input function is part of the Python standard library and is considered a built-in function. True or false?

Answers

  1. True. The print function is a built-in function of the standard library. There is no need to import it.
  2. A variable is created and assigned a data type when it is assigned a value. The value and data type for a variable can be changed with a reassignment.
  3. An escape sequence enables Python statement to “escape” from its normal behavior.
  4. b. \' is a valid Python escape sequence. Refer to Table 4.1 for a few valid Python escape sequences.
  5. The \n Python escape sequence will insert a linefeed in output.
  6. A comment in a Python script should begin with the pound or hash symbol (#) for the Python interpreter to ignore it.
  7. a. int is a Python data type. input and print are both Python functions. Refer to Table 4.2 for a refresher on the data types.
  8. The type function enables you to view a variable’s data type.
  9. If a variable is assigned the number 3.14, it will be assigned the float data type by Python. Refer to Table 4.2 for data types.
  10. True. The input function is a built-in function of the standard library. There is no need to import it.
  • + Share This
  • 🔖 Save To Your Account