Python Tutorial for Beginners 12 - While Loop and For Loops in Python

preview_player
Показать описание
In this video I am going to show How to use while Loop in Python.
while loop is used to repeat over block of code again and again until is condition is met. The while loop can be used to describe conditional iteration.While loops read a lot like English (like almost everything in Python).
while condition :
list of statements
Note the colon and indentation.
When a program repeatedly runs a set of statements it is referred to as a loop.
Also else statement can be used with while loop.
★★★Top Online Courses From ProgrammingKnowledge ★★★

★★★ Online Courses to learn ★★★

★★★ Follow ★★★

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!

Verwandte Suchanfragen zu loops python 3
python 3 while loop
python loop 3 times
python 3 break loop
python 3 for loop index
python while loop
if else python
python while else
elif python
python break
python if then
python for next
python if else elif
Рекомендации по теме
Комментарии
Автор

Dear PK, would you explain these two line of statements below again ?
a = float(input('Number ?'))
a = float(a))

md.shorifulislam
Автор

The syntax of the for loop part should have been given along with the example since u used the in operator too

ayushshaw
Автор

atention for linux use space in terminal
>>> while a<5:
...  print(a)
...  a+=1

...enter

GeorgeSariev
Автор

no=5
while no<=10:
no2=1
while no2<=10:
print(no, " X ", no2, " = ", no*no2)
no2+=1
no=no+1

ajithmoharana
Автор

for loop is not explained in detail like incrementing in steps of 1 & more than 1 or decrementing loop

ankitmakkar
Автор

Dear PK, if I want to stop the total Sum by writing 100 instead of 1, what should I to do ?

md.shorifulislam
Автор

Hi,
Maybe I missed it but why do you have the "a = float (a)" line ?? What purpose does it serve ?

Steve

stusmith
Автор

How to store the printed output directly into a list, for e.g : [0, 1, 2,3,4,]??

robin
Автор

I dont think..we have to write multiple line to execute simple program.. here is my code.. output is same ;)

a=1
s=0
while a!=0:

print("current sum is:", s)
a= float(input("enter number:"))
#a=float(a)
s=s+a
print("total sum is:", s)

else:
print("invalid option")

mixturemind
Автор

Is it necesary have line "a=float(a)"?

eduardczuwak
Автор

please clarify
if a= float('input') //input is taken in float format
float (a) //converting again float

does it makes any sense

rajatrp
Автор

why does this code(the while loop code) run in windows cmd but not in IDLE??

tasnianishat
Автор

how it is possible that the assigned value of a=1 that 1 is not mentioned on a=float(a)

bishnushrestha
Автор

In a new shell
>>> a=0
>>>While a<5:

Immediately, I see "SyntaxError : invalid syntax".

Why is this?

sreddy
Автор

if i can do a+=1, can I do a*=(some number)?

imeyris
Автор

why it is necessary to assign the value of a??

bishnushrestha
Автор

How can we print all no. In single line in case of while loop?

prahaladt
Автор

Hi sir.. in 8.53 mins, why shouldn't use double quotes... print(num) this only write? Usually if u print option we use double quotes na

SaranyaSaranya-ujum
Автор

What is the benifit of a=float(a) here?

haithamalnasrawi
Автор

Sir... in the while loop code why did you a=float (a)
in the previous step you have already type casted the value into float and then assigned to' a'. Then why did you use 'a=float(a)' again?? Please explain. :)

minimalist_pc