0

Help me pls about Dictionary function

What is the result of this code? primes = {1: 2, 2: 3, 4: 7, 7:17} print(primes[primes[4]]) I already know the answer is 17 but i don't how to do could you pls explain for me thank you

23rd Jul 2020, 6:39 PM
Paknonkit Kalayapichet
Paknonkit Kalayapichet - avatar
7 Respuestas
+ 4
Peak Kalayapichet Dictionary uses key and values. In primes now, key(1) has the value of 2, key(2) has the value of 3... Now to your question: Trying to simplify this will look like this: primes[4] = 7 primes[7] = 17 Hope this helps 😃
23rd Jul 2020, 6:53 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 2
First we take the value of primes [4] that's give 7 then after again primes [7] that's give 17.
23rd Jul 2020, 6:49 PM
Sâñtôsh
Sâñtôsh - avatar
+ 1
Dictionary has key and value a={keys: values} If u provide a key or an index it gives output as value
23rd Jul 2020, 6:47 PM
Sâgærāvürï
Sâgærāvürï - avatar
+ 1
Såñtösh Màràvi no it's not primes number its about python dictionaries
23rd Jul 2020, 6:52 PM
Sâgærāvürï
Sâgærāvürï - avatar
+ 1
I know SAI VIDYA SAGAR RAVURI but I explain code answer of Peak Kalayapichet .
23rd Jul 2020, 6:54 PM
Sâñtôsh
Sâñtôsh - avatar
0
Okk
23rd Jul 2020, 6:55 PM
Sâgærāvürï
Sâgærāvürï - avatar
0
thank you ! Now i got it!
24th Jul 2020, 9:29 AM
Paknonkit Kalayapichet
Paknonkit Kalayapichet - avatar