Installing Packages, Variables, and Lists
conda install package in the terminal or go to the Anaconda Navigator and install them from thereTip
.ipynb fileCmmd + Shift + P and type “Create: New Jupyter Notebook”base)import commandnumpy package, we use import numpy as npnpnp.function()np? Because it is a common alias for numpy. You can use any alias you want, but it is good practice to use common ones as they make your code more readablematplotlib package as wellmatplotlib package, we use import matplotlib.pyplot as pltpyplot module instead of the entire matplotlib package allows us to access the plotting functions we need without importing unnecessary components, which can be more efficientLet’s see how this work in practice!
03-variables-lists.ipynb notebook in VS Code (or create your own)Shift + Enter or click on the “Run” button+ Code in the toolbartype() functionprint() function to display the value of a variable=3 in the variable x, we use x = 3x by typing x_3
3.5
+, Subtraction: -, Multiplication: *, Division: /, Exponentiation: **print("QTM" + 151)[],# List of numbers
list_numbers = [1,2,3,4,5]
list_numbers_sqr = [1,4,9,16,25]
print(list_numbers)
print(type(list_numbers))[1, 2, 3, 4, 5]
<class 'list'>
# List with strings
# Example: Suppose you ask 5 people about their favorite colour.
# The results:
list_colours = ["red","yellow","yellow", "green","red"]
print(list_colours)
# List with mixed types
list_mixed = ["red",1,"yellow",4,5, 3.5]
# Lists can be nested too
another_list = [list_mixed, 3, 'h']['red', 'yellow', 'yellow', 'green', 'red']
[] to access elements in a listlist[0]matplotlib package to create plotshist() function creates a histogramhist() functionshow() functionscatter() functionscatter() function takes two lists as arguments
xlabel() and ylabel() functions to label the axesconda installimport commandmatplotlib packagenumpyMy name is Danilo and I am majoring in QSS
The Godfather III