quiz day 2

DAY 2

select the correct option
  1. what part of an if statement should be indented?

  2. All of it
    The first line
    The statement within it
    indentation is not require

  3. which statement ends the current iteration and continues with the next one?

  4. break
    for
    continue
    while

  5. what is the result of this code??
    >>>nums=list(range(5))

    >>print(nums(4))

  6. 4
    1,2,3,4,5
    5
    0,1,2,3,4

  7. What is the output of the following code?
    >>>while 4 == 4:
           print('4')

  8. 4 is printed once
    4 is printed four times
    4 is printed infinitely until program closes
    Syntax error

  9. What is the output of the following code?
    >>>if None:
           print(“Hello”)

  10. Nothing will be printed
    Hello
    hello
    Syntax Eror

  11. In Python, for and while loop can have optional else statement?

  12. Only for loop can have optional else statement
    Only while loop can have optional else statement
    Both loops can have optional else statement
    Loops cannot have else statement in Python

  13. What is the output of the following code?
    i = sum = 0
    while i <= 4:
             sum += i
             i = i+1
    print(i)

  14. None of the above
    10
    0
    4

  15. Is it better to use for loop instead of while if you are iterating through a sequence ?

  16. No, it’s better to use while loop.
    Yes, for loop is more pythonic choice.
    No, you cannot iterate through a sequence using loops.
    No, you cannot iterate through a sequence using while loop.

  17. Which of the following statement is true about the pass statement?

  18. The Python interpreter ignores the pass statement like comments.
    It is used as a placeholder for future implementation of functions, loops etc
    The pass statement terminates the loop containing it.
    All of the above.

  19. A __________ -controlled loop uses a true/false condition to control the number of times that it r

  20. Condition
    count
    Boolean
    decision

Thanks for your valuable time..

Popular posts from this blog

BIG DATA

C plus plus notes