Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99312 > unrolled thread

Getting math scores (Dictionary inside dictionary)

Started byCai Gengyang <gengyangcai@gmail.com>
First post2015-11-24 03:04 -0800
Last post2015-11-24 14:09 +0000
Articles 10 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  Getting math scores (Dictionary inside dictionary) Cai Gengyang <gengyangcai@gmail.com> - 2015-11-24 03:04 -0800
    Re: Getting math scores (Dictionary inside dictionary) Steven D'Aprano <steve@pearwood.info> - 2015-11-24 22:28 +1100
    Re: Getting math scores (Dictionary inside dictionary) Cai Gengyang <gengyangcai@gmail.com> - 2015-11-24 19:22 +0800
    Re: Getting math scores (Dictionary inside dictionary) Arie van Wingerden <xapwing@gmail.com> - 2015-11-24 12:10 +0100
    Re: Getting math scores (Dictionary inside dictionary) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-24 12:15 +0000
    Re: Getting math scores (Dictionary inside dictionary) Arie van Wingerden <xapwing@gmail.com> - 2015-11-24 13:23 +0100
    Re: Getting math scores (Dictionary inside dictionary) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-24 13:30 +0000
      Re: Getting math scores (Dictionary inside dictionary) Marko Rauhamaa <marko@pacujo.net> - 2015-11-24 15:41 +0200
        Re: Getting math scores (Dictionary inside dictionary) Arie van Wingerden <xapwing@gmail.com> - 2015-11-24 15:43 +0100
    Re: Getting math scores (Dictionary inside dictionary) Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-24 14:09 +0000

#99312 — Getting math scores (Dictionary inside dictionary)

FromCai Gengyang <gengyangcai@gmail.com>
Date2015-11-24 03:04 -0800
SubjectGetting math scores (Dictionary inside dictionary)
Message-ID<efdba2f0-8d09-4c83-b11c-62857e8ff20b@googlegroups.com>
results = {
  "gengyang": { "maths": 10, "english": 15},
  "ensheng": {"maths": 12, "english": 10},
  "jordan": {"maths": 9, "english": 13}
  }

How do you get gengyang's maths scores ?

Thank you ...

[toc] | [next] | [standalone]


#99316

FromSteven D'Aprano <steve@pearwood.info>
Date2015-11-24 22:28 +1100
Message-ID<565449d6$0$1593$c3e8da3$5496439d@news.astraweb.com>
In reply to#99312
On Tue, 24 Nov 2015 10:04 pm, Cai Gengyang wrote:

> results = {
>   "gengyang": { "maths": 10, "english": 15},
>   "ensheng": {"maths": 12, "english": 10},
>   "jordan": {"maths": 9, "english": 13}
>   }
> 
> How do you get gengyang's maths scores ?

Break the problem into two steps:

- get Gengyang's scores;

- then get the maths score:

scores = results['gengyang']
maths_score = scores['maths']


Now you can simplify the process:

maths_score = results['gengyang']['maths']



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#99318

FromCai Gengyang <gengyangcai@gmail.com>
Date2015-11-24 19:22 +0800
Message-ID<mailman.104.1448366002.2291.python-list@python.org>
In reply to#99312
Great, it works! Thanks a lot ..

>>> results = {
  "gengyang": { "maths": 10, "english": 15},
  "ensheng": {"maths": 12, "english": 10},
  "jordan": {"maths": 9, "english": 13}
  }

>>> print((results["gengyang"])["maths"])
10

On Tue, Nov 24, 2015 at 7:10 PM, Arie van Wingerden <xapwing@gmail.com>
wrote:

> print((results["gengyang"])["maths"])
>
> 2015-11-24 12:04 GMT+01:00 Cai Gengyang <gengyangcai@gmail.com>:
>
>> results = {
>>   "gengyang": { "maths": 10, "english": 15},
>>   "ensheng": {"maths": 12, "english": 10},
>>   "jordan": {"maths": 9, "english": 13}
>>   }
>>
>> How do you get gengyang's maths scores ?
>>
>> Thank you ...
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>

[toc] | [prev] | [next] | [standalone]


#99319

FromArie van Wingerden <xapwing@gmail.com>
Date2015-11-24 12:10 +0100
Message-ID<mailman.105.1448366006.2291.python-list@python.org>
In reply to#99312
print((results["gengyang"])["maths"])

2015-11-24 12:04 GMT+01:00 Cai Gengyang <gengyangcai@gmail.com>:

> results = {
>   "gengyang": { "maths": 10, "english": 15},
>   "ensheng": {"maths": 12, "english": 10},
>   "jordan": {"maths": 9, "english": 13}
>   }
>
> How do you get gengyang's maths scores ?
>
> Thank you ...
> --
> https://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#99321

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-11-24 12:15 +0000
Message-ID<mailman.107.1448367372.2291.python-list@python.org>
In reply to#99312
On 24/11/2015 11:04, Cai Gengyang wrote:
> results = {
>    "gengyang": { "maths": 10, "english": 15},
>    "ensheng": {"maths": 12, "english": 10},
>    "jordan": {"maths": 9, "english": 13}
>    }
>
> How do you get gengyang's maths scores ?
>
> Thank you ...
>

One way is to delete the scores for ensheng and jordan, only leaving 
those for gengyang, then extract the maths score.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#99322

FromArie van Wingerden <xapwing@gmail.com>
Date2015-11-24 13:23 +0100
Message-ID<mailman.108.1448367839.2291.python-list@python.org>
In reply to#99312
Hi Mark, what use would that have? Please show your code ...

2015-11-24 13:15 GMT+01:00 Mark Lawrence <breamoreboy@yahoo.co.uk>:

> On 24/11/2015 11:04, Cai Gengyang wrote:
>
>> results = {
>>    "gengyang": { "maths": 10, "english": 15},
>>    "ensheng": {"maths": 12, "english": 10},
>>    "jordan": {"maths": 9, "english": 13}
>>    }
>>
>> How do you get gengyang's maths scores ?
>>
>> Thank you ...
>>
>>
> One way is to delete the scores for ensheng and jordan, only leaving those
> for gengyang, then extract the maths score.
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
>
> Mark Lawrence
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#99327

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-11-24 13:30 +0000
Message-ID<mailman.111.1448371835.2291.python-list@python.org>
In reply to#99312
On 24/11/2015 12:23, Arie van Wingerden wrote:
> Hi Mark, what use would that have? Please show your code ...
>
> 2015-11-24 13:15 GMT+01:00 Mark Lawrence <breamoreboy@yahoo.co.uk>:
>
>> On 24/11/2015 11:04, Cai Gengyang wrote:
>>
>>> results = {
>>>     "gengyang": { "maths": 10, "english": 15},
>>>     "ensheng": {"maths": 12, "english": 10},
>>>     "jordan": {"maths": 9, "english": 13}
>>>     }
>>>
>>> How do you get gengyang's maths scores ?
>>>
>>> Thank you ...
>>>
>>>
>> One way is to delete the scores for ensheng and jordan, only leaving those
>> for gengyang, then extract the maths score.
>>
>> --
>> My fellow Pythonistas, ask not what our language can do for you, ask
>> what you can do for our language.
>>
>> Mark Lawrence
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>

1) I was being facetious.
2) How many times do people have to be asked not to top post here before 
they stop top posting?
3) I only have two things to say so this is superfluous.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#99328

FromMarko Rauhamaa <marko@pacujo.net>
Date2015-11-24 15:41 +0200
Message-ID<87poyzo6op.fsf@elektro.pacujo.net>
In reply to#99327
Mark Lawrence <breamoreboy@yahoo.co.uk>:

> 1) I was being facetious.
> 2) How many times do people have to be asked not to top post here
> before they stop top posting?
> 3) I only have two things to say so this is superfluous.

Mark, it may not be your objective, but you really are poisoning the
atmosphere here.


Marko

[toc] | [prev] | [next] | [standalone]


#99346

FromArie van Wingerden <xapwing@gmail.com>
Date2015-11-24 15:43 +0100
Message-ID<mailman.123.1448376233.2291.python-list@python.org>
In reply to#99328
2015-11-24 14:41 GMT+01:00 Marko Rauhamaa <marko@pacujo.net>:

> Mark Lawrence <breamoreboy@yahoo.co.uk>:
>
> > 1) I was being facetious.
> > 2) How many times do people have to be asked not to top post here
> > before they stop top posting?
> > 3) I only have two things to say so this is superfluous.
>
> Having posted only 2 times in this list I was not aware of the specific
religious mailing list book used here.
So please apologize :-)

[toc] | [prev] | [next] | [standalone]


#99336

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2015-11-24 14:09 +0000
Message-ID<n31r29$4en$2@dont-email.me>
In reply to#99312
On Tue, 24 Nov 2015 03:04:09 -0800, Cai Gengyang wrote:

> results = {
>   "gengyang": { "maths": 10, "english": 15},
>   "ensheng": {"maths": 12, "english": 10}, "jordan": {"maths": 9,
>   "english": 13}
>   }
> 
> How do you get gengyang's maths scores ?

I refer to my previous answer. Open a web browser and google "python 
dictionary"

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web