From 6296a5b75328e017ea685c67d95c9c255d0b3751 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 21:16:04 +0900 Subject: [PATCH 01/16] [Python #2] create ex8.py --- kjg/python-the-hard-way/e8.py | 11 +++++++++++ kjg/python.org | 3 +++ kjg/python.org~ | 19 ------------------- 3 files changed, 14 insertions(+), 19 deletions(-) create mode 100644 kjg/python-the-hard-way/e8.py delete mode 100644 kjg/python.org~ diff --git a/kjg/python-the-hard-way/e8.py b/kjg/python-the-hard-way/e8.py new file mode 100644 index 0000000..51adf35 --- /dev/null +++ b/kjg/python-the-hard-way/e8.py @@ -0,0 +1,11 @@ +formatter = "{} {} {} {}" +print(formatter.format(1, 2, 3, 4)) +print(formatter.format("one", "two", "three", "four")) +print(formatter.format(True, False, False, True)) +print(formatter.format(formatter, formatter, formatter, formatter)) +print(formatter.format( + "Try your", + "Own text here", + "Maybe a poem", + "Or a song about fear" +)) diff --git a/kjg/python.org b/kjg/python.org index 9cada1d..370d8d3 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -66,3 +66,6 @@ Its fleece was white as snow. And everywhere that Mary went. .......... Cheese Burger +*** Python #2: +**** ex8 +learn about a more complicated formatting of a string. {} diff --git a/kjg/python.org~ b/kjg/python.org~ deleted file mode 100644 index 13d37bc..0000000 --- a/kjg/python.org~ +++ /dev/null @@ -1,19 +0,0 @@ -*python - -*** Python #1: -**** ex0 -**** ex1 ->>> print("Hello World!") -... print("Hello Again") -... print("I like typing this.") -... print("This is fun.") -... print('Yay! Printing.') -... print("I'd much rather you 'not'.") -... print('I "said" do not touch this.') -Hello World! -Hello Again -I like typing this. -This is fun. -Yay! Printing. -I'd much rather you 'not'. -I "said" do not touch this. From 4a11b015203426e803f66e6ad11d1da1477b0dc6 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 21:31:00 +0900 Subject: [PATCH 02/16] [Python #2] create e9.py --- kjg/python-the-hard-way/e9.py | 14 ++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 kjg/python-the-hard-way/e9.py diff --git a/kjg/python-the-hard-way/e9.py b/kjg/python-the-hard-way/e9.py new file mode 100644 index 0000000..b9be9f6 --- /dev/null +++ b/kjg/python-the-hard-way/e9.py @@ -0,0 +1,14 @@ +# Here's some new strange stuff, remember type it exactly + +days = "Mon Tue Wed Thu Fri Sat Sun" +months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" + +print("Here are the days: ", days) +print("Here are the months: ", months) + +print(""" + There's something going on here. + with the three double-quotes. + We'll be able to type as much as we like. + Even 4 lines if we want, or 5 or 6 + """) diff --git a/kjg/python.org b/kjg/python.org index 370d8d3..13a8b64 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -69,3 +69,5 @@ Cheese Burger *** Python #2: **** ex8 learn about a more complicated formatting of a string. {} +**** ex9 +how to print for multiline or nextline From 63052676fc9f60d30e17e0431753ea276243cd9a Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 21:46:08 +0900 Subject: [PATCH 03/16] [Python #2] create e10.py --- kjg/python-the-hard-way/e10.py | 16 ++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 kjg/python-the-hard-way/e10.py diff --git a/kjg/python-the-hard-way/e10.py b/kjg/python-the-hard-way/e10.py new file mode 100644 index 0000000..fe56c91 --- /dev/null +++ b/kjg/python-the-hard-way/e10.py @@ -0,0 +1,16 @@ +tabby_cat = "\tI'm tabbed in." +persian_cat = "I'm split\non a line." +backslash_cat = "I'm \\ a \\ cat." + +fat_cat = ''' +I'll do a list : +\t* Cat food +\t* Fishies +\t* Catnip\n\t* Grass +''' + +print(tabby_cat) +print(persian_cat) +print(backslash_cat) +print(fat_cat) +print("\u1234") diff --git a/kjg/python.org b/kjg/python.org index 13a8b64..5a6d49f 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -71,3 +71,5 @@ Cheese Burger learn about a more complicated formatting of a string. {} **** ex9 how to print for multiline or nextline +**** ex10 +how to use \ (using special chracter) From 65f0d43cfa7fa23ac55bb3e73d58bebb7f8c3f5b Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 21:55:04 +0900 Subject: [PATCH 04/16] [Python #2] create e11.py --- kjg/python-the-hard-way/e11.py | 8 ++++++++ kjg/python.org | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 kjg/python-the-hard-way/e11.py diff --git a/kjg/python-the-hard-way/e11.py b/kjg/python-the-hard-way/e11.py new file mode 100644 index 0000000..253a825 --- /dev/null +++ b/kjg/python-the-hard-way/e11.py @@ -0,0 +1,8 @@ +print("How old are you?", end=' ') +age = input() +print("How tall are you?", end=' ') +height = input() +print("How much do you weight?", end=' ') +weight = input() + +print(f"So, you're {age} old, {height} tall and {weight} heavy.") diff --git a/kjg/python.org b/kjg/python.org index 5a6d49f..d3f5fd1 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -73,3 +73,6 @@ learn about a more complicated formatting of a string. {} how to print for multiline or nextline **** ex10 how to use \ (using special chracter) +**** ex11 +how to use key input + From e43b6d8ebc759488e0b995e643f113aa26576600 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 22:12:47 +0900 Subject: [PATCH 05/16] [Python #2] create e12.py --- kjg/python-the-hard-way/e12.py | 5 +++++ kjg/python.org | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 kjg/python-the-hard-way/e12.py diff --git a/kjg/python-the-hard-way/e12.py b/kjg/python-the-hard-way/e12.py new file mode 100644 index 0000000..16e6920 --- /dev/null +++ b/kjg/python-the-hard-way/e12.py @@ -0,0 +1,5 @@ +age = input("How old are you? ") +height = input("How tall are you? ") +weight = input("How much do you weight? ") + +print(f"So, you're {age} old, {height} tall and {weight} heavy.") diff --git a/kjg/python.org b/kjg/python.org index d3f5fd1..64a4a71 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -75,4 +75,5 @@ how to print for multiline or nextline how to use \ (using special chracter) **** ex11 how to use key input - +**** ex12 +how to use key input with print From adfc2fe765fa73edfd07b2bcf30efa16e3e435ca Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 22:37:15 +0900 Subject: [PATCH 06/16] [Python #2] create e13.py --- kjg/python-the-hard-way/e13.py | 8 ++++++++ kjg/python.org | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 kjg/python-the-hard-way/e13.py diff --git a/kjg/python-the-hard-way/e13.py b/kjg/python-the-hard-way/e13.py new file mode 100644 index 0000000..f8b7fe8 --- /dev/null +++ b/kjg/python-the-hard-way/e13.py @@ -0,0 +1,8 @@ +from sys import argv +# read the WYSS section for how to run this +script, first, second, third = argv + +print("The script is called:", script) +print("Your first variable is:", first) +print("Your second variable is:", second) +print("Your third variable is:", third) diff --git a/kjg/python.org b/kjg/python.org index 64a4a71..8ef9d17 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -77,3 +77,5 @@ how to use \ (using special chracter) how to use key input **** ex12 how to use key input with print +**** ex13 +how to use an argument when you run script From 5b5bfe07ca5ecc851d1fb10abbb931012372c2d2 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 20 May 2020 22:52:18 +0900 Subject: [PATCH 07/16] [Python #2] create e14.py --- kjg/python-the-hard-way/e14.py | 23 +++++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 kjg/python-the-hard-way/e14.py diff --git a/kjg/python-the-hard-way/e14.py b/kjg/python-the-hard-way/e14.py new file mode 100644 index 0000000..74bcd95 --- /dev/null +++ b/kjg/python-the-hard-way/e14.py @@ -0,0 +1,23 @@ +from sys import argv + +script, user_name, first, second = argv +prompt = '==> ' + +print(f"Hi {user_name}, I'm the {script} script.") +print("I'd like to ask you a few questions.") +print(f"Do you like me {user_name}?") +likes = input(prompt) + +print(f"Where do you live {user_name}?") +lives = input(prompt) + +print(f"What kind of computer do you have?") +computer = input(prompt) + +print(f""" +Alright, so you said {likes} about liking me. +You live in {lives}. Not suer where that is. +And you have a {computer} computer. Nice. +{first} and {second} +""") + diff --git a/kjg/python.org b/kjg/python.org index 8ef9d17..dffd17d 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -79,3 +79,5 @@ how to use key input how to use key input with print **** ex13 how to use an argument when you run script +**** ex14 +how to use an argument with input From 8be2fe479d0c142436465854fb88be90ed1f163c Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 21:19:18 +0900 Subject: [PATCH 08/16] [Python #2] create e15.py --- kjg/python-the-hard-way/e15.py | 19 +++++++++++++++++++ kjg/python-the-hard-way/ex15_sample.txt | 3 +++ kjg/python.org | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 kjg/python-the-hard-way/e15.py create mode 100644 kjg/python-the-hard-way/ex15_sample.txt diff --git a/kjg/python-the-hard-way/e15.py b/kjg/python-the-hard-way/e15.py new file mode 100644 index 0000000..c02e04e --- /dev/null +++ b/kjg/python-the-hard-way/e15.py @@ -0,0 +1,19 @@ +from sys import argv + +script, filename = argv + +txt = open(filename) + + +print(f"Here's your file {filename}: ") +print(txt.read()) + +txt.close() + +print("Type the filename again : ") +file_again = input("> ") + +txt_again = open(file_again) + +print(txt_again.read()) + diff --git a/kjg/python-the-hard-way/ex15_sample.txt b/kjg/python-the-hard-way/ex15_sample.txt new file mode 100644 index 0000000..8719939 --- /dev/null +++ b/kjg/python-the-hard-way/ex15_sample.txt @@ -0,0 +1,3 @@ +This is stuff I typed into a file. +It is really cool stuff . +Lots and lots of fun to have in here. diff --git a/kjg/python.org b/kjg/python.org index dffd17d..cf4f9ff 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -81,3 +81,6 @@ how to use key input with print how to use an argument when you run script **** ex14 how to use an argument with input +*** Python #3: +**** ex15 +How to use read function from file From 2af966bd8625ce1937ae581a0984e07700962d43 Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 21:39:59 +0900 Subject: [PATCH 09/16] [Python #3] create e16.py --- kjg/python-the-hard-way/e16.py | 33 ++++++++++++++++++++++++++++++++ kjg/python-the-hard-way/test.txt | 3 +++ kjg/python.org | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 kjg/python-the-hard-way/e16.py create mode 100644 kjg/python-the-hard-way/test.txt diff --git a/kjg/python-the-hard-way/e16.py b/kjg/python-the-hard-way/e16.py new file mode 100644 index 0000000..f8d3aaa --- /dev/null +++ b/kjg/python-the-hard-way/e16.py @@ -0,0 +1,33 @@ +from sys import argv + +script, filename = argv + +print(f"We're going to erase {filename}.") +print("If you don't want that, hit CTRL-C (^C).") +print("If you do want that, hit RETURN.") + +input("?") + +print("Opening th file...") +target = open(filename, 'w') + +print("Truncating the file. Goodbye!") +target.truncate() + +print("Now I'm going to ask you for three lines.") + +line1 = input("line 1: ") +line2 = input("line 2: ") +line3 = input("line 3: ") + +print("I'm going to write these to the file.") + +target.write(line1) +target.write("\n") +target.write(line2) +target.write("\n") +target.write(line3) +target.write("\n") + +print("And finally, we close it.") +target.close() diff --git a/kjg/python-the-hard-way/test.txt b/kjg/python-the-hard-way/test.txt new file mode 100644 index 0000000..e3188be --- /dev/null +++ b/kjg/python-the-hard-way/test.txt @@ -0,0 +1,3 @@ +Mary had a little lamb +Its fleece was white as snow +It was also tasty diff --git a/kjg/python.org b/kjg/python.org index cf4f9ff..312eb04 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -84,3 +84,5 @@ how to use an argument with input *** Python #3: **** ex15 How to use read function from file +**** ex16 +How to use write file From 4e9f2a33d78a07bb09ddb33a5a40bb3d4646f0b1 Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 21:54:30 +0900 Subject: [PATCH 10/16] [Python #3] create e17.py --- kjg/python-the-hard-way/e17.py | 24 ++++++++++++++++++++++++ kjg/python-the-hard-way/new_file.txt | 1 + kjg/python-the-hard-way/test.txt | 4 +--- kjg/python.org | 4 +++- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 kjg/python-the-hard-way/e17.py create mode 100644 kjg/python-the-hard-way/new_file.txt diff --git a/kjg/python-the-hard-way/e17.py b/kjg/python-the-hard-way/e17.py new file mode 100644 index 0000000..cfe8e16 --- /dev/null +++ b/kjg/python-the-hard-way/e17.py @@ -0,0 +1,24 @@ +from sys import argv +from os.path import exists + +script, from_file, to_file = argv + +print(f"Copying from {from_file} to {to_file}") + +# we could do these two on one line, how ? +in_file = open(from_file) +indata = in_file.read() + +print(f"The input file is {len(indata)} bytes long") + +print(f"Does the output file exist? {exists(to_file)}") +print("Ready, hit RETURN to continue, CTRL-C to abort.") +input() + +out_file = open(to_file, 'w') +out_file.write(indata) + +print("Alright, all done.") + +out_file.close() +in_file.close() diff --git a/kjg/python-the-hard-way/new_file.txt b/kjg/python-the-hard-way/new_file.txt new file mode 100644 index 0000000..6de7b8c --- /dev/null +++ b/kjg/python-the-hard-way/new_file.txt @@ -0,0 +1 @@ +This is a test file. diff --git a/kjg/python-the-hard-way/test.txt b/kjg/python-the-hard-way/test.txt index e3188be..6de7b8c 100644 --- a/kjg/python-the-hard-way/test.txt +++ b/kjg/python-the-hard-way/test.txt @@ -1,3 +1 @@ -Mary had a little lamb -Its fleece was white as snow -It was also tasty +This is a test file. diff --git a/kjg/python.org b/kjg/python.org index 312eb04..f2a91e2 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -85,4 +85,6 @@ how to use an argument with input **** ex15 How to use read function from file **** ex16 -How to use write file +How to write file +**** ex17 +How to copy file From 8d83c50d5978ac9d55f4a534bf05a17865918d9c Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 22:08:40 +0900 Subject: [PATCH 11/16] [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 From fad98b2be3a6508df5b2848c7a26cd45fdbd2b1d Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 22:32:42 +0900 Subject: [PATCH 12/16] [Python #3] create e19.py --- kjg/python-the-hard-way/e19.py | 20 ++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 kjg/python-the-hard-way/e19.py diff --git a/kjg/python-the-hard-way/e19.py b/kjg/python-the-hard-way/e19.py new file mode 100644 index 0000000..18d9d54 --- /dev/null +++ b/kjg/python-the-hard-way/e19.py @@ -0,0 +1,20 @@ +def cheese_and_crackers(cheese_count, boxes_of_crackers): + print(f"You have {cheese_count} cheeses!") + print(f"You have {boxes_of_crackers} boxes_of_crackers!") + print("Man that's enough for a party!") + print("Get a blanket.\n") + +print("We can just give the function numbers directly:") +cheese_and_crackers(20, 30) + +print("OR, we can use variables from our script:") +amount_of_cheese = 10 +amount_of_crackers = 50 + +cheese_and_crackers(amount_of_cheese, amount_of_crackers) + +print("We can even do math inside too:") +cheese_and_crackers(10 + 20, 5 + 6) + +print("And we can combine the two, variables and math:") +cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000) diff --git a/kjg/python.org b/kjg/python.org index 6e95efe..57a1a0d 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -90,3 +90,5 @@ How to write file How to copy file **** ex18 How to use function +**** ex19 +How to use function and variables From 991779bc672bb25bc290cf55a03e8a13bb51f294 Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 22:49:51 +0900 Subject: [PATCH 13/16] [Python #3] create e20.py --- kjg/python-the-hard-way/e20.py | 35 ++++++++++++++++++++++++++++++++ kjg/python-the-hard-way/test.txt | 4 +++- kjg/python.org | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 kjg/python-the-hard-way/e20.py diff --git a/kjg/python-the-hard-way/e20.py b/kjg/python-the-hard-way/e20.py new file mode 100644 index 0000000..8f7cee7 --- /dev/null +++ b/kjg/python-the-hard-way/e20.py @@ -0,0 +1,35 @@ +from sys import argv + +script, input_file = argv + +def print_all(f): + print(f.read()) + +def rewind(f): + f.seek(0) + +def print_a_line(line_count, f): + print(line_count, f.readline()) + +current_file = open(input_file) + +print("First let's print the whole file: \n") + +print_all(current_file) + +print("Now let's rewind, kind of like a tape.") + +rewind(current_file) + +print("Let's print three lines:") + +current_line = 1 +print_a_line(current_line, current_file) + +#current_line = current_line + 1 +current_line += 1 +print_a_line(current_line, current_file) + +#current_line = current_line + 1 +current_line += 1 +print_a_line(current_line, current_file) diff --git a/kjg/python-the-hard-way/test.txt b/kjg/python-the-hard-way/test.txt index 6de7b8c..e97bf0c 100644 --- a/kjg/python-the-hard-way/test.txt +++ b/kjg/python-the-hard-way/test.txt @@ -1 +1,3 @@ -This is a test file. +This is line 1 +This is line 2 +This is line 3 diff --git a/kjg/python.org b/kjg/python.org index 57a1a0d..aa4fc79 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -92,3 +92,5 @@ How to copy file How to use function **** ex19 How to use function and variables +**** ex20 +How to use function with file From ac073078550ac18d144a5e3fc55c3a1cd6c8db1b Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 23:14:40 +0900 Subject: [PATCH 14/16] [Python #3] create e20.py --- kjg/python-the-hard-way/e21.py | 40 ++++++++++++++++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 kjg/python-the-hard-way/e21.py diff --git a/kjg/python-the-hard-way/e21.py b/kjg/python-the-hard-way/e21.py new file mode 100644 index 0000000..a72984f --- /dev/null +++ b/kjg/python-the-hard-way/e21.py @@ -0,0 +1,40 @@ +def add(a, b): + print(f"ADDING {a} + {b}") + return a + b + + +def subtract(a, b): + print(f"SUBTRACTING {a} - {b}") + return a - b + + +def multiplay(a, b): + print(f"MULTIPLYING {a} * {b}") + return a * b + + +def divide(a, b): + print(f"DIVIDING {a} / {b}") + return a / b + + +print("Let's do some math with just functions!") + +age = add(30, 5) +height = subtract(78, 4) +weight = multiplay(90, 2) +iq = divide(100, 2) + +print(f"Age: {age}, Height: {height}, Weight: {weight}, IQ: {iq}") + +# A puzzle for the extra credit, type it in anyway. +print("Here is a puzzle.") + +what = add(age, subtract(height, multiplay(weight, divide(iq, 2)))) + +print("That becomes: ", what, "Can you do it by hand?") + + + + + diff --git a/kjg/python.org b/kjg/python.org index aa4fc79..48b693d 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -94,3 +94,5 @@ How to use function How to use function and variables **** ex20 How to use function with file +**** ex21 +How to use fucntion with return From 45075b96b4336e46f4378551954fc0e8617fcf69 Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 23:33:46 +0900 Subject: [PATCH 15/16] [Python #3] test ex22 --- kjg/python-the-hard-way/e3.py | 4 ++-- kjg/python-the-hard-way/new_file2.txt | 3 +++ kjg/python-the-hard-way/test.txt | 6 +++--- kjg/python.org | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 kjg/python-the-hard-way/new_file2.txt diff --git a/kjg/python-the-hard-way/e3.py b/kjg/python-the-hard-way/e3.py index e7067be..f7e9ac9 100644 --- a/kjg/python-the-hard-way/e3.py +++ b/kjg/python-the-hard-way/e3.py @@ -5,11 +5,11 @@ print("Roosters", 100 - 25 * 3 % 4 ) print("Now I will count the eggs : ") -print(3 + 2 + 1 - 5 + 4 % 2 -1 / 4 + 6) +print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) print("Is it true that 3 + 2 < 5 - 7?") -print(3 + 2 < 5 -7 ) +print(3 + 2 < 5 - 7 ) print("What is 3 + 2?", 3 + 2) print("What is 5 - 7?", 5 - 7) diff --git a/kjg/python-the-hard-way/new_file2.txt b/kjg/python-the-hard-way/new_file2.txt new file mode 100644 index 0000000..996a043 --- /dev/null +++ b/kjg/python-the-hard-way/new_file2.txt @@ -0,0 +1,3 @@ +test line1 +test line2 +test line3 diff --git a/kjg/python-the-hard-way/test.txt b/kjg/python-the-hard-way/test.txt index e97bf0c..996a043 100644 --- a/kjg/python-the-hard-way/test.txt +++ b/kjg/python-the-hard-way/test.txt @@ -1,3 +1,3 @@ -This is line 1 -This is line 2 -This is line 3 +test line1 +test line2 +test line3 diff --git a/kjg/python.org b/kjg/python.org index 48b693d..0656a8c 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -96,3 +96,5 @@ How to use function and variables How to use function with file **** ex21 How to use fucntion with return +**** ex22 +repeat from ex2 to ex21 From 87ad0c08427ae23f03fd8cb94dc2ead6d82deceb Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 22 May 2020 23:43:18 +0900 Subject: [PATCH 16/16] [Python #3] update python.org for ex22 --- kjg/python.org | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kjg/python.org b/kjg/python.org index 0656a8c..d631490 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -97,4 +97,7 @@ How to use function with file **** ex21 How to use fucntion with return **** ex22 -repeat from ex2 to ex21 +repeat from ex1 to ex21 +" # () ' + . < ? , = / % - * {} \n \t +open read close truncate def return print +