Lab 5: Loops | CMSC 105 Elementary Programming - Fall 2024

Lab 5: Loops

Points Possible: 100

Due: Thursday, October 3rd

In this lab, we will write programs using loops.

Submission:

  1. Submit a Python file for each of the programs.

Pair programming

Pair programming is a software development technique in which two programmers work together at one computer. One, the driver, writes code while the other, the navigator, reviews each line of code as it is typed in. The two programmers switch roles frequently.

Program 1: while loop

Using while loop, write a program to print the first 50 even numbers starting from 2.

Save the program is loop.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Comments: 5 points, input:10, computation:10, output:5)
Total: 30 points

Program 2: Names

Using a loop (for or while), write a program that reads 10 different names from a user. If the name contains the letter ‘e’, continue with next iteration. If it doesn’t contain the letter ‘e’, print the message “Name Accepted” and stop.

Hint: Use find function to search for a letter in the string.

Save the program is names.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Comments: 5 points, input:10, computation:10, output:5)
Total: 40 points

Program 3: for loop

Using for loops, write a program to print the numbers in reverse order from 100 to 1.

Hint: for i in range(100, 0, -1) can be helpful.

Save the program is countdown.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Comments: 5 points, input:10, computation:10, output:5)
Total: 30 points