Python Cheat Sheet

Description

A quick beginner guide to some basic python tools
Matt Burkes
Flashcards by Matt Burkes, updated more than 1 year ago
Matt Burkes
Created by Matt Burkes over 6 years ago
186
0

Resource summary

Question Answer
find type of object? type()
Convert to Integer int()
covert to float float()
Convert to string str()
print results print()
less than <
greater than >
equal to ==
not equal to !=
length of a string len()
capitalize first letter of each word in a string string.title()
determine if each letter in a string is lowercase string.islower()
count occurrences of a string within a string string.count(" ")
return a list with each word in a string string.split(" ")
count items in a list len()
greatest element of a list max()
smallest element of a list min()
sort elements in a list smallest to largest sorted(list)
sort elements in a list largest to smallest sorted(list, reverse = true)
find the total of the numbers in a list sum(list)
add item to the end of a list list.append()
remove the last item of a list list.pop()
remove specific items form a list list.pop(index)
create a string using elements in a list string.join(list)
create a set list = set()
add item to a set set.add(item)
remove items form a set set.discard(item)
create a tupple tupple = (item1, item2, item3) item1, item2, item3 = tupple
Basic read from a file f1 = open(file path, r) f1.read() f1.close()
Read from a file so it auto closes with open (file path, r): filedata = f.read
Show full summary Hide full summary

Similar

Code Challenge Flow Chart
Charlotte Hilton
Flvs foundations of programming dba 2
mariaha vassar
Python Appendix A - ex.1
Melissa Machado
Python Quiz
karljmurphy
Think Python
tsilvo2001
Mish mash of flashcards
xat jak
Python Programming
Jose Miguel Alvarado
Basic Python - Print Formatting
Rebecca Noel
What is Python?
Daniel Ingram