Merge remote-tracking branch 'balazs/master'

This commit is contained in:
Nico Schottelius 2020-05-27 17:02:12 +02:00
commit f46bfd4c22
3 changed files with 58 additions and 0 deletions

View file

@ -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)?

View file

@ -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

View file

@ -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")