Learning PowerShell – Homework Seven Answers
PowerShell Homework Seven
By: Steven Aiello
Answer the questions as best as possible in your own words. By answering the question in your own words you will learn more than simply repeating what you’ve heard. You are encouraged to visit the source links in the lessons to do more research on the subject.
Remember the point of the homework is not simply to finish, but to learn!
1. In your own words explain why in our stop light example in the lesson it’s possible to put any light color in any position in the if, elseif, else script
You could look phrase a stop like in an else statement like this:
If light –eq green go
Ifelse –eq yellow slow down
2. In your own words what is the main difference between if and elseif when compared to else
If and elseif are be used to test various logic statements. The last “else” statement is a catch all if all of the other conditions are not met.
3. Write some pseudo-code using if, elseif, and else for what you would do if you were not hungry, hungry, really hungry.
If I’m not hungry sit on the couch
Elseif a little hungry eat a snack
Else eat a turkey
4. Take the pseudo-code from question three write a script where you assign a value to reflect your level of hungry and evaluate that variable using the family of if statements we have discussed.
5. Give an example of an if, elseif, else type decision you make in your day to day life.
If morning get our of bed
Elseif bedtime get in bed