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)? 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/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")