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.
Friday, February 24, 2006
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!
Sunday, February 05, 2006
OK, well, hopefully by now Aaron has arrived, but I'm not there! I would like you to look at the How to Think Like a Computer Scientist site again, re-read Chapter 1, hopefully it will make a little more sense now! After you have done that I want you to look through chapters 1-3 of Byte of Python. As you are doing this, open up IDLE from the Python folder in the Start menu. You can use this interface to try out some of the commands that are discussed in the sections. We will talk more about this as we work through this week.
I will try to post each day what I want you to do and try to give you some instruction. Please continue to post on your own blog with questions you might have for me about the things you are reading so I can address your struggles in my next post!
Also, please pray for a healthy labor and birth and a quick recovery!
I will try to post each day what I want you to do and try to give you some instruction. Please continue to post on your own blog with questions you might have for me about the things you are reading so I can address your struggles in my next post!
Also, please pray for a healthy labor and birth and a quick recovery!
Thursday, February 02, 2006
Subscribe to:
Comments (Atom)