Introduction to Python
  • Introduction
  • Preface
  • Background
  • Installing Python
  • Getting Started
  • Basics
    • More Printing
    • Strings
    • Numbers
    • Exercises
    • Comments
  • Variables
    • Operators
    • Type Conversion
    • Exercises
    • A Brief Introduction to Lists
    • Game Exercise
  • Human Input
  • Functions
    • First Functions
    • Why Functions
    • Exercises
  • Indentation
  • Decisions
    • Booleans
    • Logical Operators
    • If Statements
    • Elif and Else Statements
    • Exercises
    • Rock, Paper, Scissors
    • Game Exercise
    • Game Exercise 2
  • Lists
  • Loops
    • For Loops
    • While Loops
  • More Data Structures
    • Tuples
    • Dictionaries
  • Pygame
  • Extra Content
    • Computers and Code
    • More About Python
    • For Loops with Range
    • List Slicing
Powered by GitBook
On this page
  1. Functions

Exercises

Create a new file called function_exercises.py and do the following:

  1. Create a function rect_perimeter that takes two arguments, length & width and returns the perimeter

  2. Create a function rect_area that takes two arguments, length & width and returns the area.

  3. Create a function super_hi that takes a name as an argument and returns 'Hi' plus the name in all capital letters For e.g. super_hi('Joanna') returns HI JOANNA, super_hi('Safiya') returns HI SAFIYA. Use the function upper() on a string, e.g. 'test'.upper().

PreviousWhy FunctionsNextIndentation

Last updated 6 years ago