Metode și pachete

Python pentru utilizatorii de MATLAB

Justin Kiggins

Product Manager

Metodele sunt funcții atașate variabilelor

  • Specifice tipului de variabilă
  • Accesate cu un punct
yelling = "WHY ARE YOU YELLING?"
whispering = yelling.lower()
print(whispering)
why are you yelling?
Python pentru utilizatorii de MATLAB

Metoda .format()

n_avocados = 1765
message = "I have {} avocados!".format(n_avocados)

print(message)
I have 1765 avocados!
Python pentru utilizatorii de MATLAB

Pachete Python

Logo NumPy

Logo matplotlib

Logo pandas

Python pentru utilizatorii de MATLAB
import math

math.pi
3.141592653589793
math.log(0.9)
-0.10536051565782628

Importarea unei părți dintr-un pachet:

from math import log
log(0.9)
-0.10536051565782628
Python pentru utilizatorii de MATLAB

Aliasuri pentru pachete

import datetime as dt

birth_date = dt.datetime(1961,8,4)
# Import NumPy package with common alias import numpy as np x = np.ndarray([1, 2, 3])
# Import pandas package with common alias import pandas as pd df = pd.DataFrame()
# Import Matplotlib pyplot module with common alias import matplotlib.pyplot as plt plt.show()
# Import Seaborn package with common alias import seaborn as sns sns.set_theme()
Python pentru utilizatorii de MATLAB

Să explorăm câteva metode și pachete utile

Python pentru utilizatorii de MATLAB

Preparing Video For Download...