0% found this document useful (0 votes)
11 views3 pages

ITE 260 - SAS - Day 11 - Loops and Iiteration Part 2

This document is a student activity sheet for ITE 260: Computer Programming 1, focusing on loops and iteration in Python. It includes lesson objectives, skill-building activities, coding exercises, and questions for understanding related to for loops and nested loops. The document aims to enhance students' understanding of loop structures and their applications in programming.

Uploaded by

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

ITE 260 - SAS - Day 11 - Loops and Iiteration Part 2

This document is a student activity sheet for ITE 260: Computer Programming 1, focusing on loops and iteration in Python. It includes lesson objectives, skill-building activities, coding exercises, and questions for understanding related to for loops and nested loops. The document aims to enhance students' understanding of loop structures and their applications in programming.

Uploaded by

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

ITE 260: Computer Programming 1

Module #11 Student Activity Sheets

Name: _________________________________________________________ Class


number:_____
Section: _________ Schedule: _________________________________ Date: ___________

Lesson title: Loops and Iteration - Part 2 Materials:


SAS
Lesson Objectives:
At the end of the session, your students should be able to:
1. Explain how for loop statement works in python
2. Describe the general syntax of for loop statement
3. Apply for loop structure and nested loop in the python References:
program https://www.freecodecamp.org/new
s/python-while-loop-tutorial/

Productivity Tip:
“However difficult life seems, there is always something you can do and succeed at.”- Stephen Hawking

1) Activity 2: Skill-building Activities


Let’s practice! After completing each exercise, you may refer to the Key to Corrections for
feedback. Try to complete each exercise before looking at the feedback.

A. Code Evaluation. Write the output of the Python Code.


1. What is the output of the following for loop statement?
CODE OUTPUT

for i in range(3):
print("Hello")
print("Goodbye")

2. What is the output of the following for loop statement?


CODE OUTPUT

row = 5
for i in range(1, row + 1, 1):
for j in range(1, i + 1):
print("*", end=' ')
print("")

3. What is the output of the following nested for loop statement?


CODE OUTPUT

This document is the property of PHINMA EDUCATION


ITE 260: Computer Programming 1
Module #11 Student Activity Sheets

Name: _________________________________________________________ Class


number:_____
Section: _________ Schedule: _________________________________ Date: ___________
for v in range (5):
for h in range(5):
print("*", end = " ")
print()

4. What is the output of the following for loop statement?


CODE OUTPUT

color = ['black', 'white', 'gray']


for index in range(len(color)):
print(color[index])

B. Coding Time: Open your code editors like Notepad++, Sublime, or any available IDE.
1. Create a program that will accept 5 numbers then count the number of odd and even
numbers
Expected Output:
WRITE YOUR CODE HERE
Enter 5 numbers:
1
2
5
4
1
ODD: 3
EVEN: 2

B. Activity 3: Check for Understanding


Write the answer to the following questions by completing the syntax.
QUESTION ANSWER

1. Use the range function to loop through for z in ________


a code set 10 times. print(z)

2. Loop through the items in the cats list. cats = ["Persian", "Siamese",
"Ragdoll"]
for z ___ cats:
print(z)

This document is the property of PHINMA EDUCATION


ITE 260: Computer Programming 1
Module #11 Student Activity Sheets

Name: _________________________________________________________ Class


number:_____
Section: _________ Schedule: _________________________________ Date: ___________
Answer the questions below about the following code:
n = 5
k = 5
for i in range(0,n+1):
for j in range(k-i,0,-1):
print("*",end=' ')
print()
3. What is the output of the presented
code?

4. What would happen if you changed


n+1 to n-1?

5. What would happen if you changed


print("*",end=' ') to
print(j,end=' ')?

This document is the property of PHINMA EDUCATION

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy