id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > least_likely
prev  |  next  |  chance

After doing a series of experiments, you have compiled a dictionary showing the probability of detecting certain kinds of subatomic particles. The particles names should be the dictionary's keys, and the probabilities are its values. Write a function called least_likely that takes a single list representing this dictionary as its sole parameter and returns the particle (a string) that is least likely to be observed. An example input is L = [["neutron",0.55], ["proton", 0.21], ["meson", 0.03], ["muon", 0.07], ["neutrino", 0.14]]. When called with this input, the function should return "meson". Note that the given list has a bunch of pairs, stored as lists of length 2. So it's actually a 2D list, and you should convert it to a dictionary in the course of your solution.


least_likely([[2, 0], [3, 1]]) → 2
least_likely([[2, 0.5], [3, 0.3], [True, 0.1]]) → True
least_likely([['neutron', 0.55], ['proton', 0.21], ['meson', 0.03], ['muon', 0.07], ['neutrino', 0.14]]) → 'meson'

...Save, Compile, Run (ctrl-enter)

def least_likely(L):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 100 Post-solution available

Copyright Nick Parlante 2017 - privacy