9. For loop [Python 3 Programming Tutorials]

preview_player
Показать описание
The topic which I will explain to you today is about “for statement” also known as “loop statement”, “for” loop, “while statement”, how to create “for” loop, why “for” loop is used.

Topics that are covered in this Video:
0:00 Overview
2:55 Create a for loop (Syntax of for loop)
6:53 Why for loop is used?
7:02 Use of range() function
18:51 While statement

🔖Hashtags🔖

#forloopinpython #pythonforloop #tutorial #loopinpython #python #pythonloops #pythonloops

Next Video:

Рекомендации по теме
Комментарии
Автор

Dear sir, I am watching the tutorials from last 7 days. The way of explaining the concept with example is very much effective and easy to get the things..

ausafumarkhan
Автор

I watched different tutorials in loops, and this is the best video I have ever seen! Easily understandable!

AchuVlogs
Автор

I watched different videos from other tutorial regarding loops and this one I understand the most. Thank you!

puddinfacekiki
Автор

well you have created amazing tutorial till now, few months back I started with C and now these tutorials are really good, i think i will be watching whole play

prajwalbhandari
Автор

the printing of square of only odd numbers
this approach is also effective :
for i in range(1, 10, 2):
print(i*i)

vasusharma
Автор

you explain in a great way with those explanations beside the code is awesome.Thanks

starman
Автор

very useful assignments sir... they are definitly developing logic... most of time i use solution due to lack of logic.. but still it is useful... thanks for taking efforts for us....

ganeshgunjal
Автор

Sir without declaring the items how you item put in print plz clearfy this doubt

mdasif-zebc
Автор

thnks sir.
incase if you want to print only odd number then use i%2!=0

nadeemhalbhavi
Автор

for i in range(1, 6):
s=i**2
if s%2==1:
print(s)
#output :
1
9
25

TechBalu
Автор

great channel to learn data science skills with projects.

alishmed
Автор

where can I get more challenging exercises. you are such a great teacher I need harder problems

arasukiasyan
Автор

how do i check if my code is good and it is the optimised code or not? for instance
for the one of the practice example:


1. This solution is given by dhaval (codebasics)

month_list = ["January", "February", "March", "April", "May"]
expense_list = [2340, 2500, 2100, 3100, 2980]
e = input("Enter expense amount: ")
e = int(e)
month = -1
for i in range(len(expense_list)):
if e == expense_list[i]:
month = i
break
if month != -1:
print('You spent', e, 'in', month_list[month])
else:
print('You didn\'t spend', e, 'in any month') month_list = ["January", "February", "March", "April", "May"]
expense_list = [2340, 2500, 2100, 3100, 2980]
e = input("Enter expense amount: ")
e = int(e)
month = -1
for i in range(len(expense_list)):
if e == expense_list[i]:
month = i
break
if month != -1:
print('You spent', e, 'in', month_list[month])
else:
print('You didn\'t spend', e, 'in any month')

2. My solution is:

expense_list = [2340, 2500, 2100, 3100, 2980]

month_list = ['jan', 'feb', 'march', 'april', 'may']

expense_amount = int(input('please enter an amount number: >>> '))


for i in range(len(expense_list)):
if expense_amount == expense_list[i]:
print (expense_list[i], ' was spent in', month_list[i])
break
else:
print('expense amount is not available')

please help me how can I check a good is optimized code.?

karthikchekuri
Автор

the problem for the beginner is how we know, we going to use len function with this for loop, how to build sense of think in facing the case of an algorithm?

codemedio
Автор

2:09 "...what if your list had like hundred items in it. If you start writing all of these, you'll become granddaddy by the time you're done writing this." 🤣😂🤣😂
Great and informative tutorial, with a hilarious teacher. Thank you.

OrangeTiramisu
Автор

The "continue " code ....wow! i=i+1 very important!

tsaltslinger
Автор

Hello,

Thank you, very much for your involved with teaching us with very simple and understanding way!

According your suggestion, aftera watched your tutorial I switch to exerecises and I tried to doing myself.
I have a problem with your 3-rd exercises and solution. Why in the code there's:
"month = -1" and "month != -1" and whay even I put here value "month = -10" and "month != -10" it sill working correctly?

Dnte-RN
Автор

John 15:11-14 (KJV)  These things have I spoken unto you, that my joy might remain in you, and that your joy might be full.
This is my commandment, That ye love one another, as I have loved you.
Greater love hath no man than this, that a man lay down his life for his friends.
Ye are my friends, if ye do whatsoever I command you.

tsaltslinger
Автор

thank you for the excellent content and work!

hisky
Автор

if i want to print n numbers so what should I give the range ?

deekshashadakshari
welcome to shbcf.ru