Finance Train
Menu

Python for Data Science / Quiz

Python Loops

Python Loops Quiz

5 questions

    1. Consider the following while loop:
    i = 0
    while i < 5 :
         print(i)
         i = i + 1
    

    How many prints will this while loop do?

    1. What will be the output of the following for loop?

    stocks = ['GOOG', 'AAPL'] for stock in stocks: stock print(stocks)

    1. What is the output of the following?

    i = 1 while True: if i%3 == 0: break print(i) i += 1

    1. What will be the output of the following code?

    data = [30, 40, 50, 70, 60] bigdata = [] for item in data: if item > 50: bigdata.append(item)

    print (bigdata)

    1. Which of the following methods is used to loop over a Python dictionary?
5 left