|
|
|
CST 1794 | Assignments | Stuff you will need for this course | Course list
|
Introduction to Programming Project Tasks |
||||||||||||||||||||||||||||
Date Assigned |
D2L DropBox |
Competency |
Task Description |
BooBooBoo | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Learned thus Far | import modules. Define objects, such as turtles and screens. Draw geometric figures in tutle. Use a For Loop. Define a function. Obtain a random number. Pass arguments to a function. Have a function return values. if elif else a=a+1 (that = is an assignement operator, not an equal sign like in math). while loop
input function. Cannot perform math operation on string values. Int() function. Float() function.
local versus global scope |
|||||||||||||||||||||||||||
| GetHeadset | Obtain a headset for your PC (USB is best). | |||||||||||||||||||||||||||
| Get TextBook | A Byte of Python | |||||||||||||||||||||||||||
| Publish photo of yourself to D2L. | ||||||||||||||||||||||||||||
| Drop a test text file into the "TestProg" dropbox. |
||||||||||||||||||||||||||||
| 1/10 | Install Python | Install Python 3.2 programming language. | ABOP:Chapters 3 &4. | |||||||||||||||||||||||||
| 1/10 | Idle Editor, print command. Interactive mode. Batch mode |
Use Idle to create "Hello World" program. | ABOP: Chapter 5. | |||||||||||||||||||||||||
| 1/10 | Import Modules command syntax |
Draw a square using Python Turtle Graphics. | ABOP: Chapter 10. | |||||||||||||||||||||||||
| 1/10 | Draw a triangle using Python Turtle Graphics (PTG). | |||||||||||||||||||||||||||
| 1/10 | Draw a hexagon, an octagon. | |||||||||||||||||||||||||||
| Draw a circle. | ||||||||||||||||||||||||||||
| 1/10 | Shapes | lastname.shapes.py | Draw a square, a triangle, a hexagon, and an octagon in a file named lastnameShapes.py Upload the file to D2L dropbox. |
|||||||||||||||||||||||||
| 1/17 | firstFunctions | lastname.firstfunctions.py | Create a program in which you define a function to draw a square and another function to draw a triangle. Call both functions, lift the pen up, reposition the turtle, call both functions a second time. |
|
||||||||||||||||||||||||
| 1/24 | lastnameRandomArt1 | Run a loop 20 times. Each time through the loop, randomly reposition the turtle, then draw an octagon, then randomly reposition again, then draw a square. | ||||||||||||||||||||||||||
| review4 | review4: create a turtle program. define a function which draws a hexagon . Define a function whch draws a 36 sided polygon. call those two functions 20 times. Between each time you call the functions, randomly reposition the turtle on the screen, so that the figures are drawn all over the screen. |
|||||||||||||||||||||||||||
| id statement execution sequence in firstfunctions. | ||||||||||||||||||||||||||||
| 1/31 | LastNameDrawTriangles.py | This program demonstrates the use of passing input data to a function. It also demonstrates the use of nested For loops. | Create a program named lastNamedrawTriangles.py. This program calls a function named drawTriangles. When you call the function, you pass it values to specifiy the size of the triangles being drawn, and the number of degrees to rotate between each drawing of a triangle. The function draws a triangle, rotates a few degrees, draws a new triangle, and so on, until a complete 360 degree figure has been drawn. THe pen should have color and a thcker size than default.
|
|||||||||||||||||||||||||
| 2/7 | Review5(there will be a dropbox during class next week. | Define a function which calculates miles per gallon. When you call the function, you pass it the number of miles driven, and the number of gallons burned. The function will calculate mpg , and then return mpg.
Your program will then print out the mpg. Save the file as "lastnameReview5.py". |
||||||||||||||||||||||||||
| 2/14 | Review6 | lastnameReview6.py | Write a program with the following functions:
f1noInputNoOutput() When you call this function, the function prints out your name. You don't pass the function any input parameters. The function doesn't return anything. THe printing takes place within the function.
f2inputNoOutput() When you call this function, the function prints out your name. You pass the function one input parameter, you last name. . The function doesn't return anything. THe printing takes place within the function.
f3noInputOutput() When you call this function, you don't pass it any input parameters. The function returns your name. You then print out the name. THe print statement executes outside the funciton.
f4InputOutput() When you call this function, you pass it two parameters, gallons used, and miles driven. The function calculates mpg, and returns that value. Your program prints out mpg after receiving that data from the function.
|
|||||||||||||||||||||||||
| 2/21 | lastnameMoreTurtle | Forget about functions. For now. This program will use your skills with the For Loop, variables, variables used as counters, and x and y coordinates. Draw a line from (-400,0) to (400,0). Move the pen to -400,30. Draw a line from (-400,30 to (400,30). More the pen to -400,60. Draw a line to 400,60. Redo the code to use x and y variables, so your goto statements use those x and y coordinates. Repeat for 10 times, using a for loop. Modify the program so that the pen gets thicker for each new line.
Once that works, modify the program so that program clears the screen once it is done drawing all the lines and then repeats the whole drawing over. It does this for 10 times. Once that works, modify the program so that it runs indefinitely. Replace the outer for loop with a while loop. Once that works, modify the program so that the first line only is drawn from -100 to 100, the second line from -110 to 110, the third line from -120 to 120, etc.
After that, modify any way you with color, etc. to make it way cooler. |
||||||||||||||||||||||||||
| 2/21 | For those that are struggling,
Read chapters 1, 2, 3 from http://cs.simpson.edu/files/CS_Intro_Book.pdf
|
|||||||||||||||||||||||||||
assign random interger numbers from the range -500 to 500 to the following variables: x1,y1,x2,y2,x3,y3, up to x10,y10. Now draw lines from (x1,y1) to (x2,y2). Then from (x2,y2) to (x3,y3). etc. What beautiful art you will create. |
||||||||||||||||||||||||||||
| 2/23 | lastnameTypeConvert.py | Use input function to request the user to input miles and gallons. Convert miles and gallons from string variables to floating point numbers. Calculate mpg. Print mpg. |
||||||||||||||||||||||||||
| 2/23 | lastnameReview1.7.py | answer (with comment symbols) or perform the code for questions 1 through 6 from review 1.7 page 20 from csIntroPythonGames.pdf.
http://cs.simpson.edu/files/CS_Intro_Book.pdf |
||||||||||||||||||||||||||
| 2/28 | lastnameStopLights.py | Write a program which makes a blinking red circle. Use Turtle. There are turtle methods to make turtles shaped like a circle, a larger size, a red color, invisible or visible.
use the time.sleep() function (you will have to import the time module.
Modify this to add red and yellow lights, so that you have a functional stop light.
Then add the other side of the stop light. So that when the light is green on one light, it is red on the other. Etc. |
||||||||||||||||||||||||||
| 3/1 | lastnameinputReview.py | Write a program which asks the user the following questions: ComputerSupport,Networking,PWhat is your major?(automation,rogramming) The program stores the answer as a variable. Then the program asks: What is your degree type?( AAS, Diploma) THe program stores the answer as a variable. THe program then asks (Enter your name). THe program then responds with: "Hello" username. "You are pursuing a " degree degree type.
|
||||||||||||||||||||||||||
| 3/1 | lastnameAgeinSeconds | Calculate the user's age in seconds: Prompt the user to enter his name. Greet the user by name, and then prompt him to enter his age (in years). If the use enters an age less than 21, inform the user that he cannot drink beer legally.
Convert the users age in years to age in seconds. (years * days*hours*minutes*seconds). Inform the user how old he is in seconds.
|
||||||||||||||||||||||||||
| 3/1 | lastnameForLoop | Write a program which prints numbers from 1 to 30. Use a For loop. | ||||||||||||||||||||||||||
| 3/1 | lastnameWhileLoop | Write a program which prints numbers from 1 to 30. Use a While Loop. | ||||||||||||||||||||||||||
| 3/1 | Bouncing Turtle | Use a for loop to move the turtle for a long time. Use the if statement to check if the turtle moves past 300, or -300 (x position). i When turtle passes one of those positions, flip the turtle 180degreess so he will move the other direction. THe turtle should move back and forth continuously. Find the command to change the shape of the turtle. Change the shape.
Replace the for loop with a while loop so it can run foreever.. |
You will use the if statement, and the turtle.xcor() function. Also t1.left(190) to flip the turtle. |
|||||||||||||||||||||||||
| 3/15 | ScratchHomework | Install Scratch. Download Scratch Getting started pdf file. Find a child. Age 6-16. Help them create a fun scratch program.
|
||||||||||||||||||||||||||
| 4/15 | GPSTractor | Write a program which creates a turtle called tractor. Change the shape of the turtle to be a circle Code the tractor to leave a thick brown pen trail behind itself as it moves. The turtle screen is the "field". Program the turtle to move about the field until the field is entirely plowed, that is to say, until the screen is completely brown.
|
||||||||||||||||||||||||||
| 3/22 | lastnameAllenVB1.py | Exercise 3.9 Console (10 points)
Write an application that inputs from the user the radius of a circle and prints the circle's diameter, circumference, and area. Use the following formulas (r is the radius): diameter = 2r |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| 3/22 | allenVB2 | Exercise 7.6 (10 points)
Rock, scissors, paper game in its original form, each of the two players simultaneously chooses one of rock, scissors, or paper. Rock beats scissors, paper beats rock, and scissors beats paper. If both players choose the same, it is a draw. Write a program to play the game . The player is presented with a menu: 1 = rock 2= paper 3 = scissors. THe player is asked to input 1,2 or 3..
The computer makes its choice randomly using the random number generator. The computer also decides and displays who has won. THe program should display the choice of the computer. Make the program run in a loop so that the program will replay rock paper scissors 5 times before it ends.
Now change the program so it will replay forever.
Now change the program so it will replay until the user enters 99 instead of 1, 2, or 3. If you cant get this I will show you next week.
hint: use while us != 99: .........alb
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| 3/22 | alllenTempConv |
Exercise TemperatureConversions EC Extra credit (10 points)
Write a program which asks the user to enter a temperature in Farenheit. The program converts the temp into celsius, and prints out the result.
Save the program as lastnameAllentTempConv.py. Upload to dropbox.
Hint: Celsius = 5/9 * (Fahrenheit - 32) |
||||||||||||||||||||||||||
| Tues class 3 /27 ended at page 15 of book | ||||||||||||||||||||||||||||
| 4/10 | SentenceGenerator | Exercise SentenceGeneration (10 points) Write a program that uses random number generation to create sentences. Use four lists of Strings called article, noun, verb and preposition. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. As each word is picked, concatenate it to the previous words in the the sentence. The words should be separated by spaces. When the sentence is output,it should end with a period. The program should generate and print 20 sentences. :You probably will need to review the chapter on lists
Hint: One car jumped on the dog. Try to capitalize first letter of each sentence. |
||||||||||||||||||||||||||
| http://inventwithpython.com/ | ||||||||||||||||||||||||||||
| 3/29 | We will go through chapters 2 through 6 in the inventwithpython book (prior line). You should read ahead for class next week. | |||||||||||||||||||||||||||
| 4/3 | variableNames.txt | Create a list of examples of legal and illegal variable names. Describe why they are illegal. Next, write down several good legal variable names, and bad legal variable names. |
||||||||||||||||||||||||||
| 4/3 | favoriteFoods.py | Write a program that allows a user to enter his or her two favorites foods. THe program should print out the name of a new food by joining together these two food names. | ||||||||||||||||||||||||||
| 4/3 | Tipper.py | Write a tipper program where the user enters a restaurant total bill. THe program displays two amounts, a 15 per cent tip and a 20 per cent tip. | ||||||||||||||||||||||||||
| 4/3 | CarPrice.py | Write a Car salesman program where user enters the base price of a car. The program should add on a bunch of extra fees such as tax, license, dealer prep, destination charge. The other fees should be values. Display the final price once the extras are applied. |
||||||||||||||||||||||||||
| 4/12 | GuessTheNumber.Py | Write the Guess the number program from Chapter 4.:
|
||||||||||||||||||||||||||
| 4/17 | dragon.py | Write the Dragon Realm program from Chapter 6: | ||||||||||||||||||||||||||
Tuesday 4/3 ends here. prior 3 programs were assigned for homework. Ended at "guess program in book.
|
||||||||||||||||||||||||||||
| 4/17 | Read the inventWithPython.com chapter 6 "dragonRealm". | |||||||||||||||||||||||||||
| 4/24 | listsOfLists | |||||||||||||||||||||||||||
| 5/1 | RobotCProgram | Screen shot showing the code from your robotcProgram. | ||||||||||||||||||||||||||
| Write a program that simulates a fortune cookie. The program should display one of five unique fortunes, at random, each time it's run. | ||||||||||||||||||||||||||||
| Write a program that flips a coin 100 times and then tells you the number of heads and tails. | ||||||||||||||||||||||||||||
| Write a program that counts for the user. Let the user enter the starting number , the ending number, and the amount by which to count. | ||||||||||||||||||||||||||||
| Create a program that gets a message from the user and then prints it out backwards. | ||||||||||||||||||||||||||||
| ************************** | disregard everything | below this line**************************************** | ||||||||||||||||||||||||||
| Read Chapter 2 | ||||||||||||||||||||||||||||
Chapter 2 Exercises:
|
||||||||||||||||||||||||||||
| Review the if statement | ||||||||||||||||||||||||||||
| modify the previous DrawTriangles program so that the DrawTriangles function calls a seperate DrawTriangle Function. | ||||||||||||||||||||||||||||
| Write a function which accepts no input , returns no output. | E.g. drawSquare() | |||||||||||||||||||||||||||
| Write a function which accepts input, but returns no output. | drawSquare(size) | |||||||||||||||||||||||||||
Write a function which accepts no input, but returns output. |
drawSquare() returns area |
|||||||||||||||||||||||||||
| Write a function which accepts input, and returns output. | drawSquare(size) returns area |
|||||||||||||||||||||||||||
Use a for loop to move the turtle for a long time. Use the if statement to check if the turtle moves past 300, or -300. i When turtle passes one of those positions, flip the turtle 180degreess so he will move the other direction. THe turtle should move back and forth continuously. Find the command to change the shape of the turtle. Change the shape.
Replace the for loop with a while loop. |
You will use the if statement, and the turtle.xcor() function. Also t1.left(190) to flip the turtle. |
|||||||||||||||||||||||||||
Create a screen called field. Create a turtle called tractor.
Modify tractor to look like a big red or green turtle. Paint the field green. Widen the pen, and program the tractor to plow the field. Create 2 versions of this program. 1 plows the field using coordinate geometry, the other using Turtle Geometry (i.e. Euclidian). |
||||||||||||||||||||||||||||
| Python Docs | Play the maze game. Program the maze through a file. |
|||||||||||||||||||||||||||
| Finding&using Functions. | Change color and width of lines. | |||||||||||||||||||||||||||
| Finding &usingFunctions. | Draw a dashed line. | |||||||||||||||||||||||||||
| Get assignment here from Amy Jo. | ||||||||||||||||||||||||||||
| For Loop | Redraw the shapes using a for loop. | ABOP: Chapter 8. | ||||||||||||||||||||||||||
| variagle assignment | Create variables to store first name, last name, age. Then Display. |
|||||||||||||||||||||||||||
| Create variables to store number of degrees for turtle to turn, and number of steps to take. Draw shapes. | ||||||||||||||||||||||||||||
| Redraw shapes using degrees and distance variables. | ||||||||||||||||||||||||||||
| Draw multiple squares. | ||||||||||||||||||||||||||||
| Functions | Define a function for drawing a square. Use it to draw multiple squares. | |||||||||||||||||||||||||||
| Define functions for drawing triangle, circle, octagon, pentagon, hexagon. | ||||||||||||||||||||||||||||
| Define 1 function which can draw any kind of shape. | ||||||||||||||||||||||||||||
Contrast Coordinate Geometry versus Euclidian Geometry. Draw a square using Eucldian, and then using Coordinate Geometry. Relate to GPS versus regular directions.
|
||||||||||||||||||||||||||||
Create a screen called field. Create a turtle called tractor.
Modify tractor to look like a big red or green turtle. Paint the field green. Widen the pen, and program the tractor to plow the field. Create 2 versions of this program. 1 plows the field using coordinate geometry, the other using Turtle Geometry (i.e. Euclidian). |
||||||||||||||||||||||||||||
Review Program: using turtle module, change width and color of pen. Pen is raised and lowered. turtle is modified. Screen background is modified. Variables are defined. Functions are defined and use variables. Coordinate Geometry and Turtle Geometry is used. |
||||||||||||||||||||||||||||
| Write a function which accepts no input , returns no output. | ||||||||||||||||||||||||||||
| Write a function which accepts input, but returns no output. | ||||||||||||||||||||||||||||
Write a function which accepts no input, but returns output. |
||||||||||||||||||||||||||||
| Write a function which accepts input, and returns output. | ||||||||||||||||||||||||||||
| variables, assignment | Assign x and y variables to indicate the position of the turtle. Move the turtle and reprint the variables. Show the need to update the variable assignments. | |||||||||||||||||||||||||||
variables, values, expressions, data types. Evaluating expressions. shell versus program file. |
||||||||||||||||||||||||||||
| input function. Print function. Escape codes. | ||||||||||||||||||||||||||||
| Converting between data types. | ||||||||||||||||||||||||||||
| Math. Order of operations. Math and data types. | ||||||||||||||||||||||||||||
| String Concatenation. | ||||||||||||||||||||||||||||
random.randint() function. functions that return a value versus those that don't.
|
||||||||||||||||||||||||||||
| passing arguments to functions. | ||||||||||||||||||||||||||||
| Boolean data type,. | ||||||||||||||||||||||||||||
| Comparison operators and conditions. | ||||||||||||||||||||||||||||
| If statements. | ||||||||||||||||||||||||||||
| While Loops. | ||||||||||||||||||||||||||||
| Break statement. | ||||||||||||||||||||||||||||
| If Else | ||||||||||||||||||||||||||||
| If Elif Else | ||||||||||||||||||||||||||||
| Defining functions with the Def statement. | ||||||||||||||||||||||||||||
| LISTS | ||||||||||||||||||||||||||||
import modules. Define objects, such as turtles and screens. Draw geometric figures in tutle. Use a For Loop. Define a function. Obtain a random number. Pass arguments to a function. Have a function return values. if elif else a=a+1 (that = is an assignement operator, not an equal sign like in math). while loop
input function. Cannot perform math operation on string values. Int() function. Float() function. |
||||||||||||||||||||||||||||