Professional Documents
Culture Documents
Cheat Sheet
Circle area
()
print
if user== random_item:
#Ask the user for a radius of a circle
()
int (
float
()
str( )
a list of things
len (
pi = float(3.1415)
#Calculate the area of the circle using
exponents
int = integer
area = pi(radius*2)
str = string
len = length
Statements
If Statement
if :
Triangle
import random
def areatriangle(base,height):
elif :
chance = 3
else:
score = 0
While Loop
print (list)
while :
while chance != 0:
random_item = random.choice(list)
For Loop
area = (base*height)/2
return area
base = float(input(" Enter the base of the
triangle"))
height = float(input(" Enter the height of the
triangle"))
print ("The area of the triangle is",
areatriangle(base,height))
def volumeprism(area,height):
volume= area*height
return volume
elif = else if
Sponsored by CrosswordCheats.com
cheatography.com/dragonjeen/
Page 1 of 3.
http://crosswordcheats.com
Reverse
Calculator
ask
def area_circle(r):
while True:
pi=3.1415
area= pi r * 2
index = 0
return area
radius=float(radius)
def diff(a,b):
index = int(index) + 1
return a-b
Symbol
Countdown
def mult(a,b):
return a*b
def div(a,b):
return a/b
==
equal to
!=
not equal
<
less than
>
more than
while number>0 :
<=
print(number)
print(diff(num1,num2))
>=
number = number-1
def main(num1,num2,op):
countdown to one."))
if (op == "sum"):
print(sum(num1,num2))
print(mult(num1,num2))
sort word
H
Symbol II
+
combine / plus
minus
division
multiplication
**
power
remainder
l
l
mystr = "Hello"
letter_num = 0
while letter_num < len(mystr):
print (mystr[letter_num])
letter_num = letter_num + 1
bacon2("hello", "++++++++")
bacon2("me", "-=-=-=-=-=-=-")
bacon2("<3", "<<<<<<<<<<<<<")
Sponsored by CrosswordCheats.com
cheatography.com/dragonjeen/
Page 2 of 3.
http://crosswordcheats.com
Random
Palindrome
import random
while True:
random.choice(
list
if word == "quit":
print (doubleIt("Hello"))
Convert to binary
print(myvar)
binary_string = ''
Vocabulary
variable
string
integer
float
decimal number
syntax
value
loop
modulo
remainder
Boolean
truth or false
break
while numb>0:
print (numb)
remainder = numb%2
binary_string = str(remainder)+ binary_string
numb= numb//2
in the list
while int(index)<len(word):
reverse=word[index] + (reverse)
index=int(index)+1
Palindrome = False
print ("|" + reverse + "|" + word +"|")
def isPalindrome(word):
if word == reverse:
Print Name
palindrome = isPalindrome(word)
print in seperated line
mylist=[1,2,3,4,5]
for number in mylist:
print(number)
sort list
Sponsored by CrosswordCheats.com
cheatography.com/dragonjeen/
Page 3 of 3.
http://crosswordcheats.com