Introduction to For Loops in Python (Python Tutorial #5)

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ม.ค. 2018
  • For loops Python tutorial.
    This entire series in a playlist: goo.gl/eVauVX
    Keep in touch on Facebook: / entercsdojo
    Download the sample file: www.csdojo.io/python5
    Subscribe to my newsletter: www.csdojo.io/news
    Support me on Patreon: / csdojo

ความคิดเห็น • 3.9K

  • @shuttershocker
    @shuttershocker 2 ปีที่แล้ว +51

    total4 = 0
    for item in range(1, 100):
    if item % 3 == 0 or item % 5 == 0:
    total4 += item
    print(total4)
    2318
    These videos are a lot better than my lecturer thank you! :)

    • @BakeKunRBLX
      @BakeKunRBLX 4 หลายเดือนก่อน +1

      Niceeee

    • @LeoDragonheart13
      @LeoDragonheart13 3 หลายเดือนก่อน +1

      Been trying to self teach for years and kept giving up cause I couldn't get anywhere or understand it on my own at the times, with these tutorials it's actually pretty fun and I'm enjoying it. I got most of the answer here for the problem, but completely forgot I could use "or" there, would've been stuck for an hour trying to figure it out if I hadn't looked at the comments xD

    • @Dark_dragon1212
      @Dark_dragon1212 8 วันที่ผ่านมา

      It keeps giving me 0
      What might I be doing wrong?
      Edit: nvm, found it 😅😅😅

  • @FootnotesToPlato
    @FootnotesToPlato 4 ปีที่แล้ว +1657

    who else is loving this series on quarantine

    • @Boc3phu5
      @Boc3phu5 4 ปีที่แล้ว +19

      Learning a new skill

    • @AbdulKaderAbdeenAgha
      @AbdulKaderAbdeenAgha 4 ปีที่แล้ว +8

      totally

    • @moebulldog6922
      @moebulldog6922 4 ปีที่แล้ว +7

      i need help with python

    • @jjredfox3504
      @jjredfox3504 4 ปีที่แล้ว +12

      I was so bored of doing nothing and this was just some top tier stuff

    • @0_-
      @0_- 4 ปีที่แล้ว +6

      100% me

  • @ginethespinosa9827
    @ginethespinosa9827 3 ปีที่แล้ว +261

    total = 0
    for i in range(1,100):
    if i % 3 == 0 or i % 5 ==0:
    total += i
    print (total)
    Thanks, CSDojo, I love your explanation and homework.

    • @anthonynarine5292
      @anthonynarine5292 2 ปีที่แล้ว +4

      aww why did you post this lol.

    • @cakeuwaifu
      @cakeuwaifu 2 ปีที่แล้ว +19

      @@anthonynarine5292 why not?

    • @anthonynarine5292
      @anthonynarine5292 2 ปีที่แล้ว +23

      I accidentally gazed over the answer 🤣. I unintentionally copied 😅😅😅

    • @oluwadunsinoladipo2956
      @oluwadunsinoladipo2956 2 ปีที่แล้ว +10

      @@anthonynarine5292 😹😹😹you’re the funniest person I’ve met on the net today

    • @anthonynarine5292
      @anthonynarine5292 2 ปีที่แล้ว +1

      @@oluwadunsinoladipo2956 hahahahha

  • @YeahMadeit_17
    @YeahMadeit_17 2 ปีที่แล้ว +17

    Hi! I'm Russian and i know English little bit, but TH-cam has subtitles and it gives me an opportunity to learn Python) I started watching Your videos because rus TH-cam doesn't have normal lessons. Thank u and don't stop making new videos)

  • @Rasberrychua999
    @Rasberrychua999 4 ปีที่แล้ว +528

    i literally paid around 35 grand a year to get my programming engineering degree, but lecturers and tutors are just reading the codes and not even explaining it lol -.-
    im loving how i have only watched 5 episodes and paid NOTHING, I have learnt way more about programming here compared to uni ;-;

    • @axel_r_
      @axel_r_ 3 ปีที่แล้ว +27

      Same here. I have this one teacher who is more focused on talking about the content than actually teaching the students. When this teacher is done talking its "bye!" and gone... students confused af... --> let's go to youtube and get help from the Dojo gang!

    • @tenesiadontneedja
      @tenesiadontneedja 3 ปีที่แล้ว +16

      that is exactly why I am here lol, teachers do not teach

    • @Turd13s
      @Turd13s 3 ปีที่แล้ว +1

      Wow, 35 grand went down the drain huh.

    • @axel_r_
      @axel_r_ 3 ปีที่แล้ว +10

      @@Turd13s Actually, no. You still need to pay schools to get the official papers that are needed to get into the business with the desired technologies.

    • @ahmedabdelsalamabdelhalims6968
      @ahmedabdelsalamabdelhalims6968 3 ปีที่แล้ว +1

      @@axel_r_ if you put it like that just half of 'em went down the drain...

  • @kasperderej7401
    @kasperderej7401 4 ปีที่แล้ว +463

    Please don't stop what you're doing. You're a great teacher!

    • @aidantan9566
      @aidantan9566 2 ปีที่แล้ว +6

      THAT'S WHAT SHE SAID

    • @swallowedinthesea11
      @swallowedinthesea11 2 ปีที่แล้ว +1

      bool( "THAT'S WHAT SHE SAID" )

    • @mdvlogs5418
      @mdvlogs5418 ปีที่แล้ว

      true he is the best online python (arguably the best offline teacher ) that i personally ever had

    • @pedro.fonseca
      @pedro.fonseca ปีที่แล้ว

      yes!

    • @uzbek_coding
      @uzbek_coding ปีที่แล้ว

      ​@@aidantan9566​ he's not girl you must say: THAT'S WHAT HE SAID

  • @amberniesalting9011
    @amberniesalting9011 3 ปีที่แล้ว +38

    total = 0
    for i in range(1, 100):
    if i % 3 == 0 or i % 5 == 0:
    total += i
    print(total)
    Output = 2318

    • @sanjivverasamy5716
      @sanjivverasamy5716 2 ปีที่แล้ว

      the same answer i got

    • @jaubee
      @jaubee 2 ปีที่แล้ว +1

      @@sanjivverasamy5716 ive been trying to find someone with a answer in the comments. this is what i got. he didnt have the answer on his DL file. I also did it differently
      total4 = 0
      for j in range(1, 100):
      if j % 5 == 0:
      total4 += j
      if j % 3 == 0:
      total4 += j
      print(total4)
      2633

    • @t3hdude
      @t3hdude 2 ปีที่แล้ว +3

      @@jaubee Dude I'm pretty sure the answer is 2318. You put 2 if statements I think that's why you got a different answer. It's adding the total from the first if statement to the next one, instead of adding all of them at once. Use an "or" like the comment above and you will get 2318.

    • @spartacus8742
      @spartacus8742 2 ปีที่แล้ว +3

      @@jaubee I agree with the guy above. The crux of why your way doesn’t work (I wanted to try it that way at first as well) is because you are adding numbers that are multiples of 3 AND 5 (like 15, 30) twice.

    • @joeroganpodfantasy42
      @joeroganpodfantasy42 2 ปีที่แล้ว +1

      wait a second we haven't learned or statement yet so your answer is invalid.
      This is as far as I got I have no clue how to substract the numbers that are divisible by 5 and 3 with the current knowledge:
      total3 = 0
      total5 = 0
      for i in range(1, 100):
      if i % 3 == 0:
      total3 += i
      print(total3)
      for i in range(1,100):
      if i % 5 == 0:
      total5 += i
      print(total5)
      c = total3 + total5
      print(c)

  • @luuchoo93
    @luuchoo93 3 ปีที่แล้ว +33

    The level of satisfaction I get when I end up one of your videos achieving the same results on my own, is epic.
    Great tutorial, keep it going!

  • @276sedvlintsax7
    @276sedvlintsax7 4 ปีที่แล้ว +255

    Taught me more in ten minutes than 3 of my hour python lessons.

  • @rakshitrai6050
    @rakshitrai6050 2 ปีที่แล้ว +59

    IT FEELS SO GOOD WHEN YOU UNDERSTAND THE CONCEPT... I loved your explanation and it was so understandable. I have gone through so many videos and even in different languages (As I am from India, We have many languages) but your explanation was great, I just regret why I did not found you at first. I really appreciate your work and I am gonna share it with all my known friends. Thank you very much

    • @geekyaman3842
      @geekyaman3842 2 ปีที่แล้ว +1

      yes this tutorial is indeed helpful i am from India too!

  • @blufy2804
    @blufy2804 3 ปีที่แล้ว +11

    I came with two solutions:
    First
    total = 0
    for i in range(1, 100):
    if i % 3 == 0 or i % 5 == 0:
    total = total + i
    print(total)
    And i got 2318, but because I realized we don't learn 'or' statement yet, I came to second solution
    total = 0
    for i in range(1, 100):
    if i % 3 == 0:
    total += i
    elif i % 5 == 0:
    total += i
    print(total)
    Thanks for the tutorial mate!

    • @TrexTheFirst
      @TrexTheFirst ปีที่แล้ว

      Both the ways have same answer. Which one is more efficient?

    • @farkhodkuchkarov5238
      @farkhodkuchkarov5238 ปีที่แล้ว

      But is this the right answer?
      Cause my solutions looks very similar here.

    • @ppmokgoro
      @ppmokgoro ปีที่แล้ว

      my understanding could be wrond: but didnt he say the modulo should be 3 AND 5 as opposed to 3 or 5?

  • @BoxofCarrots
    @BoxofCarrots 3 ปีที่แล้ว +78

    I have a coding exam on Monday and I was still seriously struggling with loops and lists, so this is great! Thanks!!

    • @bartoszbrown1322
      @bartoszbrown1322 ปีที่แล้ว +1

      How did it go?

    • @incognito7722
      @incognito7722 ปีที่แล้ว +8

      @@bartoszbrown1322 bruh it's 1 year the guy must be working for google by now

    • @activity5035
      @activity5035 ปีที่แล้ว +1

      @@incognito7722 nah its first year lesson I bet he is in second year

    • @kevinanand3991
      @kevinanand3991 ปีที่แล้ว +1

      @@incognito7722 Had me laughing lmao

  • @horkoser
    @horkoser 4 ปีที่แล้ว +280

    This is my attempt:
    total = 0
    for i in range(1, 100):
    if i%3 == 0 or i%5 == 0:
    total += i
    print ("Total:", total)
    Total: 2318
    Another way:
    total = 0
    for i in range(1, 100):
    if i%3 == 0:
    total += i
    elif i%5 == 0:
    total += i
    print ("Total:", total)
    Total: 2318

    • @hansonng4711
      @hansonng4711 4 ปีที่แล้ว +6

      should I use "and" or "or" ?

    • @gallonrs
      @gallonrs 4 ปีที่แล้ว +25

      @@hansonng4711 if you use and, you will add up only number that are both multiple of 3 and 5, like 15, 30, 60, etc. You should get 315 by doing that.

    • @kenanloughlin5059
      @kenanloughlin5059 4 ปีที่แล้ว +4

      Anyone else just put i % 3 == 0: and get 9

    • @dedysyaputra4472
      @dedysyaputra4472 4 ปีที่แล้ว +14

      @@hansonng4711 maybe you should check about different for AND OR NOR - > basic logic tables ,
      AND mean FALSE + TRUE = False
      OR mean False + True = True
      check this out

    • @vanwest9614
      @vanwest9614 4 ปีที่แล้ว +2

      bro i got 33

  • @MonteroKirilenko
    @MonteroKirilenko 4 ปีที่แล้ว +64

    Hey YK, thanks for the great tut. You deserve 1,000 claps on Medium :-). Here's my answer to the challenge:
    list(range(1, 100))
    total4 = 0
    for number in range(1, 100):
    if number % 3 == 0 or number % 5 == 0:
    total4 += number
    print(total4)
    2318

    • @aryabima256
      @aryabima256 2 ปีที่แล้ว +12

      I was so confused on how to solve it cause I didn't know "or" is a thing 😂

    • @sanjosabu8170
      @sanjosabu8170 2 ปีที่แล้ว +1

      @@aryabima256 same🙄😪😂😜

    • @xuanyuliang101
      @xuanyuliang101 2 ปีที่แล้ว +3

      @@aryabima256 I also didn't realize the "or" part, I tried "elif", but it didn't work😂

    • @lamp9611
      @lamp9611 2 ปีที่แล้ว +1

      AAAAA i feel dumb I included the hundred 💀💀💀

    • @revathirev365
      @revathirev365 2 ปีที่แล้ว +2

      i tried using if and elif and it worked :-) got the same , but your way of approach by using or is very time saving.

  • @tanatswamapholisamoyo7289
    @tanatswamapholisamoyo7289 ปีที่แล้ว +14

    You're a great teacher bro. Taught me more in 10 minutes than 2 of my hour long python lessons! Don't stop bro.

  • @itay5825
    @itay5825 2 ปีที่แล้ว +2

    i just started python and I've been stuck on for loops for a few days now, when i watched your video i instantly understood the concept and how it works, can't thank you enough!!!!

  • @vysakhkodavana8932
    @vysakhkodavana8932 3 ปีที่แล้ว +149

    c = list(range(1, 100))
    total = 0
    for i in c:
    if i % 3 == 0 or i % 5==0:
    total +=i
    print (total)

    • @gracepayne2936
      @gracepayne2936 3 ปีที่แล้ว +3

      Thanks so much

    • @sushilkumarlohani6709
      @sushilkumarlohani6709 3 ปีที่แล้ว +1

      Thank you

    • @crab1458
      @crab1458 3 ปีที่แล้ว +35

      He said multiples of 3 and 5, that is why he mentioned "15", so the code is actually:
      total = 0
      for i in range(1,100):
      if i % 3 and i % 5 ==0:
      total += i
      print(total)

    • @zen36158
      @zen36158 3 ปีที่แล้ว +4

      list(range(1, 101))

    • @user-ue7kh9bi6z
      @user-ue7kh9bi6z 3 ปีที่แล้ว +7

      total=0
      for e in list(range(1,101)):
      if e % 3 ==0:
      total += e
      if e % 5 ==0:
      total+=e
      print(total)
      this also works

  • @karanrubenchaudhury7283
    @karanrubenchaudhury7283 4 ปีที่แล้ว +32

    Hi Dojo, I have recently started learning Python on Udemy. I was having a hard time understanding for loops, but thanks for a simple explanation, I have got a good grasp of it now!

  • @j9studios384
    @j9studios384 3 ปีที่แล้ว +3

    Thank you so much. I have been struggling learning python on my crappy online college. I learned more in your ten minute video than I have learned staring at a digital text book for weeks. Found my new teacher for learning python

  • @emmanueloseitutu7376
    @emmanueloseitutu7376 2 ปีที่แล้ว +8

    Perfect explanation for "for loop". I'm yet to watch the while loop but I'm convinced enough.
    Thanks!

    sum, total = 0, 0
    for x in range(1,100):
    if (x%3 ==0):
    sum += x
    elif (x%5 ==0):
    total += x


    print(sum, total)

    • @emreuras2168
      @emreuras2168 2 ปีที่แล้ว +1

      rather than equals the zero both three and five you can do x % 15 == 0 same result

    • @Msliliheart
      @Msliliheart ปีที่แล้ว

      I used this and got the wrong answer for the multiples of 5.

    • @venxity6959
      @venxity6959 ปีที่แล้ว

      problem = list(range(1,100))
      sum = 0
      for element in problem:
      if element % 3 == 0 or element % 5 == 0:
      sum += element
      print (sum)
      heres the actual answer, your one doesn't work because it counts nubers that are multiples of both 3 and 5, Good try tho, Similar to what I did at first because I forgot about the "or" statement

  • @courtneyrock69
    @courtneyrock69 6 ปีที่แล้ว +23

    I experienced a moment of sheer joy when I was (finally) able to get them all to print...WITHOUT sneaking a peek at the comments to find hints lol. Your videos are really helping to motivate me to (also finally) start learning programming. Truly, thank you!!

  • @fishmasteruniverse
    @fishmasteruniverse 3 ปีที่แล้ว +14

    my answer
    :
    total=0
    for a in range(1,100):
    if a%3==0 or a%5==0:
    total+=a
    print (total)
    good video thank you alot mate!

    • @thomaslozada7918
      @thomaslozada7918 3 ปีที่แล้ว

      was putting a comma instead of an or...thanks

    • @fishmasteruniverse
      @fishmasteruniverse 3 ปีที่แล้ว

      @@thomaslozada7918 yeah I wasn't even putting anything there, but i have fixed it

    • @davidvidal5297
      @davidvidal5297 3 ปีที่แล้ว

      ​@@fishmasteruniverse my one is a bit different :
      total = 0
      for i in range(1, 100):
      if i % 3 == 0:
      total += i
      elif i % 5 == 0:
      total += i
      print(total)
      I'm new to programing didn't know about the "or" 😅 makes more sense, less coding, gotta fix that haha

    • @ALTXZ.0
      @ALTXZ.0 3 ปีที่แล้ว

      Is the answer 2318!?

  • @wilwilson8146
    @wilwilson8146 2 ปีที่แล้ว +2

    I've seen for loops explained many ways from many different people..
    Yours was by far the best I've seen and easiest to understand. 👍

  • @LAM638
    @LAM638 2 ปีที่แล้ว +2

    I don't usually leave comment in YT but your tutorial is easy to understand for beginner. Thank you

  • @blakeparker6588
    @blakeparker6588 5 ปีที่แล้ว +25

    Thanks CS dojo, I've learnt and developed my Python skills a lot through your tutorial videos!!

  • @__shaikmalikbasha__
    @__shaikmalikbasha__ 5 ปีที่แล้ว +178

    Hello Sir!
    Please provide the complete tutorials on Python.
    The way of ur explanation is extraordinary.
    I want more and more tutorials on Python by you.

    • @gronksteady
      @gronksteady 4 ปีที่แล้ว +17

      I agree he is exceptional at explaining this stuff. Far above anything I've seen or read so far.

    • @divyadeepkaushik321
      @divyadeepkaushik321 4 ปีที่แล้ว +2

      LET'S START A PETITION MAYBE
      print("lol")

    • @JustinMacri007
      @JustinMacri007 2 ปีที่แล้ว

      @@divyadeepkaushik321 we want to learn what is machine learning

  • @edylljoshwa
    @edylljoshwa 2 ปีที่แล้ว +1

    This has been the most straightforward tutorial, much helpful than the self-learning course I've paid. Thank you very much!!

  • @davida6146
    @davida6146 ปีที่แล้ว +7

    I went through my python class struggling with this but surprisingly still finished well. What you explained in this video, my instructor made it more complicated 😅
    Thank you!

  • @jenh3183
    @jenh3183 4 ปีที่แล้ว +7

    This is great. Thanks for giving so many examples, translating the code, and introducing new concepts one at a time. It really clarifies for loops.

  • @tusharedits9
    @tusharedits9 4 ปีที่แล้ว +7

    Hey CS Dojo / YK,
    You are just amazing. I loved the way you teach all the topics so easily. I am learning python and I am going watching your whole series on python because when I started to learn python I was taught that it is very hard and complicated. But now I don't think so now.
    I am from India and I am in high school right now. I wished you were my computer teacher but no problem. Thanks once again for such wonderful videos.

  • @plutus4047
    @plutus4047 2 ปีที่แล้ว

    This is the best explanation.. I'm confused and watched 3,4 videos but you are the only one who makes it clear

  • @ModernDayWanderlust
    @ModernDayWanderlust 2 ปีที่แล้ว +1

    This is awesome, thank you! I'm brand new to coding and have had trouble wrapping my brain around for loops, and this helped tremendously! I was able to figure out the homework without an issue.

  • @hannahfogle417
    @hannahfogle417 4 ปีที่แล้ว +3

    Thank you so much for this video. You helped me understand something that took me WEEKS to get under the instruction of my professor. Thank you again!

  • @kafleykishore87
    @kafleykishore87 5 หลายเดือนก่อน

    sum1 = 0
    for i in range(1,100):
    if i % 3 == 0 or i % 5 == 0:
    sum1 += i
    print(sum1)
    2318
    Your videos are really interesting and teach the concepts in a simplified form. Great Work and Thank You

  • @22niloc
    @22niloc 11 หลายเดือนก่อน

    Superbly explained !
    A two week old Newbie to python here with a newbie solution (without looking at the comments):
    total3 = 0
    total5 = 0
    total3_5 = 0
    sum = 0
    for x in my_list:
    if x % 3 == 0:
    total3 += x
    if x % 5 == 0:
    total5 == 0
    if x % 3 == 0 and x % 5 == 0:
    total3_5 += x
    sum = (total3 +total5) - total3_5
    print(sum) : 1080

  • @RahulSharma-zs9lu
    @RahulSharma-zs9lu 6 ปีที่แล้ว +24

    Thanks for all your videos I think you are best teacher we had for python on TH-cam!! All your videos are really helpful 😊

    • @alexpapadakis7912
      @alexpapadakis7912 6 ปีที่แล้ว +1

      Rahul Sharma check thenewboston . he definitely deserves first place yet

    • @RahulSharma-zs9lu
      @RahulSharma-zs9lu 6 ปีที่แล้ว +1

      Ok thanks for your suggestion!!

    • @alexwu7915
      @alexwu7915 5 ปีที่แล้ว +1

      Julien Décarie he is all right

  • @hereslookingatyoukid
    @hereslookingatyoukid 4 ปีที่แล้ว +11

    Alternate solution to using or/and/set
    total4 = 0
    for v in range(1, 100):
    if v % 3 == 0:
    total4 += v
    elif v % 5 == 0:
    total4 += v
    print(total4)
    2318

    • @joeroganpodfantasy42
      @joeroganpodfantasy42 2 ปีที่แล้ว +1

      yes this is the correct solution he wants because he hasn't intoduced and or statements.

    • @itssara2053
      @itssara2053 2 ปีที่แล้ว

      I solved it this way too !!
      But used
      Else :
      If:
      Instead of elif:

    • @ernestpaul9954
      @ernestpaul9954 2 ปีที่แล้ว

      @@itssara2053 did you get the same answer though?

    • @itssara2053
      @itssara2053 2 ปีที่แล้ว

      @@ernestpaul9954 sure , elif is a short cut of
      Else :
      If:

    • @luvie692
      @luvie692 2 ปีที่แล้ว

      I got 2327, we have the same code tho
      I used 'or', the answer is 5909 wth haha

  • @othmanabuso
    @othmanabuso ปีที่แล้ว +1

    This series, ahy 🙌, out of all TH-camrs I have gone through, you top them all, great job man.

  • @asmae3643
    @asmae3643 2 ปีที่แล้ว +2

    Hi guys.i just want u to know that this teacher made my day .i'll explain how:i used to go from video to another on youtube but still couldn't understand loop patterns and that caused me to think that i am such a stupid girl for not understading such a basic thing that most beginner programmers seem to find a piece of cake.so i thank u from the bottom of my heart .keep up the good work.greetings from morroco✌️

  • @VgGamerKnight
    @VgGamerKnight 3 ปีที่แล้ว +5

    I love this channel, I'm an absolute beginner and YK explains it so well that I don't even need to take notes.

    • @2009MazdaRX8
      @2009MazdaRX8 3 ปีที่แล้ว +2

      well mabye take notes

  • @mauricioTesla
    @mauricioTesla 2 ปีที่แล้ว +1

    CS Dojo, Thank you for providing such a great and easy to follow Python Tutorials!!!! Please continue teaching us and sharing your knowledge .

  • @Mahmoud-dq5yp
    @Mahmoud-dq5yp ปีที่แล้ว

    remainder1 = 0
    remainder2 = 0
    for i in range(1, 100):
    if i % 3 == 0:
    remainder1 += i
    if i % 5 == 0:
    remainder2 += i
    print(f"for remainder of 3: {remainder1}")
    print(f"for remainder of 5: {remainder2}")
    Thank you so much, you helped a lot.

  • @nsobomelfordrisimati5913
    @nsobomelfordrisimati5913 3 ปีที่แล้ว +6

    This channel is part of my life now, I'm loving it

    • @joshuamaji9393
      @joshuamaji9393 3 ปีที่แล้ว

      Hi man.. I see you started using this channel about a month ago. How's it coming along?.. I just started a few days back

  • @yasserfathelbab1534
    @yasserfathelbab1534 2 ปีที่แล้ว +3

    I really like how you elaborated that we can use element or anything else and where is += is coming from. great educator :))

  • @christopherwolters2048
    @christopherwolters2048 4 หลายเดือนก่อน

    I didn't know about the "or" operator in the "if" statement until I read other people's post. Thanks everyone. My first attempt was:
    sum = 0
    for i in range(1,100):
    if i % 3 ==0:
    sum += i
    elif i% 5 == 0:
    sum +=i
    print(sum)
    Answer is 2318.
    I'm going to try using "or" in the "if" statement now.
    Great videos! Thank you!

  • @VicLaranja
    @VicLaranja 3 ปีที่แล้ว +2

    Dojogang!
    Ive been learning for a week now, I have started multiple courses so far and yours is honestly the best. So thorough and well explained. Thank you!!

    • @VicLaranja
      @VicLaranja 3 ปีที่แล้ว +1

      what = 0
      for each in range(1, 101):
      if each % 5 == 0:
      print(each)
      if each % 3 == 0:
      print(each)
      Solved this btw

    • @Mr-sn2qw
      @Mr-sn2qw 2 ปีที่แล้ว

      @@VicLaranja I think u know by now, so is it correct?
      for e in range(1, 101):
      e += 1
      if e%3 ==0:
      print (e)
      elif e%5 ==0:
      print(e)

  • @gailk30
    @gailk30 2 ปีที่แล้ว +3

    Love it! Well explained.👏🏼 Just a suggestion for people who wants to see a specific example (e.g. finding the total), it will be nice to have a link to each one of your examples. 👍🏼

  • @MazorKuziaki
    @MazorKuziaki 4 ปีที่แล้ว +18

    Thank you so much for this! I'm learning Python and every now and then I'll run into a lesson that I don't understand, so I'll try to find a different TH-cam video to explain it to me in a different way. This helped tremendously.

  • @MonicaBetancourt-ln9eu
    @MonicaBetancourt-ln9eu หลายเดือนก่อน

    You absolutely make my Phyton learning experience a charm, few have the gift of knowing how to easily convey how to code, you have a gift and for that thank you so very much!

  • @tanmay9878
    @tanmay9878 3 ปีที่แล้ว +2

    Great video buddy . I tried learning python from more than 10 youtube channels but this series is best.

  • @yatink4981
    @yatink4981 5 ปีที่แล้ว +12

    You're way good than my programming teacher ,though I'm studying in one of the best institutes in India I always prefer you. Thank u so much.

  • @jaicymelisse5532
    @jaicymelisse5532 2 ปีที่แล้ว +3

    Wow, as everyone else is saying, THANK YOU!! I've been stuck in my current python course and this was a great explanation. Really explaining each part well, to help our minds understand. ✌🏼

    • @dukhtarakhtar
      @dukhtarakhtar 2 ปีที่แล้ว

      Is this video visible? I have problem

  • @charitybenignos4941
    @charitybenignos4941 3 ปีที่แล้ว

    total3=0
    for i in range(1,100):
    if i%3==0:
    total3+=i
    if i%5==0:
    total3+=i
    if i%15==0:
    total3-=i
    print(total3)
    2318
    Wow, i just saw the comments with more efficient solutions. You're such a great teacher!!!

  • @catherinepham3999
    @catherinepham3999 2 ปีที่แล้ว

    Amazing python lesson. Thank you. It really helps me. For Loops is quite difficult to understand but Dojo makes it easy for me to get the concepts of loops.

  • @kangajankuganathan7457
    @kangajankuganathan7457 5 ปีที่แล้ว +271

    total = 0
    for i in range(1, 100):
    if i % 3 == 0 or i % 5 == 0:
    total += i
    print(total)
    >>>2318

    • @theultimateknight7356
      @theultimateknight7356 5 ปีที่แล้ว

      Thanks

    • @mrxizhe
      @mrxizhe 5 ปีที่แล้ว

      thank you

    • @allstat7342
      @allstat7342 5 ปีที่แล้ว +9

      you know you're lazy when you copy this little code

    • @mohitkumar-cm5nk
      @mohitkumar-cm5nk 5 ปีที่แล้ว +4

      How come.. print (1 %3) shows 1 ..remainder should be 2 ..can you please help or guide..video time is 8:08

    • @mohitkumar-cm5nk
      @mohitkumar-cm5nk 5 ปีที่แล้ว +2

      @@swethaskr2188 I am getting it. I am stuck on this since morning..still I cant understand if you divide 3 by 1 then how come it is 1 mam.

  • @JesusJFuncia
    @JesusJFuncia 3 ปีที่แล้ว +11

    Great video. All the explanations are very clear.
    These are my attempts. With "Compute" I wasn't if you mean to just show all the multilpes of 3 and 5 or also sum them, so I have tried both.
    To show all the multiples of 3 and 5:
    for i in range(1, 100):
    if i % 3 == 0 or i % 5 == 0:
    print(i)
    To sum them:
    total4 = 0
    for i in range(1, 100):
    if i % 3 == 0 or i % 5 == 0:
    total4 += i
    print(total4)
    Total is 2318

    • @mingji753
      @mingji753 2 ปีที่แล้ว

      if we only have to find the sum of multiples of 3
      the formula is:
      for i in range(1, 101):
      if i % 3 == 0:
      print(i)
      #To add them
      total = 0
      for i in range(1, 101):
      if i % 3 == 0:
      total = total + i
      print(total)
      the answer is 1683

  • @a2editz605
    @a2editz605 2 ปีที่แล้ว +1

    My goodness, so precisely elaborated examples! Thanks a lot man!

  • @lak2693
    @lak2693 3 ปีที่แล้ว

    I actually did it and it worked thx cs dojo guy lol
    print(list(range(1 ,101)))
    for element in range(1, 101):
    if element % 3 == 0 :
    print(element)
    for element in range(1, 101):
    if element % 5 == 0 :
    print(element)

  • @puttankinamall9693
    @puttankinamall9693 5 ปีที่แล้ว +5

    Thanks cs dojo i learned alot from your videos
    Greetings here frome philippines LOVE YOU ALWAYS CS 😊

  • @runoffwithme
    @runoffwithme 4 ปีที่แล้ว +173

    total3= 0
    for i in range(1,100):
    if i % 3 == 0 or i % 5 ==0:
    total3 += i
    print(total3)
    2318

    • @cindyliang3229
      @cindyliang3229 4 ปีที่แล้ว

      but he said less than 100

    • @cindyliang3229
      @cindyliang3229 4 ปีที่แล้ว +5

      TheExtravagantMule my bad i thought he said the sum under the 100😂😂😂

    • @jayxievaldez7768
      @jayxievaldez7768 4 ปีที่แล้ว +10

      it should be multiples of 3 AND 5 as per instruction

    • @googleopinion8898
      @googleopinion8898 4 ปีที่แล้ว +2

      @@jayxievaldez7768 That would make numbers like 15, 30, 45 etc appear twice, cos they're multiples of both 5 and 3

    • @trix8259
      @trix8259 4 ปีที่แล้ว

      didnt know bout or...added 'multiples of 3 nd 5 nd deducted 15's...:(

  • @jorrisbohnson4718
    @jorrisbohnson4718 2 ปีที่แล้ว

    Thank You this and all of your other videos have helped me a lot through these tough programming times!!

  • @pyjamaprince
    @pyjamaprince 2 ปีที่แล้ว

    Thank you soo much man this helped out for my exam of tomorrow!!! Keep on doing what you're doing, you're an amazing teacher and I'll definitely will make use of more of your vids

  • @jer_chiu
    @jer_chiu 6 ปีที่แล้ว +405

    Hey CS dojo, can you do a video that suggest some project for python beginner? That would be awesome!
    support you!

    • @CSDojo
      @CSDojo  6 ปีที่แล้ว +194

      Okay!

    • @deepanshupandeyofficial
      @deepanshupandeyofficial 6 ปีที่แล้ว +9

      Hey CS dojo.....em looking for the same. will u please suggest some beginner python project.

    • @leokwok723
      @leokwok723 6 ปีที่แล้ว +2

      Yes that would be nice :P

    • @nas209
      @nas209 6 ปีที่แล้ว +2

      Fantastic

    • @paraglide01
      @paraglide01 6 ปีที่แล้ว +6

      @Deepanshu Pandey Ok here is your beginners assinement. Make a TH-cam-isch app, they say its made in Python.

  • @jamesbyford2531
    @jamesbyford2531 3 ปีที่แล้ว +15

    This is an amazing series so far, been practicing code for a year now wish I would have found this a year ago. The EOD is on point. Thanks YK!!
    def awesome():
    name = "YK"
    print(name , "You are awesome!")
    print("End of Awesomeness block.")

    • @youaremad1736
      @youaremad1736 ปีที่แล้ว +1

      Error:: function wasn’t called, “end of awesomeness block” is all that was printed into console 😂😂

    • @venxity6959
      @venxity6959 ปีที่แล้ว

      You would have to establish name="yk" outside of the function and then you would have to call the function for this to work

  • @agoooshaa
    @agoooshaa 3 ปีที่แล้ว

    THANK YOU so much I was struggling for a couple of days to understand how it works with %, and now it's all clear!!

  • @proggaparomita281
    @proggaparomita281 2 ปีที่แล้ว

    woo i did it!! i did the task and it worked! this literally made my whole week. thank you cs dojo

  • @qwertyasdf2855
    @qwertyasdf2855 3 ปีที่แล้ว +4

    I love this series and i also recommend Free Code Camp! thanks so much for this series!

  • @ri8c
    @ri8c 6 ปีที่แล้ว +47

    thanks, dude. you're the real MVP

  • @akinian_
    @akinian_ 3 ปีที่แล้ว +2

    problem = list(range(1,100))
    sum = 0
    for element in problem:
    if element % 3 == 0 or element % 5 == 0:
    sum += element
    print (sum)
    2318
    thank you for the explanation!!

  • @kikojian2973
    @kikojian2973 3 ปีที่แล้ว

    What a great tutorial of for loops! I’m stuck in it and getting upset but your video just helps me out! Thank you and pls make more vids

  • @TheProGam3rHD
    @TheProGam3rHD 2 ปีที่แล้ว +5

    I can't believe I figured this on my own! For the multiple of 3, alternatively, you can use a nested for loop:
    for i in range(1, 8):
    for n in range(1, 8):
    if i / 3 == n:
    total3 += i
    print(total3)
    Although inconvenient, this circumvents the need to use the modulo operator. This is what I came up with because I didn't even think to use it.

    • @ramy131
      @ramy131 2 ปีที่แล้ว

      this answer is wrong lmao.

    • @TheProGam3rHD
      @TheProGam3rHD 2 ปีที่แล้ว +2

      @@ramy131 Please explain how this is wrong lmao. It works. 😂

    • @ramy131
      @ramy131 2 ปีที่แล้ว

      @@TheProGam3rHD I copied and pasted it on pycharm and it gave absolutely nothing back

    • @ramy131
      @ramy131 2 ปีที่แล้ว

      @@TheProGam3rHD besides this wasn’t the challenge he fucking asked for

    • @TheProGam3rHD
      @TheProGam3rHD 2 ปีที่แล้ว +2

      @@ramy131 Well clearly 4 other people liked my comment so it worked for them. You must have done something wrong. And why the hell are you getting so butthurt?

  • @ericji8632
    @ericji8632 2 ปีที่แล้ว +11

    print(list(range(1, 100)))
    total = 0
    for i in range(1, 100):
    if i % 3 == 0 or i % 5 == 0:
    total = i
    print(total)
    this code is used to find all the numbers inside the list. Print(total) is inside of the "for loop" in this case to list all of the numbers out

    • @marimabbas6351
      @marimabbas6351 ปีที่แล้ว

      why did you do total=o and total=i in the code? I'm having trouble understanding haha

    • @dhdhdkfjgjdmf5277
      @dhdhdkfjgjdmf5277 ปีที่แล้ว +2

      @@marimabbas6351 he should have written total += i instead of total = i

    • @prachaurja
      @prachaurja ปีที่แล้ว

      @Eric Ji you did wrong bro. sorry. but the code will be like -
      sum = 0
      for i in range(1,100):
      if i%3 == 0 or i%5 == 0:
      sum = sum + i
      print(sum)

    • @chimdiikechukwu7142
      @chimdiikechukwu7142 ปีที่แล้ว

      @@prachaurja what was your final answer when you processed the code?

  • @haseen2412
    @haseen2412 3 ปีที่แล้ว

    He is great at teaching. Breaks it down into the fundamentals!

  • @luiseduardomendez8667
    @luiseduardomendez8667 3 ปีที่แล้ว +1

    You rock it! I've started with python one week ago and this kind of videos are really helpful, thank you bro!

  • @Anon72005
    @Anon72005 6 ปีที่แล้ว +4

    Love you sooooo much! Please do a part 6 thanks!!!! 😘

  • @idunno...2179
    @idunno...2179 ปีที่แล้ว +7

    Thanks this was really helpful
    Since my teacher at school doesn't really seem to teach me well.

    • @JR-bu7we
      @JR-bu7we ปีที่แล้ว

      Right there with ya man

  • @nicholasgetty1805
    @nicholasgetty1805 3 ปีที่แล้ว

    Bro you are actually the GOAT, keep it up, you explain it sooooo well

  • @amaanadorable
    @amaanadorable 3 ปีที่แล้ว

    Thank you dojo .After watching your videos , i started learning to code again .You are just an inspiration

    • @DrRCB
      @DrRCB 2 ปีที่แล้ว

      Interesting. You will certainly learn

  • @patricioreese4468
    @patricioreese4468 6 ปีที่แล้ว +101

    You are the best man! Plz make a javascript course!

    • @annewariara5290
      @annewariara5290 6 ปีที่แล้ว

      Patricio Reese yaaaaas

    • @meltdown6856
      @meltdown6856 6 ปีที่แล้ว

      Patricio Reese I too want that

    • @gabechevalier1567
      @gabechevalier1567 6 ปีที่แล้ว +5

      Late response, but if you haven't already you should look at Dan Shiffman's videos (His channel is The Coding Train, and you won't die from boredom there), or on KhanAcademy they have some courses.

    • @jettgreen8326
      @jettgreen8326 6 ปีที่แล้ว +1

      oh yeah yeah

  • @a.s2791
    @a.s2791 2 ปีที่แล้ว +5

    fantastic, I loved the fact that you gave a little challenge at the end of the video it makes learning so much fun! btw, here's the code:
    total = 0
    for i in range (1, 100):
    if (i % 3 == 0) or (i % 5 == 0):
    total += i
    print(total)
    output = 2318

    • @ev_dash
      @ev_dash 2 ปีที่แล้ว

      let me try running your work. what I did initially was:
      total4 = 0
      for i in range(1, 100):
      if (i % 3 == 0, i % 5 == 0):
      total4 += i
      print(total4)
      4950
      let me know if I made any errors.

  • @harigovind7229
    @harigovind7229 2 ปีที่แล้ว

    range(1,101)
    total4 = 0
    for i in range(1,101):
    if i % 3 == 0:
    if i % 5 == 0:
    total4 += i
    print(total4)
    Ans - 315
    Thank you for being a wonderful teacher :p, #dojogangforever!!

  • @ecodersofficial
    @ecodersofficial 2 ปีที่แล้ว

    You shown me how to use for loop! I was searching the internet, But only your gave me the right way. Thanks!

  • @intansunarmi2669
    @intansunarmi2669 5 ปีที่แล้ว +5

    This video is awesome! LOVE it! Thank you for making this vid. You have made my life much easier.
    Oh! and I got 2318 from
    for index in range(1, 100):
    if index % 3 == 0 or index % 5 == 0:
    total += index

  • @ryansmithson1269
    @ryansmithson1269 4 ปีที่แล้ว +6

    I just started to learn python today i know im super late but i think this is correct.
    Total = 0
    for i in range(1, 100):
    If i % 3 == 0 or i % 5 == 0
    Total += i
    Print(total)
    2318

    • @karthikreddy7956
      @karthikreddy7956 4 ปีที่แล้ว +1

      can you explain why we use "or" but not "and"

    • @ryansmithson1269
      @ryansmithson1269 4 ปีที่แล้ว +3

      Karthik Banna you have to use “or” because you are trying to find the multiples of 3 or 5 and adding them. If you used “and” then it would only add numbers that are a multiple of both 3 and 5 like 15 but it wouldn’t add numbers like 6 because 6 isn’t a multiple of 5

  • @aqilamasri2227
    @aqilamasri2227 3 ปีที่แล้ว

    total4 =0
    for i in range(1,100):
    if i % 3 == 0 or i % 5 ==0:
    total4 += i
    print ('Num:',i,'Total:',total4)
    thanks YK for a great video!

  • @earnwithdavemichael1762
    @earnwithdavemichael1762 2 ปีที่แล้ว

    I never thought I could understand this, until now. Thank you for this.

  • @puneetkorjani6648
    @puneetkorjani6648 2 ปีที่แล้ว +5

    i calculated seprately multiples of 3 and 5
    si first i did:
    total = 0
    for element in range(1,100):
    if element % 3 == 0:
    total + total = element
    print(total)
    so i got the sum 1683
    total = 0
    for element in range (1,100):
    if element % 5 == 0:
    total = total + element
    print(total)
    so i got sum 950
    :) so when i added both i got 1683+950 = 2633
    thanks yk for the lovely videos

  • @javierlujan9249
    @javierlujan9249 4 ปีที่แล้ว +6

    The cleanest, easiest video yet in 2020! Thank you I promise to give you a free lambo when I'm rich

    • @chrisnirmal5387
      @chrisnirmal5387 2 ปีที่แล้ว

      lool good luck making one dollar

  • @aarshrawat2222
    @aarshrawat2222 2 ปีที่แล้ว

    your explanation is much better and easier to understand in comparison with other creators for beginners. thank you so much ..dojogang

  • @QuantApplicantMattKulis
    @QuantApplicantMattKulis 10 หลายเดือนก่อน

    awesome teaching. Super easy to understand using jupyter notebook also. clear comprehensive format, great explanation of syntax. 10/10

  • @ryanarpon158
    @ryanarpon158 5 ปีที่แล้ว +14

    Hey YK! Having a great time watching your videos.
    Keep it going, buddy. :)
    By the way, tried this and my answer is 2318
    total = 0
    for i in range(1, 100):
    if i % 3 == 0:
    total += i
    elif i % 5 == 0:
    total += i
    print(total)

  • @akhilaugustine2858
    @akhilaugustine2858 5 ปีที่แล้ว +15

    total=0
    a= list(range(1,100))
    for x in a:
    if x %3==0 or x%5==0:
    total+=x
    print (total)
    >>>2318

    • @todaystop3768
      @todaystop3768 5 ปีที่แล้ว +1

      But why can't we write
      x % 3 or x % 5 == 0:
      BTW it gives a wrong answer

    • @yyaaas6691
      @yyaaas6691 5 ปีที่แล้ว +5

      no need to make a list and put it in a for the for loop

    • @kalyanbaidya7339
      @kalyanbaidya7339 5 ปีที่แล้ว

      It worked

    • @kalyanbaidya7339
      @kalyanbaidya7339 5 ปีที่แล้ว

      Thanks

    • @kalyanbaidya7339
      @kalyanbaidya7339 5 ปีที่แล้ว

      I actually joined the two statements in 'if' by a comma. Thus....

  • @justinelustre5905
    @justinelustre5905 2 ปีที่แล้ว

    I'm a python newbie so bear with me. I think have two solutions. Feel free to comment for improvement. :D
    Solution #1:
    total = 0
    for i in range(100):
    if i%3 == 0 or i%5 == 0:
    total += i
    print(total)
    Solution #2:
    total = 0
    a = [n for n in range(100) if n%3 == 0 or n%5 == 0]
    for i in a:
    total += i
    print(total)
    PS: Thank you for your vids. I am currently a student and I have my final exam in Python next week. I already failed the first exam so I have to retake it. :'( But your tutorials are literally saving me! More power to you!

  • @pineapplejuice1156
    @pineapplejuice1156 2 ปีที่แล้ว +1

    This explained all the questions I had from for loops, thanks

  • @jiyan626
    @jiyan626 4 ปีที่แล้ว +7

    Hi CS dojo, your lesson is super nice!
    And after listening, l gave the code for your final question as below:
    total4=0 #define a new variable for calculating the sum of list
    for i in range(1,100):
    if i%3==0 or i%5==0:
    total4 +=i #total4=total4+i
    print(total4)
    If l have anything wrong, pls tell me. Thank you so much!

    • @f1memelord72
      @f1memelord72 2 ปีที่แล้ว

      Very late reply I know but I have just checked your code and it works, no better way that you could have done it.

  • @yeetyot9020
    @yeetyot9020 3 ปีที่แล้ว +5

    i = ["a", "b", "c"]
    for letter in i:
    print(letter)
    So it's just changing the variable for letter to i[number] every iteration?

  • @lanceareadbhar
    @lanceareadbhar 2 ปีที่แล้ว

    Very cool. I came here because I saw multiple people using the code "for node in" and assumed node was a keyword not realizing any text would have worked there.

  • @elvistala7053
    @elvistala7053 2 ปีที่แล้ว

    just amazing how I've learnt soo much in 3days thanks a lot and I'm subbing to your channel. Loving it

  • @sohamjagtap1009
    @sohamjagtap1009 3 ปีที่แล้ว +3

    YK sir, can you tell me what would i have learnt by the end of this series? Or what level would i be on? So that when the next time i learn python from a different source, i can continue from that point on

  • @joelkye4493
    @joelkye4493 4 ปีที่แล้ว +4

    in addition to totaling multiples of 3 and 5 I wrote the following code lines to deduct multiples of 15,
    if E1 % 15 == 0:
    #deduct multiples of 15
    total4 -= E1