Python Classes
  • Course Outline
  • Course Organization
  • Material
    • Week 1
    • Week 2
      • Extensions
    • Week 3
      • Extensions
    • Week 4
    • Week 5
      • Extensions
    • Week 6
      • Extensions
    • Week 7
    • Numpy
    • Matplot
    • Pandas
    • Week 10
    • Week 11
  • Exercises
    • Week 1
    • Week 2
    • Week 3
    • Week 4
    • Week 5
    • Week 6
    • Week 7
    • Matplotlib
    • Numpy
    • Pandas
    • Matplot with Numpy
  • Solutions
    • Week 2
    • Week 3
    • Week 4
    • Week 5
    • Week 6
    • Week 7
  • Additional
    • More Resources
    • Setting up Python
  • Lectures
    • Slides
    • Recordings
Powered by GitBook
On this page
  • 0 Finish last weeks stuff!
  • 1 Fun with Functions

Was this helpful?

  1. Exercises

Week 6

0 Finish last weeks stuff!

There were a lot of exercises last week, try and finish the for/while loop exercises before attempting this weeks material on functions (don't worry about completing the challenge problems though).

1 Fun with Functions

1.1 Maximal entertainment

Create a function which takes in a list and prints out the biggest value in the list (don't use pythons max() function!)

Extension

Instead, return the maximum value and print it outside of the function

1.2 Sum thing to do

Create a function which accepts a list of numbers and prints the sum of all the numbers

Extension

Get your function to return the average value in the list (You'll want to use len())

1.3 Developing a range of skills

Create a function which mimics the function of range(), by returning a list of integers from the minimum value to the maximum value - 1 (i.e. my_range(min, max))

Extension 1

Use default arguments such that if the "min" argument is not given, the function starts counting from zero

Extension 2

Try and implement the range function using recursion (you can use another function to do the actual list creation, if you like, so long as it uses recursion!)

PreviousWeek 5NextWeek 7

Last updated 5 years ago

Was this helpful?