Code Monkey home page Code Monkey logo

py-flip-coin's Introduction

Toss coin

If you flip a coin, heads will come up 50% of the time. But if you flip a coin 10 times, what is the chance that heads will come up 5 times? 2 times?

Write flip_coin function, that conducts at least 10000 cases of flipping a coin 10 times. It should return dict, where keys are numbers of possible heads dropped (0 to 10), and values are percentage of how many that number of heads dropped out of all cases.

print(flip_coin())
# {0: 11, 1: 7, 2: 4, 3: 18, ... }

If you have done all correctly, you should note that the biggest percentage of a number of heads dropped is about the middle, 4-6 times and tends to 0 when it is about the edges 0-1 and 9-10. It calls normal distribution or Gaussian distribution.

Extra

Write draw_gaussian_distribution_graph function, that draws a graph that shows the distribution.

matplotlib is relevant library for this purpose.

You should get graph like this:

gaussian

py-flip-coin's People

Contributors

abnormaltype avatar masterpieceelbow avatar danylott avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.