Show Menu

Python Cheat Sheet by

Python3

print()
display data on the screen
"....."
use quotation mark to make it as a string
string placement
1st letter = 0
print multi variables
use comma
blank space counts as a character
len can be used for STRING ONLY
Example: juice = "­fresh water"
print (len(j­uice))
>>> 11

Python1

float()
change to number with decimal
integer()
change to number with NO decimal
Boolean = True/False
True/False
print()
display the inform­ation on the screen
input()
ask for some inform­ation from the users
len()
length of the string
# abcd
single line comment
"­"­"­abc­d"""
multi-line comments

Python2

+ Addition
== equal to
- Subtra­ction
!= not equal to
* Multip­lic­ation
< less than
/ Division
> more than
** To the power of
<= less than or equal to
% Modulo
>= more than or equal to
 

letter

upper
capital letter; upper()
lower
small letter; lower()
EX:
x = "­hel­lo8­97"
 
y = x.upper()
 
print (y) = "­HEL­LO8­97"
dot notation can only be used in STRING ONLY

Concat­enation

concat­enation
joining multiple strings together
Ex:
phrase = "­Tas­k" + "­is" + "­bal­din­g"
 
print (phrase) >>>> Taskis­balding
If you enter spaces or gaps
Ex: phrase = "Task " + "is " + "­bal­din­g"
 
print (phras­e)>­>>> Task is balding
Be aware of gaps and spaces when using concat­ena­tion.

Download the Python Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/punchtcn_python.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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.