Posts

Showing posts with the label loop

Break & Continue In Python

Image
  Code Example # Break n = input("Enter Break Number [1-10] : ") print(type(n)) n = int(n) print(type(n)) for i in range(1, 11, 1):     print(i)     if i == n:         break     else:         pass Output: Enter Break Number [1-10] : 7 <class 'str'> <class 'int'> 1 2 3 4 5 6 7 # Continue n = input("Enter Skip Number [1-10] : ") print(type(n)) n = int(n) print(type(n)) for i in range(1, 11, 1):     if i == n:         continue     print(i) Output: Enter Skip Number [1-10] : 4 <class 'str'> <class 'int'> 1 2 3 5 6 7 8 9 10 Enjoy Edge-cutting Technology 😉 Quiz Level 1 Quiz Level 2 Request Me

Python Loop & range() Function

Image
  Concept The function  range()  can take 1 to 3 of the following arguments. i)   Start ii)  End iii) Step range(start, stop, step) Note: The Default value of start is Zero always. End value user need to be mention The Default value for step is 1 always Code Example ------------------------------------------------------- For Loop ----------------------------------------------------- Example 1: for i in range(1, 6, 1):     print(i) Output:  1 2 3 4 5   Example 2: for i in range(1, 51, 10):     print(i) Output:  1 11 21 31 41   Example 3: for i in range(6):     print(i) Output:  0 1 2 3 4 5   Example 4: for i in range(50, 0, -10):     print(i) Output: 50 40 30 20 10 ------------------------------------------------------- While Loop ----------------------------------------------------- Example 1: >>> while count < limit: print(count) count += 1 O...