Social Media

Daily Python Puzzle: Set, Lambda, and Filter

What is the output of this code snippet? # popular instagram accounts # (millions followers) inst = {"@instagram": 232, "@selenagomez": 133, "@victoriassecret": 59, "@cristiano": 120, "@beyonce": 111, "@nike": 76} # popular twitter accounts # (millions followers) twit = {"@cristiano": 69, "@barackobama": 100, "@ladygaga": 77, "@selenagomez": 56, "@realdonaldtrump": 48} inst_names = set(filter(lambda x: inst[x]>60, inst.keys())) twit_names …

Daily Python Puzzle: Set, Lambda, and Filter Read More »

Daily Python Puzzle: Parameter Passing

What is the output of this code snippet?   def depreciation1(asset_value, rate): asset_value = asset_value * rate def depreciation2(asset_values, rate): for i in range(len(asset_values)): asset_values[i] = asset_values[i] * rate asset_value = 10 depreciation1(asset_value, 0.9) print(asset_value) my_asset_values = [10, 100, 1000] depreciation2(my_asset_values, 0.9) print(int(my_asset_values[0])) This puzzle demonstrates that parameters are called by object in Python. What …

Daily Python Puzzle: Parameter Passing Read More »