python-cheat-sheet
python-cheat-sheet
>>>
my_string
my_string
= 'thisStringIsAwesome'
>>>
>>>
a = 'is'
b = 'nice'
String Operations
Selecting List Elements ndex starts at 0
I
'thisStringIsAwesomethisStringIsAwesome'
Subset
>>> my_string + 'Innit'
'thisStringIsAwesomeInnit'
my_string[4:9]
>>> x=5
>>> my_list2[1][:2]
>>> x
5
String Methods
>>> my_string.upper() #String to uppercase
L ist Operations
Calculations With Variables >>>
>>>
my_string.lower() #String to lowercase
True
>>> x*2 #Multiplication of two variables
10
25
1
>>> my_list.index(a) #Get the index of an item
Typ es and Type Conversion Selecting Numpy Array Elements ndex starts at 0
I
>>>
>>>
del(my_list[0:1]) #Remove an item
str()
>>> my_list.insert(0,'!') #Insert an item
'5', '3.45', 'True' #Variables to strings >>> my_array[1] #Select item at index 1
>>> my_list.sort() #Sort the list
2
int()
Slice
array([1, 4])
True, True, True #Variables to booleans
DataCamp Workspace
Free IDE that is included
Create and share
>>> my_array * 2
array([2, 4, 6, 8])