Spring 2022 Final Exam

pdf

School

University of California, San Diego *

*We aren’t endorsed by this school

Course

10

Subject

Mathematics

Date

Feb 20, 2024

Type

pdf

Pages

22

Uploaded by BaronJackal4036

Report
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 1/22 ikea ikea 'product' str 'category' str 'price' int 'assembly_cost' int 'packages' int ikea ikea
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 2/22 offers offers 'offer' str 'category' str 'percent_off' int offers app_data app_data 'product' str 'category' str 'assembly_time' str 'x hr, y min' x y app_data app_data
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 3/22 import babypandas as bpd import numpy as np 'category' 'price' (ikea.assign(assembly_per_package = ___(a)___) .sort_values(by = 'assembly_per_package' ).___(b)___) ikea.___(a)___.get(___(b)___)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 4/22 ikea 'product' ikea extract_product_line extract_product_line (ikea.assign(product_line = ikea.get( 'product' ) .apply(extract_product_line))) def extract_product_line(x): return _________
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 5/22 offers with_offers with_offers with_offers 'percent_off' 'product' with_offers with_offers (with_offers = ikea.take(np.arange( 6 )) .merge(offers, left_on = 'category' , right_on = 'eligible_category' )) with_offers.groupby( 'product' ).max().get( 'offer' )
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 6/22 with_offers.get('price') - with_offers.get('percent_off')/100 with_offers.get('price')*(100 - with_offers.get('percent_off'))/100 with_offers.get('price') - with_offers.get('price')*with_offers.get('percent_off')/100 with_offers.get('price')*(100 - with_offers.get('percent_off')/100) app_data app_data app_data 'assembly_time' with_offers = with_offers.assign(after_price = _________) with_offers (app_data.take(np.arange( 4 )) .sort_values(by = 'assembly_time' ) .get( 'assembly_time' ) .iloc[ 0 ])
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 7/22 to_minutes 'x hr, y min' x y int to_minutes('3 hr, 5 min') app_data 'minutes' to_minutes('assembly_time') to_minutes(app_data.get('assembly_time')) app_data.get('assembly_time').apply(to_minutes) app_data.get('assembly_time').apply(to_minutes(time)) app_data def to_minutes(time): first_split = time.split( ' hr, ' ) second_split = first_split[ 1 ].split( ' min' ) return _________ app_data = app_data.assign(minutes = _________) app_data
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 8/22 'minutes' 'product' 'minutes' 'minutes' 'product' 'minutes' app_data app_data 'bed' 'outdoor'
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 9/22 app_data obs_diff outdoor = (app_data.get( 'category' ) == 'outdoor' ) bed = (app_data.get( 'category' ) == 'bed' ) obs_diff = ( ___(a)___ - ___(b)___ ) / ___(c)___
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 10/22 multi = np.random.multinomial( 2500 , [ 0.5 , 0.5 ]) (multi[ 0 ] - multi[ 1 ]) / 2500 outdoor = np.random.multinomial( 2500 , [ 0.5 , 0.5 ])[ 0 ] / 2500 bed = np.random.multinomial( 2500 , [ 0.5 , 0.5 ])[ 1 ] / 2500 outdoor - bed choice = np.random.choice([ 0 , 1 ], 2500 , replace = True ) choice_sum = choice.sum( ) (choice_sum - ( 2500 - choice_sum)) / 2500 choice = np.random.choice([ 'bed' , 'outdoor' ], 2500 , replace = True ) bed = np.count_nonzero(choice == 'bed' ) outdoor = np.count_nonzero(choice == 'outdoor' ) outdoor / 2500 - bed / 2500 outdoor = (app_data.get( 'category' ) == 'outdoor' ) bed = (app_data.get( 'category' ) == 'bed' ) samp = app_data[outdoor | bed].sample( 2500 , replace = True ) samp[samp.get( 'category' ) == 'outdoor' ].shape[ 0 ] / 2500 - samp[samp.get( 'category' ) == 'bed' ].shape[ 0 ] / 2500 ) outdoor = (app_data.get( 'category' ) == 'outdoor' ) bed = (app_data.get( 'category' ) == 'bed' ) samp = (app_data[outdoor | bed].groupby( 'category' ).count( ).reset_index( ).sample( 2500 , replace = True )) samp[samp.get( 'category' ) == 'outdoor' ].shape[ 0 ] / 2500 - samp[samp.get( 'category' ) == 'bed' ].shape[ 0 ] / 2500
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 11/22 simulated_diffs < <= > >= app_data app_data app_data 'minutes' app_data 'minutes' np.count_nonzero(simulated_diffs _________ obs_diff) / 10000
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 12/22 np.random.permutation billy_lommarp[lommarp].get('minutes').mean() np.random.choice(billy_lommarp.get('minutes'), lommarp.sum()).mean() billy_lommarp.get('minutes').mean() - billy_mean (billy_lommarp.get('minutes').sum() - billy_mean * billy.sum())/lommarp.sum() billy = (app_data.get( 'product' ) == 'BILLY Bookcase, white, 31 1/2x11x79 1/2' ) lommarp = (app_data.get( 'product' ) == 'LOMMARP Bookcase, dark blue-green, 25 5/8x78 3/8' ) billy_lommarp = app_data[billy | lommarp] billy_mean = np.random.choice(billy_lommarp.get( 'minutes' ), billy.sum()).mean() lommarp_mean = _________ billy_mean - lommarp_mean
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 13/22 calculate_meatball_plates def calculate_meatball_plates(prices): meatball_plates = 0 for price in prices: if price >= 100 and price <= 199 : meatball_plates = 1 elif price >= 200 : meatball_plates = 2 return meatball_plates def calculate_meatball_plates(prices): meatball_plates = 0 for price in prices: if price >= 200 : meatball_plates = meatball_plates + 1 if price >= 100 : meatball_plates = meatball_plates + 1 return meatball_plates def calculate_meatball_plates(prices): return np.count_nonzero(prices >= 100 ) + np.count_nonzero(prices >= 200 ) def calculate_meatball_plates(prices): return (prices >= 200 ).sum() * 2 + (( 100 <= prices) & (prices <= 199 )).sum() * 1
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 14/22
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 15/22 area_left_of(z) z -4 <= z <= 12 area_between(x, y) x y -4 <= x <= y <= 12 z = −4 z = 4 z = 0 z = 8 z = −4 z = 4 import scipy def area_left_of(z): '''Returns the area under the armchair curve to the left of z. Assume -4 <= z <= 12''' if ___(a)___: return ___(b)___ return scipy.stats.norm.cdf(z) def area_between(x, y): '''Returns the area under the armchair curve between x and y. Assume -4 <= x <= y <= 12.''' return ___(c)___
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 16/22 area_between(x, y) x y -4 <= x <= y <= 12 area_between(-2, 10)
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 17/22 area_between(0.37, 8.37)
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 18/22
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 19/22
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 20/22
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 21/22
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
24. 2. 12. 오후 9:13 Spring 2022 Final Exam https://practice.dsc10.com/sp22-final/index.html 22/22
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help