Class 24 — Wednesday October 24

Reaching an understanding with functions

Practice makes perfect — Is more than a platitude — Take it to your heart


Look both ways


Agenda


Example de jeur — module primal

  • Parameters x and y are integers. The function returns whether y is a factor of x.
  • Parameters x and y are integers. The function returns whether x and y are relatively prime; i.e., whether y is not a factor of x and vice-versa.
  • Parameter x is an integer. The function returns whether x is prime; i.e., its only factors are 1 and itself

Homework module take_two

  • Function parameter x is a numeric value. The function returns integer -1, 0, or 1 depending respectively whether x is negative, zero, or positive. The function does not print any output.
  • Function parameter s is a string. If the length of string s is odd, the function returns the middle character of s; otherwise, the function returns the two middle characters of s. The function does not print any output.

To do

 


 

 

 
   
   
   
 
  © 2019 Jim Cohoon   Resources from previous semesters are available.