Python: Function

Examples Let’s start with a simple function definition and usage- Output: Required Parameters Output: Optional Parameters Output: Return Value We can return some value at any point of the function. The return value can be received by assigning the function call to a variable. WARNING The function immediately stops executing further, when it reaches a … Read more

Python: while Loop

In the “while” loop, we iteratively execute some code, based on certain conditions. Until the mentioned/decided condition is fulfilled, we will keep iterating. “while” loop is also called “indefinite loop” as it keeps running til some logical condition is reached. Output: Output:

Python: for Loop

Loop through range Case #1 Output: Case #2 Output: Loop through Tuple Output: Loop through Set Output: Loop through List items Case #1 Output: Case #2 We can enumerate a list and loop through it to get the key and value- Output: Case #3 Let’s see how we can find the largest number of a … Read more