- 22 students
- 41 lessons
- 0 quizzes
- 10 week duration
- Installing Anaconda and running a sample Python Program
- How to use the Print function in Python?
- Arithmetic Operations in Python
- Running a Web Server using Python in Spyder
- Input Output in Python
- Starting Plots in Python
- For loop in Python
- Installing and running DJango
- Linear and Polynomial Regression using Python
- Some Problems on Lists
- Creating Classes in Python
- Inheritance in Python
- How to implement Multiple Inheritance in Python
- Using Flask-1
- Lists in Python
- Lists in Python — 1
- Sorting of Lists
- Lists in Python — Insertions
- How to make a list in python and save it in files ……
- Importing Excel Files in Python
- Mailer in Python
- How to add a simple view to a Django site?
- Python Print and I/O questions
- Print answers
- If then else in Python
- Summation of Series
- Python Print Assignment
- Loop Assignments
- Pickle in Python
- Dictionary in Python-1
- Dictionaries in Python-2
- Python OOPs Assignment
- Operator Overloading in Python
- Equation Solving using Numpy
- Starting Numpy
- Passing Data from a Python Controller to a HTML Page
- Downloading Data from a URL in Python
- Sending a Dictionary to a HTML Template and displaying it using Flask.
- Web Scraping Library-1
- Downloading data from a remote website and displaying data in an html page
- Arithmetic Operations in Python — Assignment
For loop in Python
In this lesson we shall study the Python for loop in some detail.
The simplest for loop is.
for i in range(11): print(i)
for i in range(11) will run a loop from 1 to 10 increasing by 1 every time. In the general case it is
for i in range(n+1) running a loop from 1 to n.
What happens if we want to run a loop from 3 to 9.
We shall write
for i in range(3,10): print(i)
What happens if we want to go from 9 to 3. Would changing the range variables help?
Let us try this loop.
for i in range(10,3): print(i)
The loop doesn’t run.
The correct loop is
for i in range(10,2,-1): print(i)
This brings us to the most diverse form of the Python for loop.
start=2 end=12 increment=2 for i in range(start,end,increment): print(i)
- Write a program to find the factorial of a number.
- Write a program to find the sum of factorials.
- Write a program to print the binary equivalent of a positive decimal integer.