Professional Documents
Culture Documents
Quiz2 cs104 C Solutions
Quiz2 cs104 C Solutions
Quiz2 cs104 C Solutions
Student Number:
CS 104 – Spring 2022
QUIZ 2
def sum_n_double(x,y):
return 2*(x+y)
What will be the result of the following expression? Please show result of each
term step by step.
sum_n_double(2+sum_n_double(1,2),3) + 10/sum_n_double(2,3)
Solution:
sum_n_double(2+6,3) + 10/10
sum_n_double(8,3) + 1
22 + 1
23
2. (50pts) Assume you own a portfolio of foreign currencies composed of USD (US
dollars) and EUR (euros). Write a function called totalAsset() that calculates and
outputs the value of your portfolio in TRY (Turkish liras). The function will take the
following arguments as input: amount of USD you own, USD to TRY conversion
rate, amount of EUR you own and EUR to TRY conversion rate.
For example: Assume you own 10 USD, conversion rate for USD to TRY is 14.
Additionally, you own 20 EUR and conversion rate for EUR to TRY is 15. The
function should return a result of 440 TRY.
###
usdOwn = 10
usd2try = 14
euroOwn = 20
euro2try = 15