Week4_01_ Introdcution to Google Colab
Week4_01_ Introdcution to Google Colab
Google Colab
Lab 0
What is Google Colab?
It is used for:
• web development (server-side),
• software development,
• mathematics,
• system scripting.
What is Python?
Output
You can delete a code cell by clicking on the cell then choose delete.
Now add a code and let’s start writing our program.
To see the results, you need to click on the triangle on the right side of each
single code cell.
Output
To see the results of all the cells at the same time, you need to use Run All
instruction .
Exercise
• Python was designed for readability, and has some similarities to the English
language with influence from mathematics.
Consistency:
It’s important to be consistent with indentation throughout the
codebase. All statements within the same block must be indented at the
same level.
Spaces or Tabs:
Mixing tabs and spaces for indentation is discouraged as it can lead to
syntax errors.However, it’s recommended to use spaces for better
consistency, as tabs may be interpreted differently in different
environments.
Example of wrong indentation
Python Variables
Creating Variables
• Python has no command for declaring a variable.
• A variable is created the moment you first assign a value
to it.
Example of declaring variable
Y is: Hi
X is : 5
Can we use the same variable name more than one time ?
Output
Is the variable name case-sensitive? Yes
Output
Printing multiple variables
Output
Assigning one Value to Multiple Variables
Output
Setting the Data Type
You can get the data type of a variable with the type() function.
Output
Python Operators
Comment
Comment
Let’s try to practice some math in python!
Exercise
Let’s print your age by subtracting your birthdate year from 2024!