• Python question of the day

    What would be the output of executing the following code:
    sum = 0
    for i in range(5, 0, -2): sum += i > sum
    print(sum)
     1
     2
     3
     IndexError
    Explanation:
    range(5, 0, -2) will result in [5, 3, 1] and for 5 sum += i > sum will make sum 1 and for 3 sum += i > sum will make sum 2


    Top 100 python interview questions:


  • python bootcamp 2021
datai analytics