Structured data, Python Programming

Structured data

We will often  want  to work  with  large  groups of data.   Rather  than  providing  each  number its own  value,  we need  to manage the data  into natural structures: grocery  lists, matrices, groups of employee medical records. We will explain  a simple  but  enormously useful  and ?exible list, which is conveniently create into Python: the list. The precise information  of how lists are shown inside a computer vary from language to language. We will take an abstract model  in which we think of a list as an ordered sequence of memory locations that numbers. So, for example, in Python, we may show a list of three integers as:

 

644_structured data.png

 

 

Now that we have lists, we have some new kinds  of statements, which let us extract elements of a list by specifying their indices.   An index  of 0 related to the ?rst  element of a list.  An index  of -1 related to the last element So, if a is bound as above, then we would have:

 

>>> a[0]

>>> a[2] 

>>> a[-1] 

>>> a[3] 

 

Traceback (most recent call last): File "", line 1, in IndexError: list index out of range.Note that if we attempt to access an element of the list that is not present, then a exception is generated.

 

 

847_structured data  2.png

 

 

It is also possible  to have  an empty list, which  is given in Python as []. We will show it in our memory diagrams as a short box. So example, this list  looks like this in memory:

>>> z = [3, [], [[]]]

 

 

 

515_structured data  3.png

 

Python has a useful method, len, which takes a list as an argument and gives its size. It does not look inside  the elements of the list-it just returns the number of elements at the top level of list. So, we take

 

>>> len([1, 2, 3])

3

>>> len([[1, 2, 3]])

1

 

Posted Date: 8/11/2012 1:38:38 AM | Location : United States







Related Discussions:- Structured data, Assignment Help, Ask Question on Structured data, Get Answer, Expert's Help, Structured data Discussions

Write discussion on Structured data
Your posts are moderated
Related Questions
I have python game project which is due by next Tuesday. Do you think that I can get it on time if I order today?

What are squared matrices?

given number isprime number or not

Synthetic models One  goal  of various  people in a variety of sub-disciplines of  electrical  engineering and  computer science is automatic synthesis of machine from  formal

Write a Python program to accomplish the following. Use modular design. Include at least 3 functions: one that returns zero values, one that returns one value, and one that retu

Structured data We will often  want  to work  with  large  groups of data.   Rather  than  providing  each  number its own  value,  we need  to manage the data  into natural s

There are three seating categories at a stadium. For a softball game, Class A seats cost $15, Class B seats cost $12, and Class C seats cost $9. Write a program that asks how many

Your task is to construct a translator from the subset of Python in Project 3 intocontinuation-passing style (CPS). Of course, the expected way of accomplishing this is to trans

Non-local references in procedures There  is an important subtlety in the  way  names  are handled in the  environment created by a function call. When  a value  that  is not

#question.Program 10 Assignment (Banking Objects – Savings/Checking Accounts) Create a program named 10.py that performs the following: Create a class named ChkAcct, and a class n