Let's start at the beginning: what is Python and why should you learn it?
Python is one of the world's most popular programming languages. It supports many extremely influential apps and websites, including Instagram, Google, Spotify and Netflix. Python is also widely used in data science and machine learning, making it a very "future-proof" language and one that is likely to remain in demand for a long time.
Python has a huge number of extremely influential apps. and websites, including Instagram, Google, Spotify and Netflix.
Despite its obvious strength and flexibility, Python is also one of the most beginner-friendly programming languages you are likely to encounter. Python serves as a fantastic "gateway drug" in the world of coding, offering a soft introduction to higher-level concepts such as object-oriented programming.
Python is also one of the most beginner-friendly programming languages.  The development of Python started in the eighties, under the guidance of Guido van Rossum of Centrum Wiskunde & Informatica in the Netherlands. This was Guido's brainchild, and he even called himself the & # 39; benevolent dictator for life & # 39; (BDFL) of the language, although he would retire from this role in 2018 and transfer responsibility to the Python Steering Council.
Read also: How to become a data analyst and prepare for the future of algorithms
What is Python in programming terms? Python has been conceived as an alternative to the ABC language. It is an interpreted, dynamically typed, garbage-collected language that supports countless paradigms (object-oriented, procedural, functional).
If you're just starting out, don't worry about this. Just know that Python is relatively easy to learn, but also highly sought after and very powerful. Let's take a look at how to get started with it and how to build your first, very simple app.
Getting Started with Python
First of all you need to download some software to use to start programming in Python.
Using a desktop computer means two things:
- a Python interpreter
- a Python IDE
What is a Python interpreter? This is the software that reads the Python code and runs it. Installing an interpreter is like learning a foreign language in your computer.
The IDE has become the "Integrated Development Environment". This is the program you will use to actually type in your Python code. You can save and open files this way, and all on the interpreter when you want to run it. This is your interface for Python development.
When installing an interpreter, you must decide whether to choose Python 2 or Python 3. Each version has pros and cons, but Python 2 is no longer officially supported, making Python 3 the future-proof choice.
(If you were wondering "what is Python not so good for" then one answer is that it is fragmented this way, which can cause a bit of confusion when starting!)  Download the latest Python interpreter here :
Note that you may already have a Python interpreter installed, especially if you are using macOS or Linux.
When it comes to the IDE, there are some good options to choose from. Some of these are free, others cost money, but offer advanced features. Some good options are:
PyCharm is free and is one of the most popular options for Python development. It is the tool that I recommend for most users. That said, it can be a bit complicated to set up, so follow the official documentation here.
It's easier on mobile because the IDE and the interpreter are built into one app. This is a great way for beginners to get started.
To start coding on mobile, you will find a single app and download it. Two good examples for learning the ropes are:
Other versions are available with a range of payment models. However, both are good choices for getting started for free.
Once you have installed one of these things, you are ready to write your first Python program!
Python 3: Hello World
It is tradition to learn every new programming language, starting with writing a piece of code that simply writes "Hello World" on the screen. To do this, use the following code:Print ("Hello World")
Now press "Play" and you should see the text appear on the screen.
Side Note: If you were using Python 2, you wouldn't need the brackets.
Let's go quickly to the next lesson: what is a variable in Python?
A variable is like a container that can be used to display a number or piece of text. We define this in the code by simply writing a word and then giving it a value.
For example, you could say:MyVariable = "Hi there!" Print (MyVariable)
You see the message & # 39; Hello there! & # 39; appear on the screen. Note that you don't need the quotes to print a variable, quotes are interpreted literally.
A group of letters like this is known in the programming as a & # 39; string & # 39 ;. This is one type of variable, but there are many more. Another type of variable is an integer. This is a variable that represents an integer.
So we can also say:MyVariable = 3 Print (MyVariable)
What the number 3 would print on the screen!
For some other languages, you would have to specifically specify the type of variable you wanted to use (String MyVariable = "Hello!"), But in Python, the interpreter comes up with that from context. Part of the reason this is possible is that Python uses a smaller number of variable types compared to Java, for example. For example, there are no "Booleans" in Python.
While we don't have to deal with other data types at this point, you will eventually come across the following variables in Python programming:
- ] Floats
Data manipulation in Python
Why would you ever be a variable? Because it makes your code dynamic . It means that you can change the behavior of your program depending on the user's action and various other factors.
Try running this code and see what happens:MyVariable1 = 2 MyVariable2 = 20 Print (MyVariable1 * MyVariable2)
Here's a clue: in computer talk, the symbol * is for multiplication.
You can also combine strings in interesting ways:FirstName = "Bill" LastName = "Gates" FullName = FirstName + "" + LastName print (FullName)
Your first Python 3 app!
So now we have answered the question "what is Python" and we have written a base code.
What about making something that a person could use and have fun with?
Also read: Kotlin vs Java for Android: main differences
To do this, we need to interact the user with the program. That means we have to handle imports.
Try this:username = input ("Please enter your name:") Print ("Hello" + username)
You can probably find out what's going on here! When using the "input" command, Python will prompt the user for the text in parentheses and then wait for the answer. That string is then referred to as username .
Note: Python 2 uses raw _ input instead of input .
Now we have input, the ability to talk to the user and even some basic math. Shall we put this together in a nice little app? This will tell you how long you have until you are 100 years old!UserAge = input ("How old are you?") YearsTo100 = 100 - int (UserAge) print ("In", YearsTo100, "year, you will be a hundred !!") print ("That is", int (UserAge) * 360, "days! Or", (int (UserAge) * 360) * 24, "hours.")
There is one last trick I want to share with you before we go: using conditional instructions.
A conditional instruction is an assignment that is executed only under certain conditions. This usually means checking the value of a variable first.
To use a conditional statement in Python, use the "If" statement followed by an indent.
For example:UserName = input ("Please enter your name:") print ("Hello" + username) as username == "Adam": print ("Admin mode enabled") print ("What do you want me to do now?")
In this program, the indented code is only executed if the username is Adam. Note that when we check a value instead of assigning one, we use two = signs instead of one.
Here then the user will be asked what he wants to do next, whoever they are – but only I get the admin status. Or other people called Adam.
We are just scratching what Python can do
With these basic commands and lessons you can actually do a lot. You could create a quiz, a calculator, a simple database and more! To really harness the full power of Python, you need to understand concepts such as functions, modules and more. To that end, we recommend checking out our guide to the best online Python courses.
That said, if you're a true beginner and looking for a great course that you can easily get started with, we highly recommend Encoding with Python: Training for aspiring developers that will set you back for just $ 49.99, which is an absolute bargain as the course is estimated to be about $ 700.
$ 49 .99
Coding with Python: Training for Aspiring Developers Bundle
Save  $ 641 .01Encoding with Python: Training for Aspiring Developer Bundle Buy Now
Save  $ 641 .01 $ 49 19659092] .99