
Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Prepara i tuoi esami
Studia grazie alle numerose risorse presenti su Docsity
Prepara i tuoi esami con i documenti condivisi da studenti come te su Docsity
Trova i documenti specifici per gli esami della tua università
Preparati con lezioni e prove svolte basate sui programmi universitari!
Rispondi a reali domande d’esame e scopri la tua preparazione
Riassumi i tuoi documenti, fagli domande, convertili in quiz e mappe concettuali
Studia con prove svolte, tesine e consigli utili
Togliti ogni dubbio leggendo le risposte alle domande fatte da altri studenti come te
Esplora i documenti più scaricati per gli argomenti di studio più popolari
Ottieni i punti per scaricare
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
All the main python functions for the computer science exam in Bocconi
Tipologia: Schemi e mappe concettuali
1 / 1
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!

abs abs(number) built in it find the absolute value of a number dir dir(value) built in it returns a list of names with the attributes of the given object dir() returns the list of all the object names in memory help help(value) built in it shows information about a function, a data item, or a form import import(function_name) built in^ it imports a function input input(value) built in^ it asks the user to enter some data^ the data returns as a string pow pow(value, exponent) built in it returns "value" to the power of "exponent" print print(value) built in it shows the value inserted range range (start, stop [, step]) built in it returns an object that produces a sequence of integers from start (included) to stop (excluded) by increments of step only works with integers! if start is omitted, the default value is 0; if step is a negative number there's a decrement open open('filepath',['mode']) built in: file it access a file where "filepath" specifies the name of the file, including its complete path in the disk and "mode" specifies how the file should be opened (in reading or writing mode) if "mode" is omitted the file is opened as read only dict dict() built in: S&D it creates an empty dictionary if we use an iterable object as argument it can also be non-empty len len(sequence) built in: S&D it returns the number of elements of the sequence or dictionary list list(iterable) built in: S&D it converts an iterable object into a list ex. >>>list(range(6)) is equal to [0, 1, 2, 3, 4, 5] max max(sequence) built in: S&D it finds the max among single parameters, list, tuple or strings it works also with strings where 'a' is the min value and 'z' is the max value (also 'pen'>'dog') min min(sequence) built in: S&D it finds the min among single parameters, list, tuple or strings it works also with strings where 'a' is the min value and 'z' is the max value (also 'pen'>'dog') sorted sorted(sequence) built in: S&D it returns a new list with the elements sorted in ascending order it works also with strings where 'a' is the min value and 'z' is the max value (also 'pen'>'dog') sum sum(sequence) built in: S&D it sums the numbers of the sequence if you have numbers as strings it doesn't work tuple tuple(iterable) built in: S&D it converts an iterable object into a tuple float float(value) built in: type it converts to a floating point number format format(value, 'format') built in: type it formats a value according to specific parameters int int(value) built in: type^ it converts to a integer str str(value) built in: type it converts to a string type type(value) built in: type it finds the type of data of the value inserted math.ceil math.ceil(number) math it rounds the number up 4.7 becomes 5 math.floor math.floor(number) math it rounds the number down 4.7 becomes 4 math.log math.log(number[,baseA]) math^ it returns the log of the number in base A^ if base A is omitted it's 10 math.sqrt math.sqrt(number) math^ it returns the square root of the number os.chdir os.chdir('path') os it changes the current working directory to "path" os.getcwd os.getcwd() os it returns the path of the current working directory os.getlogin os.getlogin() os it returns the name of the current Windows user os.listdir os.listdir(['path']) os it returns a list with names of files and folders available in the folder specified in "path" if "path" is omitted it uses the working directory os.rename os.rename('OldName','NewName') os it renames files or directories from "OldName" to "NewName" os.path.isfile os.path.isfile('path') os.path it returns True if the "path" is referring to a file, False otherwise os.path.join os.path.join('path','filename') os.path it concatenates "path" to "filename" putting \ random.choice random.choice(sequence) random it returns a random element from the sequence random.randint random.randint(a,b) random it generates a random integer between a and b included random.random random.random() random it generates a random floating point between 0 and 1 random.randrange random.randrange(min,max[,step]) random it returns a random integer between min (included) and max (excluded) with an increase of step webbrowser.open webbrowser.open('url',new=0) webbrowser it allows opening a URL in the browser if new=0 the url is opened in the same browser window, if new=1 a new browser window is opened, if new=2 a new browser page is opened