Category: Lpthw

LPTHW - Exercise 22: What do you know so far?

LPTHW - Exercise 22 No code or study drill in this lesson. Today we'll be going back over everything we've done so far and make sure we know what every little bit does/means. To do that we're going to go back through each lesson and identify every keyword or symbol that we've used. Then we'll write up exactly what each of those means or what it does. Useful resources There are a few excellent resources that you can keep refering back to when refreshing your memory on the points below.

Read more...

LPTHW - Exercise 21: Functions Can Return Something

LPTHW - Exercise 21 Well it feels like I'm finally getting somewhere. Learning the basics over and over again as I am (I'm also doing the Odin Project) gets a bit demoralising. Finally getting to this stage here (and prety much the same stage in the Odin Project) feels like a bit of a breakthrough. That's not to say there isn't a long way to go! It is nice though to feel a little bit like I'm emerging from the dense forrest and starting to be able to glimpse the land beyond.

Read more...

LPTHW - Exercise 20: Functions and Files

LPTHW - Exercise 20 More functions this time but here the focus seems to be on being able to follow the 'flow' of multiple functions, not ones that pass data from one to another but just being able to read and follow how a script with multiple functions works Because the script undergoes extensive alterations through the lesson, I'm going to post it in parts with my additions in a separate section below.

Read more...

LPTHW - Exercise 19: Functions and Variables

LPTHW - Exercise 19 When I first read through this lesson it seemed like a breeze, and it was, until I got to the study drills. There's nothing in the script itself that's tricky, it's mostly just a refresh of the last lesson and confirms you can write out the functions correctly. But the study drills take it to a new level with the requirement to write your own function and call it 10 different ways.

Read more...

LPTHW - Exercise 18: Names, Variables, Code, Functions

LPTHW - Exercise 18 Yey! Functions! Turns out we've already been using them in previous exercises with things like close() and open() but here we get to write our own one properly. What is a function? A function... ...lets you group a series of statements together to perform a specific task. If different parts of the script repeat the same task, you can reuse the function (rather than repeating the same set of statements).

Read more...

LPTHW - Exercise 17: More Files

LPTHW - Exercise 17 I found this to be an awkward lesson to write out. It's not hard to do it but it's hard to write it out in a post like this because the script gets quite a lot of modification. Here's the first run through of the script: 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 the following on one line how?

Read more...

LPTHW - Exercise 16: Reading and Writing Files

LPTHW - Exercise 16 Here we have a lot of 'doing'. A lot of writing anyway. Following this methodically should make it very easy to follow. Just take it one step at a time and see that what at first might appear difficult is merely 'complex' and not actually hard at all. Let's start with the lesson script and go from there... from sys import argv script, filename = argv print(f"We're going to erase {filename}.

Read more...

LPTHW - Exercise 15: Reading Files

LPTHW - Exercise 15 This is an interesting lesson. It may take a few minutes to get the mental abstraction of what is going on with the open() and read() commands. Open and read? When we work with and open files ourselves in something like a text document, we associate 'open' with 'read' i.e. we as humans read the file immediately as it opens, so we can do stuff with it.

Read more...