All about PYTHON! A simple tutorial!


Python is great because it is fast and easy to program. You can quickly code up a project to test it. There are plenty of examples of pretty much anything you can think of online.

When beginning coding, remember that it will not always go smoothly, so you need to have patience and perseverance to avoid anger, frustration, loss of hair, and potentially a computer thrown off the 3rd floor of the library. It helps to have an experienced coder to help you for when you get really stuck. In my early programming days, I have spent days trying to fix issues that ended up being super easy fixes when I asked for help. 

If you are still here, welcome, you are not afraid and are ready to learn!



Here are some things I use python for:
  • Scipy and matplotlib are great tools to modify data.
  • Raspberry Pi programming.
  • Modifying excel documents using CSV. 
One thing to keep in mind is that python is a scripting language, so it is different from languages like C and C++ which are compiled languages. A compiler converts the source code to machine language for the processor to use. A scripting language on the other hand runs on top of the runtime environment. 

When starting up programming, I always thought the hardest part was getting the environment set up so that you can get your first "hello world!" program to work. So here I would like to go over how to set it up:

  1. Install the python program from the python website. Follow the instructions to download and install. 
  2. Type "python" and press enter.
  3. Now it should print out the version of python and stuff and have a new line with ">>>"
  4. Now type your simple command, 'print "Hello World!"'
  5. This should print Hello World! in the next line. 
  6. Congrats it works!! Now look up examples online to find more complex code and see what you can do with it!!


Make sure you have the correct version of Python for the examples you are trying to reproduce. Between different versions of python, you have slight differences that could lead to a lot of frustration. For example on the print function in version 2.6 vs 3.0:

Old : print "The answer is :", 2*2
New : print("The answer is :", 2*2)

Don't forget... The interwebs is your friend. If you get stuck start reading up on examples, you should be able to find the solution to your problem. Or if you can't find the solution, code your example in more simple chunks so that you can isolate the problem and hopefully pinpoint it.

No comments:

Post a Comment