""" max3.py - print max of three numbers $ python max3.py -- largest of three integers x, y, z -- What is i ? 5 What is j ? 10 What is k ? 7 The largest is 10. Jim Mahoney | cs.bennington.college | MIT License | March 2021 """ def max_of_three(a, b, c): """ return the largest of a, b, c """ # This approach generalizes easily to more than three values # ... we just use a loop ... and end up with something similar # to the "accumulator pattern", but this time with a comparison. maximum = a if b > maximum: maximum = b if c > maximum: maximum = c return maximum def main(): print("-- largest of three integers x, y, z --") i = int(input("What is i ? ")) j = int(input("What is j ? ")) k = int(input("What is k ? ")) largest = max_of_three(i, j, k) print(f"The largest is {largest}.") if __name__ == '__main__': main()