From 4f5ecc755b82eb38be309dd1ce72de698fe5aec8 Mon Sep 17 00:00:00 2001 From: Musunuri Date: Tue, 9 Jan 2018 11:40:51 -0600 Subject: [PATCH] aswers --- __pycache__/exercise.cpython-36.pyc | Bin 0 -> 1390 bytes exercise.py | 52 ++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 __pycache__/exercise.cpython-36.pyc diff --git a/__pycache__/exercise.cpython-36.pyc b/__pycache__/exercise.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c3ef2d78e9f3d224670f092c6c8eeaf8ebb8a406 GIT binary patch literal 1390 zcma)6Pfrs;6yJY^rO*ln6EPk(!KAJ!SSkl;NF#8=$id>Jlx(IuLs{9KtuwpOVmZOp z58_wq)p+Pvz=OUwg{BmPPC9R9-oN?nd%w<`TrO+=+OPl2Xxa~LY}l}W2UC_nP>t$W zT3w?CHDT4MMKg4YPE(uC&@7#8*>!`?(Hz)Jny+c@BVUIw90p7a<_=7`2qMvXkc}Ew z8a2Ne7kWIm^nv* zfVegh;G8fqa*73I;>JfZKjw78=_5;0!N<~ez*{J#b4tRLjZ$?d3{F{@s@3X!ye|(5 z+i}yWML}|0C_07rj61tAXA%!vA?rBXg3y4+g+q6A!NFb2-LSEIhbm%JUMw?~xQ6A; zgXn3Wp}dzmHJ3o?T6@>JGeEDwZy2uL&&YNdB(Sltw%;`|1;*>@PNnflG9ep`9) z-3()>7{op*O%VPgob0DfDL4HR@Bt-uCs5f;JS>kg>mTFQbXKA-%Nxye{To^|2Z_ z&@>|6V>l#QqW83(era6l7e>#3>geRfh<3hUBw-#6{3M7u5nb;{#E};UGLe5{AXZQQ zgMg$pa``|0adxHHTxO$`E?7wux{VNo^06jhwwgyo(y}J%j;qu zP6K#^v;p#Qfc+le8#I_fkwr0!LiHH=j00Dk>T$tlQ{=q9r*HtNrg<7QfxVNsmgSd} z2>> sort_by_last_name(['Bob Smith', 'Ken Jones', 'Alex Bradino']) + ['Alex Bradino', 'Ken Jones','Bob Smith'] + """ + x = sorted(people, key=lambda name: name.split(" ")[-1]) + return (x) pass # problem 2 # ------------------------------------------------------------------- # -names = ['James', 'Susan', 'Maggie'] -ages = [4, 9, 12] - - def create_dictionary_from_lists(names, ages): # {'James':4, 'Susan':9, 'Maggie':12} # add doctests make sure it passes + """ Test create_dictionary_from_lists + + Args: + names : the first parameter + ages : the second parameter + Returns: + new_dict : return value + >>> create_dictionary_from_lists(['James', 'Susan', 'Maggie'],[4, 9, 12]) + {'James': 4, 'Susan': 9, 'Maggie': 12} + """ + new_dict = dict(zip(names, ages)) + return (new_dict) pass # problem 3 # ------------------------------------------------------------------- # -numbers = [5, 6, 7, 8, 9, 10, 11, 12] - def square_even_values_and_sum_under_10(numbers): # 6^2 + 8^2] # add doctests make sure it passes + """ Test square of evens + + Args: + numbers : the first parameter + + Returns: + squares : return value + >>> square_even_values_and_sum_under_10([5, 6, 7, 8, 9, 10, 11, 12]) + 100 + """ + l1 = filter(lambda n: n < 10, numbers)) + sum = 0 + for i in l1: + if i % 2 == 0: + sum = sum + (i*i) + return (sum) pass