0% found this document useful (0 votes)
4 views16 pages

Study Guide For Middle School Students

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

Study Guide For Middle School Students

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Let’

s
L p
into
Python
Overview of our project

● Why do we need loop?

● What is loop in python?

● How does loop work?

● Making a stairs game using loop


The Stairs Game
So why do we need LOOP ?
input (code
John Jessy Jack
editor):

print("John")
print("Jessy")
print("Jack")
output:
So why do we need LOOP ?
input (code
editor):

print("John")
print("Jessy")
print("Olivia")
print("Sophia")
print("Isabella")
print(“Timmy")
print(“Shinzo")
print(“Emma")
print(“Clark")
print(“Ruby")
So why do we need LOOP ?

input (code
editor):

Impossible !!!!
What isLoop
?
A loop is a programming construct that allows us to repeat a set of
instructions.

Do this { …………
………….

} Untill I am done
How does LOOP work?
for whil
e
Syntax for item in list: Syntax while condition:
: ……………………. : …………………….
…………………….. ……………………..

Example fruits = [ “Apple”, “Orange” Example count = 1


, “Banana” , “Grape” ] :
:
while count <= 5:
for fruit in fruits:
print(count)
print(fruit)
count += 1
How does LOOP work?
for
fruits = [ “Apple”, “Orange” , “Banana” ,
“Grape” ]
Apple Orange Banana Grape

fruit = fruit = fruit = fruit =


0 1 2 3

for “fruit=0” in for “fruit=1” in for “fruit=2” in for “fruit=3” in


fruits: fruits: fruits: fruits:
print(“fruit=0”) print(“fruit=1”) print(“fruit=2”) print(“fruit=3”)
How does LOOP work?
while

1 2 3 4 5

count = 5
3
4
1
2

while count <= 5:


count = 1 + 1 = 2
count = 2 + 1 = 3
print(count)
count += count = 3 + 1 = 4
count1= count এর আগের মান + 1 count = 4 + 1 = 5
The Stairs Game
1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

The Stairs Game


01 range()
range(stop) range(3) 0, 1, 2

range(start, stop) range(1, 5) 1,2,3,4

range(start, stop, step) range(1, 6, 2) 1,3,5


print(end=
02 “ ”)
Inputs Outputs
print(“Hello”) Hello
/n
print(“World”) World

print(“Hello”, end = “ ”) Hello World


print(“World”)
Let’s Build Gamestairs = 5
for stair in range(1, stairs + 1):
for brick in range(1, stair + 1):
print(brick, end=" ")
1 print()

1 2
stairs = 5
1 2 3
for 1 in range(1, 6):
2
3
1 2 3 4
for 2
3
1 in range(1, 4
2
3 ):
1 2 3 4 5 2
print( 1
3 , end=" ")
print()
Question
s?
Feel Free to Ask Anytime !

You might also like