Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is a CS question using concept of dictionary, I am confused and need help in python, thanks! Write a function dct_op that takes in

this is a CS question using concept of dictionary, I am confused and need help in python, thanks!image text in transcribed

Write a function dct_op that takes in a dictionary (the player's name (strings) as the key and a list of total game points (integers) as value) and a function func. Your function should apply function func to each integer in the list and return an updated dictionary. Assume the input func always takes in an integer and returns another integer. Note: You can solve this problem using one-line dictionary comprehensions in the format below. You are not required to but it is very similar to list comprehensions, so give it a try! This link might be helpful. {key:valuefor(key,value)initerable} Example: > example ={x:x+10 for x in [1,2,3,4,5]} >> print(example) {1:11,2:12,3:13,4:14,5:15} def update_stats(dct, func): "I" dct ={ 'Curry': [26,21,30], 'James': [26,22,18]} >> update_stats (dct, squared) \{'Curry': [676,441,900], 'James': [676,484,324]} dct ={ 'Poole': [15,11,27,23], 'Tatum': [35,21,22,28],\ 'Harden': [28,11,22,19]} > update_stats(dct, identity) \{'Poole': [15,11,27,23], 'Tatum': [35,21,22,28], 'Harden': [28,11,22,19]} > update_stats (dct, lambda x:x+1 ) \{'Poole': [16,12,28,24], 'Tatum': [36,22,23,29], 'Harden': [29,12,23,20]}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Has the priority order been provided by someone else?

Answered: 1 week ago

Question

Evaluating Group Performance?

Answered: 1 week ago