I went to learnpython.org and absent mindedly clicked the tutorial to see what it was like. Lesson 1 - change the word "goodbye" to the word "hello", then click run. Anyone with a word processor can do this lesson. So far, so good.
Lesson 2:
Quote:
Variables and Types
Python is completely object oriented, and not "statically typed". You do not need to declare variables before using them, or declare their type. Every variable in Python is an object, and therefore every object supports the following functions:
OK, what's an object, what's declaring, what are variables, what are functions? Are all objects variables? Lesson 2 and I'm already applying philosophy because I'm so confused.
help(object) - Shows information on how to use the object.
dir(object) - shows the internal structure of the object - all its methods and members.
This tutorial will go over a few basic types of variables.
Numbers
Python supports two types of numbers - integers and floating point numbers. (It also supports complex numbers, which will not be explained in this tutorial).
What's an integer? What's a floating point number?
To define an integer, use the following syntax:
myint = 7
To define a floating point number, you may use one of the following notations:
myfloat = 7.0
myfloat = float(7)
Strings
Strings are defined either with a single quote or a double quotes.
mystring = 'hello'
mystring = "hello"
The difference between the two is that using double quotes makes it easy to include apostrophes (whereas these would terminate the string if using single quotes)
mystring = "Don't worry about apostrophes"
There are additional variations on defining strings that make it easier to include things such as carriage returns, backslashes and Unicode characters. These are beyond the scope of this tutorial, but are covered in the Python documentation.
Simple operators can be executed on numbers and strings:
one = 1
two = 2
three = one + two
hello = "hello"
world = "world"
helloworld = hello + " " + world
Mixing operators between numbers and strings is not supported:
# This will not work!
print one + two + hello
Exercise
The target of this exercise is to create a string, an integer, and a floating point number. The string should be named mystring and should contain the word "hello". The floating point number should be named myfloat and should contain the number 10, and the integer should be named myint and should contain the number 20.
As per the red, that's one fucker of a learning curve. I think integers are 'whole numbers" i.e. 5, not 5.2. I am deriving from the use of function that its meaning is quite literal. This is the problem though - you could fathom this shit out eventually, but programming beginners guides should never be written by programmers, they should be written by teachers. And not programmers who became teachers either. The sad thing is for those of us with 'fuck all maths' being taught to program can really help with learning maths because it give us a useful, compelling reason to do some.
Anyone know of any sites that are good at explaining this stuff properly?