Show Menu
Cheatography

fahpf Cheat Sheet by

VOCABULARY

blank
empty
float
the number in decimal
input
inform­ation that is put in it
integer
whole number or counting
loop
goes on (again and again)
number
number
print
to show inform­ation
string
a list of character such as number, letter and symbols
syntax
grammar or structure of lauguage
value
the amount of something
variable
hold a value and can be change
 

EXAMPLES

print ("" + "­1" + "­2")
12
print (int(2.5))
2
print (float­(2.5))
2.5
print (float­(in­t(2.5)))
2.0
number1 = 11 number2 = 22 sum = str(nu­mber1) + str(nu­mber2) print(sum)
1122
number1 = "­11" number2 = "­22" sum = int(nu­mber1) + float(­num­ber2) print(sum)
33.0
bacon = "keep calm and eat bacon" letter = bacon[5] print (letter)
c
index = 0 index = index + 1 index = index + 2 text = "coke zero is the best" print (text[­index])
e
index = 2 index = index * 5 text = "coke zero is the best" print (text[­index])
i
myboolean = 2 != 3 if myboolean: print ("tr­uth­") else: print ("li­es")
truth
myboolean = 2 == 3 if myboolean: print ("tr­uth­") else: print ("li­es")
lies
boolean1 = 2 <= 3 boolean2 = 2 >= 3 if boolean1 == boolean2: print (1) else: print (3)
3
boolean1 = 2 <= 3 boolean2 = 2 >= 3 if boolean1 == boolean2: print (1) elif boolean1 != boolean2: print (2) else: print (3)
2
index = 0 while index < 4: index = index + 4 print (index)
4
hello = "­hello there!­" out = "­" for letter in hello: out = letter
!
print(out) hello = "­hello there!­" out = "­" for letter in hello: out = letter + out
!ereht olleh
 

MATH

==
equal to
!=
not equal to
<
less than
>
more than
<=
less than or equal
>=
more than or equal
%
Modulo, find the remainder Vocabulary variable Hold a value and can be changed syntax Grammar or structure of language modulo Find the remainder boolean True or false floating point The number in decimal
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.