min4.py
#!/usr/bin/env python
#
# Read line with 4 numbers, and print the minimum
import sys
import string
# Print message to the user
sys.stdout.write("Please enter 4 numbers.\n")
# Read a line from the user
line = sys.stdin.readline()
# Separate the line to strings
ss = string.split(line)
# Check for 4 strings
if len(ss) != 4:
# Show error message and go away
sys.stderr.write("Sorry, I did not get 4 numbers\n")
sys.exit(1)
# Convert the character-strings to integer numbers
w = int(ss[0])
x = int(ss[1])
y = int(ss[2])
z = int(ss[3])
##################################################
# Now we want to find the minimum of (w,x,y,z) ##
##################################################
# Get min(w,x)
if w < x:
mwx = w
else:
mwx = x
# Get min(y,z)
if y < z:
myz = y
else:
myz = z
m = mwx; # Just guess
# But myz may be smaller, so
if myz < m:
m = myz
# Happy End
sys.stdout.write("... and the minimum is: %d \n" % m)
sys.exit(0)
Generated by GNU enscript 1.6.4.