LPTHW - Exercise 8: Printing Printing

LPTHW - Exercise 8 Another copy one here but there were things to learn conceptually that haven't been brought up before. Look at how formatter is declared right at the beginning. Throughout the rest of the exercise we just add the relevant data and it'll print in the way set in the formatter variable. I think this is a subtly important concept to begin to learn, that you can setup the structure of how to do something and allow the data to come later, knowing it'll be output how you intended.

Read more...

LPTHW - Exercise 7: More Printing

LPTHW - Exercise 7 This is the start of a rote copying stretch. That said, I did a few bits of my own towards the bottom of the script as you'll see below. Having a play around with the code helps me to get a feel for the different things it does. Just trying something to see what it does is a fun way to learn. I think as time goes by actually reading up on docs first will start to become the more efficient way to do things, but I don't think we're at that stage just yet.

Read more...

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