From 67f6d003576d3228d47f9dff7d2020d9d991fe60 Mon Sep 17 00:00:00 2001 From: llnu Date: Tue, 26 May 2020 09:28:42 +0200 Subject: [PATCH 1/5] ex12 created, unanswered question added --- balazs/python-the-hard-way/ex12/notes.org | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 balazs/python-the-hard-way/ex12/notes.org diff --git a/balazs/python-the-hard-way/ex12/notes.org b/balazs/python-the-hard-way/ex12/notes.org new file mode 100644 index 0000000..50efbeb --- /dev/null +++ b/balazs/python-the-hard-way/ex12/notes.org @@ -0,0 +1,13 @@ + + +* The code: +age = input("How old are you? ") +height = input("How tall are you? ") +weight = input("How much do you weigh? ") + + +print(f"So, you're {age} old, {height} tall and {weight} heavy.") + +* When will input run? At the variable initalization or when calling the function? + +* How do I debug, and step through the code to see what's happening in the background (and possibly see the anwser for the prev question)? From f9f6b41ce14e7e3df36c5a7cb7cd0cd69a4876a2 Mon Sep 17 00:00:00 2001 From: llnu Date: Tue, 26 May 2020 10:37:36 +0200 Subject: [PATCH 2/5] ex17 created, answered question added --- balazs/python-the-hard-way/ex17/notes.org | 24 ++++++++++++++++++++++ balazs/python-the-hard-way/ex17/notes.org~ | 24 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 balazs/python-the-hard-way/ex17/notes.org create mode 100644 balazs/python-the-hard-way/ex17/notes.org~ diff --git a/balazs/python-the-hard-way/ex17/notes.org b/balazs/python-the-hard-way/ex17/notes.org new file mode 100644 index 0000000..4fe2344 --- /dev/null +++ b/balazs/python-the-hard-way/ex17/notes.org @@ -0,0 +1,24 @@ +* Questions + +** Why does Opening and Reading the file is done in 2 steps? What's the difference? +in_file = open(from_file) +indata = in_file.read() + +"Opening" a file doesn't actually bring any of the data from the file into your program. It just prepares the file for reading (or writing), so when your program is ready to read the contents of the file it can do so right away. +*** Source: +https://stackoverflow.com/questions/20308998/what-is-the-difference-between-opening-and-reading-a-file-in-python + +** What does 'w' mean? (from ex16) +target = open(filename, 'w') + +It's a string with a character in it for the kind of mode for the file. + +'w' = write +'r' = read +'a' = append + + + +* Note + +" character messes up the copy in org or emacs diff --git a/balazs/python-the-hard-way/ex17/notes.org~ b/balazs/python-the-hard-way/ex17/notes.org~ new file mode 100644 index 0000000..852b46f --- /dev/null +++ b/balazs/python-the-hard-way/ex17/notes.org~ @@ -0,0 +1,24 @@ +* Questions + +** Why does Opening and Reading the file is done in 2 steps? What's the difference? +in_file = open(from_file) +indata = in_file.read() + +"Opening" a file doesn't actually bring any of the data from the file into your program. It just prepares the file for reading (or writing), so when your program is ready to read the contents of the file it can do so right away. +*** Source: +https://stackoverflow.com/questions/20308998/what-is-the-difference-between-opening-and-reading-a-file-in-python + +** What does 'w' mean? (from ex14) +target = open(filename, 'w') + +It's a string with a character in it for the kind of mode for the file. + +'w' = write +'r' = read +'a' = append + + + +* Note + +" character messes up the copy in org or emacs From aa16a38e3fb17b5838b0fa6e01b97a308e42fc3a Mon Sep 17 00:00:00 2001 From: llnu Date: Tue, 26 May 2020 10:39:57 +0200 Subject: [PATCH 3/5] removed temp file (global gitignore is now in place) --- balazs/python-the-hard-way/ex17/notes.org~ | 24 ---------------------- 1 file changed, 24 deletions(-) delete mode 100644 balazs/python-the-hard-way/ex17/notes.org~ diff --git a/balazs/python-the-hard-way/ex17/notes.org~ b/balazs/python-the-hard-way/ex17/notes.org~ deleted file mode 100644 index 852b46f..0000000 --- a/balazs/python-the-hard-way/ex17/notes.org~ +++ /dev/null @@ -1,24 +0,0 @@ -* Questions - -** Why does Opening and Reading the file is done in 2 steps? What's the difference? -in_file = open(from_file) -indata = in_file.read() - -"Opening" a file doesn't actually bring any of the data from the file into your program. It just prepares the file for reading (or writing), so when your program is ready to read the contents of the file it can do so right away. -*** Source: -https://stackoverflow.com/questions/20308998/what-is-the-difference-between-opening-and-reading-a-file-in-python - -** What does 'w' mean? (from ex14) -target = open(filename, 'w') - -It's a string with a character in it for the kind of mode for the file. - -'w' = write -'r' = read -'a' = append - - - -* Note - -" character messes up the copy in org or emacs From 65d2f55a8b176610058b34ca5b0dff7c8d6e27b3 Mon Sep 17 00:00:00 2001 From: llnu Date: Wed, 27 May 2020 16:58:20 +0200 Subject: [PATCH 4/5] added ex31 --- balazs/python-the-hard-way/ex31/mountain.py | 21 ++++++++++++++++++++ balazs/python-the-hard-way/ex31/mountain.py~ | 21 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 balazs/python-the-hard-way/ex31/mountain.py create mode 100644 balazs/python-the-hard-way/ex31/mountain.py~ diff --git a/balazs/python-the-hard-way/ex31/mountain.py b/balazs/python-the-hard-way/ex31/mountain.py new file mode 100644 index 0000000..718e382 --- /dev/null +++ b/balazs/python-the-hard-way/ex31/mountain.py @@ -0,0 +1,21 @@ + + +while True: + print("""You are on a mountain. +There is a smaller mountain ahead of you and there is a bigger mountain behind you.""") + + print("Where do you go?") + + print("""1. Forward +2. Backward""") + + direction = input("> ") + + if direction == "1": + print("You continued your journey forward, and you arrived on a smaller mountain.") + + elif direction == "2": + print("You continued your journey backward, and you arrived on a bigger mountain.") + + else: + print("You decided to rest, and decide later") diff --git a/balazs/python-the-hard-way/ex31/mountain.py~ b/balazs/python-the-hard-way/ex31/mountain.py~ new file mode 100644 index 0000000..deee108 --- /dev/null +++ b/balazs/python-the-hard-way/ex31/mountain.py~ @@ -0,0 +1,21 @@ + + +while True: + print("""You are on a mountain. +There is a smaller mountain ahead of you and there is a bigger mountain behind you. + +Where do you go? + +1. Forward +2. Backward""" + + direction = input("> ") + + if direction == "1": + print("You continued your journey forward, and you arrived on a smaller mountain.") + + if direction == "2": + print("You continued your journey backward, and you arrived on a bigger mountain.") + + else: + print("You decided to rest, and decide later") From f5ddee1da4481c03e692671d2b67f92bab021a21 Mon Sep 17 00:00:00 2001 From: llnu Date: Wed, 27 May 2020 16:58:56 +0200 Subject: [PATCH 5/5] added ex31 --- balazs/python-the-hard-way/ex31/mountain.py~ | 21 -------------------- 1 file changed, 21 deletions(-) delete mode 100644 balazs/python-the-hard-way/ex31/mountain.py~ diff --git a/balazs/python-the-hard-way/ex31/mountain.py~ b/balazs/python-the-hard-way/ex31/mountain.py~ deleted file mode 100644 index deee108..0000000 --- a/balazs/python-the-hard-way/ex31/mountain.py~ +++ /dev/null @@ -1,21 +0,0 @@ - - -while True: - print("""You are on a mountain. -There is a smaller mountain ahead of you and there is a bigger mountain behind you. - -Where do you go? - -1. Forward -2. Backward""" - - direction = input("> ") - - if direction == "1": - print("You continued your journey forward, and you arrived on a smaller mountain.") - - if direction == "2": - print("You continued your journey backward, and you arrived on a bigger mountain.") - - else: - print("You decided to rest, and decide later")