filmov
tv
Python Quiz 5: Continue Statement Quiz | Can you guess the output of this simple Python code?

Показать описание
In this video, we will learn how to use the range() function and the continue statement in Python. The range() function creates a sequence of numbers from 0 to one less than the specified value. The continue statement skips the current iteration of a loop and moves on to the next one. We will use these concepts to write a simple program that prints the numbers from 0 to 4, except for 3.
The code is as follows:
```python
for i in range(5):
if i == 3:
continue
print(i)
```
We start by using a for loop to iterate over the range(5) sequence, which gives us the values 0, 1, 2, 3 and 4. Inside the loop, we check if the current value of i is equal to 3 using an if statement. If it is, we use the continue statement to skip printing it and go back to the beginning of the loop. Otherwise, we print i using the print() function.
When we run this code, we get the following output:
```text
0
1
2
4
```
As you can see, we have successfully printed all the numbers from 0 to 4 except for 3. This is how we can use the range() function and the continue statement in Python.
If you enjoyed this video, please give it a thumbs up 👍and leave a comment 💬 below. Don't forget to subscribe 🔔to my channel for more Python tutorials like this one.
YouTube Playlists:
You can also follow me on:
Thanks for watching! 🙏**
#codingshorts #coding #codingshortvideo #pythonbasics #pythonprogramming #python #codinglife #pythontutorial #yasirbhutta
The code is as follows:
```python
for i in range(5):
if i == 3:
continue
print(i)
```
We start by using a for loop to iterate over the range(5) sequence, which gives us the values 0, 1, 2, 3 and 4. Inside the loop, we check if the current value of i is equal to 3 using an if statement. If it is, we use the continue statement to skip printing it and go back to the beginning of the loop. Otherwise, we print i using the print() function.
When we run this code, we get the following output:
```text
0
1
2
4
```
As you can see, we have successfully printed all the numbers from 0 to 4 except for 3. This is how we can use the range() function and the continue statement in Python.
If you enjoyed this video, please give it a thumbs up 👍and leave a comment 💬 below. Don't forget to subscribe 🔔to my channel for more Python tutorials like this one.
YouTube Playlists:
You can also follow me on:
Thanks for watching! 🙏**
#codingshorts #coding #codingshortvideo #pythonbasics #pythonprogramming #python #codinglife #pythontutorial #yasirbhutta