0% found this document useful (0 votes)
98 views

Laboratory Exercise 6 - Looping Statements

The document outlines learning outcomes, materials, and problems for a Python programming assignment in Linux. It includes 3 programming problems: 1) inputting and finding the largest of 10 numbers using different loops, 2) inputting ages and counting participants by age group, and 3) inputting voltages and checking for active, cutoff or breakdown conditions. The source code provided implements solutions for the 3 problems.

Uploaded by

rinobi
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)
98 views

Laboratory Exercise 6 - Looping Statements

The document outlines learning outcomes, materials, and problems for a Python programming assignment in Linux. It includes 3 programming problems: 1) inputting and finding the largest of 10 numbers using different loops, 2) inputting ages and counting participants by age group, and 3) inputting voltages and checking for active, cutoff or breakdown conditions. The source code provided implements solutions for the 3 problems.

Uploaded by

rinobi
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/ 4

I.

INTENDED LEARNING OUTCOMES

TLO1. Discuss the looping statement in python


TLO2. Apply Linux OS in creating programs.

II. MATERIALS

Quantity Part Number Description


1 - Bootable VMware Software
1 - Bootable CentOS Linux ISO
1 set - Personal Computer with working hard
disk (at least 40GB)

III. PROBLEM

Create a python program in Linux Operating System and execute the given
problems below: (30 points each)

1. Input 10 numbers and display the largest number among the input. Apply the use of for
loop, while loop, and do-while loop
2. Your program will require to input the number of participants and the age of each
participant. Display how many are minor, legal, or senior citizens at the end of the
program.
3. If the input voltage is 5V, it is ACTIVE! If less than 5V, it is CUTOFF. If greater than 5V, it is
BREAKDOWN. Your program will continue to ask for input voltage until you enter a
CUTOFF voltage. In addition, the program will terminate if there is a BREAKDOWN voltage
input.

2
IV. Source Code
# 1. Input 10 numbers and display the largest number among
# the input. Apply the use of for loop, while loop,
# and do-while loop
import sys

highest = -sys.maxsize
num = []

# there's no do-while loop in python


x = 0
while x < 10:
num.append(int(input("Enter number %s: " % str(x + 1))))
x += 1

for y in num:
if y > highest:
highest = y

print ("Highest number: " + str(highest))

# 2. Your program will require to input the number of


# participants and the age of each participant.
# Display how many are minor, legal, or senior
# citizens at the end of the program.
age = []
participants = int(input("Enter number of participants: "))
x = 0
while x < participants:
age.append(int(input("Enter age of participant #%s: " % str(x +
1))))
x += 1

# Assuming 18+ is legal, 60+ is senior


m = 0
l = 0
s = 0
for y in age:
if y < 18:
m += 1
elif y > 59:
s += 1
else:
l += 1

print("Minors: %s\nLegals: %s\nSeniors: %s" %(m, l, s))

3
# 3. If the input voltage is 5V, it is ACTIVE! If less than
# 5V, it is CUTOFF. If greater than 5V, it is BREAKDOWN.
# Your program will continue to ask for input voltage
# until you enter a CUTOFF voltage. In addition, the
# program will terminate if there is a BREAKDOWN voltage input.
v = 5
while v == 5:
v = int(input("Enter voltage: "))

V. OUTPUT

4
CONCLUSION

REFERENCES

Rubrics:

Source Code and 80%


Output
Conclusion/References 20%
Total

You might also like