• 20 hours
  • Medium

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 4/27/23

Optimize your code with the control flows

Evaluated skills

  • Optimize your code with the control flows
  • Question 1

    Select the true statements about for-in   loops:

    Careful, there are several correct answers.
    • It allows us to repeat a block of code for a specified number of times  

    • It allows us to repeat a block of code for an unpredictable number of times

       

    • It has the following syntax:

      for i in 1 ..< 5:
      print ("Hello!")

       

    • It has the following syntax:

      for i in 1 ... 5 {
      print ("Hello!")
      }

       

  • Question 2

    How many times will the phrase "How are you?" be printed in the following example:

    for i in 0 ..< 5 {
    print ("How are you?")
    }

     

    • 3 times

       

    • 4 times

       

    • 5 times

    • 6 times

  • Question 3

    What will be the final value of  x   after the following code is executed?

    var x = 3
    x += 5
    x /= 4
    x *= 12
    • 0

       

    • 12

       

    • 24

    • 36

Ever considered an OpenClassrooms diploma?
  • Up to 100% of your training program funded
  • Flexible start date
  • Career-focused projects
  • Individual mentoring
Find the training program and funding option that suits you best