Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python data structures

list = [same as array with different features] 
array = [23, 'arrayItem', True, ['Hi', 34, False] ]
dictionary = {'key' : 'value'}
object = class testObj:
tuple = ( "a", "b", "c", "d" ); #same as list but non-changable
Comment

python data structures

x = "You Rock!" #str	
x = 69	#int	
x = 69.9	#float	
x = 1j	#complex	
x = ["red", "blue", "green"]	#list	
x = ("red", "blue", "green")	#tuple	
x = range(20)	#range	
x = {"name" : "Taylor", "age" : 35}	#dict	
x = {"red", "blue", "green"}	#set	
x = frozenset({"red", "blue", "chegreenrry"})	#frozenset	
x = True	#bool	
x = b"You Rock!"	#bytes	
x = bytearray(10)	#bytearray	
x = memoryview(bytes(10))	#memoryview	
x = None	#NoneType
Comment

data structures in python

1
2
3
4
5
6
7
8
my_list = [1, 2, 3]
print(my_list)
my_list.append([555, 12]) #add as a single element
print(my_list)
my_list.extend([234, 'more_example']) #add as different elements
print(my_list)
my_list.insert(1, 'insert_example') #add element i
print(my_list)
Comment

data structures in python

1
2
3
4
5
6
7
8
9
my_list = [1, 2, 3, 'example', 3.132, 10, 30]
del my_list[5] #delete element at index 5
print(my_list)
my_list.remove('example') #remove element with value
print(my_list)
a = my_list.pop(1) #pop element from list
print('Popped Element: ', a, ' List remaining: ', my_list)
my_list.clear() #empty the list
print(my_list)
Comment

PREVIOUS NEXT
Code Example
Python :: python run only when list is bigger 
Python :: generate natural numbers python 
Python :: tweepy to dataframe 
Python :: three periods in python 
Python :: python basic programs quadratic equation 
Python :: python pattern glob extension searching 
Python :: python using boolean len 
Python :: Python Program to Display Powers of 2 Using Anonymous Function 
Python :: tkinter window not responding during progress bar 
Python :: create date range python 
Python :: travis deployment script for django applications to heroku 
Python :: transform jpg image into array for conv2d 
Python :: string times python 
Python :: python bill 
Python :: python selenium disable JavaScript Detection 
Python :: adjusted price in crsp pandas 
Python :: scatter plot actual vs predicted python 
Python :: pip unknown command import 
Python :: flip a coin with array in python 
Python :: odd number list generator 
Python :: Access the Response Methods and Attributes in python 
Python :: error in matplotlib setup command: use_2to3 is invalid 
Python :: Python match.span() 
Python :: pandas mappin ID to value in different row 
Python :: copy bdc to feature class arcpy 
Python :: queue data structure in python 
Python :: dict get keys tcl 
Python :: dft numpy amplitude 
Python :: Creating a bag-of-words in scikit-learn 
Python :: patoolib extract password-protected archives 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =