For all of the following, write both the function and some code that calls and tests the function.
Complete the following without using ANY outside aid. If necessary, refer only to the python help()
command or the official documentation at https://python.org.
Use your preferred programming environment (IDLE, Pycharm, Visual Studio Code, etc.)
n
. Using a for loop, print the string n
times.target
. Using a for loop, count the number of times target
appears in the list and print the total.target
. Using a while or for loop, print the first index in the list where target
appears. Print not present
if it does not exist in the list.There are a few ways to solve each problem. Here are a few: week2-soln.py
Submit your .py
file to Canvas for a check. You are not graded on completeness or correctness – this is for learning and feedback.
if-else
.for
loop and working with the list index
.