Logistics
- Roll
- Wonderings? Comments?
Exam
Next Time:
- Algorithms & Programming Fundamentals
Questions? Comments? Wonderings? — Have fun! See you Thursday.
Questions? Comments? Wonderings? — Have fun! See you Thursday.
Thus far our learning activities have been designed to expose you to programming in a manner that you might use with your students. We are going to get a little more formal with our treatment of programming. The next several days will involve:
At least that's the plan right now. We'll see how it turns out :-)
Snap! uses less data and more actions than most programming languages but it does make use of both. We've seen a good sampling of actions and a little bit of data. In most programming languages the actions are input of data, manipulation of data, and the output of resulting data. We'll get a little better taste of that in our next activity.
The key to programming is to organize the actions in a useful manner. There are four basic ways to organize actions—sequence, selection, repetition, and modularization.
This seems super simple. Just put the actions in sequence one after the other. But sometimes the order matters and sometimes it does not. And sometimes you forget and action and have to figure out where it goes.
Also, when you start using the other organizing techniques you still have to sequence things but in a more complicated manner.
Selection is choosing actions. It might be simple, just choosing to do or not do an action. It might involve choosing between two actions. Selection is most often done by using an if
statement. We are all familiar with "if" situations, if you are sleepy go to bed, if it is raining take a rain protector, etc. But the familiar concept gets more difficult when programming.
Perhaps the most difficult part of using selection is figuring out the test or question that allows you to choose. An added difficulty is that the action you choose might have another selection element in it and that selection element might have another, and so on and so on. Simple in theory a bit harder in practice on some problems.
I received the following request for assistance from a pair of students in our class.
We would like to list the names of numerous states and ask the student to write the name of the capital in the blank. We have imported the list of states and capitals and would like to keep track of how many capitals the student gets right. We would like to stop after maybe 20? Once the quiz is over, there will be another speaking part wrapping up the quiz. This is what we have in mind, but are unsure how to carry out the program after the speaking parts.
I suggested that they had all the ideas but that putting the ideas in pseudocode/algorithmic form might help them figure out how to proceed in Snap! The algorithm I suggested was:
set correctCount to 0 repeat 20 times | set itemNumber to random between 1 & length of states list | ask what is the capital of itemNumber of states | if answer = itemNumber of capitals | | add 1 to correctCount | | say correct | else | | say incorrect | |=================== |===============================
We'll do pseudocode algorithms for one simple and one more complex exercise as a class, then pairs/groups work to develop algorithms/pseudocode for the other problems. Once the algorithms are done, the programs/scripts can be produced.
Accept input from the user for the number of hours worked and the pay rate and report the gross pay for those values.
Repeatedly (4 times) roll two different dice (probably two different sprites) and calculate the total of each die's rolls. Include some wait time between each roll so the change of rolls can be seen in the sprite costumes. After the four rolls, have each die report its total.
Questions? Comments? Wonderings? — Have fun! See you Tuesday.
Questions? Comments? Wonderings? — Have fun! See you Thursday.
Questions? Comments? Wonderings? — Have fun! See you Thursday.
We've had an extra day to work on variables, I/O, data manipulation and other actions. Are there any questions about any of the items in the learning activity for basic data and actions? Are there any questions more generally?
We have worked with numbers and, to a lesser extent, with text. There is another kind of data often used in programming—Boolean data. There are lots of numeric values and lots of text values, there are only two Boolean values—true and false. Booleans are used to answer questions about data values or the state of the program. Typically, you use them in if
and repeat until
blocks but there can be used nearly anywhere you would use other data.
The goal of the next learning activity is to familiarize you with the conditional operators and expressions that result in Boolean values (true or false). Let's look at the learning activity and see what questions you have.
Work and example or two demonstrating how to code the activity. Then students work on the Boolean data and actions activity
if
activity.Questions? Comments? Wonderings? — Have fun! See you Thursday.
Review the Boolean data and actions activity to see what questions students have and/or what learning or insights they wish to share.
We have worked with numbers, to a lesser extent, with text, and now with Boolean data. That prepares us to use data in a manner that allows us to choose actions rather than merely doing actions. We do that with selection statements/blocks—if
and if...else...
blocks.
The goal of the next learning activity is to become more adept at planning what needs to be done by when choices about actions are necessary. . Let's look at the learning activity and see what questions you have.
Work an example or two demonstrating how to code the activity. Then students work on the selection activity
repetition
activity.Questions? Comments? Wonderings? — Have fun! See you Tuesday.
Review the selection learning activity. Respond to any questions students have.
Review the repetition learning activity. Go over the example(s) given in the activity description. Respond to any questions students have.
The goal of the next learning activity is to become more adept at planning what needs to be done by when choices about actions are necessary. . Let's look at the learning activity and see what questions you have.
Work and example or two demonstrating how to code the activity. Then students work on the selection activity
Questions? Comments? Wonderings? — Have fun! See you After Spring Break.
(Instructor out of town at a conference) Students are to work on the repetition learning activity with their partners. A better solution is for everyone to attend class so everyone can help everyone.
Review the repetition learning activity. Respond to any questions students have — there were no questions.
Ask: Are all of you ready for an exam that might include any one of these questions other than the sieve or Eratosthenes? Any questions? (Now there were some questions. Discussion and working of problems ensued. Contact you partner or classmates if you were absent.)
Last official chance ... Any questions, or wonderings concerning repetition in general or specific to the repetition learning activity? Respond to any questions students have.
The final fundamental of programming is modularization. That's what we'll start on next time.
Review the repetition learning activity. Respond to any questions students have
The final fundamental of programming is modularization. One (perhaps the simplest) way to think of modularization is that you are just making up you own instructions. We just have to remember that the instructions must consist of instructions that the computer already knows how to accomplish. If we make up the new instructions correctly, then we expand what the computer knows how to do and can make programs out of the original instructions and any new instructions that have been created. Questions? Comments? Wonderings?
Now, let's get a little more formal (computer science-y) about modularization
Respond to any questions students have. Use remaining class time for work on the activity
The final fundamental of programming is modularization. That's what we'll start on next time.
Respond to any questions students have.
Respond to any questions students have.
See the robots notes.