Popular recipes tagged "meta:requires=random"http://code.activestate.com/recipes/tags/meta:requires=random/popular/2017-07-15T00:46:59-07:00ActiveState Code RecipesUno (Text-Based) (Python) 2017-07-15T00:46:59-07:00Brandon Martinhttp://code.activestate.com/recipes/users/4194238/http://code.activestate.com/recipes/580811-uno-text-based/ <p style="color: grey"> Python recipe 580811 by <a href="/recipes/users/4194238/">Brandon Martin</a> (<a href="/recipes/tags/artificial_intelligence/">artificial_intelligence</a>, <a href="/recipes/tags/cards/">cards</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/text_game/">text_game</a>, <a href="/recipes/tags/uno/">uno</a>). </p> <p>A text based recreation of the classic card game featuring functional AIs to play with. Some rules have been modified. User interface is text based, non-curses, using only simple python commands to draw it. </p> Space Assault (Python) 2016-04-06T23:31:28-07:00Tage Burnetthttp://code.activestate.com/recipes/users/4193902/http://code.activestate.com/recipes/580636-space-assault/ <p style="color: grey"> Python recipe 580636 by <a href="/recipes/users/4193902/">Tage Burnett</a> (<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This is a game I created on Python without the use of Pygame</p> The many uses of randomness - Part 2 (Python) 2016-07-17T17:26:47-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580690-the-many-uses-of-randomness-part-2/ <p style="color: grey"> Python recipe 580690 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/random_number/">random_number</a>, <a href="/recipes/tags/simulation/">simulation</a>, <a href="/recipes/tags/testing/">testing</a>). </p> <p>This is the second recipe in the series about the uses of randomness in Python. The first recipe is here:</p> <p><a href="https://code.activestate.com/recipes/580674-the-many-uses-of-randomness-part-1/?in=user-4173351" rel="nofollow">https://code.activestate.com/recipes/580674-the-many-uses-of-randomness-part-1/?in=user-4173351</a></p> <p>This second recipe shows some uses of random numbers to generate random characters and random strings of various categories, and some purposes for which these generated strings can be used in testing.</p> chroma (Python) 2016-05-30T11:48:10-07:00aaahttp://code.activestate.com/recipes/users/4194184/http://code.activestate.com/recipes/580671-chroma/ <p style="color: grey"> Python recipe 580671 by <a href="/recipes/users/4194184/">aaa</a> (<a href="/recipes/tags/2d/">2d</a>, <a href="/recipes/tags/game/">game</a>). </p> <p>Python personnal game code</p> The many uses of randomness - Part 1 (Python) 2016-06-01T19:36:28-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580674-the-many-uses-of-randomness-part-1/ <p style="color: grey"> Python recipe 580674 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/random_number/">random_number</a>). </p> <p>This recipe shows some of the many uses of random numbers, using the random function from the random module from Python's standard library. A subsequent recipe or two will show other uses, both of other functions from the module, and for other purposes.</p> <p>The uses shown in this recipe have to do with using random float values, and scaling them and offsetting them, and also how to get a repeated/predictable series of random numbers.</p> Generate a set of random integers (Python) 2016-02-18T19:34:17-08:00Lance Spencehttp://code.activestate.com/recipes/users/4193647/http://code.activestate.com/recipes/580613-generate-a-set-of-random-integers/ <p style="color: grey"> Python recipe 580613 by <a href="/recipes/users/4193647/">Lance Spence</a> (<a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/random/">random</a>). </p> <p>This is just a short and simple script that generates a set of random numbers. You enter how many random numbers you want and the program will generate them.</p> <p>The num is multiplied by 10 in the upper limit within the for loop to give you larger generated integers. Adjust it as needed.</p> The Game of Battleships in Python (Python) 2014-02-22T06:13:41-08:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578836-the-game-of-battleships-in-python/ <p style="color: grey"> Python recipe 578836 by <a href="/recipes/users/4184772/">Captain DeadBones</a> (<a href="/recipes/tags/beginner/">beginner</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Another fun game that is fun to program and play. No special AI (yet). But still and entertaining game. </p> <p>For more info about <a href="http://thelivingpearl.com/2014/02/17/the-game-of-battleships-in-python/">Battleships in Python</a> follow the link. </p> Money Game (Python) 2014-12-22T23:38:38-08:00Lance Spencehttp://code.activestate.com/recipes/users/4191386/http://code.activestate.com/recipes/578988-money-game/ <p style="color: grey"> Python recipe 578988 by <a href="/recipes/users/4191386/">Lance Spence</a> (<a href="/recipes/tags/classes/">classes</a>, <a href="/recipes/tags/games/">games</a>). </p> <p>I created this simple program as a possible start to something larger while I continue to learn Python. It's a simple program that can be used to help young kids learn to count change in US currency.</p> HANGMAN! (Python) 2015-09-21T20:49:41-07:00Burak Tandoganhttp://code.activestate.com/recipes/users/4191373/http://code.activestate.com/recipes/578984-hangman/ <p style="color: grey"> Python recipe 578984 by <a href="/recipes/users/4191373/">Burak Tandogan</a> (<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/hangman/">hangman</a>, <a href="/recipes/tags/python/">python</a>). Revision 9. </p> <p>Classic Hangman on console, check how hang the man with codes! Click 'download' and left click the .py file, have fun!</p> Create tabular PDF reports with xtopdf and tablib in Python (Python) 2014-12-25T17:48:53-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578991-create-tabular-pdf-reports-with-xtopdf-and-tablib-/ <p style="color: grey"> Python recipe 578991 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/reportgeneration/">reportgeneration</a>, <a href="/recipes/tags/reporting/">reporting</a>, <a href="/recipes/tags/reportlab/">reportlab</a>, <a href="/recipes/tags/tablib/">tablib</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to create tabular PDF reports, i.e. PDF reports containing tabular data - rows and columns, using Python, xtopdf (a PDF creation library) and tablib (a Python library for manipulating tabular data). </p> Rock,Paper,Scissors (Python) 2014-12-19T05:39:38-08:00Burak Tandoganhttp://code.activestate.com/recipes/users/4191373/http://code.activestate.com/recipes/578983-rockpaperscissors/ <p style="color: grey"> Python recipe 578983 by <a href="/recipes/users/4191373/">Burak Tandogan</a> (<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/paper/">paper</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/rock/">rock</a>, <a href="/recipes/tags/scissors/">scissors</a>). Revision 2. </p> <p>A simple game :)</p> Game of Life - Python 3.4 & tkinter (Python) 2014-09-05T15:02:11-07:00Peter Mhttp://code.activestate.com/recipes/users/4190729/http://code.activestate.com/recipes/578928-game-of-life-python-34-tkinter/ <p style="color: grey"> Python recipe 578928 by <a href="/recipes/users/4190729/">Peter M</a> (<a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>I took this well-know game to design my own solution, and make a GUI for it.</p> <p>To run the program, you will need to create a txt file with rows of dots, so like this:</p> <p>...... ...... ...... ......</p> <p>and name it empty_board.gol (I have tested this program withwith 55x55)</p> <p>It is functional and not object oriented.</p> <p>My game of life algorithm is probably not the best one around (suggestions welcome), but I think this program is a nice demo of with tkinter can do and how easy it is to program GUI's with tkinter.</p> <p>It has been written and tested in python 3.4 but I guess any version 3 should work, and probably only minor changes are needed to make it work in 2.6 or 2.7 (e.g. change tkinter to Tkinter).</p> Hangman Game (Demo) (Python) 2014-12-22T14:05:55-08:00Malcolm Jeremy Lewishttp://code.activestate.com/recipes/users/4191332/http://code.activestate.com/recipes/578987-hangman-game-demo/ <p style="color: grey"> Python recipe 578987 by <a href="/recipes/users/4191332/">Malcolm Jeremy Lewis</a> . </p> <p>Game is not finished yet...</p> TicTacToe (Python) 2014-12-14T16:23:44-08:00Malcolm Jeremy Lewishttp://code.activestate.com/recipes/users/4191332/http://code.activestate.com/recipes/578980-tictactoe/ <p style="color: grey"> Python recipe 578980 by <a href="/recipes/users/4191332/">Malcolm Jeremy Lewis</a> (<a href="/recipes/tags/tic/">tic</a>). </p> <p>A simple TicTacToe script including AI (Artificial Intelligence)</p> Tic Tac Toe (Python) 2014-07-30T19:34:23-07:00Gauravhttp://code.activestate.com/recipes/users/4190360/http://code.activestate.com/recipes/578905-tic-tac-toe/ <p style="color: grey"> Python recipe 578905 by <a href="/recipes/users/4190360/">Gaurav</a> (<a href="/recipes/tags/tac/">tac</a>, <a href="/recipes/tags/tic/">tic</a>, <a href="/recipes/tags/toe/">toe</a>). Revision 2. </p> <p>Classic Tic Tac Toe game with AI. Created using Python 2.7.6</p> create a unique session key (Python) 2014-07-03T16:32:53-07:00john stinsonhttp://code.activestate.com/recipes/users/4190325/http://code.activestate.com/recipes/578903-create-a-unique-session-key/ <p style="color: grey"> Python recipe 578903 by <a href="/recipes/users/4190325/">john stinson</a> (<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/sessions/">sessions</a>). </p> <p>A simple function that will generate a secure and unique session key.</p> A simple Matrix class (Python) 2012-05-14T13:34:31-07:00Anand B Pillaihttp://code.activestate.com/recipes/users/4169530/http://code.activestate.com/recipes/578131-a-simple-matrix-class/ <p style="color: grey"> Python recipe 578131 by <a href="/recipes/users/4169530/">Anand B Pillai</a> (<a href="/recipes/tags/algebra/">algebra</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/matrix/">matrix</a>). Revision 3. </p> <p>A simple class in Python representing a Matrix with basic operations, operator overloading and class factory methods to make Matrices from different sources.</p> Encode multipart form data for uploading files via POST (Python) 2013-09-22T21:27:24-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578668-encode-multipart-form-data-for-uploading-files-via/ <p style="color: grey"> Python recipe 578668 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/multipart/">multipart</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>This function lets you encode form fields <em>and</em> files in multipart/form-data format for uploading files via HTTP POST.</p> Pseudo-Random Experiment: Coin Toss (Python) 2014-03-31T18:51:15-07:00Fabian Mayerhttp://code.activestate.com/recipes/users/4189629/http://code.activestate.com/recipes/578859-pseudo-random-experiment-coin-toss/ <p style="color: grey"> Python recipe 578859 by <a href="/recipes/users/4189629/">Fabian Mayer</a> (<a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/toss/">toss</a>). </p> <p>This Python Script flips a coin a user defined number of times and returns the frequency and relative frequency for heads and tails.</p> Public Key Encryption (RSA) (Python) 2013-12-27T06:43:59-08:00Mohammad Taha Jahangirhttp://code.activestate.com/recipes/users/4188847/http://code.activestate.com/recipes/578797-public-key-encryption-rsa/ <p style="color: grey"> Python recipe 578797 by <a href="/recipes/users/4188847/">Mohammad Taha Jahangir</a> (<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/inverse/">inverse</a>, <a href="/recipes/tags/multiplicative/">multiplicative</a>, <a href="/recipes/tags/primality_testing/">primality_testing</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/publickey/">publickey</a>, <a href="/recipes/tags/rsa/">rsa</a>). Revision 3. </p> <p>Simple code to create and use public/private keypairs. Accompanied by a rudimentary encoder.</p>