Introduction to Python Programming (Beginner’s Guide)
This article was published as a part of the Data Science Blogathon
Today’s blog is all about starting the journey towards python programming. so this blog is dedicated to all those who are from any domain whether they are students, working employees, mechanical engineers who are willing to learn to program, and newbies. Nowadays python is the most widely used programming by tech giants like Google, Netflix, Facebook. Looks interesting right, then let’s get started.
What is Python??
Python is a high-level object-oriented programming language that was created by Guido van Rossum. It is also called general-purpose programming language as it is used in almost every domain we can think of as mentioned below:
- Web Development
- Software Development
- Game Development
- AI & ML
- Data Analytics
This list can go on as we go but why python is so much popular let’s see it in the next topic.
Why Python Programming?
You guys might have a question in mind that, why python? why not another programming language?
So let me explain:
IEEE spectrum list of top programming language 2021. The list of programming languages is based on popularity.
How do we get started?
Now in the era of the digital world, there is a lot of information available on the internet that might confuse us believe me. what we can do is follow the documentation which is a good start point. Once we are familiar with concepts or terminology we can dive deeper into this.
Following are references where we can start our journey:
Official Website: https://www.python.org/
Udemy Course: https://www.udemy.com/course/python-the-complete-python-developer-course/
I hope now you guys are excited to get started right so you might be wondering where we can start coding right so there are a lot of options available in markets. we can use any IDE we are comfortable with but for those who are new to the programming world I am listing some of IDE’s below for python:
1) Visual Studio: https://visualstudio.microsoft.com/
2) PyCharm: https://www.jetbrains.com/pycharm/
3) Spyder: https://www.spyder-ide.org/
4) Atom: https://atom.io/
5) Google Colab: https://research.google.com/colaboratory/
1) NASA (National Aeronautics and Space Agency): One of Nasa’s Shuttle Support Contractors, United Space Alliance developed a Workflow Automation System (WAS) which is fast. Internal Resources Within critical project stated that:
“Python allows us to tackle the complexity of programs like the WAS without getting bogged down in the language”.
Nasa also published a website (https://code.nasa.gov/) where there are 400 open source projects which use python.
2) Netflix: There are various projects in Netflix which use python as follow:
- Central Alert Gateway
- Chaos Gorilla
- Security Monkey
Amongst all projects, Regional failover is the project they have as the system decreases outage time from 45 minutes to 7 minutes with no additional cost.
3) Instagram: Instagram also uses python extensively. They have built a photo-sharing social platform using Django which is a web framework for python. Also, they are able to successfully upgrade their framework without any technical challenges.
Applications of Python Programming:
1) Web Development: Python offers different frameworks for web development like Django, Pyramid, Flask. This framework is known for security, flexibility, scalability.
2) Game Development: PySoy and PyGame are two python libraries that are used for game development
3) Artificial Intelligence and Machine Learning: There is a large number of open-source libraries which can be used while developing AI/ML applications.
4) Desktop GUI: Desktop GUI offers many toolkits and frameworks using which we can build desktop applications.PyQt, PyGtk, PyGUI are some of the GUI frameworks.
How to Become Better Programmer:
The last but most important thing is how you get better at what programming you choose is practice practice practice. Practical knowledge only acquired by playing with things so you will get more exposure to real-world scenarios. Consistency is more important than anything because if you practice it for some days and then you did nothing then when you start again it will be difficult to practice consistently. So I request you guys to learn by doing projects so it will help you understand how things get done and important thing is to have fun at the same time.
Approach to be followed to master Python:
“Beginning is the end and end is the beginning”. I know what you are thinking about. It is basically a famous quote from a web series named “Dark”. Now how it relates to Python programming?
If you researched on google, youtube, or any development communities out there, you will find that people explained how you can master programming in let’s say some “x” number of days and like that.
Well, the reality is like the logo of infinity which we can see above. In the programming realm, there is no such thing as mastery. It’s simply a trial and error process. For example. Yesterday I was writing some code where I was trying to print a value of a variable before declaring it inside a function. There I had seen a new error named “UnboundLocalErrorException“.
So the important thing to keep in mind is that programming is a surprising realm. Throughout your entire career, you will be seeing new errors and exceptions. Just remember the quote – “Practise makes a man perfect”.
Now here is the main part. What approach to follow in order to master Python Programming?
Well here it is:
Step-1: Start with a “Hello World” Program
If you happened to learn some programming languages, then I am sure you are aware of what I am talking about. The “Hello World” program is like a tradition in the developer community. If you want to master any programming language, this should be the very first line of code we should be seeking for.
Simple Hello World Program in Python:
Step-2: Start learning about variables
Now once we have mastered the “Hello World” program in Python, the next step is to master variables in python. Variables are like containers that are used to store values.
Variables in Python:
my_var = 100
As you can see here, we have created a variable named “my_var” to assign a value 100 to the same.
Step-3: Start learning about Data Types and Data Structures
The next outpost is to learn about data types. Here I have seen that there is a lot of confusion between data types and data structures. The important thing to keep in mind here is that data types represent the type of data. For example. in Python, we have something like int, string, float, etc. Those are called data types as they indicate the type of data we are dealing with.
While data structures are responsible for deciding how to store this data in a computer’s memory.
String data type in Python:
my_str = "ABCD"
As you can see here, we have assigned a value “ABCD” to a variable my_str. This is basically a string data type in Python.
Data Structure in Python:
This is known as a dictionary data structure in Python.
Again this is just the tip of the iceberg. There are lots of data types and data structures in Python. To give a basic idea about data structures in Python, here is the complete list:
Step-4: Start learning about conditionals and loops
In any programming language, conditionals and loops are considered one of the backbone.
Python is no exception for that as well. This is one of the most important concepts that we need to master.
if(x < 10): print("x is less than 10") elif(x > 10): print("x is greater than 10") else: print("Do nothing")
As you can see in the above example, we have created what is known as the if-elif-else ladder
for i in "Python": print(i)
The above code is basically an example of for loop in python.
Once you start programming with Python, you will be seeing that if we missed any white spacing in python then python will start giving some errors. This is known as Indentation in python. Python is very strict with indentation. Python is created with a mindset to help everyone become a neat programmer. This indentation scheme in python is introduced in one of python’s early PEP(Python Enhancement Proposal).
Here are some additional resources which might be helpful for you to dive deeper as follow:
Python Projects: https://realpython.com/tutorials/projects/
Coding Challenge: https://www.hackerrank.com/
These are some useful link which helps you get more into python.
I hope guys you like this post and got an idea of what python is all about in brief which will give IP you some guidance so you can start your journey to the programming world. This is just the tip of the iceberg. There are a lot more advanced concepts like generators, decorators, OOP, etc. to master. However, in order to master those concepts, we must master the basics first.
Please share this with your friends and colleagues.
The media shown in this article are not owned by Analytics Vidhya and is used at the Author’s discretion.