Skip to content

Category: Uncategorized

Lists


Lists In Python you define a list using brackets.  An empty list would simply be list = [].  A list can have any number of elements.…

Dictionary


Dictionary Python supports a data structure known as dictionary:  a set which contains key, value pairs. For every key in a dictionary,  there is a…

Read file


Read file In Python you reading files is part of the standard library.  To read files, you can use the readlines() function. This will read…

Write file


Creating new files To create new files, you can use this code: #!/usr/bin/env python # create and open file f = open(“test.txt”,”w”) # write data…

Slices


Slices A slice can be taken from a string or list, just as you can take a slice from a pizza. Python starts numbering of…

Scope


Scope Variables have a certain reach within a program. A global variable can be used anywhere in a program, but a local variable is known…