#22 Python Tutorial for Beginners | Break Continue Pass in Python

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing about:
#1 break
#2 continue
#3 pass

In Python, break, continue, and pass are control flow statements that are used to
alter the normal flow of execution in a loop or conditional statement.

#1
break: The break statement is used to terminate a loop prematurely when a certain condition is met.
Once the break statement is encountered inside a loop, the loop is immediately terminated and the program continues
with the next statement after the loop.

for i in range(1, 6):
if i == 3:
break
print(i)

output:
1
2

#2
continue: The continue statement is used to skip the current iteration of a loop and move on to the next iteration,
without executing the remaining code in the loop for the current iteration.

for i in range(1, 6):
if i == 3:
continue
print(i)

output:
1
2
4
5

#3
pass: The pass statement is a placeholder statement that is used to indicate that no action should be taken. It is often used
as a placeholder when writing code that will be filled in later.

for i in range(1, 6):
if i == 3:
pass
else:
print(i)

output:
1
2
4
5

Editing Monitors :

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

My college life would be great if I had a professor like you in my college

Arjunsiva
Автор

i am experienced programmer so watching on 2x speed but for your bbye i slow down the your way of saying bbye is awesome

AmitKhuranaSir
Автор

I will complete my python within 1 week by your teaching sir.
I thank you very much sir for teaching this course.

jurrulokeshyadav
Автор

I had literally searched whole YouTube in search of a video that could explain me loops but I didn't get one. Then, I found this channel and finally I understood loops and even make programs using while and for loops.
Thank you Navin sir :)

rraushan
Автор

av=6
x=int(input('how many candies do you want'))
for i in range(0, x):
if i<av:
print('candy')

rajtiwari
Автор

You are a really great man.... I learned from you and practise some programs and i did it... First time in my life i can create the logic..🙌🙌🙌

divyanshusingh
Автор

To check if a given number is prime or not:

i=2
p = int(input("Enter a number:"))
while i<p:
if (p%i!=0):
pass
else:
print(p, "is not a Prime number")
break
i+=1
if (i==p):
print(p, "is a Prime number")

akarshasudheer
Автор

When you will start with "Machine Learning"? It's going to be awesome if you teach us.

flamboyantperson
Автор

Teaching is an art. You've got it man👍 very logical progression for beginners.

stmpcol
Автор

I had just started your python tutorial and it was the best. One request is that at last please also show how to make games and software in python.

tirthshah
Автор

#fibonacci
list1 = [0, 1]
for i in range(48):

print('bye')
print(list1)

DevendraSingh-xtwn
Автор

Break : to end the loop. It uses with if statement to put a condition so you can break the loop and exit.

Continue : to skip the remaining code of the loop when a certain condition happen (like in if statement), but still looping.

Pass: uses for impty blocks when you don't have a code to write.

Ihsan_almohsin
Автор

x=int(input("Enter a no."))
s=0
i=1
while(i<=x):
if x%i==0:
s+=1
i+=1

if s==2:
print("Prime no")
else:
print("Not prime")

BhuveshDhiman
Автор

Great course! The answer beneath looks correct to find out if a number is prime.
x=int(input("is this number prime?"))
for i in range (2, x):
if x%i==0:
print (x, " is not prime")
break
else :
print (x, "is prime")
break

touristknud
Автор

For the first one:

a = 1
b = 1
for i in range(50):
print(a)
print(b)
a = a + b
b = b + a

talhaordukaya
Автор

2)prime numbers between 1-50


for x in range(1, 50):
for i in range(2, x):
if x % i == 0:
pass
break
else:
print(x)

Chiranjeevi-xqqy
Автор

2.
a=int(input("enter a integer"))
count=0
for i in range(1, a+1):
if(a%i==0):
count=count+1

if count==2:
print(a)

rohithsardar
Автор

I have never heard a explanation about loop... Brilliant explanation 👌... Thanks a lot sir.

selvib
Автор

fibonacci solution
a = [0, 1]
for i in range(0, 49):
b = a[-1]+a[-2]
a.append(b)
print(a)

sainikhila
Автор

a, b=0, 1
for i in range(0, 51, 1):

print(a, end=' ')
a, b=b, a+b

alirezafahama