Latest recipes tagged "demonstration"http://code.activestate.com/recipes/tags/demonstration/new/2012-12-07T01:49:19-08:00ActiveState Code RecipesWar Game (Version 6) (Python) 2012-12-07T01:49:19-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578370-war-game-version-6/ <p style="color: grey"> Python recipe 578370 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/card/">card</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/game/">game</a>). </p> <p>As the final version of the War Game, development finally came to a halt as the prototype exceeded it bounds for design. Yes, you can write your program as one large function, but should you? This recipe demonstrates that program without proper style can lead to a mess very quickly. Practice good coding standards, or you can easily loose focus and the ability to maintain your code.</p> War Game (Version 5) (Python) 2012-12-07T01:40:06-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578369-war-game-version-5/ <p style="color: grey"> Python recipe 578369 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/card/">card</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/game/">game</a>). </p> <p>Part of the War Game set, this version of War Game further advanced the program in an environment without curses. Showing another iteration of development, the recipe here program for more fun with a virtual card game and ASCII graphic card representations while playing.</p> Averaging Literal Numbers (Python) 2012-12-06T13:44:42-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578365-averaging-literal-numbers/ <p style="color: grey"> Python recipe 578365 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/numbers/">numbers</a>). </p> <p>One program that a teacher may assign to beginning programming students would be to take a list of numbers and average them together. This recipe does just that and is designed to be easy to read and follow, showing what is possible with a few lines of Python.</p> Samuel F. B. Morse's Code (Python) 2012-12-06T04:20:31-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578364-samuel-f-b-morses-code/ <p style="color: grey"> Python recipe 578364 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/morse/">morse</a>, <a href="/recipes/tags/morse_code/">morse_code</a>, <a href="/recipes/tags/morse_practice_oscillator/">morse_practice_oscillator</a>, <a href="/recipes/tags/sound/">sound</a>). </p> <p>Many people have heard of Morse['s] Code, and it still is a helpful skill to have in certain context, as advanced as technology has become. The following recipe shows two sample ways that it can be implemented and shows some diversity in how problems can be solved in Python or many other languages for that matter.</p> Countdown Timer (Python) 2012-12-06T03:24:35-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578363-countdown-timer/ <p style="color: grey"> Python recipe 578363 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/timer/">timer</a>, <a href="/recipes/tags/utility/">utility</a>). </p> <p>Ever wanted to set a timer that went off after a specified number of hours / minutes / seconds? This Windows recipe runs on the command line and does that with the arguments it accepts. Simple but effective, the program works well for remembering food in the oven among other things.</p> Command Line Windows Alarm Clock (Python) 2012-12-05T23:53:49-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578362-command-line-windows-alarm-clock/ <p style="color: grey"> Python recipe 578362 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/alarm/">alarm</a>, <a href="/recipes/tags/clock/">clock</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>Using primitive but simple calculations, the alarm program below will find the offset to the time specified, sleep, and awake to run an alarm until terminated. This Windows recipe utilizes the <code>msvcrt</code> and <code>winsound</code> modules to operate and has limited use elsewhere.</p> Byte Frequency Analyzer (Python) 2012-12-05T23:48:53-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578361-byte-frequency-analyzer/ <p style="color: grey"> Python recipe 578361 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>When beginning to compress a file or studying it to break certain forms of encryption, sometimes it is helpful to know how many bytes of a certain category are in a file. This recipe is a simple frequency analysis tool that may be helpful towards that end and can provide a starting point for those interested tools for such fields.</p> File To Hex (Python) 2012-12-05T23:45:05-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578360-file-to-hex/ <p style="color: grey"> Python recipe 578360 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>There are lots of hex editors out there, but how difficult is it to actually write a program that just displays a file in simple hex format? As this recipe shows, a few functions and lines in Python makes it rather easy to accomplish.</p> Media File Renamer (Python) 2012-12-05T21:04:38-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578359-media-file-renamer/ <p style="color: grey"> Python recipe 578359 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>Have you ever been annoyed with the names digital cameras give to their pictures? After considering the problem and wanting to standardize filenames, the following program was written to give files in their respective directories similar names according to a convention. For those who may be just starting out with programming and have a similar objective, this recipe may help show some of what may be involved in the process.</p> File Path Logger (Python) 2012-12-05T20:59:38-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578358-file-path-logger/ <p style="color: grey"> Python recipe 578358 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>If you want a list of directories and the files they contain, this program will log such information to a file for you. For those wondering how to walk directories and their contents, this little recipe provides an <code>engine</code> function that provides a simple demonstration of the <code>os.walk</code> function.</p> Directory Cleaner (Python) 2012-12-05T20:56:05-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578357-directory-cleaner/ <p style="color: grey"> Python recipe 578357 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>If there is a particular directory that you want purged of its files and want a solution in Python, this simple program is designed to do just that. This recipe is just meant as a starting point for those wondering how to delete all files and sub-folders from a central folder.</p> Markov Encryption Demonstration 2 (Python) 2012-03-14T17:39:17-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578076-markov-encryption-demonstration-2/ <p style="color: grey"> Python recipe 578076 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/encode/">encode</a>, <a href="/recipes/tags/encoding/">encoding</a>, <a href="/recipes/tags/encrypt/">encrypt</a>, <a href="/recipes/tags/encryption/">encryption</a>). </p> <p>This program is meant to act as an example of how to use ME with data that needs to be obfuscated. The functionality provided via the GUI demonstrates both the ability to encrypt and decrypt all text that the UTF-8 encoding can handle. Explanations come later.</p> Markov Encryption Demonstration 1 (Python) 2012-03-16T18:59:06-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578062-markov-encryption-demonstration-1/ <p style="color: grey"> Python recipe 578062 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/encode/">encode</a>, <a href="/recipes/tags/encoding/">encoding</a>, <a href="/recipes/tags/encrypt/">encrypt</a>, <a href="/recipes/tags/encryption/">encryption</a>). </p> <p>This is a simple GUI program that shows Markov Encryption at work. It is built to be interactive and has all needed code embedded within itself. This version of ME library is not very efficient and represents an early attempt at developing and easily testing the code. Certain limits are built into the program, and the code is not meant to be robust at this stage. This program is a proof-of-concept design meant to ensure that the work being done was viable for future use and that the encryption process could be carried out both ways, both in encoding plaintext and decoding ciphertext.</p> Morse Code (Python) 2012-01-12T23:45:12-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578012-morse-code/ <p style="color: grey"> Python recipe 578012 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/example/">example</a>, <a href="/recipes/tags/experiment/">experiment</a>, <a href="/recipes/tags/morse/">morse</a>, <a href="/recipes/tags/morse_code/">morse_code</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/sound/">sound</a>). Revision 3. </p> <p>After seeing another recipe recently that helps people with Morse Code, I was inspired to clean up the following code just a bit to make it worthy for the rest of the world. After being executed, it waits for lines of text to be entered, compiles each one in turn into timing codes, and plays them back with a simple execution</p> Pendulum Simulation with Turtle (Python) 2011-01-27T22:59:54-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577553-pendulum-simulation-with-turtle/ <p style="color: grey"> Python recipe 577553 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/simulation/">simulation</a>, <a href="/recipes/tags/turtle/">turtle</a>). </p> <p>This program was written per R.T.Giles's second assignment in 10COF180 (November 25, 2010). A student under his instruction wanted help writing a program, and while not required, a GUI was placed on the program's output to visually demonstrate what was taking place within the program. The recipe below provides a simple simulation of a undamped pendulum and produces a visual representation for about thirty seconds. The code could be greatly improved but gives a demonstration of what a few turtle commands can do in Python. Very little code must be written to produce graphics on the computer screen.</p>