Fichas
Python Cheat Sheet
Fichas del conjunto (31)
- 1find type of object?type()
- 2Convert to Integerint()
- 3covert to floatfloat()
- 4Convert to stringstr()
- 5print resultsprint()
- 6less than<
- 7greater than>
- 8equal to==
- 9not equal to!=
- 10length of a stringlen()
- 11capitalize first letter of each word in a stringstring.title()
- 12determine if each letter in a string is lowercasestring.islower()
- 13count occurrences of a string within a stringstring.count(" ")
- 14return a list with each word in a stringstring.split(" ")
- 15count items in a listlen()
- 16greatest element of a listmax()
- 17smallest element of a listmin()
- 18sort elements in a list smallest to largestsorted(list)
- 19sort elements in a list largest to smallestsorted(list, reverse = true)
- 20find the total of the numbers in a listsum(list)
- 21add item to the end of a listlist.append()
- 22remove the last item of a listlist.pop()
- 23remove specific items form a listlist.pop(index)
- 24create a string using elements in a liststring.join(list)
- 25create a setlist = set()
- 26add item to a setset.add(item)
- 27remove items form a setset.discard(item)
- 28create a tuppletupple = (item1, item2, item3)
item1, item2, item3 = tupple - 29Basic read from a filef1 = open(file path, r)
f1.read()
f1.close() - 30Read from a file so it auto closeswith open (file path, r):
filedata = f.read - 31—
Información
- Descripción
- A quick beginner guide to some basic python tools
- Creado por
- Matt Burkes
- Visitas
- 226
- Etiquetas
- Valoración