# 1.15 Itse1359-1070-strings part 2  (Page 2/5)

 Page 2 / 5

## A practical example

Many years ago when I did a tour of duty as an enlisted man in the U.S. Air Force, the drill sergeant had a habit of lining us up and telling us to "count off."

What that meant was that the first person in the line called out the number one , the person behind him called out the number two , the person behind him called out the number three , etc.

(Since learning about computer programming, I now wonder if the first person should have called out zero. I notice that thefirst case of Ebola in the United States is being identified by the CDC as case 0.)

## Assigning an ordinal index

I'm sure the drill sergeant didn't realize that what he was doing was assigning an ordinal index value to each person in the line (and neither did I realize it at the time) .

## Using an ordinal index

Even though he didn't know the technical details of ordinal indices, he didn't have any difficulty yelling, "Number six, wash dishes, number fourteen,peel potatoes, number twenty-two, carry out the garbage, etc."

That is what using an index is all about -- using an ordinal index to select an item. As you will see in a future module titled Itse1359-1080-Lists Part 1 , this is also referred to as a subscription in Python. In the context of this module, indexing is the process of assigning an ordinal index value to each data item contained in some sort of acontainer.

In other words, we assign an ordinal number to each item, which describes the numerical position of the item in the container.

A dozen eggs:

For example, if you were very careful, you could use a felt tip pen to assign an ordinal index to each of the twelve eggs contained in acarton containing a dozen eggs. (Should you start with zero or one?)

Then you could extract the egg whose index value is 9 from the container and eat it for breakfast.

Having assigned the index, we can use that index to access the data item corresponding to that index, as in "Number six, wash dishes."

## Index values automatically assigned

In this module, we will be using the index values that are automatically assigned to the characters in a string for the purpose of accessing thosecharacters, both individually, and in groups.

## Slicing

Here is what Magnus Lie Hetland has to say on the topic of slicing (and indexing as well.) Although this quotation was taken from a discussion of lists, it applies equallywell to strings. (Note that some material was deleted from the quotation for brevity.)

According to Magnus Lie Hetland:

"One of the nice things about lists is that you can access their elements separately or in groups, through indexing and slicing.

Indexing is done (as in many other languages) by appending the index in brackets to the list. (Note that the first element has index 0) ...

(This is the answer to the question about the first egg -- Baldwin)

Slicing is almost like indexing, except that you indicate both the start and stop index of the result, with a colon (":") separating them: ...

Notice that the end is non-inclusive. If one of the indices is dropped, it is assumed that you want everything in that direction. i.e. list[:3]means "every element from the beginning of list up to element 3,non-inclusive." ...

list[3:] would, on the other hand, mean "everyelement from list, starting at element 3 (inclusive) up to, and including, the last one."

For really interesting results, you can use negative numbers too: list[-3]is the third element from the end of the list..."

how environment affect demand and supply of commodity ?
Wht at the criteria for market ?
Amos
what is difference between monitory policy and fiscal policy?
monetary policy is a policy thrust by National Govt(CBN) to influence government spending, purchase &taxes
Frank
necessity of economics
I will say want,choice,opportunity cost,scarcity,scale of preference
Alao
what is monopoly market.How price output are determined under monopoly market
bisham
b) Monopoly market is an impecfect market where s single firm having the innovation to produce a particular commodity.Prices are determined through output since there are no other competitive.
Frank
Monopoly market:firm has market power & does not respond to market price
Frank
Explain the process of price determination under perfect competition market with suitable diagram
Price determination under perfect competition via this process :firms have no market power to influence price rather firms respond to market price.
Frank
price is different from demand- demand is amount of commodity
demand is amount /quantity of commodity a potential buyer is willing to buy at a given price at market
Frank
demand is a desire of customer on commodity with the ability to pay it and willing to buy it at given price of commodity
Harika
demand is price of what
show that shortrun average cost
what is economics
what is money
Mbah
what is money
Mbah
Difine macro economics
agaba
money is a medium of exchange between goods and services,maybe inform of currency.
Wesonga
Economics is study of how human beings strive to satisfy numerous wants using limited available resources.
Wesonga
how do you find the maximum number of workers the firms should employ order to produce where there are increasing returns
Jane
what are implications of computing national income?.
agaba
pl
MUDASIRU
what is the formulae for calculating national income
MUDASIRU
it calculated by value added method
Praveen
classify the production units like agriculture, banking, transport etc
Praveen
money is anything that is generally acceptetable for human
Ogbaji
Estimate the net value added(NVA) at fixed cost by each industrial structure
Praveen
definition of unemployment
what are the causes of unemployment?
The main causes of unemployment are listed below. 1. Frictional unemployment 2. Cyclical unemployment 3. Structural unemployment
assani
We can also categorize the causes on a broader sense as: 1. Political and 2. Social cause As unemployeement root causes are embaded in this two.
Yonathan
would opportunity cost exist if there was no scarcity?
assani
yes just because the opportunity cost arose when there is Alternative to choose among the alternatives.
I am thinking that, if our resources were unlimited, then there wouldn't be any need to forgo some wants. Hence the inexistence if opportunity cost
assani
Politics
Job
politics has done what?
assani
consider time assani
Mary
I'm Emmanuel,...I taught the main cause is the change in gov't.
Emmanuel
...Lack of capital to set up a firm respectively
Emmanuel
🙈
Emmanuel
I would like to bring in Educational levels can also be the cause the cause of the problem respectively
Emmanuel
I think the main causes of unemployment is lack of INFRASTRUCTURAL DEVELOPMENT OVER POPULATION OVER DEPENDENT ON GOVERNMENT LACK OF SELF EMPOWERMENT...
ananti
lack of skills among the new generation is the serious issue.
Vishal
Where I come from , I don't see why education or personal aspects seem to do with unimployment, technically the motivation and eigerness in all works of live is there , dispite the cultural influence and physical bearriors;the thing we lacking is Government Support and open market ethics.
Joe
sorry about that-(repation). We have a over powering ethical political system that's displacing the marketing asspects of economy and causing large scale unemployment right across the board...
Joe
can someone Explain Expansionary Monetary Policy and Contractionary Monetary Policy Using one of the instrument of Monetary Policy? Please am kinda lost here?. ta
using a graph show the case of substitute and compliment goods
can anyone give me a simple explanation to Five Sector Macroeconomics?
Emmanuel
Can someone please define what economics is
economics simply is a social science subject that study human behavior.
dajan
economics is a social science which studies human behaviour as a relationship between ends and scarce means that has alternative uses
Alao
Can someone please tell me how to calculate GDP
Emmanuel
emmanual kapal to calculate GDP (Gross Domestic Product) has three method in calculating it (1)income approach (2) expenditure approach (3) value added method
Alao
thanks Alae
Emmanuel
u are welcome
Alao
in basic terms economics is revered to as battery system, it date back to when Men sees the need to exchange sapless goods and produce to gain , either wealth , basic necessities or to establish trading ties for personal benefit or social asspects in terms of coexistence and continuity, future .
Joe
what is the law of demand
keep other thing constant, when the price increases demand decrease when the price decreases demand increases of the commodity.
sj
all things being equal,quantity demanded decrease as price increase and increase as price decrease
Seth
there's practial joke to it ..." the higher the demand ; scarcity, increase in production and drop in quality"... quite the controversy - for example China vs Europe, United States and we are all boxed up in between somewhere...
Joe
Other thing remain constant the low price of commodity the high quantity of commodity and vice versa is true
Baraka
Explain Effective demand
What is effective demand
Anita
like Modi is in demand...best example of effective demand
Pranav
Don't get you
Anita
Anita you mean you don't get me or who?
Onyeking
level of demand that represents a real intention to purchase by people with the means to pay
Pranav
Got questions? Join the online conversation and get instant answers!