A201 Introduction to Programming 1

A201 Homework 6

Due Date: Tuesday, October 3, 2023.

Goal: to use for loops with a sequence in Python.

Make sure to complete Lab 6 before doing the homework.

Create a Python script file called hw6.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it.

Ex. 1. Tupples as sequences

Write a program that goes through a tupple of numbers representing the temperatures taken at regular intervals in a day, at least 6 of them. The program should store this tupple in a variable, and then compute the average temperature. For that, use a for loop going over the temperature and adding all the values to a variable called sum, initialized as 0. Then at the end, divide the sum by their count, and output a message communicating what the average temperature was on that day.

Ex. 2. Password verification

Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain:

The program should output a message saying that the password is valid, or if it isn't valid, saying why not. For example, if the password has a length of 5, the output should say "The password is too short; a minimum of 6 characters required" and so on.

Homework Submission

Upload the files lab6.py and hw6.py in Canvas, Assignments, Homework 6.