Data Types & Variables
Why do we need to know if a data type is text or a number? Because Python needs to understand if an item is a number to perform calculations with it.
Let’s start with what we will learn together.
We will discuss how to code in Python using Google Colab, a free online platform by Google designed for collaboration.
We will also do our first exercise together. Then, we will talk about who uses Python and the pros and cons of using this programming language.
Now, let’s talk about why we are using Google Colab
It’s simple: Google Colab is free to use on any device. You don’t need to install anything, which makes it convenient for everyone.
Next, let’s discuss how we will learn to code in Python here in Level 1. We will start with a basic exercise using Google Colab to print “Hello World.”
Although we will be using Google Colab to teach Python in this course, you can use any other Python platform you prefer while reading and doing the exercises.
In addition to the exercise, at the end of Level 1, we will have a short quiz to help reinforce what we have learned together.
There are many ways to code with Python for free.
You can download software for Windows, Mac, or Linux.
However, for this course, we will use Google Colab, a free online service from Google that works on desktops, laptops, and even mobile devices.
Google Colab is similar to Gmail in that it is cloud-based.
You can access Google Colab at this website: Google Colab.
The great thing about Google Colab is that everything you need to code is available right there. You don’t need to download anything, which means the code you create in Google Colab will work on any device.
For this Course, there is no need to pay for the Pro version of Google Colab. The free version provides all the tools we need.
To get started with Google Colab, you need a Gmail address, which is free and easy to set up.
Once you’re logged in, you can create new notebooks, which are stored on your Google Drive. Similar to Google Docs or Google Sheets, you can share your notebooks by clicking the share button.
To code, simply type your code next to the play button and click the play button to run it.
You can also add text to explain your code by clicking “+text.” However, we prefer to add comments directly to the code using the hash sign (#).
Comments are in green and are not read by Python when you run the code.
It’s important to add comments to your code so that others can understand it, or so you can understand it yourself if you come back to it later.
Google Colab saves your work automatically in the cloud, so you don’t need to worry about losing your progress.
You can also name your code by clicking on the file name in the top left corner. The extension “ipynb” stands for “Interactive Python Notebook.”
You can save a copy of your notebook or export it to GitHub, where people share code. Google Colab also has autocomplete to help you while coding.
There are several pros to using Google Colab:
However, there are some cons too, such as GPU limitations if you use it extensively, and it’s not secure enough for corporate use since it runs in the cloud.
Despite these limitations, Google Colab is an incredible free tool for learning how to code in Python.
Welcome to our first exercise. For this exercise, follow these three steps:
# This code prints Hello World
print("Hello World")
After completing these steps, we will explain the answer in the next chapter. If you get an error message, don’t worry, we’re just starting.
Google uses Python extensively in its web search systems and even employed Guido van Rossum, the inventor of Python.
Today, Python is mostly associated with AI and data analysis. Many large companies like Goldman Sachs, JP Morgan, Microsoft, Spotify, and Pixar use Python for machine learning and data processing.
Python can be used for many things, which opens up numerous career opportunities. For example, YouTube and Netflix use Python for their platforms.
Python is also used in fields like algorithmic trading, risk management, financial modeling, autonomous vehicles, national security, and supply chain management.
The pros of using Python include its ease of learning, free availability, and a large number of libraries.
It has a huge user base, making it easy to find help and code samples online. Many companies are hiring Python programmers due to its widespread use in AI.
However, Python has some cons. It is slower than compiled languages like C++. In this book, we will teach you how to use tools like NumPy, Pandas, and Polars to make Python faster.
Compiled languages like C++ are pre-assembled and run quickly, while interpreted languages like Python are assembled on-the-fly.
This means you can see the results almost instantly, which makes Python fun to use. However, if you need to build a very fast application, like a video game, a compiled language might be a better choice.
Understanding the difference between compiled and interpreted languages is important because it helps you choose the right tool for the job.
While Python is great for many applications, there are times when a compiled language might be more appropriate.
Why do we need to know if a data type is text or a number? Because Python needs to understand if an item is a number to perform calculations with it.
Once we have a variable of a data type in python that is either an integer or a float, we can perform mathematical operations on it.
Why should we learn to use Python built-in functions? Because they can save us a lot of time when we’re programming.
We already discussed how to use several data types. Now, we’ll talk about another data type called list.