Module quiz: Getting started with Python - Module 1

Module quiz: Getting started with Python - Module 1

  1. Python is a dynamically typed language. What does this mean?

    • Python supports both functional and object oriented programming.

    • Python does not require a type for a variable declaration. It automatically assigns the data type at run time.

    • Python requires you to explicitly set the correct data type and value before assigning a variable.

    • Python requires that you specify the type of variable before it being assigned.

  2. How do you create a block in Python?

    • A block is created using a colon following by a new line and indentation

    • A block is created by a new line

    • A block is created using a semi colon and a new line

    • A block is created using a semi colon and indentation

  3. When declaring variable in Python, can a variable name contain white space?

    • Yes

    • No

  4. How can a variable be deleted in python?

    • The remove keyword

    • A variable cannot be deleted

    • The def keyword

    • The del keyword

  5. In Python, how can you convert a number to a string?

    • enumerate()

    • float()

    • int()

    • str()

  6. An Integer - int in Python can be converted to type Float by using the float function?

    • True

    • False

  7. What is the purpose of break in a for loop in Python?

    • To terminate the code

    • The break keywork is used to debug a for loop.

    • The break statement will suspend the code until continue is run.

    • It controls the flow of the loop and stops the current loop from executing any further.

  8. An enumerate function is used to provide the index of the current iteration of a for loop.

    • True

    • False

  9. What will be the output of the code below:

     a = isinstance(str, "aa")
    
     print(a)
    
    • It will throw an error.

    • “aa”

    • False

    • True

  10. Select all the valid input() formats among the following.

    Select all that apply

    • input("")

    • input()

    • "" = input("My name is: " + name)

    • name = input("What is your name? ")