Learning Python - Tutorial #1
Introduction
This is a brief first tutorial for learning Python using Google's Colaboratory.
It will cover loading the package, using a function within the package, and assigning a variable. We will use the numpy package as an example.
Loading the numpy package
numpy is a useful package for data analytics work.
In the code below, numpy is imported and abbreviated as np.
It is a normal convention to load them upfront at the start of the script.
import numpy as np
Exploring the mean function within numpy
Let's check out the mean function in numpy. We can do so by typing np.m in the console below. You can see mean among the list of available functions in numpy.
Let's calculate the mean of an array of 1,2,3 using the code below.
np.mean([1,2,3])
Assigning variable
Let's name the variable that comprised 1,2,3 as list_of_nums. Notice the square bracket encapsulating the numbers separated by commas? This is how an array of values can be created.
list_of_nums = [1,2,3]
Problem to solve
To create a new variable called my_mean and assigned the mean of list_of_nums to it.
This is the solution which used what we learn in this tutorial.
my_mean = np.mean(list_of_nums)
The original file is located at: https://colab.research.google.com/drive/1zgTvee6cupneaKrx0G_0lExikzkcHsRV
Leave Learning Python - Tutorial #1 to:
Read more #programming posts
Best Posts From keeideas
We have not curated any of keeideas's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From keeideas
- The striving - non-striving conundrum in sport and the likes
- ESB 2025 Debate Summary: Artificial Intelligence Will Make Obsolete the Use of Physical Modelling in Biomechanics
- Body composition app
- Impetus
- Pose estimation using Javascript within a HTML through TensorFlow.js
- Personal clout, AI, and Education
- Tech & AI skills every sport Science, sport Management, and PE student should learn
- When two AIs are better than one: My multi-agentic learning hack
- Offline version of the translator app
- English to Chinese Speech Translator using Python Flask