Machine-Learning-Day-0

Getting Started with Python in VS Code

学习之前需要准备啊, 这就是Day-0~

Prerequisites
  • Install Vs Code
  • Install Vs Code Python extension
  • Install Python3
Hello World
  • Start VS Code in a project (workspace) folder
    At a command prompt or terminal, create an empty folder called "hello", navigate into it, and open VS Code (code) in that folder (.) by entering the following commands:
mkdir hello
cd hello
code .
  • Select a Python interpreter
    Python is an interpreted language, and in order to run Python code and get Python IntelliSense, you must tell VS Code which interpreter to use.
    From within VS Code, select a Python 3 interpreter by opening the Command Palette (⇧⌘P), start typing the Python: Select Interpreter command to search, then select the command.
  • Create hello.py
    hello.py with following code:
msg = "Hello World"
print(msg)
  • Run it
    Right-click in the editor and select Run Python File in Terminal
Another Example: Standardplot
  • Import numpy and matplotlib
    Use the Command Palette to run Terminal: Create New Integrated Terminal with following command:
# macOS
sudo python3 -m pip install matplotlib
  • Create standardplot.py
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 20, 100)  # Create a list of evenly-spaced numbers over the range
plt.plot(x, np.sin(x))       # Plot the sine of each x point
plt.show()                   # Display the plot
  • run it.


    Machine-Learning-Day-0_第1张图片
    Figure_1.png
Github Code:

Day-0 Code

你可能感兴趣的:(Machine-Learning-Day-0)