How to Iterate in Python

The while loop It allows you to repeat a set of actions until a statement is true. Eg: n = 5 while n > 0: print(n) n = n - 1 print('Blastoff!') This is executed as follows Creates and sets n to 5. Goes to the while statement and checks if n is greater than 0. Right now it’s true, so we move inside the loop. Prints n, ie outputs 5....

March 4, 2021 · 3 min · Harsh Kumar

Learning Python: Functions

What is a Function A function takes a set of inputs and produces an output. Eg: >>>type(32) <class 'init'> Here type is a function that takes 32 as an input and produces its class. Some Built-in functions max : gives the “largest character” in the string >>>max('Hello world') 'w' min : gives the “smallest character” in the string >>>min('Hello world') ' ' len : gives the number of characters in the string...

March 3, 2021 · 3 min · Harsh Kumar