From 8d83c50d5978ac9d55f4a534bf05a17865918d9c Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 22:08:40 +0900 Subject: [PATCH] [Python #3] create e18.py --- kjg/python-the-hard-way/e18.py | 21 +++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 kjg/python-the-hard-way/e18.py diff --git a/kjg/python-the-hard-way/e18.py b/kjg/python-the-hard-way/e18.py new file mode 100644 index 0000000..0eb6184 --- /dev/null +++ b/kjg/python-the-hard-way/e18.py @@ -0,0 +1,21 @@ +# this one is like your scripts wih argv +def print_two(*args): + arg1, arg2 = args + print(f"arg1: {arg1}, arg2; {arg2}") + +# ok, that *arg is actually pintless, we can just do this +def print_two_again(arg1, arg2): + print(f"arg1: {arg1}, arg2: {arg2}") + +# this just takes one argument +def print_one(arg1): + print(f"arg1: {arg1}") + +# this one takes no argument +def print_none(): + print("I got nothing.") + +print_two("Zed","Shaw") +print_two_again("Zed","Shaw") +print_one("First!") +print_none() diff --git a/kjg/python.org b/kjg/python.org index f2a91e2..6e95efe 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -88,3 +88,5 @@ How to use read function from file How to write file **** ex17 How to copy file +**** ex18 +How to use function