For Loop in Python (So Easy to Understand) #9

  Рет қаралды 165,165

Programiz

Programiz

Күн бұрын

Пікірлер: 225
@programizstudios
@programizstudios 2 жыл бұрын
🔥 Learn Python with a more hands-on experience with Programiz PRO-interactive lessons, quizzes & challenges. Try Programiz PRO: bit.ly/right-python
@programizstudios
@programizstudios 4 жыл бұрын
Hey Guys! At 0:45, there is a minor error on our part. "Python" is a sequence of 6 characters, not 7.
@mkarazli
@mkarazli 4 жыл бұрын
No its true. PYTHO&N
@BrokeCanadian
@BrokeCanadian 4 жыл бұрын
I count 7 characters in my sequence "Python🐍"
@raahulsingz
@raahulsingz 3 жыл бұрын
@Zak MB If you just increment start value by 1, you will get the answer: n1=int(input("Enter number1: ")) n2=int(input("Enter number2: ")) print("The numbers between them: ") for i in range(n1+1,n2): #The number starts from n1+1 and n2 is excluded by default print(i)
@SpodermanISLoVe
@SpodermanISLoVe 3 жыл бұрын
This channel is really underrated, such good content.
@otatop7359
@otatop7359 4 жыл бұрын
i know i am late in this video but i just started learning from yesterday and i am catching up pretty fast thanks to you guys. I was learning c from the website back then too.
@Mugen89K
@Mugen89K 3 жыл бұрын
This code isn't correct in answering the video's question. Look at the example he gives in his link if you haven't already.
@enzy6434
@enzy6434 3 жыл бұрын
total = sum(range(1, 101)) print(total) Easy way to do it in just 2 lines using the sum() function. Though its a shortcut that doesn't use a for-loop obviously.
@sethmitchell840
@sethmitchell840 2 жыл бұрын
Figured it out ' ' ' number = 1 total = 0 for number in range(1,101) total = number + total print(total) ' ' ' Not too bad, but a little brain tease.
@Priyanshukumar_48
@Priyanshukumar_48 2 жыл бұрын
Just liten carefully whatever sir told We have to print the result in such format that it is like Result=1+2+3+4+............+100 Not the sum of all those number
@sauravsingh9795
@sauravsingh9795 2 жыл бұрын
for i in range (1, 100): print(i, "+", end=" ") print(100, end=" ") print("=", sum (range(1,101)))
@SharkSnuggie
@SharkSnuggie Жыл бұрын
A much easier way to do it is: sum = sum(range(1, 101)) print(sum)
@chomeboy
@chomeboy Жыл бұрын
@@SharkSnuggie sum is a built in function and you can use it as a variable?? dang.. that's crazy.
@adheeshakaumadi
@adheeshakaumadi 7 ай бұрын
@@chomeboy yes you can use it as a variable
@RishabhMall-s1z
@RishabhMall-s1z 6 күн бұрын
​@SharkSnuggie easier way: n=100 print(n*(n+1)/2)
@MohammedJaseemTp
@MohammedJaseemTp 3 жыл бұрын
7:23 n = int(input("enter the limit")) i=0 j=1 for i in range (0,n): sum = i+j i= sum j= sum+1 print(sum)
@HariPrasad-mn5vu
@HariPrasad-mn5vu 3 жыл бұрын
Guys if u want to learn python this is the best content some one can give you this can even compete with paid course worth a thousand dollar. Glad got a teacher like you thanks for the videos
@hamburguesete
@hamburguesete 4 жыл бұрын
Great video ! I love the way you explain evereything, it all makes sense. Keep up the great vídeos ! I have a small feedback, I know that every video you teach us a new tool of programing that opens up a whole new universe of small projects that we can do to get better, and at the end of the video you give us a smal project "homework" but its always very oriented in training that specific tool, i think that at the end of every video you should give us 3 small but yet challenging projects that we will use everything that we learned until that point. Thank you so much for the awesome content, and i hope you understand what im saying.. im sorry for the bad english.. Much love from Brasil !! 🇧🇷👍
@shankarsai2067
@shankarsai2067 4 жыл бұрын
True, We need some challenging one's
@programizstudios
@programizstudios 4 жыл бұрын
Hi Raphael! Good to know that you are enjoying our videos. We will take your feedback into consideration while creating new videos. Thanks.
@VladimirTheAesthete
@VladimirTheAesthete 3 жыл бұрын
Highly underrated channel, thanks a lot pal!
@irynahryma2605
@irynahryma2605 Жыл бұрын
Thank you for your lessons! You 're explaining really very good. I solved the task,you gave at the end of the video and I was excited, when it ran and everything was correct.
@harikrishanankurup8956
@harikrishanankurup8956 3 жыл бұрын
This was the first video I saw, and it was very much useful. And this is not the last video. Now I am gonna watch the complete playlist. Thanks. And keep uploading
@vedanshchn
@vedanshchn 2 жыл бұрын
I wrote this!! # Sum of any range of numbers a = int(input("Input the first number in the range: ")) z = int(input("Input the last number in the range: ")) sum = 0 for i in range(a , z+1): sum += i i += 1 print(sum)
@letstry2854
@letstry2854 4 жыл бұрын
Thanks sir 👍 Keep uploading...I am regular viewer!!
@Aravindblaze95
@Aravindblaze95 4 ай бұрын
sum = 0 for numbers in range(1,101): sum = sum + numbers print(sum,"=",end=" ") for number in range (1,100): print(number,"+",end=" ") print("100", end=" ")
@Aravindblaze95
@Aravindblaze95 4 ай бұрын
Output: 5050 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100
@malikcimen740
@malikcimen740 4 жыл бұрын
thaks a lot everything clearer than my professor's telling xD
@GTheo.
@GTheo. Жыл бұрын
Man you are born to teach.. even a 5 years old can understand you..
@multitaskprueba1
@multitaskprueba1 4 жыл бұрын
You are a genius and a great professor! Thanks a lot!
@125-ronaka7
@125-ronaka7 3 жыл бұрын
loved the way of teaching , as well as the content
@torpedoe1936
@torpedoe1936 3 жыл бұрын
So simply explained. Unbelievable. Thanx boss!
@shadanakhtar5095
@shadanakhtar5095 3 жыл бұрын
Your video's are very nice you explain it very nicely i made soo many programs on python by only watching your video it helped me alot Thank you bro
@before2am
@before2am 3 жыл бұрын
def numsum(): sum=0 for current_number in range(0,101): sum = current_number + sum print(sum)
@ashmitakaran6755
@ashmitakaran6755 2 жыл бұрын
2:33 It's not working.....I wrote the exactly same program in programiz python compiler and its no running but saying "invalid syntax''
@brandonlittlejohn8055
@brandonlittlejohn8055 2 жыл бұрын
idk if you'll ever see this comment python sensei but i want you to know you deserve great things in life your videos have helped me so much in my learning journey
@topan3689
@topan3689 Жыл бұрын
number = int(input("Enter an integer: ")) for count in range(1, 100): product = number + count print(number, "+", count, "=", product) Provided: 1 / it should be this one code, if I am correct. If not - please correct me. Thanks!
@swagger1982
@swagger1982 Жыл бұрын
To find Sum from 1 to 100 why you are taking number?
@AnsonCheung1049
@AnsonCheung1049 2 жыл бұрын
for loop in range (1,100000): if loop == 1: num2=0 num1=num2 num2=loop+num1 if loop ==100: print(num2)
@kirisutokyoto3505
@kirisutokyoto3505 3 жыл бұрын
number = range(1,101) For a in number: print (a,"+",end="")
@ajithkumar-mg2lx
@ajithkumar-mg2lx 2 жыл бұрын
Nice Bro
@স্টোরিলিন
@স্টোরিলিন 2 жыл бұрын
total = 0 # looping for summation of any series "x" to "y" x=int(input("enter the lower range : ")) y=int(input("enter the upper range : ")) for number in range(x,y+1): total = total + number print(total)
@rock8938
@rock8938 3 жыл бұрын
sum=0 for count in range(1,101): sum=sum+count print(sum)
@gamingtech2211
@gamingtech2211 3 жыл бұрын
_*Your Programming Task:- number = int(input("Enter the integer")) for count in range(1, 101) : sum = number + count print(number, "+", count, "=", sum)
@kusumguragain4756
@kusumguragain4756 Жыл бұрын
this is wrong , no one have provided the correct answer in comment section
@gabrielladangler1722
@gabrielladangler1722 4 жыл бұрын
Great videos! You've made it easy to learn Python, especially coming from a background in C. I do have a quick question: towards the beginning of the video, you say that the string 'Python' has 7 characters. Does this include a null character, or was this simply a mistake? Thank you! :)
@programizstudios
@programizstudios 4 жыл бұрын
Oh! It's an error on our part. "Python" is a sequence of 6 characters, not 7. And, they do not end with the null character like in C programming.
@gabrielladangler1722
@gabrielladangler1722 4 жыл бұрын
@@programizstudios Thank you for the clarification! :)
@grood.8925
@grood.8925 4 жыл бұрын
6:05 i am confused u have not declared the count variable and yet its showing the desired output. pls reply
@programizstudios
@programizstudios 4 жыл бұрын
The count variable is declared in the first line of the loop. # notice count variable in for count in range(1, 10): for count in range(1, 10): print(count)
@grood.8925
@grood.8925 4 жыл бұрын
ok understood ...thank you
@Mugen89K
@Mugen89K 3 жыл бұрын
Thank you very much for the awesome tutorials. Easily one of the best tutorials out there! One question, where is the github project you mention in the video? I can't find it in your comments or description.
@siderealvictor9813
@siderealvictor9813 4 жыл бұрын
sir mai python aapki website sai krta hoon vahan zyada syllabus hai yahan sai pr mujhe vahan literals nhi samajh aa rha aap us pr video bnaugai??
@majidalich2947
@majidalich2947 2 жыл бұрын
sum_num = 0 for i in range(1, 101): sum_num = sum_num + i print(sum_num)
@Priyanshukumar_48
@Priyanshukumar_48 2 жыл бұрын
Here it is... Print("result") For i in range(1,100): Print(i,end="+") Print(i+1)
@surya691
@surya691 2 жыл бұрын
Awesome lecturing brother 👍👍
@meghanajana621
@meghanajana621 11 ай бұрын
n = int(input("Enter a number:")) for c in range(1, 11): p = n * c print(c,"x",n,"=",p) this is my first tables code with for loop and I've done it without seeing the real code
@DigitalAcademyOnline
@DigitalAcademyOnline 3 жыл бұрын
Learning Python is something you would like to get in your skills, but you do not know where to start? This NEW channel will help you out leaning Python Programming from scratch - for complete Beginners, Intermediate and Advanced Levels
@avantika6077
@avantika6077 11 ай бұрын
using range function:( i did it myself so I didn't see what was coming) number=int(input("Enter the number:")) for count in range(1, 11, 1): product=count*number print(count,"x", number,"=", product) output: Enter the number:5 1 x 5 = 5 2 x 5 = 10 3 x 5 = 15 4 x 5 = 20 5 x 5 = 25 6 x 5 = 30 7 x 5 = 35 8 x 5 = 40 9 x 5 = 45 10 x 5 = 50 small note in (1,11,1), the first one is the starting, the 11 means upto 10 and 1 means(number of steps, i.e after 1, take 1+1=2, similar to count+=1)
@saharshprathibh6336
@saharshprathibh6336 3 жыл бұрын
number = int(input("Enter any number")) for count in range(1,11): sum = number + count print(number,"+",count,"=",sum)
@kusumguragain4756
@kusumguragain4756 Жыл бұрын
this is not a correct answer for the above question
@ugabuga4456
@ugabuga4456 4 жыл бұрын
I have 2 string exercises which are making me hate programming with python from the heart as they are suppose to be as easy as returning 1+1. def pairs(txt): if len(txt)%2==0: right_indexes=list(range(1,len(txt),2)) print(right_indexes) left_indexes=list(range(0, len(txt), 2)) print(left_indexes) right_letters=map(list(txt).__getitem__,right_indexes) left_letters=map(list(txt).__getitem__,left_indexes) pairs=list(zip(left_letters,right_letters)) return pairs I've ended up creating this list of paired tuples thinking it might help me understand better as I noticed how comparing 2 things next to each other. Because if the number of things is odd at the right side edge, it's not easy for me to know what to do. But it's not helping me to solve these very simple problems as I have no idea how to implement a for or while loop from pairs [(A,B),(B,C),(A,B),(C,C),(C,D)] for these 2 exercises: 1)Make a function that removes letters that are alone. Like if you have like ABBCABCCCD it would return BBCCC 2)Make another function which does the opposite turning like ABBCABCCC returns ACABD removing duplicates alight together (not just all). my brain only works to turn the whole thing into a set... ;____; When things are like this and you truly have to understand loops.... plus conversion as one is suppose to input a string and output should be a string.... I really feel like I'm the dumbest person alife Please help me solve these.
@mycreativecorner8831
@mycreativecorner8831 2 жыл бұрын
Great video👍, the way of your explanation is very good👌, all concepts are clear.
@avantika6077
@avantika6077 11 ай бұрын
Code to find sum upto any number n=int(input("Enter the number:")) for i in range(0, n+1, 1): i*=(n+1)/2 print("The sum from 0 to", n, "is:",int( i))
@Penguindude_
@Penguindude_ 3 жыл бұрын
Spoiler for the task I did it like this n = 1 w = 0 While n
@mohammadkazifaruk2097
@mohammadkazifaruk2097 10 ай бұрын
you are such a great on python
@MohammedJaseemTp
@MohammedJaseemTp 3 жыл бұрын
limit = int(input("enter the limit")) current_number=0 next_number=1 for current_number in range (0,limit): sum = current_number+next_number current_number = sum next_number = sum+1 print(sum)
@স্টোরিলিন
@স্টোরিলিন 2 жыл бұрын
not working properly, :-(
@ArunKumar-zz4tg
@ArunKumar-zz4tg Жыл бұрын
Awesome Explanation Brother
@Titina7183
@Titina7183 2 жыл бұрын
Your tutorials are very clear! Thanks for sharing your knowledge. Would there be a way to identify if the value entered is not an integer and show a message in that case, if not, do and show the sum? Thanks
@jasontuladhar1222
@jasontuladhar1222 3 жыл бұрын
Can you please give the answers to the task you gave us at 7:22 and the other ones you gave in other vids.
@RjAhtesham
@RjAhtesham 3 жыл бұрын
your videos are always helpful heartly thanks
@panagiotisbotonakis2349
@panagiotisbotonakis2349 4 жыл бұрын
Thank you so much. This video was very helpful!
@girishgh9793
@girishgh9793 Жыл бұрын
count=1 number=2 while count
@liw4972
@liw4972 3 жыл бұрын
Thank you for explaining the concept simply. it is awesome
@jubayethossain8132
@jubayethossain8132 3 жыл бұрын
sum=0 for i in range (1,101): sum=sum+i print(sum)
@asadzamir9249
@asadzamir9249 3 жыл бұрын
But this not work bro
@brahimayoada2657
@brahimayoada2657 2 жыл бұрын
This guy is the 🐐
@amarnathm314
@amarnathm314 3 жыл бұрын
Hi, thanks for sharing the knowledge. I have tried the counting program for num in range(1,11) sum=sum+num print(sum) when i say print, it is printing for sum value for every iteration, but if i need to print only the last sum value, can you please let me know how to do it
@amarnathm314
@amarnathm314 3 жыл бұрын
got it, we need to place the print statement out of the loop
@vincentkim6127
@vincentkim6127 3 жыл бұрын
I geess this is one month older thread though, this is how I did it. sum(list(range(101))) I am a beginner, and I feel like I am missing something.... It does its job though, right?
@cristianacrestani5941
@cristianacrestani5941 3 жыл бұрын
number = int(input('Enter a number for sum')) count = 1 for count in range (1,101): sum = number+count print(number, "+", count, "=" , sum)
@Abdulbasittia
@Abdulbasittia 2 жыл бұрын
Bro, you make things easier 🙏
@hannahgilbert3467
@hannahgilbert3467 Жыл бұрын
You’re brilliant - thank you :)
@raviteja_sannala
@raviteja_sannala 3 жыл бұрын
number = range(1,101) for i in range(len(number)): print(number[i], end='+')
@ahmadullahlutfi6946
@ahmadullahlutfi6946 3 жыл бұрын
well explained, keep up the good work bro.
@kanika1
@kanika1 2 жыл бұрын
number = int(input("enter a number:")) for count in range (1, 101): product = number + count print(number, "+", count, "=", product)
@naga_nihal_playz5777
@naga_nihal_playz5777 3 жыл бұрын
Great video! Understood everything
@IamKudos
@IamKudos 2 жыл бұрын
wait so is whatever you write between the for and in functions followed with a range, means nothing? No matter what I write down it will keep on going down the list of range. But I can't leave it blank either?
@khalilmahmood
@khalilmahmood 2 жыл бұрын
yes, since it is like a variable, that you normally assign value to, they cannot start with number and cannot have space in between the name, and can only contain (A-z, 0-9, and _ )
@shivasharma2576
@shivasharma2576 4 жыл бұрын
You making a 14 years old learn python. 🐨
@shankarsai2067
@shankarsai2067 4 жыл бұрын
what do you mean bro.... not getting it?
@karthik9354
@karthik9354 4 жыл бұрын
@@shankarsai2067 he is trying to say he don't know how to use A computer
@efeucar6032
@efeucar6032 2 жыл бұрын
this video was very helpful!
@banana_assasin3907
@banana_assasin3907 2 жыл бұрын
this is the hardest thing ive learnt so far
@shahporanhimel9207
@shahporanhimel9207 3 жыл бұрын
a=sum(range(1,101)) print(a) Got 5050 :3
@godwinakoto4578
@godwinakoto4578 4 жыл бұрын
infact kudos to you Punit and your team for such a great tutorial on python for beginners ! it is very clear and easy to follow
@mekkakelvin8057
@mekkakelvin8057 2 жыл бұрын
Thanks for your clear enlightenment on python. But mine did not work has yours did. It only took the last digit of the series of number who in my case was 20. This is my code Number = int(input("Enter an integer:")) Product=number*count Print(number, "X", count, "=", product)
@veerrr09
@veerrr09 Жыл бұрын
For anyone watching this video in 2023 (soon to be 2024): Here is the homework answer if you want it :> : number = 0 for number in range(0,100): number = number+1 print(number) Explanation : So we will always start from 0 to obtain the next number. And as explained in the video, we take the range as well. So after that since we gave our beginning value of number '0', '0' + 1 = 1. And this will continue till the range is satisfied. This is the magic of for loop! If somebody didnt understand, I am so sorry. Maybe I shouldnt be a teacher 😃
@MProtik
@MProtik 2 жыл бұрын
wait..!! How did he used # in every line by one click 4:50
@gauravfromuttaranchal5921
@gauravfromuttaranchal5921 3 жыл бұрын
Kya batoo bhut achha tutorial h bahi keep it up
@unnikrishnan-zi1ep
@unnikrishnan-zi1ep 3 жыл бұрын
Can you pls paste the link of github repository to find the programming the examples or more samples to work on
@DREYM360
@DREYM360 10 ай бұрын
result = 0 for num in range(1, 101): result += num if num < 100: print(num, "+ ", end="") else: print(num, end="") print(" =", result)
@cactusdg
@cactusdg 4 жыл бұрын
a = 0 for b in range(0,101): a = a + b print(a)
@SHPUDY
@SHPUDY 4 жыл бұрын
thanks
@joyceadhiambo9977
@joyceadhiambo9977 2 жыл бұрын
my answer number=int(input('Enter number:')) for sequence in range(1,101): sum=number+sequence print(number,'+',sequence,'=',sum)
@ibekwevictor1158
@ibekwevictor1158 2 жыл бұрын
Thank you for this tutorial.
@sarbjitchoong4578
@sarbjitchoong4578 2 жыл бұрын
Hi, I used the for statement for the assignment, and this is my answer: count = 0 total = 0 for count in range(0, 100): total = total + count count = count + 1 total1 = total + count print(total, "+", count, "=", total1) total thank you
@mynameisv630
@mynameisv630 2 жыл бұрын
no the out put must be in the format of 1+2+3+4....+100 and when you type range(0,100) the out put ends at 99 so we have to type range(0,101)
@sanajayakrishna
@sanajayakrishna 4 жыл бұрын
Not only python, but it is also better to make a video tutorial playlist on other programming languages like kotlin, swift, etc
@xrhstos1330
@xrhstos1330 4 жыл бұрын
Well he just started making videos, he cant upload 100's videos at once
@sanajayakrishna
@sanajayakrishna 4 жыл бұрын
@@xrhstos1330 is he the only one, then he should hire someone as interns
@xrhstos1330
@xrhstos1330 4 жыл бұрын
@@sanajayakrishna if you want to see videos for a language from someone else, you could also find another yt channel.
@DanyloNihmatulin
@DanyloNihmatulin Жыл бұрын
number = 100 product = 0 for sum in range(1, number + 1): product = product + sum print(product)
@saravanapothi574
@saravanapothi574 4 жыл бұрын
sum = 0 for count in range(1, 101): sum=sum+count Print("sum is:", sum)
@kkminicrafts4988
@kkminicrafts4988 6 ай бұрын
#PROGRAM TO FIND THE SUM OF GIVEN NATURAL NUMBERS ans = 0 num = int(input("ENTER THE NUMBER = ")) print("ANSWER = ") for count in range(1,num+1): print("step",count,"=",ans,"+",count) ans = ans + count print("Total answer =",ans)
@zoeyyuen4204
@zoeyyuen4204 Жыл бұрын
For result in range(1,101): Sum= i + result Result += 1 Print(sum)
@AnanthuAS-k2q
@AnanthuAS-k2q Жыл бұрын
Here i is not defined any where how its run
@brotherhood2001
@brotherhood2001 3 жыл бұрын
I want , please give a video on list, tuple, set and dictionary using for loop
@slimerelaxation5398
@slimerelaxation5398 2 жыл бұрын
how do we do this in a loop Accept names of 5 colours from the user and store it in list called ‘colours’.
@saumyatripathi2212
@saumyatripathi2212 3 жыл бұрын
Plz solve the practice question from while loop
@okbruh1617
@okbruh1617 4 жыл бұрын
Good presentation buddy
@pachakutiq266
@pachakutiq266 4 жыл бұрын
we can use the following code to obtain the result : sum(range(1,101)) Please feel free to correct me if am wrong but the answer is 5050 so i guess we can do it that way.
@abdulraheemabioye4246
@abdulraheemabioye4246 4 жыл бұрын
I ran this code... didn't work
@pachakutiq266
@pachakutiq266 4 жыл бұрын
@@abdulraheemabioye4246 I guess , I did it with a variable , sorry for the vague answer 😅 Code : x = sum(range(1,101)) print(x) That should work! I used it in another way last time , I don't remember exactly will let u know when I do
@Mathu2006
@Mathu2006 Жыл бұрын
number=0 for number in range(0,100): value=number+1 print(value,"+")
@dannydj2908
@dannydj2908 4 жыл бұрын
product = 0 for count in range(0,101): product = product + count print(product)
@programizstudios
@programizstudios 4 жыл бұрын
It's correct but you are printing the result in each iteration of the loop. Instead, just print the result once after the loop ends. Also, you can give a better variable name like total instead of product.
@madhumahendran6077
@madhumahendran6077 2 жыл бұрын
Could anyone clarify me how the result of the sum of 1 to 100 is not executed in the rows but as sum of all? i believed the for loop will provide result in rows, like 1+1 =2 2+1=3 etc
@magiiicuno3981
@magiiicuno3981 Жыл бұрын
total_sum = 0 for i in range(1,101): total_sum += 1 print(total_sum , "+", end=" " )
@GaurieVerma
@GaurieVerma 3 жыл бұрын
I checked out the answer for the task on github and the output is supposed to only be 5050, but when i write the same code in python i get a whole lot of numbers and the last number is 5050. am i doing something wrong or is it supposed to be like that?
@konstantinskoblik6640
@konstantinskoblik6640 2 жыл бұрын
Perhaps the indentation level of print(total) is similar to "total = total + number". So print(total) is the part of body "for". If print(total) has the same indentation level as "total=0", it'll work out. You'll get 5050 without unnecessary numbers such as 4950, 4851, etc.
@Kartv3li
@Kartv3li 3 жыл бұрын
answer: **x = 0 for i in range (1,101): x =+ i print(i)**
@DoubleTroubleSigma
@DoubleTroubleSigma 4 жыл бұрын
Please teach C also
@MuhammadUmer-bm5ek
@MuhammadUmer-bm5ek 3 жыл бұрын
sum=0 for count in range(1,101): sum=sum + count print("sum of 1 to 100 is=",sum)
@bhaktibhosale3427
@bhaktibhosale3427 3 жыл бұрын
Thank you so much sir👍
@abdulraheemabioye4246
@abdulraheemabioye4246 4 жыл бұрын
Hello, i ran the code as written in github and the output listed the all the sum iterations (i.e 1,3,6,10... 5050) instead of just the output (5050). Kindly assist. Thanks
@swagger1982
@swagger1982 Жыл бұрын
To print the result it must be outside the for loop To get outside the for loop remove all space before the print(result)
@sandipansarkar9211
@sandipansarkar9211 4 жыл бұрын
great explanation
@ramakrishnadevireddy2395
@ramakrishnadevireddy2395 4 жыл бұрын
for a in range(101): print('+',a, end=' ')
@karthikkiran338
@karthikkiran338 4 жыл бұрын
where's other part of the code? end is not defined
@pachakutiq266
@pachakutiq266 4 жыл бұрын
we dont have to use for to complete that task
@shivaansehgal2602
@shivaansehgal2602 4 жыл бұрын
Genius
Pass Statement in Python (When to use it?) #11
3:08
Programiz
Рет қаралды 54 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 431 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
While Loop in Python (Perform a Task 1000000 times With Ease) #8
10:12
Python Functions (The Only Guide You'll Need) #12
16:57
Programiz
Рет қаралды 619 М.
6 Tips to write BETTER For Loops in Python
9:19
Patrick Loeber
Рет қаралды 251 М.
"break" & "continue" Statements in Python #10
8:01
Programiz
Рет қаралды 102 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,3 МЛН
How I Would Learn Python FAST (if I could start over)
12:19
Thu Vu data analytics
Рет қаралды 688 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 254 М.
List Comprehension - BEST Python feature !!! Fast and Efficient
14:51
Python Simplified
Рет қаралды 200 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 447 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН