Having learnt enough Swift to write a neat watch face app for Apple Watch this summer, I thought I’d turn my attention to learning some Python.
Firstly, I wanted a way to edit Python commands in a decent editor and run them. It appears that Xcode doesn’t support this out of the box, but this handy StackOverflow question gives the details on how to set it up.
Secondly, I wanted a series of challenges/tutorials to walk through the basic syntax of Python. HackerRank.com is very good for this sort of thing and has a decent set of exercises to work through.
My first bug was very revealing about the differences between Python and strongly-typed languages like F# and C++:
N = int(raw_input().strip()) if (n > 10): print( "big" ) elif ( N < 0 ): print( "negative" ) else: print( "normal" )
The Python Interpreter doesn’t give an error because of the typo “n > 10” instead of “N > 10” – it just carries on regardless!
Finally, Python Software Foundation seems like a good reference site with lots of examples.
See also the next post in this series.