diff --git a/3exercises/ex20.py b/3exercises/ex20.py new file mode 100644 index 0000000..2dd61b9 --- /dev/null +++ b/3exercises/ex20.py @@ -0,0 +1,33 @@ +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 +print_a_line(current_line, current_file) + +current_line = current_line + 1 +print_a_line(current_line, current_file) diff --git a/Codecadmey Projects/ex7_ch3,L1?.py b/Codecadmey Projects/ex7_ch3,L1_.py similarity index 100% rename from Codecadmey Projects/ex7_ch3,L1?.py rename to Codecadmey Projects/ex7_ch3,L1_.py diff --git a/PHW.md b/PHW.md index 3ab16e6..7d626ad 100644 --- a/PHW.md +++ b/PHW.md @@ -1,3 +1,15 @@ -# +# Function Checklist (ex19) -ex19. +1. Did you start your function definition with def? +2. Does your function name have only characters and _ (underscore) characters? +3. Did you put an open parenthesis right after the function name? +4. Did you put your arguments after the parenthesis separated by commas? +5. Did you make each argument unique (meaning no duplicated names)? +6. Did you put a close parenthesis and a colon after the arguments? +7. Did you indent all lines of code you want in the function four spaces? No more, no less. +8. Did you “end” your function by going back to writing with no indent (dedenting, we call it)? +When you run (“use” or “call”) a function, check these things: +1. Did you call/use/run this function by typing its name? +2. Did you put the ( character after the name to run it? +3. Did you put the values you want into the parentheses separated by commas? +4. Did you end the function call with a ) character?