Create a program that takes input from the user and converts it into a list with a string for each word in the input.
The program should then print each word on a separate line in reverse order.
Next the program asks for a single word.
Check to see if this new word occurred in the original list of words. Print a message telling whether the word given was valid or not.
Now join all the words from the original input with an underscore between them and print that string.
Thursday, March 01, 2007
Wednesday, February 07, 2007
Fruitful Functions
You need to create a program that calculates the Area of any given shape.
The program should give the user a list of possible shapes:
Rectangle, Parallelogram, Triangle, Circle, Square, and Trapezoid.
Then you will need to ask for the dimensions of the figure and calculate the area.
You should create functions for each of the different shapes. These functions should have parameters for each of the dimensions of that shape.
We will be talking about the process for each of these things at the beginning of class.
The program should give the user a list of possible shapes:
Rectangle, Parallelogram, Triangle, Circle, Square, and Trapezoid.
Then you will need to ask for the dimensions of the figure and calculate the area.
You should create functions for each of the different shapes. These functions should have parameters for each of the dimensions of that shape.
We will be talking about the process for each of these things at the beginning of class.
Friday, February 02, 2007
Programming Assignment #1
Splash Screen
For your assignment today I'd like you to create a program that prints a splash screen (welcome screen). It should be at least 12 lines, though it can also include a couple blank lines. Try to make this welcome screen somewhat graphical and not just text (use symbols to draw it).
A splash screen is what appears on the screen as the computer loads a program. It should be a few strings that all appear at the same time. This can be done either with a multi-line string, or with multiple print statements.
For your assignment today I'd like you to create a program that prints a splash screen (welcome screen). It should be at least 12 lines, though it can also include a couple blank lines. Try to make this welcome screen somewhat graphical and not just text (use symbols to draw it).
A splash screen is what appears on the screen as the computer loads a program. It should be a few strings that all appear at the same time. This can be done either with a multi-line string, or with multiple print statements.
Friday, January 19, 2007
Circumnavigation
Today you should be finishing Step 13. Guido is supposed to circumnavigate a rectangle, then an irregular polygon. Both of these should be done with a while loop that is looking for Guido's starting location (a beeper that he drops at the beginning). They should take about 8 and about 12 lines respectively. When you are done with the irregular polygon talk to Travis have him make sure you are doing it properly, then you can move on to Step 14.
Don't forget to post to your blog!
Don't forget to post to your blog!
Monday, January 15, 2007
Guido's Birthday
To celebrate his 18th birthday Guido displays 10010 (18 in binary). We are going to attempt a race to see who can tell Guido to display '1010000110110' in the most efficient way.
Guido cleans the street. He should be able to clean the street with the same program even with different amounts of garbage. I will give you a couple of different worlds to work with and clean.
Community Service
Guido cleans the street. He should be able to clean the street with the same program even with different amounts of garbage. I will give you a couple of different worlds to work with and clean.
Tuesday, January 02, 2007
Welcome to Computer Programming!
Welcome to class! Computer Programming will be a great time to learn. We will be learning new problem solving techniques and new ways to look at problems. We will also be learning a new language with its own grammar and syntax. We will have a lot of fun, and be challenged in many ways!
Course Syllabus
- Content
- How to Think Like a Computer Scientist
- http://www.ibiblio.org/obp/thinkCS/python/english/index.htm
- by Allen B. Downey, Jeffrey Elkner and Chris Meyers
- A Byte of Python
- http://www.byteofpython.info/read/
- Swaroop C H
- Prerequisites
- Keyboarding class (or ability to type 25 wpm)
- Computer Applications
- Algebra 1 & Geometry
- Course Goals
- To learn the concepts and methodologies of structured computer programming.
- To become familiar with Python.
- To analyze problems and learn to think like a computer programmer.
- Course Outline
- Weeks 1-3 Introduction
- Understanding the thought process behind program creation
- Weeks 4-9 Python
- Variable, Functions, Conditionals, and Recurrsion
- Strings, Lists, and Tuples
- Weeks 10-18 Python
- Object-Oriented Programming
- Classes, objects, functions, and methods
- Linked Lists and Stacks
- Grading Criteria
- Online Journal -- 40%
- Assignments -- 40%
- Quizzes -- 10%
- Final Project -- 10%
First Assignment
For this class you will need to create a blog site. On this site you will be posting a short journal entry during each class discussing things you have learned or are struggling with. You can also post about the project you are working on and difficulties you are having with it. This journal will be a large portion of your grade (40%). It does not need to be a huge task each day, but I want to be able to see how you are doing and what you are struggling with.
The blog you create needs to be solely used for this class. Be sure that you enable comments for registered users so I can comment on your posts and give you pointers.
Also, once you have created your site, comment on this post and give me the website of your blog. I will be adding links to each of your sites.
To create the page, click on the link at the top of this page "Get your own blog".
The blog you create needs to be solely used for this class. Be sure that you enable comments for registered users so I can comment on your posts and give you pointers.
Also, once you have created your site, comment on this post and give me the website of your blog. I will be adding links to each of your sites.
To create the page, click on the link at the top of this page "Get your own blog".
Monday, April 17, 2006
Quest Game Tasks
This week we will be working on multiple tasks to work to improve the controls and to make sure we understand the quest file.
Before we get started I want to look at the restrictions() method.
Task 1:
Edit the go() method to work for movement in all directions (north, south, east, west, up, and down).
Task 2:
Create your own world. It needs to contain 5 rooms and at 4 items. The player should be able to navigate around. These do not need to be part of your final game, just a basic world for practice.
Task 3:
You need to add a "Drop" command for dropping items from your inventory into the room.
Task 4:
You need to add a "commands" command for listing all legal commands. It should list only the primary commands and not all the variations.
You should have all of these tasks completed by the end of the week! On Friday we will be able to begin work on your actual projects.
Tuesday, April 04, 2006
def findspot(self,num,array,low,high):
mid=(low+high)/2
if high==low:
if num>array[low]:
return high
else:
return low
else:
if numreturn self.findspot(num,array,low,mid)
elif num>array[mid]:
return self.findspot(num,array,mid+1,high)
else:
return mid
def sort(self):
items = self.cards
sorts=[Card(),Card()]
done = 0
for i in items:
if done == 0:
sorts[0]=i
else:
spot=self.findspot(i,sorts,0,done)
sorts[spot:spot]=[i]
done=done+1
self.cards = sorts[:len(sorts)-1]
Wednesday, March 08, 2006
For today's project you need to create a function that takes an input of a string and a list. The list should contain all valid commands. The string is an input from the user. The function should return True if one of the words is in the commands list and False if it is not.
Create a test program with a list of commands.
bob
Create a test program with a list of commands.
bob
Friday, February 24, 2006
I'd like you to continue to work on the program from yesterday. If you have completed the basic form of it, work on adding a while loop to allow you to repeat. DO NOT USE RECURSION! If you are having trouble with any part, ask your classmates for help. Travis has already completed this using a while loop.
There is a discussion of the while loop in chapter 6 of BoP.
If you get this done, read the end of chapter 5 in HtTLaCS. Starting at 5.6. These talk about recursion and calculations. They give a couple of great examples of recursion. Section 5.8 gives us a great way to make sure the input for a function is correct. Now we can use this statement with any input to be sure that we are getting an integer. We can compare the type to the type of an integer. This doesn't affect this program as much, but can be very useful at a later time.
There is a discussion of the while loop in chapter 6 of BoP.
If you get this done, read the end of chapter 5 in HtTLaCS. Starting at 5.6. These talk about recursion and calculations. They give a couple of great examples of recursion. Section 5.8 gives us a great way to make sure the input for a function is correct. Now we can use this statement with any input to be sure that we are getting an integer. We can compare the type to the type of an integer. This doesn't affect this program as much, but can be very useful at a later time.
Thursday, February 23, 2006
Please finish up your program from yesterday. It should start with a welcome message, then ask for the type of shape. According to the shape given, it should give the area in a neatly formatted way. Don't forget to add comments!
If the user gives a shape that is not recognized, you should give a message listing the shapes that are valid and give them the opportunity to try again.
When you are done, save the file as: area_[name].py into the class "python\area programs\" folder. (replace [name] with your first name!)
As a bonus, add a while loop that allows you to find the area of multiple shapes.
You can also add abbreviations for the shapes so the user doesn't have to type the full name in. (But they should also be able to type the full name as well).
Once you are done, you may play around with some of the things you've been learning.
If the user gives a shape that is not recognized, you should give a message listing the shapes that are valid and give them the opportunity to try again.
When you are done, save the file as: area_[name].py into the class "python\area programs\" folder. (replace [name] with your first name!)
As a bonus, add a while loop that allows you to find the area of multiple shapes.
You can also add abbreviations for the shapes so the user doesn't have to type the full name in. (But they should also be able to type the full name as well).
Once you are done, you may play around with some of the things you've been learning.
Tuesday, February 21, 2006
Monday, February 20, 2006
Today we will be continuing our look at functions. We will be learning how to use conditional statements as well as how to receive input from the user.
Create a program that will greet a user, then ask for their name and age.
Then the computer will print a blank line for each year of their age and say good-bye using the name given at the beginning.
You will need to create a function for the blank lines.
When you have completed it, post the program on your blog. Be sure to use
Create a program that will greet a user, then ask for their name and age.
Then the computer will print a blank line for each year of their age and say good-bye using the name given at the beginning.
You will need to create a function for the blank lines.
When you have completed it, post the program on your blog. Be sure to use
andtags in "Edit Html" mode so that I can see the indentations.
Friday, February 17, 2006
Today we will be continuing through BoP Chapter 4 and HtTLaCS Chapter 3. Go ahead and click on the link for BoP and we will pick up there.
Today we will be finishing much of the basics so that next week we can begin actually doing some projects.
Today we will be finishing much of the basics so that next week we can begin actually doing some projects.
Thursday, February 09, 2006
OK, one more day without me. . . We will talk next week about the things you have been doing and applying them. Today I want you to open up Guido again. I have a new project for you. Open the file "binaryAdd.wld" from the "python\gvr" folder.
This world gives two binary numbers (along 2nd and 3rd avenues). You need to write a program that will add these binary numbers and place the result on first avenue with no other beepers left. When done, place guido on the east side of the wall. After completing the program your answer should be: 110010100
When you have the program done, you can test it by doing this addition problem:
1101001
1001011
You should get this:
10110100
Once you get that, try changing your world so it will actually add more than two binary numbers (move the wall along the north.) You may have to carry multiple times. . .
If you are having troubles, here are a couple of hints. You will need to highlight the next section in order to read them. (In case you want to try without any accidental seeing of my algorithm.)
Hint 1:
Hint 2:
OK, that was fun! Here is a real hint!
In order to do this I would create a couple of different stages. First I would take care of adding the columns, then of going through and taking care of any carrying.
If you can't get it from there, go ahead and look at hint 3.
Hint 3:
To add the columns you will want a definition that simply goes up collecting all beepers, then places them back at the bottom of the column. Do this until you reach the westward wall.
Hint 4:
Remember in binary you can only have a zero or a one. If any spot has a 2 it needs to be carried forward (leaving zero behind). Start at the far right, and check each spot to see if it needs to carry. (This can be another definition inside of a while loop.)
This world gives two binary numbers (along 2nd and 3rd avenues). You need to write a program that will add these binary numbers and place the result on first avenue with no other beepers left. When done, place guido on the east side of the wall. After completing the program your answer should be: 110010100
When you have the program done, you can test it by doing this addition problem:
1101001
1001011
You should get this:
10110100
Once you get that, try changing your world so it will actually add more than two binary numbers (move the wall along the north.) You may have to carry multiple times. . .
If you are having troubles, here are a couple of hints. You will need to highlight the next section in order to read them. (In case you want to try without any accidental seeing of my algorithm.)
Hint 1:
Hint 2:
OK, that was fun! Here is a real hint!
In order to do this I would create a couple of different stages. First I would take care of adding the columns, then of going through and taking care of any carrying.
If you can't get it from there, go ahead and look at hint 3.
Hint 3:
To add the columns you will want a definition that simply goes up collecting all beepers, then places them back at the bottom of the column. Do this until you reach the westward wall.
Hint 4:
Remember in binary you can only have a zero or a one. If any spot has a 2 it needs to be carried forward (leaving zero behind). Start at the far right, and check each spot to see if it needs to carry. (This can be another definition inside of a while loop.)
OK, well, after looking at your programs I see a couple of things they are missing. . .
First of all, they do not contain the two lines of comment at the beginning like they are supposed to, see previous post, the first two lines should start with #! and #.
Second is a misunderstanding of a splash screen. A splash screen is an image or message that fills up all or most of the screen while the actual program is loading. It should not be a scrolling message as everything should appear on the screen at once. I was looking for something that would display more like this:
Also, didn't sound like you actually got around to reading the the sections I assigned:
GvR - 18
HtTLaCS - 2
BoP - 4
Please read and comment upon!
First of all, they do not contain the two lines of comment at the beginning like they are supposed to, see previous post, the first two lines should start with #! and #.
Second is a misunderstanding of a splash screen. A splash screen is an image or message that fills up all or most of the screen while the actual program is loading. It should not be a scrolling message as everything should appear on the screen at once. I was looking for something that would display more like this:
Also, didn't sound like you actually got around to reading the the sections I assigned:
GvR - 18
HtTLaCS - 2
BoP - 4
Please read and comment upon!
Wednesday, February 08, 2006
Well, I just read through everyone's posts, and I found about what I expected. It took me a while to really understand what I was doing with the interface, I'm still not sure I completely understand it. . . But I'll give some ideas.
OK, first of all, when using IDLE there are 2 parts you have to think about. First is the basic interface you see first when you open the program. This interface allows you to run single commands, and test new things.
The other interface is more like a text editor, but with formatting and allows you to create and save modules (files). To get it open, go to file and new window. Now you can create your hello world program and save it to a file for later access.
To access and run the file you've created there are a couple of options:
The easiest one of these is to go to the run menu and select 'run module' (or hit f5)
We'll worry about other methods later, for now this should allow you to create and run files.
Another thing you may have noticed is that programs that have been shown have a couple of lines before the print command that don't seem to do anything, these are comments. These comments are not completely necessary, but have reasons. The first line should be:
"#! c:/python24/python -this line contains the directory of the interpreter
The second line should include the filename:
# helloworld.py
We'll also use comments in other places, but these are not necessary for as simply a program as we are creating now.
For your assignment today I'd like you to create a program that prints a splash screen (welcome screen). It should be at least 12 lines, though it can also include a couple blank lines. Try to make this welcome screen somewhat graphical and not just text (use symbols to draw it).
Once you have the program completed, please also read over:
GvR chapter 18
HtTlaCS chapter 2
BoP section 4
Please paste your program into your post for today. Also include any other comments about struggles you are having with the IDLE interface. And questions or comments from today's reading.
Have fun! Oh, and go to whittakersingapore.blogspot.com for pictures!
OK, first of all, when using IDLE there are 2 parts you have to think about. First is the basic interface you see first when you open the program. This interface allows you to run single commands, and test new things.
The other interface is more like a text editor, but with formatting and allows you to create and save modules (files). To get it open, go to file and new window. Now you can create your hello world program and save it to a file for later access.
To access and run the file you've created there are a couple of options:
The easiest one of these is to go to the run menu and select 'run module' (or hit f5)
We'll worry about other methods later, for now this should allow you to create and run files.
Another thing you may have noticed is that programs that have been shown have a couple of lines before the print command that don't seem to do anything, these are comments. These comments are not completely necessary, but have reasons. The first line should be:
"#! c:/python24/python -this line contains the directory of the interpreter
The second line should include the filename:
# helloworld.py
We'll also use comments in other places, but these are not necessary for as simply a program as we are creating now.
For your assignment today I'd like you to create a program that prints a splash screen (welcome screen). It should be at least 12 lines, though it can also include a couple blank lines. Try to make this welcome screen somewhat graphical and not just text (use symbols to draw it).
Once you have the program completed, please also read over:
GvR chapter 18
HtTlaCS chapter 2
BoP section 4
Please paste your program into your post for today. Also include any other comments about struggles you are having with the IDLE interface. And questions or comments from today's reading.
Have fun! Oh, and go to whittakersingapore.blogspot.com for pictures!
Subscribe to:
Posts (Atom)