Solving Problems with google colabratory

Solving Problems with google colabratory


The chocolate problem

You have 1 box of chocolates, the box contains some chocolates (feel free to add number, preferably divisible by 12). You give your papa 1/3 of the chocolates in the box, you give your mama 1/2 of the remaing chocolates, then you divide the rest of the chocolates with 4 friends. How many chocolates do each of your friends have.


  • Hmm, you could just take the strain, and solve the math problem.
  • Or you could do a BM and solve this easily with google colab.

Let's solve this in google colab or Jupyter notebook. Run this and see the magic. All you need to do is open the IDE copy over the code and run it( Shift +enter for Jupyter notebook , ctrl+ enter colab)

Here is the code:

Box_of_chocolates = 48 # User input
Papa_share=1/3
Mama_share=(1-Papa_share)*(1/2)
Friend_share_total=1-Papa_share-Mama_share
Friend_share_each=Friend_share_total/4
Papa_choc = Box_of_chocolates*Papa_share
Mama_choc = Box_of_chocolates*Mama_share
Friend_total_choc=Box_of_chocolates*Friend_share_total
Friend_each_choc=Box_of_chocolates*Friend_share_each
Output = Friend_each_choc # Change what you see output for
print (round(Output))



See you soon, share your feelings about this!

BM

Comments

Popular Posts