计算机科学导论

《计算机科学导论》学习笔记(27) - 课程 27: 累积实践问题

匿名 (未验证) 提交于 2019-12-03 00:25:02
题目: # Question 1: Pick One # Define a procedure, pick_one, that takes three inputs: a Boolean # and two other values. If the first input is True, it should return # the second input. If the first input is False, it should return the # third input. # For example, pick_one(True, 37, 'hello') should return 37, and # pick_one(False, 37, 'hello') should return 'hello'. def pick_one () : print pick_one( True , 37 , 'hello' ) #>>> 37 print pick_one( False , 37 , 'hello' ) #>>> hello print pick_one( True , 'red pill' , 'blue pill' ) #>>> red pill print pick_one( False , 'sunny' , 'rainy' ) #>>> rainy