The due date for this homework is Sunday, February 18, 11:00pm. Note, this is an extension on our typical Friday deadlines.
This homework is designed to give you practice with the following topics:
for
loops with range
function.As usual, we encourage you to start early.
Your task is to complete following steps:
hw3_racing.py
, hw3_resizetower.py
, and
hw3_randompassword.py
, in the unzipped folder. You are
expected to write your programs in these files.hw3_racing.py
. This file is used in Part 1hw3_resizetower.py
. This file is used in Part 2hw3_madlibs.py
. This file is used in Part 3Notice that each starter .py
file has a header with some
information for you to fill in. Please do so. Your feedback helps the
instructors better understand your experiences doing the homeworks and
where we can provide better assistance.
Central New York Racing
You and your friends really enjoy the Fast and Furious movies and have started to race between Hamilton and Cazenovia (please don’t do this). You are tasked with writing a program to calculate and analyze driving times for this race. Given the times of a certain number of drivers (entered by the user), your program should perform the following tasks:
|
).|
-separated
string to a list of decimal values.min
and max
built-in functions. You must
NOT use the sum
function. Instead, you must use the
accumulator pattern in order to compute the average drive time.Example program output (25.5|28.0|23.0|22.9|27.6
is the
input that the user enters):
Enter drive times (|-separated): 25.5|28.0|23.0|22.9|27.6
Average drive time: 25.40 seconds
Fastest drive: 22.90 seconds
Slowest drive: 28.00 seconds
Note: In hw3_racing.py
we have provided
you with a code structure and descriptions for each function. Make sure
to read and follow these instructions. Add parameters and return values
along with their corresponding type annotations wherever it’s needed. DO
NOT modify the code structure (for example by adding or removing
functions) before consulting with your instructor.
Tower Resized
Continuing last week’s exploration of the Tower, we will now make a scalable version of the Tower. In other words, the art is not a fixed sequence of characters, but a pattern that can be drawn at a variety of scales. Visit Tower webpage to get a sense of how the tower must look at different scales.
Each program must ask the user for a positive number and then scale the text pattern accordingly.
Example program output (1
is the input entered by the
user):
Specify the scale: 1
||
||
__{{}}__
__{::::::::}__
||||||||||||||
(_)()()()()(_)
(_)()()(_)
____][____
___][___
||
||
|%%%%%%|
|%%%%%%|
|%%%%%%|
|%%%%%%|
__{{}}__
__{::::::::}__
||||||||||||||
Note: In hw3_resizetower.py
we have
provided you with a code structure and descriptions for each function.
Make sure to read and follow these instructions. Add parameters and
return values along with their corresponding type annotations wherever
it’s needed. DO NOT modify the code structure (for example by adding or
removing functions) before consulting with your instructor.
Random Password
You recently got your online bank account hacked in a recent attack.
In order to create a better password that isn’t just
password123
, you decide to create a random password
generator to make sure your passwords are more secure. Write a Python
program that generates random passwords for users based on their desired
password length. The program should:
length
of the
password.length
number of characters from the
string of all permitted characters (a mix of uppercase letters,
lowercase letters, digits, and special characters).Example program output (10
is the input entered by the
user):
Enter the desired password length: 10
Generated password: fdj)6i%Kt6
Note: In hw3_randompassword.py
we have
provided you with a code structure and descriptions for each function.
Make sure to read and follow these instructions. Add parameters and
return values along with their corresponding type annotations wherever
it’s needed. DO NOT modify the code structure (for example by adding or
removing functions) before consulting with your instructor.
Your assignment will be graded on two criteria:
Correctness [90%]: This document contains examples for each program. Be sure that you run your program once for each example and make sure it works correctly for each one! Then, run your code with additional examples of your choosing.
The correctness part of your grade is broken down as follows:
Category | Portion of grade |
---|---|
Part 1 | 30% |
Part 2 | 30% |
Part 3 | 30% |
.py
files must be followed closely in order to get
full credit.Program design and style [10%]: style and program design become increasingly important the more complex your program becomes. For these first programs, adhere to the following guidelines:
Challenge problems are entirely optional extensions to the homework. If you complete them successfully, you are rewarded with a sense of accomplishment and a small number of extra points on the homework. They are intended for students who want to explore a little further; only pursue the challenge problem after you have successfully completed the homework.
For this week, the challenge problem is to implement a scalable ascii art pattern of your choosing. For inspiration, you can take a look at the Wikipedia page on ASCII Art and the ASCII art archive.
If you choose to do the challenge problem, please write your code in
a separate file called hw3_challenge.py
. Have fun!