Show Menu
Cheatography

Python 123456 Cheat Sheet (DRAFT) by

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

Vocabulary

variable
something that can change
string
a list of characters

Addition

string + string
combines the strings together
string + number
crash
number + number
math (addition)

Mul

string * string
crash
string * number
combines the string multiple times
number * number
math - multiply
string ** number
crash

Mul

string * string
crash
 

Functions

print()
displays inform­ation on the screen
input()
receives info from the user
int()
converts a value to an integer
float()
converts a value to a floating point
str()
converts a value to a string
 

Example Code


mylist3 = [1, 'hello', 2.5]

print (mylist)
print (mylist2)
print (mylist3)

#how to make a list with all numbers from 0-99

mynumbers = range(5)

for num in mynumbers:
    print (num)