Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary Of Loops in Python

Rating
-
Sold
-
Pages
4
Uploaded on
07-04-2023
Written in
2022/2023

The document provides an introduction to loops in Python, which are used to execute a block of code repeatedly until a certain condition is met. There are two types of loops in Python: for loops and while loops. A for loop is used to iterate over a sequence of elements, such as a list or a string, and execute the code for each element. The document explains how to use a for loop with different sequences A while loop is used to execute a block of code repeatedly as long as a certain condition is true. The document explains how to use a while loop with different conditions, The document also covers some advanced topics such as continue statements, and printing patterns in Python.

Show more Read less
Institution
Course

Content preview

PYTHON LOOPS



# In Python, we have three main types of loops:

# The while loop, the for loop, and nested loops.

# In this exercise, we'll wrap it up with an exercise on
printing a certain pattern, so let's begin.

Taking User Input:

—> In Python, every input that you take from the user is
automatically taken in the string format, and you need to
convert this into an int. Within the braces, you take the input,
and within the braces, take the number entered by the user.

—> If the user enters say 10 or 12 or any other number
which is not a multiple of 7, you have to take the input again.

While Loop:

—>The while loop is used to check if the value mod 7 is not
equal to 0. In this case, because it was not 0, this means
that the while's condition is true.

For Loop:

—>In a for loop, a counter is a variable that keeps track of
the number of times you've already repeated your names in
your ngers.




fi

Written for

Institution
Course

Document information

Uploaded on
April 7, 2023
Number of pages
4
Written in
2022/2023
Type
SUMMARY

Subjects

$6.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
s3sharma

Get to know the seller

Seller avatar
s3sharma
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions