.py
files on your computer, and then upload those files.This homework assignment must be submitted in Gradescope by 10am CST on Tuesday, September 14, 2021.
This homework assignment is about the topics of worksheet 3, i.e. lists, while loops and for loops.
Collaboration is prohibited, and you may only access resources (books, online, etc.) listed below.
The course materials you may refer to for this homework are:
Expected to be most useful:
Allowed and possibly useful, but probably less relevant than the links above:
This homework assignment has 2 problems, numbered 2 and 3. The grading breakdown is:
Points | Item |
---|---|
2 | Autograder |
4 | Problem 2 |
4 | Problem 3 |
10 | Total |
Ask your instructor or TA a question by email, in office hours, or on discord.
Gradescope will show the results of the automated syntax check of all submitted files as the score for problem 1.
Write a program hwk3prob2.py
that asks the user for three integers:
k
The program should then print the numbers n**k
for each integer n
between the start value and stop value (including both endpoints).
Here is an example of what the interface and output should look like. Here the user asks for the cubes of integers from 5 to 10 inclusive.
Start value: 5
Stop value: 10
Exponent: 3
125
216
343
512
729
1000
In this example, the user typed the numbers 5
, 10
, and 3
, and the rest of the text is output from the program.
Write a program hwk3prob3.py
that asks the user to select a username. (The name won't actually be used for anything.)
The rules for usernames are:
If the user requests a name that violates either rule, the program should say that name is not allowed and ask again, repeating until they enter an acceptable name. Once they enter an acceptable name, the program should just print "Your username is X" where X is replaced with whatever they entered, and exit.
# List of prohibited usernames. Copy this into your code (without this comment).
prohibited_usernames = [ "system", "administrator", "ddumas", "heliotrope", "sudo", "reboot" ]
Here's what it should look like when you run the program:
Select a username: system
That username is not allowed.
Select a username:
That username is not allowed.
Select a username: sudo
That username is not allowed.
Select a username: grogu
Your username is grogu