While Loops in Python | Python Tutorial - Day #18
ฝัง
- เผยแพร่เมื่อ 5 ก.พ. 2025
- Python is one of the most demanded programming languages in the job market. Surprisingly, it is equally easy to learn and master Python. This python tutorial for absolute beginners in Hindi series will focus on teaching you python concepts from the ground up.
Access the Playlist: • Python for Beginners (...
Link to the Repl: replit.com/@co...
Join Replit the browser-based IDE used in this course - join.replit.co...
►Checkout my English channel here: / @programmingwithharry
►Instagram: codewithharry
python, C, C++, Java, JavaScript and Other Cheetsheets [++]:
Playlist: • Coding CheatSheets 🧾 b...
►Learn in One Video[++]:
Python[15 Hr]: • Python Tutorial For Be...
Python Advance[3.5 Hr]: • Python Programming Cou...
Python[1 Hr]: • Learn Python In Hindi ...
Python[2 Hr]: • Python Tutorial In Hin...
Python[15 Min]: • 15 Minute Python Tutor...
JavaScript[1 Hr]: • JavaScript Tutorial
C[1.3 Hr]- • C Programming Tutorial...
php[1 Hr]: • Learn Php In One Video...
php[2.3 Hr]: • Php Tutorial for Begin...
php[Project]- • Login And Registration...
HTML[30 Min]: • HTML 5 Tutorial For Be...
CSS[8.5 Hr]: • CSS Tutorial In Hindi ...
CSS[1.4 Hr]: • CSS 3 Tutorial For Beg...
Wordpress[3.2 Hr]: • How To Make a WordPres...
Angular[2 Hr]: • Angular Tutorial in Hindi
Java[2.3 Hr]: • Java tutorial in hindi 🔥
Web Scraping[1 Hr]: • Web Scraping Tutorial ...
MongoDB[2 Hr]: • MongoDb Tutorial For B...
Numpy[1 Hr]: • Numpy Tutorial in Hindi
Android Dev[12 Hr]- • Android Development Tu...
Linux[1 Hr]: • Linux Tutorial For Beg...
JQuery[1.1 Hr]: • jQuery Tutorial For Be...
Git and GitHub[1.1 Hr]: • Git & GitHub Tutorial ...
►Complete course [playlist]:
React: • React Js Tutorials in ...
Python- • Python Tutorials For A...
OOP Python- • Object Oriented Progra...
Java: • Java Tutorials For Beg...
JavaScript- • JavaScript Tutorials I...
PHP- • PHP Tutorials in Hindi
C- • C Language Tutorials I...
C++- • C++ Tutorials In Hindi
Git & GitHub- • Git and GitHub Tutoria...
Android Dev- • Android Development Tu...
Python GUI- • Python GUI: Tkinter Tu...
Web Development- • Web Development Tutori...
Python Django: • Python Django Tutorial...
Projects Using HTML, CSS & Javascript- • Projects Using HTML, C...
Data Structure and Algo: • Data Structures and Al...
Follow Me On Social Media
►Website (created using Django Rest & Angular): www.codewithha...
►Facebook: / codewithharry
►Instagram: / codewithharry
Twitter: / codewithharry
Comment "#HarryBhai" if you read this 😉😉
Code Backup Repository: github.com/CodeWithHarry/100-days-of-code-youtube
Day 18
Moye more
Control + c to control this
I've 2 years of experience in python development. Even though I know a lot. I watch all of Harry bhai's videos and love the way he explains. Good job Harry Bhai 👍
Love bhaai
Help me sir how I start my journey
I am 1st year it student
After read any programing language I forget it
🙏✊
@@rajibsant9741 same here
@@rajibsant9741 Mery bhai mene MBA kia hai or mein programing seekh raha hn jb mein seekh skta hn to ap mujh sy kafi choty ho apki picking power mery sy zyada hai practice zyada sy zyada karo or jxt ek programing language par focus karo
@@umerkhan-kv9gd ok
9:13s, I heard this story for the second time, in the last video of Python. And yes I have also used this many times but in winters when I go to the mountains.Then I did it to warm up the computer. It helps to heat up many computers.👍🏻👍🏻👍🏻
Day #18 done! The story of the ants was pretty interesting 😆
It has happened to my laptop a few times in June-July. 🤣🤣
@@DeepakKumar-mb2lw what was on the laptop that made ants to come? 🤔
@@Sioslayer there was nothing but the my room was on top floor and because of summer 🌞 due to high temperature, room temperature was too hot 🥵 so ants usually get inside laptop 😔💻 and does even come out later 😭
I was inconsistent for a few days but yesterday I covered all that up. And now i am all caught up. :)
Truly commendable playlist, completely understood python.
I am not from IT, 30 years exp in Maintenance department (Mechanical Engineering) I have learned coding Python from Harry ( as well others ! )... thanks Harry!
so still what you do ?
@RUBAB KHAN Working with manufacturing company.
I am From mechanical engineering sir
Bro kya karna padega mechanical engineer ban ne ke liye
@@Amar-yaduvanshi23 mechanical engineering ki exam pass karni padegi bhai🤣🤣🤣
🤣🤣 Bhai, honestly, chitiya (ants) ka example bahot hi achcha that.. learning with fun.
Hats off to you sir ji 🤠
Is line ko comments per dhundne aya tha,,,Apka comment sa dil khush ho gaya,,,,
9:27 😂
I have learned many things from and still I just want to learn more things from you whatever you teach us is the easiest way to make us understand that's why I love to watch your videos.
hey ...that hack about getting rid of ants using a while loop ... ! truly genius bro !
I am doing 8=10 lectures easily daily. hope to finish in 10 days all 100 lectures. So interesting. Thak you Harry. I am a Professor Of Medicine. MD Medicine but i will make good use of this programming knowledge and have already made scripts to manage pt data, medical records, pharmacy etc using php n mysql. Now will try to do the same using python. jango and flask look daunting to me right now, but i am ready to work hard and dont get tired sitting n codign for 12-14 hrs daily. Just love it. Thanks for being such a good tacher n giving all this away for free. We r giving u a lot of yt watch hrs :D
Day 4 of #100DaysOfCode. Today in this video 18, I learned about Python's while loops, which execute statements as long as a condition is true, and how to use else statements with them. I also explored emulating do-while loops using an infinite while loop and a break statement with an if condition, ensuring the loop body executes at least once.
Thank You Harry Bhaiya.
Day 18 Done 🔥🔥, Amazing video harry bhai the way you teach us we loved that Thank you so much for being our Harry Bhai & Teacher ❤❤🙌🙌
Harry bhai you are great man❤️
Harry Sir, I'm right now in class 9th and i have extreme intrest in computers and i want to work for Google or Microsoft in the future, so i am learning web dev and python since class 8. I've made a fully functional chess ai in python on my own and a portfolio website. My question is, Is this the right time to do all this?
yep bro me too starting at your age
Keep your mathematics really strong it will help you a lot
such a good method of teaching.I don't know i directly understand the programme syntax
Thank you Harry Bhai for these videos. It really help me alot
Respected Harry Sir, please never stop coding, doing TH-cam videos, bcoz you are God for us..God bless you sir..
With the break statement we can stop the loop even if the while condition is true
With the continue statement we can stop the current iteration, and continue with the next
With the else statement we can run a block of code once when the while condition no longer is true
10:33
Else statement will execute because -5 is less than 0
Dude, your teaching is brilliant. Talking about something else I really enjoy the way you say "bahut" 😂. It has stuck in my mind and now I also say it the same way 😄
bhot easy kr diya h apne learning hamare liye thank you so much for helping us......😇
do..while is a loop in which a set of instructions will execute at least once (irrespective of the condition) and then the repetition of loop's body will depend on the condition passed at the end of the while loop. It is also known as an exit-controlled loop.
One could be an excellent programmer but that doesnt mean he will be a good teacher as well.
Harry bhai has both the skills which makes him an extra ordinary teacher, keep up the good work!!!.
amazing harry bhai
Harry sir! Great love from Pakistan ❤
In case of decrementing while loop where we don't need to print 0 we can simply write ---
while i :
print(i)
i = i-1
in case of C,we could write
while(i--){
printf("%d",i);
}
Given we need to initialize i as 6 instead of 5
10:43
Thanks for this ultimate course ❤❤
Following is an example of using combination of while loop and break statement as do while loop in python.
i = 10
while (True):
print(i)
i = i+1
if i>10:
break
LOVE YOU HARRY BHAI❤
harry yrr You are teaching very well.
Day 18 done ✅
This course is awesome 🔥🔥
Harry bhai please make a detailed Android course series like this. btw gr8 content & love you 💖❤️
make video for web 3
Thank you sir ❤️❤️
# table
Number = int(input("Enter number"))
i=1
while i
in while loop, always give a variable first,
second give a condition which is true at the start of the loop,
third put the command in the loop,
fourth within the loop convert the condition into false.
Pranam bhrata 🙏 apka bahutt baht dhanyawad ❤️😌🙏😇
Thank you for free python course
make video for web 3
i wrote this program with for loop it can print any table of number input by user
intro = " Table Writer Program "
print(intro.center(50, "*"))
n = int(input("Enter NUmber: "))
for i in range(n, 11*n, n):
print(i)
print ("Table Writer Program".center(50, "*"))
n = int(input("enter bich: "))
for i in range(11):
print ( n , "x" , i, "=", n * i )
Good evening sir thank you for this video
Day - 18 Completed😍
print("""Do you want to use calculator?
Press 1 to 9 for YES
Press 0 for NO""")
a = int(input())
while a:
welcome = "welcome to calculator world"
print(welcome.title())
a = int(input("Enter the first number: "))
b = int(input("Enter the Second number: "))
x = int(input("""1. Enter 1 for add
2. Enter 2 for Sub
3. Enter 3 for Div
4. Enter 4 for Mul
"""))
match x:
case 1:
c = a + b
print ("Add is: ", c)
case 2:
c = a - b
print ("Sub is: ", c)
case 3:
c = a / b
print ("Div is: ", c)
case 4:
c = a * b
print ("Mul is: ", c)
case _:
print("Enter the correct option")
print("""Still do you want to use calculator?
Press 1 to 9 for YES
Press 0 for NO""")
a = int(input())
else:
print("I respect your decision")
Par harry bhai 98 to 38 se greater tha to condition false hui to direct done with the loop print hona chahiye tha na instead of printing i also???
Same question
Bro itna observation skill hai toh aap ye computer programing kyu kar rahe ho detective ban jao
bro program dekho user input lene ke directly baad print(i) hai fhir loop ke bahar aata hai toh pehle print hoga fir condition check karega ki condition true hai ya nahi
while True:
number = int(input("enter the value of number:= "))
print(number)
if not number > 10:
break;
@CodeWithHarry agar aapne value count= count-1 agar 5 dali to else execute hoga bro
9:01 lol...CodeWithHarry and the ant wars🤣😂
answers=['east','islamabad']
q1=input('where does the sun rises= ')
q2 = input('what is the capital of pakistan= ')
prize=100
while q1 in answers and q2 in answers:
print('Both answers are right and you wont',prize*2)
break
while q1 in answers and q2 not in answers:
print('one is right and one wrong so you won ',prize)
break
while q1 not in answers and q2 in answers:
print('one is right and one wrong so you won ',prize)
break
while q1 not in answers and q2 not in answers:
print('Both the answers are wrong so you won ',prize*0)
break
Nice piece of coding❤
10:27
Yes
Else block will definitely execute
DOUBT🚨🚨🚨 5:35 why did the 'i' get printed? it was inside the 'while' function so it shouldn't have been printed right?
#Day 18 in 100DaysOfCode. Maintaining consistency is a difficult thing.
indeed... but we have 2 if we want 2 outstand the crowd.
Your videos are awesome 😎
Thanks
🤩🤩🤩
once we created a variable named "coun"t outside while loop and stored a integer and then how we can redefine the same named-variable as in this case count=count-1 again redefined.
I didn't understand this thing.
please help someone..
i=0
while(i
I hav a doubt plz solve
Ques.- Write a program to display all the integers from 1 up to and including some integer entered by the user followed by a list of each number's prime factors. Number greater than 1 that only have a single factor will be marked as prime.
For example, if the user enter 10 then the output of the program should be :
Enter the maximum value to display : 10
1=1
2=2 (prime)
3=3(prime)
4=2*2
5=5(prime)
6=2*3
7=7(prime)
8=2*2*2
9=3*3
10=2*5
Interesting question
Wait I'll try this after I'm done with watching the video
Well it's easy
You can 1st take the user input and store it in a variable , say n
Then use the for loop with 1 as the start value and n as your step value
Further , inside the for loop , you can use the if-else statement
In the if part , you can check if it's prime or not & then write a print statement according to what you want as the output
But it will be better if you define a function already for the prime number and then check it , it will save your time also & will help you while writing down the factors :)
@@nanhakachua863 problem in checking prime no.?😔🤔
And also how i will factor them
aapky is new course se mujhy loops samah ay hen purane se nhi arahe the 😂shukar hai mai bhi loop kr k aapki video p hi aaya
Present sir 🤚
@CodeWithHarry bro, I am new to programming and here is what I did to print the table of 3
i = 0
k = 0
while i < 32:
while k < 11:
print("3 * ", k ,"=" ,i)
i= i+3
k= k+1
yeah that is right but you can do it in easier by by using for loop like this
print("The table of 3 is:-
")
k=1
for i in range(3,30+1,3):
print("3 *",k,"= ",i)
k=k+1
# number multiplication order program till 10:
a = 1
b = int(input("enter number :"))
while (a < 11):
print(a,"*",b,"=",a*b)
a = a + 1
if we will use else in while loop else will be executed whether it enters while loop or not.
10:04 , else statement tb execute karta hai jab loop me break statement nahi ho, agar only statement he print karna hai toh normal be toh likh sakte hai...
2 din me 18 video nipta diya mene with making notes and program, tabhi course h aapka 😍😍😍
Thank you for this course
Thank you harry Bhai 💞💞💞💞💞💞💞💞💞
The loop starst from 1 then it prints the 3 number and it leaves the third number and prints 4 ,likewise it iterates every third number between 1 to 12
Your video is very helpfull for me
12:47 do while loop मतलब पहले इस्तेमाल करो फिर,,,,, ।first you do ,then the confition ,if condition not match then dont do
what an intelligence of harry bhai #ants_around_harry's_laptop 😂😂
good explanation
Thank you bhai for your love and support towards us. 🥰🥰
Harry Bhai Core Java k course le ke aao ek vedio banado... Wipro training period m sikhne ko bola h project m lgenge Java.. but study source nhi mil rha koi acha... Tum banado plz bhaiya next week m 😊❤️
for loop in range(4):
print(2)
a=int(input("ENTER YOUR NUMBER HERE: "))
while (a
number = int(input("Enter a positive number: "))
while True:
print(number)
if not number > 0:
break
is this correct?
#Emulation of do while loop in python
i = 100
while 1:
print("Hi",i)
i+=1
if i>90:
break
13:36
So basically this program is emulation of do while loop. it runs at least one time even if the exit condition is false
In python there's no do while loop. So we can create it by creating an infinite loop in which well write one exit condition by using if statement if that condition met then we'll use break statement to come out of loop.
So in above program if i>90 then loop will be terminated. I have taken i = 100. Even then loop will run one time and then it will be terminated.
10:35 Else execute hoga kyuki wo loop sae bahar ayega
Great ❤️🔥❤️🔥
Instead of writing, count = count + 1/ count = count - 1
we could also write count +=1/ count -=1
#it basically means the same thing, its just an easier way of writing it.🤗
Day 18✨
hi what's your class level?
@@nirrawal5265 11th
@@nirrawal5265 11th
Boss I came back to this video for revision. One thing I really want to know is what is the shortcut Key u r using after selecting a chuck of code and commenting it out with a single button? Thank you
Ctrl + /
num = int(input("Enter a number (greater than 0) : "))
getName = input("Enter your name : ")
for num in range(num):
if(num%2==0):
print("Hi", getName)
else:
print("I Love You💝!")
Present Sir , #Day_18
print(" guess the number game")
print(" between (1-20)")
your_friendnum = int(input("enter a number for your friernd in order to play between 1-20 (dont show them🤫): "))
num = int(input("enter a number: "))
while(num != your_friendnum):
num = int(input("guess the number again😛: "))
if num == your_friendnum :
print("you guessed it right!!!!!🤩")
elif num == your_friendnum-1 :
print("you are close😏")
elif num == your_friendnum+1 :
print("you are close")
a simple game made by a 12 years old.(duh!🙄)
yes sir else is executed because the loop is out or its output is false
Present Sir 🤞
You r awesome mere bhai😘😘
Break is a termination of loop
Continue is a skip current execution
clg ki chitiya wali story is evergreen , in every loop video of harry🤣😂
day 18, things are getting difficult, slowly but definitely, hope i get through these 100 days
Ustad ji♥️♥️
Sir i am in 11 and doing python and u r awsome
Hi, finally i have covered all past videos.
a=int(input("enter any no yoy want to make table="))
b=1
print("this is your table")
while(b
Thankss man good code
Sir i have a doubt...
If the condition in while loop is wrong, it is executed once and then end the loop. Why it executes once??
Why don't it just exit from the loop??
question - how to emulate a do-while loop in python
ans -
while True:
number = int(input("Enter a positive number :
"))
print(number)
if not number > 0:
break
print("done with emulation")
Bhai tera code tab tak chalta rahega jab tak negetive value nahi dalega tho kya fayda?
But well try though👍
The else condition will also print along with while loop
Thx
Thank you for your support sir
My practice solution
#Decrementing while loop
i = 5
while (i > 0):
print(i)
i = i -1
else:
print("Happy New Year")
#Increment while loop
y = 1
while (y 0:
break
i am a beginer in programimg , you alredy maked a tutorial playsilt , which one will i
compleate frist
while loop ka is sai best use mene aaj tak nahi dekha