Question
%matplotlib inline import numpy as np import matplotlib.pyplot as plt a = 1 + 5 b = 2 c = a + b print(a /
%matplotlib inline import numpy as np import matplotlib.pyplot as plt
a = 1 + 5 b = 2 c = a + b print(a / b) print(a // b) print(a - b) print(a * b) print(a**b)
a = np.array([[3, 1], [1, 3]]) b = np.array([[3], [5]]) print(a * b) print(np.dot(a, b)) print(np.dot(b.T, a)) c = a**(-1.0) print(c * a)
t = np.arange(10) g = np.sin(t) h = np.cos(t) plt.figure() plt.plot(t, g, 'k', t, h, 'r');
t = np.arange(0, 9.1, 0.1) g = np.sin(t) h = np.cos(t) plt.figure() plt.plot(t, g, 'ok', t, h, '+r');
t = np.linspace(0, 10, 20) print(t) t = np.logspace(0.001, 10, 9) print(t) t = np.logspace(-3, 1, 9) print(t) y = np.exp(-t)
plt.figure() plt.plot(t, y, 'ok') plt.figure() plt.semilogy(t, y, 'ok')
LW 1 Lab 0 - Python and Jupyter notebook introduction In [ ]: %matplotlib inline import numpy as np import matplotlib.pyplot as plt 1.1 1 Warm-up Exercises Try the following commands on your jupyter notebook or python editor and see what output they produce. In [ ]: a = 1 + 5 b = 2 C = a + b print(a / b) print(a // b) print(a - b) print(a * b) print(a**b) In [ ]: a = np.array([[3, 1], [1, 3]]) b = np.array([[3], [5]]) print(a * b) print(np. dot(a, b)) print(np. dot (b.T, a)) c = a**(-1.0) print(c * a) In [ ]: t = np.arange(10) 8 = np. sin(t) h = np.cos(t) plt.figure() plt.plot(t, g, 'k', t, h, 'r'); LW t = np.arange(0, 9.1, 0.1) 1 8 = np.sin(t) h = np. cos(t) plt.figure() plt.plot(t, g, 'ok', t, h, '+r'); In [ ]: t = np. linspace(0, 10, 20) print(t) t = np.logspace(0.001, 10, 9) print(t) t = np.logspace(-3, 1, 9) print(t) y = np. exp(-t) plt.figure() plt.plot(t, y, 'ok') plt.figure() plt.semilogy (t, y, 'ok')Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started