Change language

Become Proficient In Python Programming JT Devs | Loops in python 2022

Become Proficient In Python Programming JT Devs | Loops in python 2022

Hello guys, my name is Joel Mukanya am a CEO and Founder at JT Devs for today video, we going to look at some examples that we going to use uh in python okay those examples will be base on loops let define a loop. A loop base actually allows us to repeat something or a block of statement yeah that will be a loop so let say for example you want to know how many times do you have to display numbers from 1 to 10 then you will need a loop so you just have to type in on statement then you need to increment your counter then it will display from those lowest numbers to the highest number or from the highest number to the lowest numbers it will depend on your logic. Let start with the while loop. A while loop most of the time we use it when we actually do not know where to stop or when to stop then it kind of a process then if something your program somewhere you are dealing with a process of knowing things while youre doing something then you can use while loop First, let create a counter. A counter will be anything, any variable that you wanna use in my case am going to use cnt equals to zero then we say while cnt is less than seven why? because we want to display numbers from zero to six then we say cnt. Then after that, we have to increment our counter then let increment it. Then we going to say cnt += 1 then we have one to six What is a range()? A range allows us to generate some numbers from start to end. So we going to see it in action using a for loop a for loop allows us to know or to generate numbers from lowest numbers to highest numbers or from highest numbers to lowest numbers then it also allows us to repeat something but with a for loop, we already know where we should end our loop i, it will be your counter. Then we will say range(10) let say for instance, if we want to display from 1

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically