cs115 Lab03 v1
cs115 Lab03 v1
Lab 03
Notes:
● Upload your solutions as a single .zip file to the Lab03 assignment for your section on
Moodle. You must use the following naming convention: Lab03_Surname_FirstName.zip
where Surname is your family name and FirstName is your first name
● You should not use lists, tuples, dictionaries in your solution.
● For each of the functions below, you should include a docstring comment. The docstring
should have the following format:
"""
Summary of what the function is for
Parameters:
param1 (param1 type): Description of param1
Returns:
type: variable/value
"""
Copy the line below in your program and use it as a global variable.
KEY = "a@bpdqi!l1mwnuo0s5t+z2A4B8E3G6WM"
a. A function, star_number,that returns the nth member of the Star Numbers sequence
using the formula below:
𝑓(𝑛) = 6 𝑛(𝑛 − 1) + 1
b. A function, square_pyr_number, which returns the nth member of the Square
Pyramidal Numbers sequence using the formula below:
𝑛(𝑛+1)(2𝑛+1)
𝑓(𝑛) = 6
c. A function show_options which displays the menu shown below:
*** SEQUENCES ***
1. Star Numbers
2. Square Pyramidal Numbers
d. A function, select_sequence,that inputs a selection from the user (either 1 or 2). If
user input is invalid, the function displays a message and keeps prompting for input until
a valid choice is made. The function should return the user’s choice. (Optional: You can
consider returning functions instead of integer values.)
e. Using the functions defined above, write a program to generate the first 10 values of the
selected number sequence. See the sample runs below.
Sample Run 1: (User inputs are in red) Sample Run 3: (User inputs are in red)