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

  Рет қаралды 1,676,386

CS Dojo

CS Dojo

Күн бұрын

Пікірлер: 3 900
@shuttershocker
@shuttershocker 3 жыл бұрын
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! :)
@Bakekun
@Bakekun 10 ай бұрын
Niceeee
@LeoDragonheart13
@LeoDragonheart13 9 ай бұрын
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 6 ай бұрын
It keeps giving me 0 What might I be doing wrong? Edit: nvm, found it 😅😅😅
@abhipatel4595
@abhipatel4595 4 ай бұрын
@@LeoDragonheart13if you are stuck for that long, you should ask chatgpt, thats what i always do when im really stuck and can’t figure it out 👍❤️
@nrrdpanda
@nrrdpanda 4 ай бұрын
Ooo nice! the "or" threw me off.. i couldn't figure out what i was doing wrong haha
@kasperderej7401
@kasperderej7401 4 жыл бұрын
Please don't stop what you're doing. You're a great teacher!
@aidantan9566
@aidantan9566 3 жыл бұрын
THAT'S WHAT SHE SAID
@swallowedinthesea11
@swallowedinthesea11 2 жыл бұрын
bool( "THAT'S WHAT SHE SAID" )
@mdvlogs5418
@mdvlogs5418 2 жыл бұрын
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
@ginethespinosa9827
@ginethespinosa9827 4 жыл бұрын
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 жыл бұрын
aww why did you post this lol.
@cakeuwaifu
@cakeuwaifu 2 жыл бұрын
@@anthonynarine5292 why not?
@anthonynarine5292
@anthonynarine5292 2 жыл бұрын
I accidentally gazed over the answer 🤣. I unintentionally copied 😅😅😅
@oluwadunsinoladipo2956
@oluwadunsinoladipo2956 2 жыл бұрын
@@anthonynarine5292 😹😹😹you’re the funniest person I’ve met on the net today
@anthonynarine5292
@anthonynarine5292 2 жыл бұрын
@@oluwadunsinoladipo2956 hahahahha
@RestIsPhilosophy
@RestIsPhilosophy 4 жыл бұрын
who else is loving this series on quarantine
@Boc3phu5
@Boc3phu5 4 жыл бұрын
Learning a new skill
@AbdulKaderAbdeenAgha
@AbdulKaderAbdeenAgha 4 жыл бұрын
totally
@moebulldog6922
@moebulldog6922 4 жыл бұрын
i need help with python
@jjredfox3504
@jjredfox3504 4 жыл бұрын
I was so bored of doing nothing and this was just some top tier stuff
@0_-
@0_- 4 жыл бұрын
100% me
@276sedvlintsax7
@276sedvlintsax7 4 жыл бұрын
Taught me more in ten minutes than 3 of my hour python lessons.
@musicheals3145
@musicheals3145 3 жыл бұрын
Wht
@rapzyszn19
@rapzyszn19 3 жыл бұрын
same lmao
@checkbouncer
@checkbouncer 2 жыл бұрын
that’s sad
@EsaFromtheVillage
@EsaFromtheVillage 2 ай бұрын
Agreed
@emmanueloseitutu7376
@emmanueloseitutu7376 2 жыл бұрын
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 жыл бұрын
rather than equals the zero both three and five you can do x % 15 == 0 same result
@Msliliheart
@Msliliheart 2 жыл бұрын
I used this and got the wrong answer for the multiples of 5.
@venxity6959
@venxity6959 2 жыл бұрын
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
@Rasberrychua999
@Rasberrychua999 4 жыл бұрын
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_ 4 жыл бұрын
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 4 жыл бұрын
that is exactly why I am here lol, teachers do not teach
@Turd13s
@Turd13s 4 жыл бұрын
Wow, 35 grand went down the drain huh.
@axel_r_
@axel_r_ 4 жыл бұрын
@@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 4 жыл бұрын
@@axel_r_ if you put it like that just half of 'em went down the drain...
@rakshitrai6050
@rakshitrai6050 3 жыл бұрын
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 жыл бұрын
yes this tutorial is indeed helpful i am from India too!
@luuchoo93
@luuchoo93 4 жыл бұрын
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!
@ghostiegoobie
@ghostiegoobie 3 жыл бұрын
I have a coding exam on Monday and I was still seriously struggling with loops and lists, so this is great! Thanks!!
@incognito7722
@incognito7722 2 жыл бұрын
@Bartosz Brown bruh it's 1 year the guy must be working for google by now
@activity5035
@activity5035 2 жыл бұрын
@@incognito7722 nah its first year lesson I bet he is in second year
@kevinanand3991
@kevinanand3991 2 жыл бұрын
@@incognito7722 Had me laughing lmao
@vysakhkodavana8932
@vysakhkodavana8932 4 жыл бұрын
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 4 жыл бұрын
Thanks so much
@sushilkumarlohani6709
@sushilkumarlohani6709 4 жыл бұрын
Thank you
@crab1458
@crab1458 4 жыл бұрын
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 4 жыл бұрын
list(range(1, 101))
@ティツィアーノ
@ティツィアーノ 4 жыл бұрын
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
@Mahmoud-dq5yp
@Mahmoud-dq5yp 2 жыл бұрын
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.
@YeahMadeit_17
@YeahMadeit_17 2 жыл бұрын
Hi! I'm Russian and i know English little bit, but KZbin has subtitles and it gives me an opportunity to learn Python) I started watching Your videos because rus KZbin doesn't have normal lessons. Thank u and don't stop making new videos)
@tanatswamapholisamoyo7289
@tanatswamapholisamoyo7289 2 жыл бұрын
You're a great teacher bro. Taught me more in 10 minutes than 2 of my hour long python lessons! Don't stop bro.
@christopherwolters2048
@christopherwolters2048 10 ай бұрын
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!
@horkoser
@horkoser 4 жыл бұрын
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 жыл бұрын
should I use "and" or "or" ?
@gallonrs
@gallonrs 4 жыл бұрын
@@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 жыл бұрын
Anyone else just put i % 3 == 0: and get 9
@vanwest9614
@vanwest9614 4 жыл бұрын
bro i got 33
@haronbansilan2984
@haronbansilan2984 4 жыл бұрын
I learned a lot on this conversation. Thank you all
@courtney-nogel
@courtney-nogel 6 жыл бұрын
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!!
@itay5825
@itay5825 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!!!!
@amberniesalting9011
@amberniesalting9011 3 жыл бұрын
total = 0 for i in range(1, 100): if i % 3 == 0 or i % 5 == 0: total += i print(total) Output = 2318
@sanjivverasamy5716
@sanjivverasamy5716 3 жыл бұрын
the same answer i got
@jaubee
@jaubee 2 жыл бұрын
@@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 жыл бұрын
@@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 жыл бұрын
@@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 жыл бұрын
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)
@blufy2804
@blufy2804 3 жыл бұрын
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 2 жыл бұрын
Both the ways have same answer. Which one is more efficient?
@farkhodkuchkarov5238
@farkhodkuchkarov5238 2 жыл бұрын
But is this the right answer? Cause my solutions looks very similar here.
@ppmokgoro
@ppmokgoro 2 жыл бұрын
my understanding could be wrond: but didnt he say the modulo should be 3 AND 5 as opposed to 3 or 5?
@LAM638
@LAM638 3 жыл бұрын
I don't usually leave comment in YT but your tutorial is easy to understand for beginner. Thank you
@petrapocoloco2471
@petrapocoloco2471 3 жыл бұрын
can't agree more :)
@nsobomelfordrisimati5913
@nsobomelfordrisimati5913 3 жыл бұрын
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
@karanrubenchaudhury7283
@karanrubenchaudhury7283 4 жыл бұрын
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!
@kafleykishore87
@kafleykishore87 11 ай бұрын
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
@VgGamerKnight
@VgGamerKnight 4 жыл бұрын
I love this channel, I'm an absolute beginner and YK explains it so well that I don't even need to take notes.
@v0styr0-u4n
@v0styr0-u4n 3 жыл бұрын
well mabye take notes
@j9studios384
@j9studios384 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
@VicLaranja
@VicLaranja 4 жыл бұрын
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 4 жыл бұрын
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 3 жыл бұрын
@@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)
@__shaikmalikbasha__
@__shaikmalikbasha__ 6 жыл бұрын
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 5 жыл бұрын
I agree he is exceptional at explaining this stuff. Far above anything I've seen or read so far.
@divyadeepkaushik321
@divyadeepkaushik321 4 жыл бұрын
LET'S START A PETITION MAYBE print("lol")
@JustinMacri007
@JustinMacri007 2 жыл бұрын
@@divyadeepkaushik321 we want to learn what is machine learning
@Fishtyi
@Fishtyi 4 жыл бұрын
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 4 жыл бұрын
was putting a comma instead of an or...thanks
@Fishtyi
@Fishtyi 4 жыл бұрын
@@thomaslozada7918 yeah I wasn't even putting anything there, but i have fixed it
@davidvidal5297
@davidvidal5297 4 жыл бұрын
​@@Fishtyi 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 4 жыл бұрын
Is the answer 2318!?
@22niloc
@22niloc Жыл бұрын
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
@davida6146
@davida6146 2 жыл бұрын
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!
@MonteroKirilenko
@MonteroKirilenko 5 жыл бұрын
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 3 жыл бұрын
I was so confused on how to solve it cause I didn't know "or" is a thing 😂
@sanjosabu8170
@sanjosabu8170 3 жыл бұрын
@@aryabima256 same🙄😪😂😜
@xuanyuliang101
@xuanyuliang101 3 жыл бұрын
@@aryabima256 I also didn't realize the "or" part, I tried "elif", but it didn't work😂
@lamp9611
@lamp9611 3 жыл бұрын
AAAAA i feel dumb I included the hundred 💀💀💀
@revathirev365
@revathirev365 3 жыл бұрын
i tried using if and elif and it worked :-) got the same , but your way of approach by using or is very time saving.
@MonicaBetancourt-ln9eu
@MonicaBetancourt-ln9eu 7 ай бұрын
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!
@JesusJFuncia
@JesusJFuncia 4 жыл бұрын
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
@TheProGam3rHD
@TheProGam3rHD 3 жыл бұрын
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 3 жыл бұрын
this answer is wrong lmao.
@TheProGam3rHD
@TheProGam3rHD 3 жыл бұрын
@@ramy131 Please explain how this is wrong lmao. It works. 😂
@ramy131
@ramy131 3 жыл бұрын
@@TheProGam3rHD I copied and pasted it on pycharm and it gave absolutely nothing back
@ramy131
@ramy131 3 жыл бұрын
@@TheProGam3rHD besides this wasn’t the challenge he fucking asked for
@TheProGam3rHD
@TheProGam3rHD 3 жыл бұрын
@@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?
@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!!!
@rafaelkacaribu2081
@rafaelkacaribu2081 2 ай бұрын
total4 = 0 total5 = 0 for i in range (1, 100): if i % 3 == 0: total4 += i if i % 5 == 0: total5 += i print(total4+total5) different aswer than yours, wow
@yatink4981
@yatink4981 6 жыл бұрын
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.
@sreepaljsp
@sreepaljsp 5 жыл бұрын
IIT or NIT?
@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)
@kangajankuganathan7457
@kangajankuganathan7457 5 жыл бұрын
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 жыл бұрын
you know you're lazy when you copy this little code
@mohitkumar-cm5nk
@mohitkumar-cm5nk 5 жыл бұрын
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 жыл бұрын
@@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.
@lanceareadbhar
@lanceareadbhar 3 жыл бұрын
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.
@hereslookingatyoukid
@hereslookingatyoukid 4 жыл бұрын
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 жыл бұрын
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
@wilwilson8146
@wilwilson8146 3 жыл бұрын
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. 👍
@yasserfathelbab1534
@yasserfathelbab1534 2 жыл бұрын
I really like how you elaborated that we can use element or anything else and where is += is coming from. great educator :))
@tusharedits9
@tusharedits9 4 жыл бұрын
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.
@othmanabuso
@othmanabuso 2 жыл бұрын
This series, ahy 🙌, out of all KZbinrs I have gone through, you top them all, great job man.
@ericji8632
@ericji8632 2 жыл бұрын
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
@manba7344
@manba7344 2 жыл бұрын
why did you do total=o and total=i in the code? I'm having trouble understanding haha
@dhdhdkfjgjdmf5277
@dhdhdkfjgjdmf5277 2 жыл бұрын
@@manba7344 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?
@blakeparker6588
@blakeparker6588 5 жыл бұрын
Thanks CS dojo, I've learnt and developed my Python skills a lot through your tutorial videos!!
@asmae3643
@asmae3643 3 жыл бұрын
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✌️
@RahulSharma-zs9lu
@RahulSharma-zs9lu 6 жыл бұрын
Thanks for all your videos I think you are best teacher we had for python on KZbin!! All your videos are really helpful 😊
@alexpapadakis7912
@alexpapadakis7912 6 жыл бұрын
Rahul Sharma check thenewboston . he definitely deserves first place yet
@RahulSharma-zs9lu
@RahulSharma-zs9lu 6 жыл бұрын
Ok thanks for your suggestion!!
@alexwu7915
@alexwu7915 6 жыл бұрын
Julien Décarie he is all right
@jamesbyford2531
@jamesbyford2531 3 жыл бұрын
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 2 жыл бұрын
Error:: function wasn’t called, “end of awesomeness block” is all that was printed into console 😂😂
@venxity6959
@venxity6959 2 жыл бұрын
You would have to establish name="yk" outside of the function and then you would have to call the function for this to work
@plutus4047
@plutus4047 3 жыл бұрын
This is the best explanation.. I'm confused and watched 3,4 videos but you are the only one who makes it clear
@jenh3183
@jenh3183 4 жыл бұрын
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.
@orubele11
@orubele11 3 жыл бұрын
total3 = 0 total5 = 0 for i in range (1,100): if i %3 ==0: total3 +=i elif i %5 ==0: total5 +=i Total = (total3 + total5) print('Total:', Total) Total = 2318 Awesome teaching.
@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!!
@jaicymelisse5532
@jaicymelisse5532 2 жыл бұрын
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
@ryansmithson1269
@ryansmithson1269 4 жыл бұрын
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 жыл бұрын
can you explain why we use "or" but not "and"
@ryansmithson1269
@ryansmithson1269 4 жыл бұрын
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
@JRom_19
@JRom_19 2 жыл бұрын
multiples_of_three = 0 for i in range(1, 100): if i % 3 == 0: multiples_of_three += i multiples_of_five = 0 for i in range(1, 100): if i % 5 == 0: multiples_of_five += i total_sum = multiples_of_five + multiples_of_three print(total_sum) I got 2633. I think i did this the long way but I was proud be able to figure out something finally. Thank you for this content
@idunno...2179
@idunno...2179 Жыл бұрын
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
@Stabby5656
@Stabby5656 5 жыл бұрын
for i in range(1, 100): if i % 3 == 0: total += i elif i % 5 == 0: total += i print(i)
@AzraelVM
@AzraelVM 5 жыл бұрын
this is the line i went too :P
@the69prophet47
@the69prophet47 5 жыл бұрын
your code is incomplete. You have to reduce those numbers which are common multiple of 3 & 5, for eg, 15,30... these numbers would have come twice with the above code. Now you've to add this line to the code. if i % 3 and i % 5 == 0 total = total - i you'll eliminate the common multiples once and the result would be 1998
@ivanott7196
@ivanott7196 3 жыл бұрын
When I studied programming at university, I thought I was stupid for being very slow to understand it. As a geo-engineer, we basically understand something through why the result or outcomes become like that instead of just accepting it has to be like that. The programming teacher basically just asked us to watch videos, take tests and do little projects but barely teaching in the depth. I was kinda angry because I think she needs to use different methods how to teach programming to the future engineers, instead of treating us like future IT guys. So this channel does make me understand in detail why the outcomes like that. Thank you!
@a.s2791
@a.s2791 3 жыл бұрын
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.
@akhilaugustine2858
@akhilaugustine2858 5 жыл бұрын
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 жыл бұрын
But why can't we write x % 3 or x % 5 == 0: BTW it gives a wrong answer
@yyaaas6691
@yyaaas6691 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....
@deVon30241
@deVon30241 4 жыл бұрын
Wow, some of you people are really smart. My answer did not even come close and some of you had nice, simple solutions.
@trianglebean3884
@trianglebean3884 4 жыл бұрын
don’t sell yourself short b! everyone in the comments are at different levels, and people only post those when they’re pretty confident about it. keep going n you’ll be spitting out nice, simple solutions too !!!
@deVon30241
@deVon30241 4 жыл бұрын
@@trianglebean3884 much appreciated. Coding is so open ended in a way, which kinda throws me off, it requires a different kind of thinking than I'm used to. There's many ways to reach a solution, but there's always a best way, that requires some creativity and a fundamental understanding of the program. Its fun!
@vikasmaurya6332
@vikasmaurya6332 5 жыл бұрын
total4 = 0 for f in range(1,100): if f % [3,5] == 0: total4+= f print(total4) The Answer will be 1683 950 respectively.
@mrbluetop8404
@mrbluetop8404 4 жыл бұрын
its 2318.
@gailk30
@gailk30 2 жыл бұрын
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. 👍🏼
@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!
@jiyan626
@jiyan626 5 жыл бұрын
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.
@jer_chiu
@jer_chiu 6 жыл бұрын
Hey CS dojo, can you do a video that suggest some project for python beginner? That would be awesome! support you!
@CSDojo
@CSDojo 6 жыл бұрын
Okay!
@deepanshupandeyofficial
@deepanshupandeyofficial 6 жыл бұрын
Hey CS dojo.....em looking for the same. will u please suggest some beginner python project.
@leokwok723
@leokwok723 6 жыл бұрын
Yes that would be nice :P
@nas209
@nas209 6 жыл бұрын
Fantastic
@paraglide01
@paraglide01 6 жыл бұрын
@Deepanshu Pandey Ok here is your beginners assinement. Make a KZbin-isch app, they say its made in Python.
@FernandoGonzalez-fk7vb
@FernandoGonzalez-fk7vb 3 жыл бұрын
Very clear explanation, thank you. Here is my code: total = 0 for i in range(1, 100): if (i % 3 or i % 5) == 0: total += i print(total)
@peethos
@peethos 3 жыл бұрын
If I'm not mistaken, you're not supposed to use brackets in the third line, you're supposed to separate the two arguments so the code should look something like this total = 0 for i in range(1, 100): if i % 3 ==0 or i % 5 ==0: total += i print (total) And on the terminal you should get 2318. I hope it helps.
@patricioreese4468
@patricioreese4468 6 жыл бұрын
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 жыл бұрын
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 жыл бұрын
oh yeah yeah
@puttankinamall9693
@puttankinamall9693 5 жыл бұрын
Thanks cs dojo i learned alot from your videos Greetings here frome philippines LOVE YOU ALWAYS CS 😊
@Ravinder9
@Ravinder9 3 жыл бұрын
best part was the way you explain the code that what it really means to write 'i' or any other thing , really helpfull really looking for such explanantion thanks once again
@puneetkorjani6648
@puneetkorjani6648 3 жыл бұрын
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
@rafaelkacaribu2081
@rafaelkacaribu2081 2 ай бұрын
total4 = 0 total5 = 0 for i in range (1, 100): if i % 3 == 0: total4 += i if i % 5 == 0: total5 += i print(total4+total5) the answer is the same as yours :)
@ryanarpon158
@ryanarpon158 5 жыл бұрын
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)
@simidolalawani6616
@simidolalawani6616 4 жыл бұрын
Same
@dryedapricot1086
@dryedapricot1086 3 жыл бұрын
his explanations are really quite clear y = 0 for i in range(1,101): if i % 5 == 0: y += i elif i % 3 == 0: y += i
@javierlujan9249
@javierlujan9249 4 жыл бұрын
The cleanest, easiest video yet in 2020! Thank you I promise to give you a free lambo when I'm rich
@chrisnirmal5387
@chrisnirmal5387 3 жыл бұрын
lool good luck making one dollar
@MazorKuziaki
@MazorKuziaki 4 жыл бұрын
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 KZbin video to explain it to me in a different way. This helped tremendously.
@akinian_
@akinian_ 3 жыл бұрын
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!!
@ri8c
@ri8c 6 жыл бұрын
thanks, dude. you're the real MVP
@fabryperot8081
@fabryperot8081 6 жыл бұрын
grow up
@ankitmahajan3882
@ankitmahajan3882 6 жыл бұрын
shut up kid
@carloscosta2751
@carloscosta2751 4 жыл бұрын
list=[ ] sum=0 for i in range(100): if i%3==0 or i%5==0: list.append(i) sum += i print(list) print(sum)
@BenDover-vh9rs
@BenDover-vh9rs 4 жыл бұрын
Thank you, very smooth
@JoulezzzProject
@JoulezzzProject 4 жыл бұрын
Finally! I didn't understood how the fuck do it. It was a headcracker since he was asking for all the multiples and the script he was using was summing all the results. Thank you.
@carloscosta2751
@carloscosta2751 4 жыл бұрын
@eman elkholy That's odd. Make sure you have declared an empty list before the loop typing list_name = [ ]. When you don't declare a list making it equal to an empty pair of square brackets, Python considers it as an integer. That's probably where your error comes from.
@DeshawnMichaels
@DeshawnMichaels 3 жыл бұрын
Much love bro! run = 0 for y in list(range(1,100)): if y%3 == 0: run += y elif y%5 == 0: run += y print(run) = 2318
@qwertyasdf2855
@qwertyasdf2855 4 жыл бұрын
I love this series and i also recommend Free Code Camp! thanks so much for this series!
@joelkye4493
@joelkye4493 5 жыл бұрын
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
@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!
@Chefian-ow4jy
@Chefian-ow4jy 5 жыл бұрын
print(list(range(1,100))) total1 = 0 for i in range(1,100): if i % 3 == 0: total1 +=i elif i % 5 == 0: total1 +=i print(total1) 2318
@rikeshpoudel7462
@rikeshpoudel7462 5 жыл бұрын
well done , but you didn't need to write the first line of code unless you need to see the list....
@ts8960
@ts8960 5 жыл бұрын
total = 0 for E in range(1, 100): if E % 3 == 0 or E % 5 == 0: total += E print(total)
@utsavsapkota2049
@utsavsapkota2049 5 жыл бұрын
Total =0 for e in range (1,100): if e % 3 == 0: Total += e elif e % 5 == 0: Total += e Print(total) Is this correct? This is what I did and got 2318
@maxrandom569
@maxrandom569 5 жыл бұрын
That's right, well done!
@ts8960
@ts8960 5 жыл бұрын
total = 0 for E in range(1, 100): if E % 3 == 0 or E % 5 == 0: total += E print(total)
@arielrr
@arielrr 4 жыл бұрын
TWIN
@MinhBinh-dr9rc
@MinhBinh-dr9rc 4 жыл бұрын
Its not correct. Dojo said "the both multiple of 3 and 5...and 15 is the first number". So I think it have to be: if (e%3==0) and (e%5==0):
@Zilgamech
@Zilgamech 4 жыл бұрын
​@@MinhBinh-dr9rc He explains @9:35 that you sum 3, 6 then 9 and so on... And noticed that eventually you get to 15 which is a multiple of both. That's why your code is wrong because it only counts the numbers that are multiples of 3 and 5 instead of the multiple of 3 and the multiples of 5 like he explains.
@CleoTheBigBlackDog
@CleoTheBigBlackDog 3 жыл бұрын
a = list(range(1, 101)) total = 0 for e in a: if e % 3 == 0: total += e print(e) if e % 5 == 0: total += e print(e) Thank you for teaching me
@milesalaoui7885
@milesalaoui7885 2 жыл бұрын
The result with explanation Paste this code for line by line explanation: The Result is 2318 List_of_100=list(range(1,100) ) # excludes the number 100 List_3=[] List_5=[] for i in range(1,100): if i % 3 == 0: List_3.append(i) elif i % 5 == 0: List_5.append(i) print("This is the list of multiple of 3 :", List_3) print("This is the sum of multiple of 3 :",sum(List_3)) print(" ") print("This is the list of multiple of 5 :", List_5) print("This is the sum of multiple of 5 :",sum(List_5)) print(" ") List_3_5=[] for i in List_3: List_3_5.append(i) for i in List_5: if i not in list_3_5: List_3_5.append(i) print("This is the list of all the element :",List_3_5) print("This is the total without duplicate: ",sum(List_3_5))
@anthonyo.onwuchekwa9909
@anthonyo.onwuchekwa9909 Жыл бұрын
nicely done. Love what you did with the L
@brigidggee7722
@brigidggee7722 5 жыл бұрын
list(range(1,100)) for n in range(1,100): if n%3==0 and n%5==0: print(n)
@sameergupta8640
@sameergupta8640 5 жыл бұрын
That's what I did.
@tsatsralt9112
@tsatsralt9112 5 жыл бұрын
actually that is incorrect. He said sum of the numbers that is divided by 3 or 5. So, instead of using (and) you should use (or)
@G_Breaker
@G_Breaker 2 жыл бұрын
total = 0 for i in range(1,101): if i % 3 == 0 and i % 5 == 0: total += i print(total) : output 315
@yeetyot9020
@yeetyot9020 4 жыл бұрын
i = ["a", "b", "c"] for letter in i: print(letter) So it's just changing the variable for letter to i[number] every iteration?
@Renzore-iw7tx
@Renzore-iw7tx 6 жыл бұрын
var = 0 for num in range(1, 100): if num % 3 == 0 and num % 5 == 0: var += num print(var)
@LoyaltyKama
@LoyaltyKama 4 жыл бұрын
the code is actually: mul = [] for i in range(1, 100): if i % 3 == 0: mul.append(i) elif i % 5 == 0: mul.append(i) print(mul) #u dont need to put "and", and u can also use .append
@chagantisrichandana8251
@chagantisrichandana8251 4 жыл бұрын
The simple thing is If(i%15==0):
@LoyaltyKama
@LoyaltyKama 4 жыл бұрын
@@chagantisrichandana8251 what?😂😂😂
@chagantisrichandana8251
@chagantisrichandana8251 4 жыл бұрын
@@LoyaltyKama I don't understand why ur laughing He asked both multiples of 3 and 5 That is 15,30,45...etc For the above numbers n%15 ==0 we use
@chagantisrichandana8251
@chagantisrichandana8251 4 жыл бұрын
@@LoyaltyKama do you have any further doubt?
@leopoldomusic
@leopoldomusic 3 жыл бұрын
Thanks CS Dojo for putting together such a great course! I am looking to do a career change and this is my first contact with programming. It is being very helpful! Here's my attempt to the challenge: total5 = 0 for e in range(1,100): if e % 3 == 0: if e % 5 == 0: total5 += e print(total5) 315
@ME0WMERE
@ME0WMERE 3 жыл бұрын
that will only add an item to the list if it divides by both three and five
@MaximQuantum
@MaximQuantum 4 жыл бұрын
I got 2318. My answer: total = 0 for i in range(1,100): if i % 3 == 0 or i % 5 == 0: total += i print(total)
@gkdawg5154
@gkdawg5154 4 жыл бұрын
Shouldn’t it be and
@gkdawg5154
@gkdawg5154 4 жыл бұрын
Maxim Quantum instead of or
@polrivarola399
@polrivarola399 4 жыл бұрын
@@gkdawg5154 That just gives you the sum of numbers which are both multiple of 3 and 5 and throws you 315
@sinyiheng3732
@sinyiheng3732 4 жыл бұрын
I came up with this solution as well. It seems that Python knows to nullify any duplicates? Correct me if I am wrong.
@adityaranjan7916
@adityaranjan7916 4 жыл бұрын
he said 3 *and* 5 so i used 'and' rather than 'or'. my code was total = 0 for i in a: if i % 5 ==0 and i % 3 == 0: total = total + i print (total)
@edylljoshwa
@edylljoshwa 2 жыл бұрын
This has been the most straightforward tutorial, much helpful than the self-learning course I've paid. Thank you very much!!
@intansunarmi2669
@intansunarmi2669 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
@marsh725
@marsh725 4 жыл бұрын
I know I'm late but here's mine 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)
@xixyaxgaming4313
@xixyaxgaming4313 3 жыл бұрын
you could get rid of your first line of code as it doesnt help to find the sum of all multiples of 3 and 5. Other than that though that works great!
@marsh725
@marsh725 3 жыл бұрын
@@xixyaxgaming4313 Thanks a lot for this comment it helped
@Dalai33
@Dalai33 Жыл бұрын
Omg thank you!!!! Finally someone who understands python is teaching python.
@bengibengi2300
@bengibengi2300 4 жыл бұрын
Hey, *instead of if i % 3 == 0 or i % 5 ==0: why can't we just use elif alongside if?* I got the same answer (2318) in a different way from the others but here's what I did: total = 0 for i in range(1, 100): if i % 3 == 0: total += i *elif i % 5 == 0:* total += i print(total) *Output: 2318* Anyways, I'm sorry for the really really late reply. I started learning how to code just because of quarantine, haha. Good luck to all the others! And hope this helps someone out. :) *Edit: I didn't realize YK included the solutions in Python Tutorial 7. Glad I was right at least :3
@maromus2496
@maromus2496 4 жыл бұрын
I did the same
@abhishekbagva5110
@abhishekbagva5110 4 жыл бұрын
print(sum([i for i in range(100) if i%3==0 or i%5==0])) You could use list comprehension, to save a few lines, but it does exactly the same as yours:
@bengibengi2300
@bengibengi2300 4 жыл бұрын
Yeah, I learnt about list comprehension later on. They really save a lotta time. Right now I'm making a to-do web app using Django ._.
@leonliu2035
@leonliu2035 4 жыл бұрын
Works, but less efficient than using or statement.
@officialcoffeebag
@officialcoffeebag 4 жыл бұрын
t = 0 for i in range(1,100): if i % 3 == 0: t += 1 elif i % 5 == 0: t += 1 print(t) why I am not getting same output as yours, please help
@deepmarsonia2463
@deepmarsonia2463 6 жыл бұрын
Keep making tutorials. Very nice explained I solved this Here is code CS DOJO, sum = 0 for i in range(1, 101): if i % 3 == 0: sum = i + 1 print(i) sum1 = 0 for a in range(1,101): if a % 5 == 0: sum1 = 0 + a print(sum1) print("/n now the answer is:") q = sum + sum1 print(q)
@Ricebow11
@Ricebow11 6 жыл бұрын
why did you do sum - i + 1? when i compile your code, it look like you just capture multiple of 3 and 5. The task was to take ALL multiple of 3 and 5 that are less than 100. Correct me if i am wrong.
@prithvisubaraja
@prithvisubaraja 6 жыл бұрын
its not right bud
@elavarasanraja1320
@elavarasanraja1320 6 жыл бұрын
Your code is right..but it's not right code for the answer he put forward... listen to question again you could figure it out..
@johnluca3865
@johnluca3865 6 жыл бұрын
Yours works but is unnecessarily too complicated. When coding you wanna make it as simple as possible so others can understand while still making sure the code actually works. Here is a simpler version of urs total1 = 0 for i in range(1,101): if i % 3 == 0 or i % 5 == 0: total1 = total1 + i print(total1) This one instead of adds them all together it lists the numbers off which is the concept i needed to make a program to do my homework assignment
@abhiiiii_
@abhiiiii_ 6 жыл бұрын
mul = 0 mul2 = 0 for i in range(1, 100): if i % 3 == 0: mul += i elif i % 5 == 0: mul2 += i print("sum of all multiples of 3:", mul) print("sum of all multiples of 5:", mul2)
How To Use Functions In Python (Python Tutorial #3)
14:55
CS Dojo
Рет қаралды 2,4 МЛН
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 86 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 132 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 5 МЛН
For loops in Python are easy 🔁
5:06
Bro Code
Рет қаралды 382 М.
For Loops in Python | Python for Beginners
9:17
Alex The Analyst
Рет қаралды 64 М.
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 1,7 МЛН
Introduction To Lists In Python (Python Tutorial #4)
9:55
CS Dojo
Рет қаралды 1,2 МЛН
AI, Machine Learning, Deep Learning and Generative AI Explained
10:01
IBM Technology
Рет қаралды 560 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 620 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 214 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 86 МЛН