注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
90 minutes to complete 13 questions, with 3 numerical sequences, 7 probability/stats, and 3 OOP coding
Some prob/stat problems i remembered
1. A and B roll a dice. If A gets 1, A wins. If not, A can re-roll, and if A gets 1~3, A still wins, otherwise B rolls the dice. If B gets 6, B wins. Otherwise, dice go back to A. What is the probability that A wins?
2. A bag has 10 cards, randomly draw two without replacement, and call them x and y. What is the variance of "x+4y?"
3. Two indistinguishable urns. One contains 4x $2 and 6x $10. The other contains 9x $2 and 1x $10. I drew a $2 from one of the urns. Now I can pick one bag and draw another coin. What is the expected payoff if played optimally.
OOP coding:
1. About __str__ and __repr__ methods, and inheritence.
class Item:
def __init__(self, title, creator):
self.title = title
self.creator = creator
s
- init (self, transaction type, amount, balance): Initializes a new transaction object.
- str(self): Returns a string representation of the transaction in the format "Type: (self.transaction type), Amount: (self.amount), Balance: (self balance)"
BankAccount Class
- init (self, initial balance): Initializes a new bank account with the given initial balance.
- process transaction(self, transaction amount, transaction type): Processes the given transaction and updates the account balance.
|