Metodi e pacchetti

Python per utenti MATLAB

Justin Kiggins

Product Manager

I metodi sono funzioni legate alle variabili

  • Specifici per il tipo di variabile
  • Si accede con un punto
yelling = "WHY ARE YOU YELLING?"
whispering = yelling.lower()
print(whispering)
why are you yelling?
Python per utenti MATLAB

Il metodo .format()

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

print(message)
I have 1765 avocados!
Python per utenti MATLAB

Pacchetti Python

Logo NumPy

logo matplotlib

logo pandas

Python per utenti MATLAB
import math

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

Importare parte di un pacchetto:

from math import log
log(0.9)
-0.10536051565782628
Python per utenti MATLAB

Alias dei pacchetti

import datetime as dt

birth_date = dt.datetime(1961,8,4)
# Importa il pacchetto NumPy con alias comune import numpy as np x = np.ndarray([1, 2, 3])
# Importa il pacchetto pandas con alias comune import pandas as pd df = pd.DataFrame()
# Importa il modulo pyplot di Matplotlib con alias comune import matplotlib.pyplot as plt plt.show()
# Importa il pacchetto Seaborn con alias comune import seaborn as sns sns.set()
Python per utenti MATLAB

Scopriamo metodi e pacchetti utili

Python per utenti MATLAB

Preparing Video For Download...