Assignment 20 — function implementation
Due before class Monday, March 26
Module take_two.py
- Your module should implement the below two functions.
- A simple tester taken.py is available.
Function signum( x )
- Function parameter
x
is a numeric value. The function does not print any output. The function returns integer-1
,0
, or1
depending respectively whetherx
is negative, zero, or positive.
- A run of of the tester should produce output
f( -3.5 ): -1
f( 0 ) : 0
f( 5 ): 1
Function mid( s )
- If the length of
s
is odd, the function returns the middle character ofs
; otherwise, the function returns the two middle characters ofs
. The function does not print any output.
- For example,
mid(
'abcdef'
)
evaluates to'cd'
andmid(
'abcde'
)
- A run of of the tester should produce output
mid( 'abcdef' ): 'cd'
mid( 'abcde' ): 'c'
Warning: fopen(/l/cs1112/public_html/defs/htm/181-trailer): Failed to open stream: No such file or directory in /l/cs1112/public_html/defs/php/read.php on line 5
Unable to open file!