November 1, 2022

In programming, while loop keeps running the statements (code) as long as the given condition is true. To start, it checks the condition. Then, it moves on to follow the steps Inside the while loop, we can make as many statements as we want to make. If we want, the situation could be any way…

October 31, 2022

A for loop is used to repeat a code over lists, data types, dictionaries, sets, or even strings. The for loop will go into the specified list and run the code for each item on the list. Example: In this example, we are going to use a for loop to print Hello world! 5 times…

October 30, 2022

A nested loop is a loop that is programmed inside another loop. We can nest any type of loop inside any type of loop. That is, we can put a while loop in a for loop, a for loop inside a while loop, a while loop inside a while loop, or a for loop inside…

October 29, 2022

As explained in the program above, we use the break statement to stop the execution of the loop and bring the control out of the loop. Let us use the break statement in another loop now: Example: Create a list of the odd numbers between 1 and 20 (use while, break) In this code, if…

October 28, 2022

A continue statement is used to skip one repetition or loop when the condition is met. That allows the loop to run the next loop instead. It is like saying skip this code, on to the next loop. This statement does not bring the control out of the loop like the break statement. Let us…

October 27, 2022

We use the pass statement when we want the loop to wait or do nothing when the condition is met. This statement will not skip or stop the loop, it is like telling Python to “pass” on that code. Programmers use this statement when they don’t know or have the value to set a condition…

October 26, 2022

Today, the Python programming language is one of the most popular. When we write Python code for Production-Level Data Science Projects, our code grows in size, and as a result, most likely, it gets messy over time. In other words, if you keep your code in the same file as it grows, this makes it…

October 25, 2022

If we want to build a module, we need to save the script we want in a “.py” file. In this case, the name of the Python file is changed to become the name of the module. For Example, In this example, we will first create a function called “welcome” and save it as a…

October 24, 2022

All kinds of variables can be stored in a module, including arrays and dictionaries. Functions can also be stored in a module. For Example, Open the newmodule.py file and write this code in it and save the file: Now let us import the module again and try to access the person1 dictionary: Output: Hello, Tobby…

October 23, 2022

Python’s interactive shell comes with a lot of built-in functions, so we already know that. Because they’re part of the shell, functions like these are always ready to use: print () and input () for I/O (input/output), functions for converting numbers like int (), float (), complex (), functions for converting data types such as…

Python Tutorials