Application#

How to Submit#

Your answers to this chapter’s application questions should be added to the notebook template.

Submit the Colab link on Canvas for the assignment submission.

Application Questions#

Question #1#

Let’s say we want to create a function that prints an input string a specific number of times.

Breaking down the steps of that program:

  • Get the input string (message)

  • Get the number of times (x)

  • Print the string x number of times

We might also need some way of tracking how many times we’ve printed the string so it stops at the specified number.

Q1A: Describe how you would start building out a program to accomplish this task? What functions, statements, or keywords would you need to use? How would you start to organize this program?

Q1B: See where you can get with writing this program. What parts of the program were you able to get working? Where did you run into challenges? Answer to this question includes program + comments that document process and explain your code.

Q1C: How does the sample program compare to your approach? What was similar? What was different? How are you thinking differently (if at all) about how to approach this type of program?

Question #2#

But let’s say we don’t want to use an input() statement as part of the function- what if we wanted to pass specific values to the function?

Q2A: Modify the program you built for the previous section to take specific values as inputs (rather than get inputs as part of the function). Answer to this question includes program + comments that document process and explain your code.

Q2B: Then, create a named function and function call for this program. Answer to this question includes program + comments that document process and explain your code.

Q2C: What parts of the program were you able to get working? Where did you run into challenges?

Question #3#

Q3: Write a function is_even that determines whether or not a number n is even. Include the function definition as well as a sample function call. Answer to this question includes program + comments that document process and explain your code.

Question #4#

Q4: Write a function average that determines the average value of a list. Include the function definition as well as a sample function call. Answer to this question includes program + comments that document process and explain your code.

Question #5#

Q5: Write a function uniq that takes a list and returns a new list containing only unique values. Include the function definition as well as a sample function call. Answer to this question includes program + comments that document process and explain your code.