Show Menu
Cheatography

Python - Basics Cheat Sheet (DRAFT) by

This will include all the information About Python - Basics; This includes the basic syntax, variables, data types, conditionals, typecasting, exceptions, functions, lists, tuples, sets and dictionaries.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Vocabulary

String
a list of characters such as numbers, letters, symbols
Variable
holds a value and can be changed
Input
something that the user types in
Float Number
number with a decimal point
Syntax
grammar or rules on progra­­mming
Integer
number with no decimal point
Print
displays inform­­ation on the screen
value
the number or string can be store in valuable
Syntax Error
make impossible to the phase
loop
the condition used in python
operator
the signs used for mathem­­atics condition
module
text for storing the python code
This summary simplifies and organizes your data for clarity and quick reference.

Functions

print()
displays inform­­ation on the screen
input()
receives inform­­ation from the user
int()
converts a value to an integer
float()
converts a value to a decimal number
str()
converts a value to a string
len ()
length of the string
while ... :
loop statement
if ... :
if statement used as a condition or loop in python
else:
another condition used after if statement
"­"­"
multi-line comment
# ...
a line comment
for ... in ...
a list
True
a condition in a loop
False
a condition in a loop
... [ x ]
the x'th letter of the string
import ...
import a codeor something like formula in python
This covers a range of basic Python functions, condit­ions, loops, comments, and statements to help you understand their purpose and use.

Operations

+
add
-
subtract
*
multiply
/
divide
//
floor division
**
exponent
%
module
==
equal to
!=
unequal to
<
lesser than
<=
lesser than or equal to
>
greater than
>=
greater than or equal to

TypeCa­sting

int()
x = int(1)
1
float()
y = float(2.8)
2.8
str()
z = str("3v­")
3v

variables

Hello World
print(­"­Hello world!­")
Hello World with a Variable
msg = "­Hello World!­"
print (msg)
Concat­enation (combining strings)
name = 'albert'
lname = 'einstein'
Full = name + ' ' + lname
print(­Full)
Variables are used to store values. A string is a series of
charac­ters, surrounded by single or double quotes.

Data types

str
int
float
complex
list
tuple
range
dict
set
frozenset
bool
bytes
bytearray
memoryview
NoneType
 

Condit­ional

 

For loops

 

While loops

 

Iteration

 

Recursion

 

Switch

 
 

Exceptions

 

List

 

Tuple

 

Set

 

Dictio­naries