Why you should learn how to program in Python?

Why you should learn how to program in Python?

Introduction

In this article I pretend to talk about my own experiences and impressions of working with Python, I would like to explain how is the felling of developing with this technology, the necessary time to learn it, the troubles that you may have with the language during the learning process, the things that it can aggregate to your set of skills and also about the market.

First of all, what is Python?

Python is a interpreted programming language created by the computer scientist Guido van Rossum in 1991. Currently it is in the version 3.7.2. You can find more information about the language in the official website.

What can I do with Python?

Python is a general purpose programming language, so basically it's possible to do everything with it, but I can mention some interesting stuff that you as a computer scientist, software engineer or even a high school student can use it for:

  • Solve math and physics problems - Sometimes in our daily tasks we face the problem of dealing with repetitive and/or difficult math problems, so instead of solving this repetitive tasks time after time, you can simply create a python script that can solve these problems for you. Let's say for example that you need to calculate the magnetic field of a solenoid. You just need to apply the formula right? But now imagine that you need to calculate 100 different values for the same formula, it is not going to be interesting to do the same task over and over again right? So what can you do to make your life easier? Create a script that can read the values and return the results to you! And with Python you can to it in a simple and fast way, and as The Zen of Python says:
Simple is better than complex
"""
Definition: The Magnetic Field of a Solenoid is the number of spirals (n)
divided by the length of the solenoid (l), then this result is multiplied
by the constant of magnetic permeability (u) and finally multiplied by
the electric current (i).
"""

# Function to solve the physics problem
def magnetic_field_of_solenoid(n, u, i, l):return (n/l)*u*i

# Lists with the values that we will pass to the funtion
n = [1,2,3,4,5,6,7,8,9,10]
u = [7,5,8,9,8,9,4,5,4,4]
i = [10,9,8,7,6,5,4,3,2,1]
l = [4,5,6,7,8,9,10,11,12,13]
    
# Loop to calculate and show the result of each exercise 
for index in range(len(n)):
    result = magnetic_field_of_solenoid(n[index], u[index], i[index], l[index])
    print(result)
  • Work with data from documents- Sometimes in our daily activities we can face the boring situation of reading texts or datasheets to get information and put in somewhere else, with Python you can open these kind of files, copy the values into arrays, dictionaries or even custom classes, do the necessary work with the values and save it somewhere else like a database, a datasheet or simply show it on your screen. To give you an example let's say that you have a basic csv file with the information of some persons (in this example it will be the name and birthday), and for some reason you need to separate this csv file in another two, one with people under eighteen and other with people over eighteen, and you must also save these new files with the age of each person. Using Python you can do this task in a really simple and fast way, and the work that could take hours doing by hand can take some minutes for the machine.
"""
Definition: This script is responsible for reading the name and the birthday
of a person, then getting the age and saving all these informations into another
two files 'under_eighteen.csv' and 'over_eighteen.csv'.
How to use: Put a csv file with the name 'persons.csv' inside of the same folder
of this script and execute it.
"""
import csv
from datetime import datetime

# The desired way to format dates
date_format = '%d/%m/%y'

# Storage info about each person
class Person():def __init__(self, name, birthday):
        self.name = name
        self.birthday = datetime.strptime(birthday, date_format) 

    def get_age(self):return (datetime.now() - self.birthday).days // (365.25) 

    def to_write(self):return [self.name, self.birthday.strftime(date_format), self.get_age()]

# Function to write the csv files
def write_file(file, persons):with open(file, 'a', newline='') as file:
    writer = csv.writer(file)
    for person in persons:
        writer.writerow(person.to_write())

# Lists of differente ages of persons
over_eighteen = []
under_eighteen = []

# Read a csv and get the info and storage into the lists
with open('persons.csv', 'r') as file:
    data = csv.reader(file, delimiter=',', quotechar='|')
    for info in data:
        person = Person(info[0], info[1])        
        if(person.get_age() >= 18.0):
            over_eighteen.append(person)
        else:
            under_eighteen.append(person)

# Write the files with the processed values
write_file('over_eighteen.csv', over_eighteen)
write_file('under_eighteen.csv', under_eighteen)

Many other examples you can find with a simple search on google.

Now that I know the reason for learning Python, how can I learn it?

There's a lot of different ways of learning Python, if you are a programmer you can simply read the official documentation and probably search on some websites like stackoverflow and solve all you problems. If you are not a programmer, or you are just a beginner, or even if you want to have a course to learn it, and get a diploma, I would recommend you to search for some courses in your city or even on the internet. There's a really good course offered by the University of Michigan on Coursera that I really recommend. It's called Python for Everybody (Getting started with Python).

How many time do I need to learn Python?

Probably in two or three weeks you can already start solving some problems even if you do not have any experience with another programming language. But to start using the language with a good "flow" I can say that it's going to take around two or three months depending of how much effort you do to learn it. From six months to a year you are probably able to solve some regular tasks with Python without major problems. But of course, it depends of how much time you expend learning the language.

What kind of problems can I find in my journey?

The most common problem (specially for beginners or non programmers) is that you don't really now how to use the language to solve your problems, sometimes you can just fell that you are learning the language and it's cool, but it's not useful at all, to avoid this I really recommend that from the first beginning you should think about problems that you really want to solve, but please do not imagine to solve extremely difficult problems from the very beginning, in this way you can avoid to get frustrated and give up. So these are some problems that I can list for you as a beginner:

  • Physics and Mathematics defined formulas
  • Text searching (e.g.: Remove from the text the phrases that contains one specif word, or list of words)
  • Automate the organization of datasheets (as in the example that I gave you)
  • Automate the filling of documents. (e.g.: you can create a document in word, libre office, html, latex or something like this, than you can use a Python script where you just need to put the values and the script goes filling the values in the document for you. You could for example create a chemistry template with the following fields: group members, date, place, materials used, chemicals used, steps, expected results and real results. You just need to create the template once, then all you need to do is to fill it using the Python script, and wait for the final document)

How is the market for Python?

Recently Python is being used in a lot of applications specially for Artificial Intelligence, Data Science, Machine Learning, Back-end development and scripts, is also being used in lectures from universities from the entire world. You can find a lot of jobs for Python (you just need to do a small search on LinkedIn, stackoverflow jobs, freelancer, or even on Google to see it). There's also a lot of recruiters searching for developers with knowledge in Python, specially for back-end development with Django or Flask, so in some cases you don't even need to search for a job, they are searching for you! Of course it depends a little from your location, but at least here in Germany and Europe in general, there's a lot of recruiters searching for Python developers, is impressive the amount of purposes that I receive every week. Some years ago, I was never expecting to receive a lot of proposals of work without going to search for it.

How is the Python community?

Python has a huge community on the internet, and has also a lot of open source projects where any person with knowledge in Python can help to develop. You can find a lot of these open source projects in Github, some examples of open source projects are.: Tensor Flow Models, Flask, Django and Face Recognition.

So, what is the conclusion?

Python is like a hammer, is a powerful tool if used wisely, it can be used by any person that give at least a little bit of effort to learn how to use it, can be used by computer scientists, owners of companies, managers, high schools students, scientists and other people in their very own life and scope. Maybe Python is not the solution to solve all you problems, but can at least help you with some of them, specially the repetitive ones. The market for Python is really good at the moment, and I see for the future a increase of demand for professionals that knows how to program in this language, huge companies like Google are also looking for Python developers. Python can open a lot of opportunities for you, and I can say it by own experience, one year ago I was working as a intern in a company in Brazil, and I basically just get that opportunity because I knew the basics of Python, then after 5 months in that company learning more and more about Python and Django I applied for a job here in Germany, and once more my experience with Python helped me to achieve my goal. If you have some similar experiences, or have something relevant to aggregate or to correct in this article, please fell free to comment or contact me on LinkedIn or by email on [email protected].

要查看或添加评论,请登录

社区洞察

其他会员也浏览了