Python is one of the fastest growing programming languages in the world! To help you master this language we have made a quick reference guide and are going to cover a few of the basics things to be aware of when starting out with python.
This guide will run through the basics very basics of python and this to be aware of when started toward on the track toward using all the platforms that can be programmed with it such as Windows, Mac, Linux, and the Raspberry Pi you can also use MicroPython that will let you code hardware like The Circuit Playground Express, Pycom and many others.
Types
Python is a dynamically typed language this means that the type of the object is stored with the object. In practice this means that you do not have to declare your types as you do in a language like C. This is great and saves a lot of time working out your types, however on occasion you will run into problems where it assigns a type you are not expecting. One example if you compare a user input of 10 to the number 10 it will not work because the input will be stored as a string.
x = input(“Enter the number 1”) y = 1 if (x==y): print(“The number is the same”) else: print(“something went wrong”)
White Space
Python uses white space to group code statements rather than brackets ({}) or begin and end statements that are common in other languages. block below will loop over the two tabbed print statements but only print over after the grouped code has finished.
for i in range(0,10) print(i) print(10-i) print(“over”)
Something to be aware of with this white space is that not all white space is the same so code that has been copied from and external source may give errors due to different types of white space(This can also be a problem when copying in code with " in it).
Getting Help with Python
One of the best things about Python is that there are loads of places get help and find tools to get your project running sooner. We have put together a cheat sheet that gives you all the Python basics right at your fingertips so you won’t need without digging through the Official Python Documentation.
If you have any questions about python or have some advice that you would like to share with new python coders post in the thread below and let us know.