Assignment On Python 1
Assignment On Python 1
II. Problems
Meltdown Mitigation
Problem Specification
This exercise contains information on developing a simple control system for a nuclear
reactor.
For a reactor to produce the power it must be in a state of criticality. If the reactor is in a
state less than criticality, it can become damaged, and if it goes beyond criticality, it can
overload and result in a meltdown.
We want to mitigate the chances of meltdown and correctly manage reactor state.
Tasks
Check for criticality
The first thing a control system has to do is check if the reactor is balanced in criticality.
A reactor is said to be critical if it satisfies the following conditions:
Once the reactor has started producing power its efficiency needs to be determined.
Efficiency can be grouped into 4 bands:
1. voltage
2. current
3. theoretical_max_power
Your final task involves creating a fail-safe mechanism to avoid overload and meltdown.
This mechanism will determine if the reactor is below, at, or above the ideal criticality
threshold.
The reactor’s state can be determined by temperature*neutrons_produced_per_second .
Criticality can then be increased, decreased, or stopped by inserting or removing control
rods into the reactor.
If the reactor’s state < 90% of threshold , output status code ‘LOW’, indicating
that control rods must be removed to produce power.
If the reactor’s state is within plus or minus 10% of threshold , output status code
‘NORMAL’, indicating that the reactor is in optimum condition and control rods
are in an ideal position.
If if it’s not in the above ranges, the reactor is going into meltdown and a status
code of ‘DANGER’ must be passed so that it can be shut down immediately.
1. temperature ,
2. neutrons_produced_per_second
3. threshold
Currency Exchange
Problem Specification
Your friend Chandler plans to visit tourist destinations across the United States. Sadly,
Chandler’s math skills aren’t good and he’s pretty worried about being finessed by
currency exchange booths during his trip. He’s discussing the travel plan with you and
wants your help with currency calculations.
During the discussion, you both learn that exchange booths dont deal with fractional
amounts.
Tasks
Chandler will need to exchange Euros for USDs. These are the tasks:
and returns an integer corresponding to the number of bills, in USD, that fits into the
amount of Euros budgeted. Assume that 1 Euro = 1.05 USD.
Note: Round down to the nearest denomination (whole bill) as the exchange booth will
not return the fractional amount.
>>> whole_bills(127.5, 5)
25
and returns the total value of the bills, in USD, the exchange booth will give back.
1. budget : The amount of money you are planning to exchange (in Euros).
2. denomination : The value of a single bill.
3. exchange_rate : The amount of domestic currency equal to one unit of foreign
currency (assume 1 Euro = 1.05 USD).
4. spread : The percentage taken by the exchange booth as a fee, written as an
integer.
This function should return the maximum value of the new currency (in integer), after
calculating the exchange rate plus the spread. Remember that the currency
denomination is a whole number.
Note: Spread needs to be converted to decimal by dividing it by 100.
Example: If 1.00 EUR = 1.05 USD and the spread is 10 , then the actual exchange rate will
be: 1.00 EUR == 1.155 USD because 10% of 1.05 is 0.105, which gets added as an
additional fee.