def PrintExtremes(live):
 hist = thinkstats2.Hist(live.prglngth)
 thinkplot.Hist(hist, label='live births')
 thinkplot.Save(root='first_nsfg_hist_live', title='Histogram', xlabel='weeks', ylabel='frequency')
 print('Shortest lengths:')
 for (weeks, freq) in hist.Smallest(10):
  print(weeks, freq)
 print('Longest lengths:')
 for (weeks, freq) in hist.Largest(10):
  print(weeks, freq)

def PrintExtremes ( live ) : hist = thinkstats2 . Hist ( live . prglngth ) thinkplot . Hist ( hist , label = 'live births' ) thinkplot . Save ( root = 'first_nsfg_hist_live' , title = 'Histogram' , xlabel = 'weeks' , ylabel = 'frequency' ) print ( 'Shortest lengths:' ) for ( weeks , freq ) in hist . Smallest ( 10 ) : print ( weeks , freq ) print ( 'Longest lengths:' ) for ( weeks , freq ) in hist . Largest ( 10 ) : print ( weeks , freq )
plots the histogram of pregnancy lengths and prints the extremes .