Cheatography
https://cheatography.com
This cheat sheet made by Team 7 Group 2 Gen 11 cyber security
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Data Types
Integer |
10, -20 |
Float |
3.7, -1.4 |
String |
"abc", "hello!" |
Boolean |
True, False |
List |
[ value, ... ] |
Tuple |
( value, ... ) |
Dictionary |
{ key: value, ... } |
Set |
{ value, value, ... } |
Arithmetic Comparisons
x < y |
Less Than |
x > y |
Greater Than |
x <= y |
Less Than or Equal |
x >= y |
Greater Than or Equal |
x == y |
Equal |
x != y |
Not Equal |
Statements
If Statement |
if (expression): statements |
Else If Statement |
elif (expression): statements |
Else Statement |
else: statements |
Loop
While Loop |
while (expression): statements |
For Loop (Iterating over a collection) |
for item in collection: statements |
For Loop (Counting) |
for i in range(start, end, step): statements # (start is included; end is not) |
Function Definitions
Function return value with parameters |
def name(parameter1, par2, ...): statements return expression |
Function return value without parameters |
def name(): statements return expression |
Function non-return value with parameters |
def name(parameter1, par2, ...): statements |
Function non-return value without parameters |
def name(): statements |
|
|
Arithmetic Operators
x + y |
Addition |
x - y |
Subtraction |
x * y |
Multiplication |
x / y |
Division |
x % y |
Modulus |
x // y |
Floor Division |
x ** y |
Exponentiation |
x operators= y |
e.g.: x += 1 |
Input/Output
Input |
input() |
Output |
print() |
Conversion Functions
int(expr) |
Converts expression to integer |
float(expr) |
Converts expression to float |
str(expr) |
Converts expression to string |
String / List / Tuple Operations
len(s) |
Length of s |
s[i] |
ith item in s (0-based) |
s[start : end] |
Slice of s from start (included) to end (excluded) |
x in s |
True if x is contained in s |
x not in s |
True if x is not contained in s |
s + t |
The concatenation of s with t |
s * n |
n copies of s concatenated |
Group Members of Team 7
Full name |
ID |
Sin Hong |
IDTB110277 |
Oeng Vengku |
IDTB110346 |
Phoeurn Rozariya |
IDTB110147 |
Rous Sovann Makara |
IDTB110159 |
|