You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
449 B

11 years ago
  1. #!/usr/bin/env python
  2. import argparse
  3. parser = argparse.ArgumentParser()
  4. parser.add_argument("square", type=int,
  5. help="display a square of a given number")
  6. parser.add_argument("-v", "--verbose", action="store_true",
  7. help="increase output verbosity")
  8. args = parser.parse_args()
  9. answer = args.square**2
  10. if args.verbose:
  11. print("the square of {} equals {}".format(args.square, answer))
  12. else:
  13. print(answer)