[Tutor] isbetween function chapter 5 How to Think Like Computer Scientist

Eri Mendz jerimed at myrealbox.com
Tue Oct 19 14:45:38 CEST 2004


Hello all,

I'm a newbie trying to learn Python at my own pace. I work in sales NOT 
programming so please excuse me of obvious things i may overlook in the 
course of my self-teaching.

Here is the code i made trying to solve the exercise mentioned in the 
subject of my email. I made it like so as i think pure if-elif-else 
statement is unwieldy. Of course its just me and pros here got something 
to correct my statement:

#!/usr/bin/env python
# filename: isbetween.py
# description: make function with 3 parameters & determine the median
# Author: Eri Mendz
# Tue Oct 19 15:07:22 AST 2004
# CYGWIN_NT-5.0

def test1(x,y,z):
   if x > y and x > z:       # x is highest
     if y > z:               # z-y-x
       print y, "is between", z, "and", x
     else:                   # y-z-x
       print z, "is between", y, "and", x

def test2(x,y,z):
   if y > x and y > z:       # y is highest
     if x > z:               # z-x-y
       print x, "is between", z, "and", y
     else:
       print z, "is between", x, "and", y

def test3(x,y,z):
   if z > x and z > y:       # z is highest
     if x > y:               # y-x-z
       print x, "is between", y, "and", z
     else:
       print y, "is between", x, "and", z

def isbetween(x,y,z):
   test1()
   test2()
   test3()

# test isbetween()
isbetween(23,10,56)

I get:
TypeError: test1() takes exactly 3 arguments (0 given)

Dumb me i didnt supplied arguments as required. But do i really have to 
do that? I like the 3 functions to act as dummy functions (sort of) and 
let the real work happen inside isbetween(). Kindly enlighten me how to 
do it right.

-- 
Regards,
erimendz ** use firefox/thunderbird **
http://www.spreadfirefox.com/?q=affiliates&id=6670&t=58



More information about the Tutor mailing list