<< Chapter < Page Chapter >> Page >

Then the subscription selects the value in the mapping that corresponds to that key.

In other words, the system looks up the word in the dictionary and returns the value that corresponds to that word.

I will have more to say about mappings in a future module.


I discussed slicing at some length in the earlier module titled Itse1359-1070-Strings Part 2 . I will simply refer you back to that module for the discussion on slicing.

A mutable sequence

According to the Python Language Reference -- 3.2. The standard type hierarchy :

Mutable sequences:

Mutable sequences can be changed after they are created.

There are currently two intrinsic mutable sequence types:

  • Lists - The items of a list are arbitrary Python objects. Lists are formed by placing a comma-separated list of expressions in square brackets. (Note that there are no special cases needed to form lists of length 0 or 1.)
  • Byte Arrays - A bytearray object is a mutable array. They are created by the built-in bytearray() constructor. Aside from being mutable (and hence unhashable), byte arrays otherwise provide the same interface andfunctionality as immutable bytes objects.

This module does not discuss ByteArrays .

A list

According to The Python Tutorial -- 3.1.3. Lists :

"Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.
Like strings (and all other built-in sequence type), lists can be indexed and sliced.
All slice operations return a new list containing the requested elements."

Some sample programs

Creating, indexing, and slicing lists

A list can be written as a sequence of comma-separated values (items) surrounded by square brackets.

Lists can also be nested within other lists.

List items do not all have to be of the same type.

An example list

The Python script shown in Listing 4 creates a simple list containing four elements of different types. The types of the elements are respectively, a float value, an integer , a string , and another integer .

Listing 4 . An example list.
# Illustrates creating, # indexing, and slicing lists.# #-------------------------------theList = [3.14,59,"A string",1024] print("Print index value 2")print(theList[2])print("Print a short slice") print(theList[0:3]) print("Print the entire list")print(theList[:100])

After creating the list, the program uses a subscription (index) to extract and print the value at index 2 (remember the first item is at index 0) .

Then it uses the slice notation to extract and print two different slices from the list.

The first slice extracts and prints the elements from index 0 through index 2 inclusive. (Remember, the items selected by a slice do not include the index specified by the upper limit value, which is 3 in this case.)

The second slice extracts and prints the entire list. If you don't understand these two slices, go back and review the module titled Itse1359-1070-Strings Part 2 where I discussslicing in detail.

Questions & Answers

Do somebody tell me a best nano engineering book for beginners?
s. Reply
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
how to fabricate graphene ink ?
for screen printed electrodes ?
What is lattice structure?
s. Reply
of graphene you mean?
or in general
in general
Graphene has a hexagonal structure
On having this app for quite a bit time, Haven't realised there's a chat room in it.
what is biological synthesis of nanoparticles
Sanket Reply
what's the easiest and fastest way to the synthesize AgNP?
Damian Reply
types of nano material
abeetha Reply
I start with an easy one. carbon nanotubes woven into a long filament like a string
many many of nanotubes
what is the k.e before it land
what is the function of carbon nanotubes?
I'm interested in nanotube
what is nanomaterials​ and their applications of sensors.
Ramkumar Reply
what is nano technology
Sravani Reply
what is system testing?
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
good afternoon madam
what is system testing
what is the application of nanotechnology?
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
anybody can imagine what will be happen after 100 years from now in nano tech world
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
silver nanoparticles could handle the job?
not now but maybe in future only AgNP maybe any other nanomaterials
I'm interested in Nanotube
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Itse 1359 introduction to scripting languages: python. OpenStax CNX. Jan 22, 2016 Download for free at https://legacy.cnx.org/content/col11713/1.32
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Itse 1359 introduction to scripting languages: python' conversation and receive update notifications?