21. What Python code instructs the computer to loop through values from 100 to 500?

  • for x in range(100, 501):
  • for x in range(100, 500):
  • for x in range(101, 501):
  • for x in range(101, 500):

22. A data professional wants to set up a for loop. They write the following code: for x in range(100, 501, 20): . What is the step value of the range() function?

  • 20
  • 500
  • 100
  • 501

23. Fill in the blank: In Python, the index() method interprets a string as a _____.

  • boolean
  • substring
  • sequence of characters
  • string slice

24. A data professional assigns the string 'spinach and asparagus' to the variable vegetables. What code can they use to find the index of the character 'c'?

  • spinach.index(‘c’)
  • index.vegetables(‘c’)
  • vegetables.index(‘c’)
  • index.spinach(‘c’)

25. A data professional assigns the string 'football' to the variable sport. What Python code will return the slice 'ball'?

  • sport[ :4]
  • sport[1:4]
  • sport[4: ]
  • sport[-1]

26. What type of loop can a data professional use to repeat a specific block of code until a condition is met?

  • if loop
  • for loop
  • else loop
  • while loop

27. What Python code can a data professional use to concatenate the strings 'jelly' and 'fish'?

  • ‘jelly’ + ‘fish’
  • ‘jelly’ < ‘fish’
  • ‘jelly’ > ‘fish’
  • ‘jelly’ == ‘fish’

28. In Python, what method works by interpreting a string as a sequence of characters, where each character has a numbered slot?

  • format()
  • range()
  • type()
  • index()

29. Fill in the blank: A data professional can use the format() method to insert specific _____ in a larger string.

  • substrings
  • for loops
  • while loops
  • libraries

30. A data professional wants to set up a for loop. They write the following code: for x in range(0, 26, 5): . What is the step value of the range() function?

  • 25
  • 26
  • 0
  • 5

31. What Python code can a data professional use to concatenate the strings 'brain' and 'storm'?

  • ‘brain’ % ‘storm’
  • ‘brain’ != ‘storm’
  • ‘brain’ == ‘storm’
  • ‘brain’ + ‘storm’

Leave a Reply