Entries by Hannah Wangui

defsecond_max(lst): Return the second highest number in a list of positive integers. “”” >>> second_max([3, 2, 1, 0]) 2 >>> second_max([2, 3, 3, 4, 5, 6, 7, 2, 3]) 6 >>> second_max([1, 5, 5, 5, 1]) 5 >>> second_max([5, 6, 6, 7, 1]) 6 >>> second_max([5, 6, 7, 7, 1]) 7 “”” “*** YOUR CODE HERE ***”

defsecond_max(lst): Return the second highest number in a list of positive integers.   “”” >>> second_max([3, 2, 1, 0]) 2 >>> second_max([2, 3, 3, 4, 5, 6, 7, 2, 3]) 6 >>> second_max([1, 5, 5, 5, 1]) 5 >>> second_max([5, 6, 6, 7, 1]) 6 >>> second_max([5, 6, 7, 7, 1]) 7 “”” “*** YOUR CODE […]

 

Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

fromimport sqrtdefis_square(n): float(sqrt(n)) == int(sqrt(n))defsquares(seq): perfect squares. math return “””Returns a new list containing elements of the original list that are >>> seq = [49, 8, 2, 1, 102] >>> squares(seq) [49, 1] >>> seq = [500, 30] >>> squares(seq) [] “”” “*** YOUR CODE HERE ***”

fromimport sqrtdefis_square(n): float(sqrt(n)) == int(sqrt(n))defsquares(seq): perfect squares. math   return   “””Returns a new list containing elements of the original list that are >>> seq = [49, 8, 2, 1, 102] >>> squares(seq) [49, 1] >>> seq = [500, 30] >>> squares(seq) [] “”” “*** YOUR CODE HERE ***”   Looking for a Similar Assignment? Order now and […]

 

Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

defpairs(n): >>> pairs(1) [[1, 1]] >>> x = pairs(2) >>> x “””Returns a new list containing two element lists from values 1 to n [[1, 1], [2, 2]] >>> pairs(5) [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]] >>> pairs(-1) [] “”” “*** YOUR CODE HERE ***”

defpairs(n): >>> pairs(1) [[1, 1]] >>> x = pairs(2) >>> x   “””Returns a new list containing two element lists from values 1 to n     [[1, 1], [2, 2]] >>> pairs(5) [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]] >>> pairs(-1) [] “”” “*** YOUR CODE HERE ***”   Looking for a Similar Assignment? Order […]

 

Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

defminmax(s): with defining two variables at the beginning. Do not use the built in max or min functions “””Return the minimum and maximum elements of a non-empty list. Hint: start >>> minmax([1, 2, -3]) [-3, 2] >>> x = minmax([2]) >>> x [2, 2] >>> minmax([4, 5, 4, 5, 1, 9, 0, 7]) [0, 9] >>> minmax([100, -10, 1, 0, 10, -100]) [-100, 100] “”” “*** YOUR CODE HERE ***”

defminmax(s): with defining two variables at the beginning. Do not use the built in max or min functions   “””Return the minimum and maximum elements of a non-empty list. Hint: start   >>> minmax([1, 2, -3]) [-3, 2] >>> x = minmax([2]) >>> x [2, 2] >>> minmax([4, 5, 4, 5, 1, 9, 0, 7]) [0, 9] […]

 

Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"