Python Programming Introduction

python.jpg

Hi everyone and thank you for your interest in the awesomeness of Python. During my college curriculum I had heard about Python and kind of brushed it off as a joke thinking there is no way it is as powerful as the big dogs of the pack, c++ and Java, but after a year of working with it at an enterprise level I have changed my tone and feel it can definitely benefit you to learn it no matter what your level.

Let me give you some advantages of Python that make me feel this way:

  •  Easy to quickly write programs and run them without needs for fancy build logic
  • Comes preloaded in Linux and Mac distros, simply load up a terminal and type python to get started with the shell
  • The syntax, or language of the program, is closer to human readability then other languages making it easier to focus on your problem solving
  • Makes it easier to use variables and data structures without complex declarations or methods leading to more code in less time
  • Tons of libraries of prewritten functions that you can bring in with imports to help solve common problems such as working with the operating system or working with stuff over the internet. 20 Python libraries you cant live without
  • Can use to automate simple repetitive tasks to reduce manual efforts and increase your daily efficiency
  • Can use it as a self contained web server to quickly make your own web applications

It is also worth noting one of the main disadvantages of the language:

  • It is an interpreted language, meaning that another program written in another language, typically C, reads your code and makes it do the stuff. This double duty of checking out what you wrote makes it slower then if it was written in that language directly. Fortunately, unless you’re writing something that will be used by millions of people at once or running something on extremely large data this usually isn’t a problem.

Now, how do you use such a miracle language. If your in mac or linux just start writing a py script and run python on it. If you’re on windows you can head over to the Python Release 2.7.13 page and download the Windows MSI.  Upon fininishing installing, you will see a new python folder in your start menu where you can run the IDLE graphical user interface and start writing the code.

Just to get it going, lets start with a “Hello world” program where we will just display the contents hello world to the person that ran your program. If you want a fancy IDE (Integrated development environment) for working with python you can grab the community edition of PyCharm.

To start making your program open a text editor on Mac or Linux and save the file as HelloWorld.py or on Windows open the IDLE gui. Then copy what’s in the screen shot:

HWorld

Hello World app in Windows IDLE

Now to run the program from a Mac or Linux go to the directory where your HelloWorld.py file is in a terminal and type “python HelloWorld.py” and in the IDLE editor just press F5 which will run your script in a dedicated Python shell. Note you can also use this shell to type commands directly into it and test out things.  Either way you ran the program you should now see “Hello World” output to the screen.  Which may not seem like much but this is just an entry point to some really cool things you can do such as automatically skimming for popular posts on reddit, setting up an emailer using Gmail to automate sending stuff to a mailing list, serving full web applications on Amazon web services, build games and game bots, research machine learning with Scikit experiments, pass encrypted messages to your friends in forums, and tons more.

I plan on covering some of these in later posts so please stick around and follow me here or on twitter @comsciu also if you’re interested I have been considering starting a python course on things that have personally helped me on the job, and maybe another course on using python to write Alexa Skills Kits for the Echo device, which if you are unfamiliar is a digital assistant that’s awesome for playing music, setting alarms, or managing your google calender. You can check it out below. If you’re interested in either of these courses please leave a comment on this blog and i’ll start making the material to put up on Udemy for the time being.

Summary:

  1. Discussed the advantages of python
  2. Python usage in Windows, Mac, and Linux
  3. Creating a simple HelloWorld.py script which output text to the console
  4. Talked about other uses of python
  5. Asked you guys if your interested in learning more!?!?

Thanks for making it this far and hope you follow along, i’m passionate on helping you guys if I know there is interest! Have a great day.

~Stefan B, comsci.com~

Leave a Reply