Python Quiz For Beginners
1) What is the Output of the following code? for x in range(0.5, 5.5, 0.5): print(x)
We cannot use the float numbers in range() function. Please refer to the following articles *Python range() function *How to generate a range of float numbers
2) Can we use the "else" clause for loops? for Example: for i in range(1, 5): print(i) else: print("this is else block statement" )
We can use the else block after the end of for/while loop. The else block is used to check the successful execution of a loop. If the loop executed successfully without any issues, the else block executes.