A Brief History
Python was released in 1991 by Guido Van Rossum. During team meetings in the early days of Python, the title "Benevolent Dictator for Life" was bestowed upon Van Rossum. This venerable title has since been reserved for only a small group of giants of the open-source software development world.
And in case you were wondering: Yes, the Python programming language was named after Monty Python, the British comedy sketches. Because, with Python, coding is fun!
Python was created with usability, efficiency and simplicity in mind. Python developer Tim Peters expands on this mindset with the "Zen of Python" ...
"Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Readability counts."
What is Python, anyway?
Python is a multipurpose, server-side programming language that is rapidly gaining popularity. It's known for its ease of use, versatility and vast array of libraries. Python is used by Youtube, NASA, Pixar, Netflix and Facebook-- just to name a few. It is one of the top programming languages that developers use, are currently learning, or are requested to know by potential employers.
Companies using Python, Stack Overflow Ranking, jetBrains Ranking, PYPL ranking
Python is known for it's ease of use. The syntax and grammar of Python are specifically designed to be as straightforward, intuitive and concise as possible. It is often recommended as the first programming language to learn for beginners. And, it is especially easy to pick up for developers that have familiarity with other languages.
Python is also known for it's versatility . It has great extensibility and versatility because of its modules. Extensibility is how much a framework can extend to another system and how easy this is to implement. There are many different modules, libraries and packages that can be used with Python. Whatever it may be that you want to build with Python, there is most likely already a built-out foundation for it.
What does it look like to code in Python?
Now that you know all about it, let's see what it's like to actually code with Python. Here's a small astrology program, named Bob, that will ask for a user's birthday, and respond based on that information.
# Let's build an astrology program!
# print a greeting
print('Hello astrologer!')
# ask user for name
print('What is your name? ')
# assign user name to a variable
my_name = input()
The print()
method will print any value passed into it. Here, we print a greeting and ask for a users name. At this point, we can assign a variable to input()
, and whatever the user inputs will be saved as their name.
# app introduces itself
print('Hi ' + my_name + '! My name is Bob.')
print('My birthday is 06/18/2023. That means I am a Gemini!')
# ask user for birthday
print('When is your birthday? (Please input in this format: 00/00/0000) ')
# assign user birthday to variable
my_birthday = input()
Now, we have our users birthdate information. But, anything passed into input()
will automatically be stored as a string. To use this data in the form of a number, we'll have to convert the datatype.
We can use the int()
method to convert a string to an integer. We also only need certain positions from the input in order to determine the user's birthday and month. We can use bracket notation to access particular values of the input, based on their indexes.
# create month and day variables
my_month = int(my_birthday[0:2])
my_day = int(my_birthday[3:5])
Now we have stored the users birthday information data as numbers, and can use it as such.
# determine user's sign based on month and day variables
if my_month == 1 and my_day < 20 or my_month == 12 and my_day > 21:
my_sign = 'Capricorn'
elif my_month == 1 and my_day > 19 or my_month == 2 and my_day < 19:
my_sign = 'Aquarius'
elif my_month == 2 and my_day > 18 or my_month == 3 and my_day < 21:
my_sign = 'Pisces'
elif my_month == 3 and my_day > 22 or my_month == 4 and my_day < 20:
my_sign = 'Aries'
elif my_month == 4 and my_day > 21 or my_month == 5 and my_day < 21:
my_sign = 'Taurus'
elif my_month == 5 and my_day > 22 or my_month == 6 and my_day < 21:
my_sign = 'Gemini'
elif my_month == 6 and my_day > 22 or my_month == 7 and my_day < 23:
my_sign = 'Cancer'
elif my_month == 7 and my_day > 24 or my_month == 8 and my_day < 23:
my_sign = 'Leo'
elif my_month == 8 and my_day > 24 or my_month == 9 and my_day < 23:
my_sign = 'Virgo'
elif my_month == 9 and my_day > 24 or my_month == 10 and my_day < 23:
my_sign = 'Libra'
elif my_month == 10 and my_day > 24 or my_month == 11 and my_day < 22:
my_sign = 'Scorpio'
elif my_month == 11 and my_day > 23 or my_month == 12 and my_day < 22:
my_sign = 'Sagittarius'
These statements are known as conditions. Depending on the conditions of the users birthdate data, we can assign a variable to store the appropriate sign.
# respond with user sign
print('You are a ' + my_sign + '! I knew you were crazy.')
print('Wanna know your moon and rising?')
answer = input()
if answer == 'yes':
print('Please enter your birth time and location!')
else:
print('Typical ' + my_sign + '. Whatever!')
There you have it! In just a few moments, we've created a program that takes in data about a user and responds based on that data.
How does Python stack up to other languages?
Pros
Usability: Python is easy to learn and use, and is quite powerful considering.
Extensibility: Python has many different libraries to support different kinds of applications.
Community: Python has a large community with many resources available online. This may be especially important for beginners.
Scalability: Python is can be used for small, simple apps or it can be used for large projects by big companies.
Great for backend: Although Python is a general language, it is particularly useful for backend. Data science, automation, machine learning and AI are all areas of strength for Python.
Pros of Python,
More Pros of Python
So far, we've only looked at the advantages of using Python. As it is a popular language, it's no surprise there are so many.
But, just like any programming tool, there are upsides and downsides. In the case of Python, there are aspects of it that may not be ideal for a given developer, depending on their specific goals.
Cons
Possibly too general: while in many ways this is an advantage of Python, it can also be a disadvantage. Sure, you can build pretty much anything with Python. But just because you can, doesn't mean you should. In particular, Python is weaker than other languages when it comes to mobile apps and 3D rendering. If your goal is build a game, mobile app, or website, Python may not be the best choice. Other languages are more specialist than Python, and may be a better choice for one specific project.
Slowness: Python is dynamically typed, and as such, it is read slower. It has a "global interpreter lock", meaning that only one thread of code can by read by the interpreter at a time. While this difference in speed may not be particularly dramatic compared to other languages, it is something to consider.
Conclusion
In conclusion, there are many advantages to Python. It is versatile, intuitive and in high demand. If you are planning to work in data science, automation or machine learning, it may be especially great to use. Otherwise, if you are planning to work in an area that would be better suited by another specialized programming language, you can always focus on one language now and learn Python later on. For a software developer, Python is a great skill to have in your repertoire.
Ready to get started? Here's a few simple exercises to help you dip your toes into Python.
Top comments (0)