Date archives "October 2016"

Journey to Python – Introduction

Learning a new language or program can sometimes be a little intimidating. Foreign syntax, operators, and functions can be overwhelming and seem like a lot to take in. I’ve heard many great things about Python from my fellow coding friends. They explained to me that it would be a relatively easy and straightforward language to pick up, especially with my prior CPSC 210 Java knowledge. I find programming very interesting as it gives developers full reign and freedom. I like to compare a programmer and a language to an artist and a paintbrush. The possibilities of what one can do is only limited to his/her willingness to learn and the ability to express ideas creatively.

Because I have minimal Python knowledge, I will be learning the basics from multiple sources such as: LearnPython.org, YouTube, etc.

The first thing that came to my attention is that you do not need to declare variables and their type before using them. This is a new concept to me because in my past programming experience, objects had a variable name and declared type prior to their use.

Example in Java: String s1 = new String(“hello”)

Example in Python: s1 = “hello”

Also in Python, you are able to assign more than one variable at the same time using commas. However, I imagine this could get quite messy with more variables.

Example in Python: a, b = 3, 4 in which a is 3 and b is 4.

Some things to keep in mind: An exercise on LearnPython.org used the function isinstance(object, classinfo)  https://docs.python.org/2/library/functions.html#isinstance

They also used the symbol % which is actually a string formatting operator but can also be use as modulus/remainder. Same as Math 220!       https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting

%s – String (or any object with a string representation, like numbers)

%d – Integers

%f – Floating point numbers

You can also multiply strings with a number. Example: “hi” * 5 = “hihihihihi”

My first impressions: After working through simple introduction modules, it seems that Python and Java have many similarities. However, this is just the very beginning of Python for me and I am excited to see how the two differ as I get more in depth.