TWiki> CS111 Web>WebLeftBar>NotesS18>CodeS18 (revision 23)EditAttach

CS 111 - Spring 2018

Sample Code

Note that this wiki attaches the Python programs as text files. You will need to change the filenames after downloaded to remove the .txt extension, or just cut and paste from the web page.

Sound Manipulation Code:

• lect0424d.py.txt - Code to create a sine wave for a given frequency
• lect0424c.py.txt - Code to determine the frequency based on a character input for Project 4
• lect0424b.py.txt - Code to decrease the pitch of a sound (cut it in half)
• lect0424a.py.txt - Code to increase the pitch of a sound (double the pitch)
• lect0419d.py.txt - Joins two sounds together so they play in sequence
• lect0419c.py.txt - Creates a "sound byte" from an existing sound
• lect0419b.py.txt - Copies a sound
• lect0419a.py.txt - Repeating a sound X times (where X doesn't need to be an integer) - uses repeated subtraction to determine the remainder from integer division
• lect0417c.py.txt - Repeating a sound X times (where X doesn't need to be an integer) - uses the modulas operator, %, in calculation to determine remainder from integer division
• lect0417b.py.txt - Repeating a sound X times (where X must be an integer)
• lect0417a.py.txt - Maximizing the volume of a sound without losing any information - "Normalizing" the sound's volume
• lect0412c.py.txt - Function to Blend two sounds together (play at same time)
• lect0412b.py.txt - Function to Fade-in a sound
• lect0412a.py.txt - Same code as lect0403b.py but using a FOR LOOP
• lect0403b.py.txt - Function to double the "volume" of a sound
• lect0403a.py.txt - Select a sound file (.wav) from the computer and play it
Picture Manipulation Code:
Turtle Drawing Code
• lect02013d.py.txt - Function to draw arc where turtle is returned to original starting position before arc is drawn.
• lect02013c.py.txt - Function to draw star of a given color, where pen color is restored to original pen color. Change to the pen is localized to the function
• lect02013b.py.txt - Function to draw star of a given color, but pen color extends outside of the function
• lect02013a.py.txt - Functions to the draw star and draw circle
• lect0208g.py.txt - Adding more circles to the design from lect0208f.py
• lect0208f.py.txt - Using the loop Counter variable to change to size of the circles drawn and the color of the circles drawn
• lect0208e.py.txt - Drawing multiple circles across the world using a loop
• lect0208d.py.txt - Drawing multiple circles highlighting the difference between the 2 different "reposition Turtle" functions
• lect0208c.py.txt - Drawing multiple circles showing similarities between the 2 different "reposition turtle" functions
• lect0208b.py.txt - Moving the code to reposition a turtle into a function, making main() easier to read
• lect0208a.py.txt - Drawing two circles with the reposition code between the two function calls
• lect0206d.py.txt - Code drawing multiple Circles and multiple hexagons
• lect0206c.py.txt - Code to draw multiple "Circles" - each circle is a 30 sided polygon
• lect0206b.py.txt - Code to draw multiple Octagons using a function
• lect0206a.py.txt - Code that opens a picture on the computer, draws on it, displays it, then saves the updated picture back on the computer
• lect0201h.py.txt - Code showing how to draw on a picture rather than a world
• lect0201f.py.txt - Drawing multiple hexagons of different sizes
• lect0201e.py.txt - Drawing multiple hexagon spun around from a central point
• lect0201d.py.txt - Modifying lect0201a.py to call the drawHex function
• lect0201c.py.txt - Modifying the drawHex function to include a length parameter
• lect0201b.py.txt - Drawing two hexagons using on "drawHex" functions
• lect0201a.py.txt - Drawing multiple hexagons with one loop nesting inside another loop
• lect0130d.py.txt - Drawing two hexagons using loops
• lect0130c.py.txt - Drawing a blue square without a loop, drawing a red hexagon with a loop
• lect0130b.py.txt - Drawing a blue square and a red hexagon
• lect0130a.py.txt - Drawing a blue square and a red triangle
• lect0125d.py.txt - Drawing 2 squares of different colors
• lect0125c.py.txt - Showing the difference in syntax between FUNCTIONS and METHODS
• lect0125b.py.txt - Drawing 2 squares using Turtles
• lect0125a.py.txt - Draw a square using a Turtle
General Python Code
Topic attachments
I Attachment Action Size Date Who Comment
jpg batmanGreenScreen.jpg manage 12.1 K 2018-03-22 - 19:42 UnknownUser
jpg blue-mark.jpg manage 59.7 K 2018-03-22 - 19:42 UnknownUser
jpg jenny-red.jpg manage 94.4 K 2018-03-06 - 17:35 UnknownUser
txt lect0118a.py.txt manage 0.1 K 2018-02-01 - 21:08 UnknownUser
txt lect0118b.py.txt manage 0.6 K 2018-01-19 - 02:02 UnknownUser
txt lect0125a.py.txt manage 0.3 K 2018-01-25 - 18:44 UnknownUser
txt lect0125b.py.txt manage 0.6 K 2018-01-25 - 18:44 UnknownUser
txt lect0125c.py.txt manage 0.7 K 2018-01-25 - 18:44 UnknownUser
txt lect0125d.py.txt manage 0.8 K 2018-01-25 - 18:44 UnknownUser
txt lect0130a.py.txt manage 0.8 K 2018-01-30 - 18:01 UnknownUser
txt lect0130b.py.txt manage 1.0 K 2018-01-30 - 18:01 UnknownUser
txt lect0130c.py.txt manage 0.9 K 2018-01-30 - 18:01 UnknownUser
txt lect0130d.py.txt manage 1.0 K 2018-01-30 - 18:01 UnknownUser
txt lect02013a.py.txt manage 2.3 K 2018-02-13 - 19:58 UnknownUser
txt lect02013b.py.txt manage 2.3 K 2018-02-13 - 19:58 UnknownUser
txt lect02013c.py.txt manage 2.6 K 2018-02-13 - 19:58 UnknownUser
txt lect02013d.py.txt manage 3.2 K 2018-02-13 - 19:58 UnknownUser
txt lect02015a.py.txt manage 0.6 K 2018-02-15 - 17:51 UnknownUser
txt lect0201a.py.txt manage 0.9 K 2018-02-01 - 21:09 UnknownUser
txt lect0201b.py.txt manage 0.8 K 2018-02-01 - 21:11 UnknownUser
txt lect0201c.py.txt manage 0.8 K 2018-02-01 - 21:11 UnknownUser
txt lect0201d.py.txt manage 0.9 K 2018-02-01 - 21:13 UnknownUser
txt lect0201e.py.txt manage 0.8 K 2018-02-01 - 21:17 UnknownUser
txt lect0201f.py.txt manage 0.8 K 2018-02-01 - 21:17 UnknownUser
txt lect0201h.py.txt manage 0.5 K 2018-02-04 - 23:31 UnknownUser
txt lect0206a.py.txt manage 0.7 K 2018-02-06 - 17:43 UnknownUser
txt lect0206b.py.txt manage 1.1 K 2018-02-06 - 17:43 UnknownUser
txt lect0206c.py.txt manage 1.7 K 2018-02-06 - 17:43 UnknownUser
txt lect0206d.py.txt manage 1.9 K 2018-02-06 - 17:43 UnknownUser
txt lect0208a.py.txt manage 1.9 K 2018-02-08 - 17:42 UnknownUser
txt lect0208b.py.txt manage 2.5 K 2018-02-08 - 17:42 UnknownUser
txt lect0208c.py.txt manage 3.2 K 2018-02-08 - 17:43 UnknownUser
txt lect0208d.py.txt manage 3.3 K 2018-02-08 - 17:43 UnknownUser
txt lect0208e.py.txt manage 2.8 K 2018-02-08 - 17:43 UnknownUser
txt lect0208f.py.txt manage 2.9 K 2018-02-08 - 17:43 UnknownUser
txt lect0208g.py.txt manage 2.9 K 2018-02-08 - 17:43 UnknownUser
txt lect0220a.py.txt manage 0.8 K 2018-02-20 - 18:42 UnknownUser
txt lect0220b.py.txt manage 0.9 K 2018-02-20 - 18:42 UnknownUser
txt lect0220c.py.txt manage 0.9 K 2018-02-20 - 18:42 UnknownUser
txt lect0220d.py.txt manage 1.2 K 2018-02-20 - 18:42 UnknownUser
txt lect0227a.py.txt manage 1.2 K 2018-03-02 - 15:50 UnknownUser
txt lect0227b.py.txt manage 1.1 K 2018-03-02 - 15:50 UnknownUser
txt lect0227c.py.txt manage 1.1 K 2018-03-02 - 15:50 UnknownUser
txt lect0227d.py.txt manage 1.1 K 2018-03-02 - 15:51 UnknownUser
txt lect0227e.py.txt manage 1.2 K 2018-03-02 - 15:51 UnknownUser
txt lect0301a.py.txt manage 1.4 K 2018-03-02 - 15:51 UnknownUser
txt lect0301b.py.txt manage 1.4 K 2018-03-02 - 15:51 UnknownUser
txt lect0301c.py.txt manage 1.8 K 2018-03-02 - 15:51 UnknownUser
txt lect0301d.py.txt manage 1.8 K 2018-03-02 - 15:51 UnknownUser
txt lect0301e.py.txt manage 1.9 K 2018-03-02 - 15:51 UnknownUser
txt lect0306a.py.txt manage 1.0 K 2018-03-06 - 17:34 UnknownUser
txt lect0306b.py.txt manage 1.2 K 2018-03-06 - 17:34 UnknownUser
txt lect0306c.py.txt manage 1.2 K 2018-03-06 - 17:34 UnknownUser
txt lect0306d.py.txt manage 1.3 K 2018-03-06 - 17:34 UnknownUser
txt lect0306e.py.txt manage 1.4 K 2018-03-06 - 17:35 UnknownUser
txt lect0308a.py.txt manage 0.5 K 2018-03-08 - 18:43 UnknownUser
txt lect0308b.py.txt manage 1.6 K 2018-03-08 - 18:43 UnknownUser
txt lect0308c.py.txt manage 1.1 K 2018-03-08 - 18:43 UnknownUser
txt lect0308d.py.txt manage 1.2 K 2018-03-08 - 18:43 UnknownUser
txt lect0313a.py.txt manage 1.2 K 2018-03-13 - 16:12 UnknownUser
txt lect0313b.py.txt manage 1.2 K 2018-03-13 - 16:12 UnknownUser
txt lect0313c.py.txt manage 1.2 K 2018-03-13 - 16:12 UnknownUser
txt lect0313d.py.txt manage 1.3 K 2018-03-13 - 16:12 UnknownUser
txt lect0315a.py.txt manage 1.3 K 2018-03-16 - 17:41 UnknownUser
txt lect0315b.py.txt manage 1.5 K 2018-03-16 - 17:41 UnknownUser
txt lect0315c.py.txt manage 1.5 K 2018-03-16 - 17:41 UnknownUser
txt lect0315d.py.txt manage 1.1 K 2018-03-16 - 17:41 UnknownUser
txt lect0315e.py.txt manage 1.7 K 2018-03-16 - 17:41 UnknownUser
txt lect0315f.py.txt manage 1.2 K 2018-03-16 - 17:41 UnknownUser
txt lect0320a.py.txt manage 1.4 K 2018-03-22 - 19:29 UnknownUser
txt lect0320b.py.txt manage 0.2 K 2018-03-22 - 19:28 UnknownUser
txt lect0320c.py.txt manage 1.4 K 2018-03-22 - 19:28 UnknownUser
txt lect0320d.py.txt manage 1.6 K 2018-03-22 - 19:28 UnknownUser
txt lect0320e.py.txt manage 2.2 K 2018-03-22 - 19:28 UnknownUser
txt lect0322a.py.txt manage 2.2 K 2018-03-22 - 19:28 UnknownUser
txt lect0322b.py.txt manage 2.5 K 2018-03-22 - 19:28 UnknownUser
txt lect0322c.py.txt manage 2.3 K 2018-03-22 - 19:28 UnknownUser
txt lect0322d.py.txt manage 2.3 K 2018-03-22 - 19:28 UnknownUser
txt lect0322e.py.txt manage 2.4 K 2018-03-22 - 19:27 UnknownUser
txt lect0322f.py.txt manage 1.4 K 2018-03-22 - 19:27 UnknownUser
txt lect0322g.py.txt manage 1.7 K 2018-03-22 - 19:27 UnknownUser
txt lect0322h.py.txt manage 1.3 K 2018-03-22 - 19:27 UnknownUser
txt lect0403a.py.txt manage 0.2 K 2018-04-05 - 14:36 UnknownUser
txt lect0403b.py.txt manage 0.7 K 2018-04-05 - 14:36 UnknownUser
txt lect0412a.py.txt manage 0.6 K 2018-04-12 - 20:37 UnknownUser
txt lect0412b.py.txt manage 1.0 K 2018-04-12 - 20:37 UnknownUser
txt lect0412c.py.txt manage 0.9 K 2018-04-12 - 20:37 UnknownUser
txt lect0417a.py.txt manage 1.1 K 2018-04-17 - 20:27 UnknownUser
txt lect0417b.py.txt manage 1.0 K 2018-04-17 - 20:27 UnknownUser
txt lect0417c.py.txt manage 0.9 K 2018-04-17 - 20:27 UnknownUser
txt lect0419a.py.txt manage 0.9 K 2018-04-19 - 16:03 UnknownUser
txt lect0419b.py.txt manage 1.1 K 2018-04-19 - 16:03 UnknownUser
txt lect0419c.py.txt manage 1.4 K 2018-04-19 - 16:03 UnknownUser
txt lect0419d.py.txt manage 1.8 K 2018-04-19 - 16:03 UnknownUser
txt lect0424a.py.txt manage 1.1 K 2018-04-24 - 17:27 UnknownUser
txt lect0424b.py.txt manage 1.4 K 2018-04-24 - 17:27 UnknownUser
txt lect0424c.py.txt manage 0.7 K 2018-04-24 - 17:27 UnknownUser
txt lect0424d.py.txt manage 0.9 K 2018-04-24 - 17:27 UnknownUser
txt template.py.txt manage 0.5 K 2018-01-19 - 02:02 UnknownUser
Edit | Attach | Print version |  | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r23 - 2018-04-24 - 17:31:23 - Main.troy

 Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu WISESTHelping Women Faculty AdvanceFunded by NSF