October 2014
Intermediate to advanced
280 pages
7h 20m
English
In the last exercise of Chapter 7, Lists and Recursion, you wrote a span funtion. Use it and list comprehensions to return a list of the prime numbers from 2 to n.
The Pragmatic Bookshelf has offices in Texas (TX) and North Carolina (NC), so we have to charge sales tax on orders shipped to these states. The rates can be expressed as a keyword list:[17]
| | tax_rates = [ NC: 0.075, TX: 0.08 ] |
Here’s a list of orders:
| | orders = [ |
| | [ id: 123, ship_to: :NC, net_amount: 100.00 ], |
| | [ id: 124, ship_to: :OK, net_amount: 35.50 ], |
| | [ id: 125, ship_to: :TX, net_amount: 24.00 ], |
| | [ id: 126, ship_to: :TX, net_amount: 44.80 ], |
| | [ id: 127, ship_to: :NC, net_amount: 25.00 ], |
| | [ id: 128, ... |
Read now
Unlock full access