Category: Lpthw

LPTHW - Exercise 6: Strings Text

LPTHW - Exercise 6 More working with strings and text in this exercise. Having looked into string formatting in the last exercise I realised that I was looking into something quite a bit further on in the course than I needed to right now. x = "There are {!a} types of people.".format(10) binary = "binary" do_not = "don't" y = f"Those who know {binary} and those who {do_not}." print(x) print(y) print(f"I said: {x!

Read more...

LPTHW - Exercise 5: More Variables Printing

LPTHW - Exercise 5 Exercise 5 takes us back over variables and printing. It also introduces us to 'format strings'. One key thing to understand about Python is that there seems to have been a bit of a 'mess' around handling strings. This course exploits the behaviour available in Python 3.6 and above. And I can see why - it's the closest to the way Python 2 handled strings.

Read more...

LPTHW - Exercise 4: Variables Names

LPTHW - Exercise 4 First introduction to variables here. Variable has a very dry and precise definition in Computer Science: In computer programming, a variable or scalar is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity of information referred to as a value. Don't let that put you off though. A variable can be thought of simply as a thing with a name that stores some information.

Read more...

LPTHW - Exercise 3: Numbers and Math

LPTHW - Exercise 3 This was the first tricky one, and probably deliberately so. If you've come here from Google, it might be because you didn't find this StackOverflow post yet, or maybe this post popped out on top for you particular search term. Either, way... ...you want to know why the answer to the Rooster question is 97, right? Well, the simple answer is there's an order to the operations you must perform and you can see this in the completed example below.

Read more...

LPTHW - Exercise 2: Comments and Pound Characters

LPTHW - Exercise 2 Another gentle intro/recap of the first lesson. # A comment, this is so you can read your program later # Anything after the # is ignored by python. print("I could have code like this.") # and the comment after is ignored # You can also use a comment to 'disable' or comment out a piece of code: # print "This won't run." print("This will run.") Learn Python The Hard Way Study Drills 1.

Read more...

LPTHW - Exercise 1: A Good First Program

LPTHW - Exercise 1 Pretty simple introduction this, just a few print statements. Example code will be below the answers to the student questions... # print("Hello again!") # print("I Like typing this.") # print("This is fun.") # print('Yay! Printing.') # print("I'd much rather you 'not'.") # print('I "said" do not touch this.') print "This is another line." Learn Python The Hard Way Study Drills 1. Make your script print another line.

Read more...

LPTHW - Ex 0: The Setup

This is all about setting up your development environment. I wasn't going to bother writing this up as it seemed like a fairly basic thing but that's just not the case. There are so many considerations when it comes to how you want to set things up and as a newbie you can get yourself off down a rabbit hole and find you need to redo a bunch of things later on down the road when your skill improves or you need to change systems.

Read more...

Learn Python The Hard Way

In addition to the Odin Project I've decided to simultaneously undertake the Learn Python The Hard Way course by Zed Shaw. Learning two things at once might sound overkill but spending 6 hours plus a day on one topic can just lead to burnout. So, with a range of things to cover, I hope to spread out the brain pain and probably learn a little faster or more deeply than I would otherwise.

Read more...