Professional Documents
Culture Documents
Pca221 Python-Sheet
Pca221 Python-Sheet
Words
Variable
(cont)
String
symboles
areaofcircle(user_radius))
Boolean
index = 0
Math Operations
!=
+
plus
3 != 2
while
reverse = word[index] +
reverse
minus
3-2=1
times
3*2=6
divide
9/3=3
3%2=1
numbers
index = index + 1
3+2=5
createlist(quitword):
print ("Keep entering words to
Calculating Fibonacci
quitword)
fbonacci = [0,1]
mylist = []
print(0)
while True:
user_word
print(1)
**
power
3 ** 2 = 9
<
less than
2<3
>
more than
3>2
<=
2 <= 3 , 3
while
len(fbonacci)
<
50:
fbonacci[len(fbonacci) - 2] +
if user_word
return mylist
fbonacci.extend([number])
print(number)
item in mylist:
if item == user_word:
>= 3
//
2//2000 =
decimal point
int()
duplicate = True
if (duplicate == True):
print ("Duplicate
decimal place
Calculate the Area of The Circle using def()
print()
def
float()
areaofcircle(r):
user_radius = foat(input("Enter
the Radius: "))
Word!")
else:
mylist.append(user_word
decimal point
pi = 3.1415
area = pi (r * 2)
return area
input("Please
== (quitword):
fbonacci[len(fbonacci)-1]
3 >= 2 , 3
number =
<= 3
>=
elif
not equal to
false
equal to
if/else
How To Reverse
reverse = ''
==
Syntax
Modulo
input()
len()
userlist = createlist("stop")
str()
import
print (userlist)
By pca221
Sponsored by CrosswordCheats.com
cheatography.com/pca221/
Page 1 of 2.
http://crosswordcheats.com
user_word[frstnumber]
lastletter
user_word[length - 1]
if frstletter ==
lastletter:
Guessing Game
= 3
if integer == 0:
score = 0
index = 0 binary2
= ''
while index < len(binary):
binary2 = binary[index] +
mylist =
['bowling','badminton','table
binary2
index = index + 1
tennis','basketball','golf']
print
("Words:"
print(binary2)
,mylist)
randomitem =
frstletter
== frstnumber + 1
lastletter == length 1
Math Operations
random.choice(mylist)
userguess = input("Please guess
a word: ")
if userguess == randomitem:
length = length - 2
("That's
Correct!
("Sorry, wrong
number
string *
break
else:
length = len(user_word)
if isPalindrome(user_word)
== True:
crash
string *
combine
number
string many
number
multiply
numbers
string **
crash
string
crash
number
math
**
exponents
number
number
number
integer
times
string
string **
crash
else:
string +
together
chance = chance - 1
if user_word == ("quit"):
Working")
add numbers
not.")
word: ")
together
choice!")
while True:
("Working") = ("Stop
number
return False
("Stop ") +
string
number
combine
string
if length == 0 or
1:
string +
int(integer)
palindrome")
= ''
while
else:
print (user_word, "is
not a palindrome")
By pca221
cheatography.com/pca221/
integer !=
0:
remainder = integer % 2
integer = int(integer / 2)
remainderstr = str(remainder)
Sponsored by CrosswordCheats.com
Page 2 of 2.
http://crosswordcheats.com