+ INFORMATION

Share on social networks!

How to install Python quickly

A few weeks ago, we told you 10 reasons why you should learn to program in Python. But if you are still not convinced, in this article, we will talk about how to start programming with Python and the best way to do it.

Before starting:

1. Programming in Python is fun.

Python code is easier to write and understand than other comparable programming languages. This is due to its easy syntax. Even if you've never programmed before, you'll be able to understand what the code does just by reading it normally.

2. The syntax is not too strict

In Python, it is not necessary to specify the data type of a variable. In addition, the semicolon is not necessary after each statement (something that more than one will appreciate 😉)

Python forces you to follow best practices (like proper indentation). This may seem like torture at first, but it can make programming much easier for beginners.

3. Expressiveness of language

Python allows you to write programs with extensive functionality in just a few lines of code. It's amazing what you can do with Python once you master the fundamentals.

4. A great community and support

Python is supported by a large community. There are several active online forums that can help you if you get stuck.

Here are some examples:

Once we have everything clearer, the next question is:

How to install the program?

At this point I must refer you to my previous article, where we talked about operating systems to start working with Python.

Once you have chosen yours, we will explain the installation process for each of them.

We want to show you how to install and use Python on your operating system in the easiest way possible. This way, you can quickly get started in programming.

Python Installation Guide on MacOSX

  1. Open the page python download in your browser and select Download Python 3.10.7 (you may see a different version, always select the latest one).
  2. When the download is complete, you must open the .dmg file and follow the installation instructions.
  • A good editor can be a great help for Python development. We recommend Sublime Text (download Sublime Text 3) either Visual Studio Code. Both editors can be used for free. To simplify, we are going to select the Sublime Text editor in this guide.
  • The installation works like any other program.
  • Open Sublime Text and select File > New File (shortcut: Cmd+N). Then save (Cmd+S or File > Save) the file with the .py extension (for example, Helloworld.py).
  • Write your code and save it. You can use this code to test:

print("Hello, world!")

This simple program writes "Hello World" at the command line. Select Tools > Build (Cmd + B). You will see “Hello World” in the Sublime Text console. Congratulations, you've just run your first Python program!

Installation instructions for Windows

  1. Open the page python download in your browser and select Download Python 3.10.7 (you may see a different version, always select the latest one).
  2. When the download is complete, double-click the file to open it.
  3. Along with Python, a small IDE called IDLE will be installed.
  4. Open IDLE and write the following code.
  5. print("Hello, world!")
  6. To create a new file in IDLE, select File > New Window (shortcut: Ctrl+N).
  7. Write your Python code (you can use the code below for now) and save it (shortcut: Ctrl+S) with the file extension .py (e.g. hello.py)

print("Hello, world!")

  • Choose Run > Run Module (Shortcut: F5) to see the output of your program. Congratulations, you just ran your first Python program.

At this point, it's time to move on to the next step.

Your first Python program

The classic way to start programming is always the “Hello World” example. A "Hello World" program simply produces the text "Hello World" as we have seen in the previous section.

Therefore, let's choose another example:

  1. # Sum of two numbers
  2. number1 = 2
  3. number2 = 4
  4. sum = number1+number2
  5. print(sum)

How does this Python program work?

Line 1: # Sum of two numbers

All lines starting with # in Python programming are comments.

Comments are used in programming to explain the purpose of the code. This helps other programmers understand the intent of the code. Comments are completely ignored by compilers and interpreters.

Line 2: number1 = 2

Here, number1 is a variable. You can store a value in a variable. Therefore, the number 2 is stored in this variable.

Line 3: number2 = 4

Likewise, the number 4 is stored in the variable number2.

Line 4: sum = number1+ number2

The variables number1 and number2 are added with the "+" operator. The result of the addition is stored in another variable, sum.

Line 5: print(sum)

The print() function outputs to the screen. In our case, the number 6 is displayed on your monitor.

It is important to remember something:

To represent a statement in Python, a new line is used. The use of semicolons (cf. C/C++, PHP) is optional and it is recommended to omit this one. Braces are used to represent a block.

Yes, I know… it's something very simple. How do I keep moving forward?

¡Discover much more complex cases in our Master in Advanced Programming in Python for Big Data, Hacking and Machine Learning!

Subscribe to our newsletter to stay up to date with all the news

EIP International Business School informs you that the data in this form will be processed by Mainjobs Internacional Educativa y Tecnológica, SA as the person responsible for this website. The purpose of collecting and processing personal data is to respond to the query made as well as to send information about the services of the data controller. Legitimation is the consent of the interested party.
You can exercise your rights of access, rectification, limitation and deletion of data in compliance@grupomainjobs.com as well as the right to file a claim with the supervisory authority. You can consult additional and detailed information on Data Protection in the Privacy Policy that you will find in our Web page
marter-in-python

Leave a comment