Skip to main content

Python program to print and add numbers starting 1 onwards till the sum of them is less than 100

Below is the code snippet to print the sum of number from 1 to 100 in Python.
Check the indents.



  1. #Declaring Variable 
  2. sum=0 
  3. #Now Running For Loop from 1 to 100
  4.  
  5. #range(0,n) take 0 and leave the last element 'n' 

  6. for i in range (1,101): 
  7. #Checking weather sum is less than 100 or not
  8.       while((sum+i)<100):
  9.           sum+=i
  10.           print(sum,'\n')
  11.           #Once Printed Sum Now Break The While Loop
  12.           break
  13. #End Of Program




#END OF THE PROGRAM

Comments

Popular posts from this blog

Facebook is testing ‘Green Screen’ editing tool for content creators

"Green Screen" will be available as an editing tool for the social media app whereas on Instagram it is available as an AR filter or effect." Facebook is testing a new feature for creators. The new “Green Screen” tool will allow users to add any video or image in the background of the Facebook Stories they create. This option is similar to the one available on Instagram already. However, it will be available as an editing tool for the social media app, whereas on Instagram it is available as an AR filter or effect. This tool was spotted by Mamun Billah via Social Media Today. As per the screenshot shared, the user can see the option in the stories section. The user can choose a photo or video from the Gallery section. When the user chooses the option, it is also labelled as “GREEN SCREEN by Instagram” at the bottom. Here’s the screenshot of the feature Green screen feature comes to facebook stories section! @MattNavarra pic.twitter.com/np9uMuQJaZ — Mamun Billah (@mamun...

Java or C++?

Which programming language should I choose ? H ey Folks, If you are reading this blog, most probably you are going to start Competitive coding or you are initiating the journey of programmar. Or maybe you are a professional, Engineer well never mind. In this blog, I will explain to you the keypoint and language you should choose for your Programming Journey or for your Competitive Journey. To the point, if you are planning to start Competitive Programming , and no prior Kowlege of JAVA and I am assuming you are completely beginner, then without any doubt go for C++ . Why I am saying so, let me explain it in the simplest way. In CPP, you can use a lot of libraries helpful in competitive coding, and most important C++ is the most reliable and low latency language. when you will use the STL library to implement your code then you will fall in love with C++.You can easily use the property of Stack, Queue, and Priority Queue using STL and when it comes to program latency ...