21. What will this iterative statement do?

for i in [0, 5]:

print(i)

  • Output the integer 0
  • Output the integers 0, 1, 2, 3, and 4
  • Output the integers 0 and 5
  • Output the integers 0, 1, 2, 3, 4, and 5

22. If you want to run a loop that repeats if a count variable is less than 50, what code should your loop header contain?

  • while count < 50:
  • while count == 50:
  • print(50)
  • count = count + 50

23. Fill in the blank: If you use Python code to reduce the manual effort needed to manage an access control list, this is an example of _____.

  • debugging
  • reassignment
  • automation
  • data analysis

24. The purpose of the following code is to print an "Attempting connection" message while the value of the count variable is less than 10. The value of count should increase by 1 with each iteration of the loop. What is wrong with the code? Select all that apply.

count = 1

while count < 10:

print("Attempting connection")

count = count + 1

  • The line with print(“Attempting connection”) is not indented.
  • The line with while count < 10: is not indented.
  • The line with count = count + 1 is not indented.
  • The line with count = 1 is not indented

25. Fill in the blank: String data _____.

  • must be placed in parentheses
  • must be placed in brackets
  • must be placed in quotation marks
  • must include a decimal point

26. Which data type always has a value of either True or False?

  • Boolean
  • Float
  • List
  • String

27. How do you assign the string value "rtp3426" to a variable called device_id?

  • device_id = “rtp3426”
  • device_id = rtp3426
  • device_id(rtp3426)
  • device_id(“rtp3426”)

28. Fill in the blank: If you ran the following code, the output would _____.

var1 = 9.5

var1_type = type(var1)

print(var1_type)

  • indicate that var1 contains float data
  • output 9.5 to the screen
  • reassign var1 as string data
  • reassign var1 as float data

Shuffle Q/A 3

29. You wrote the following code:

if attempts >= 5:

print("locked")

else:

print("try again")

If the value in the attempts variable is 3, what will Python do?

  • First output the message “try again” and then output the message “locked”
  • Output the message “locked”
  • Output the message “try again”
  • First output the message “locked” and then output the message “try again”

30. What iterative statement should you use if you want to print the numbers 1, 2, and 3?

  • for i in [1,3]:

    print(i)

  • for i in range(1,3):

    print(i)

  • for i in range(0,3):

    print(i)

  • for i in [1, 2, 3]:

    print(i)

Leave a Reply