WIDBA - The busiest DBA in Wisconsin, its all I do and I do it well

Sunday, January 20, 2013

Powershell and a poor man's math tutor

Math.  It is an important thing, hard to realize when you are 6 and learning to add, subtract and multiply, but as parents we know its important and want our kids to do better.  To keep math interesting, I have made it increasingly harder and tried to add complexity and different delivery methods all the time, sometimes its adding coins or using prices in the grocery stores with scenarios to keep them learning.  This weekend I whipped up an excel spreadsheet where my son could type in answers and get the correct/incorrect answer right away.  He liked being able to use the computer to do this, so today I decided to whip up a quick program that would allow him to choose a symbol and the size of the numbers if he wanted.  It is pretty basic and could use ShowUI, but certainly might keep him interesting for a few nights.

 [string]$symbol = "+"  
 if($lowNum -eq $null){ $lowNum = Read-Host "Please enter low number for equations"}  
 if($highNum -eq $null) { $highNum = Read-Host "Please enter high number for equations"}  
 if($symbol -eq $null) {$symbol = Read-Host "Please enter the symbol for the equations"}  
   $rand = New-Object system.random  
   $first = $rand.next($lowNum,$highNum)  
   $last = $rand.next($lowNum,$highNum)   
   write-host $first " " $last  
     [string]$ansString = "What is {0} {1} {2}?" -f $first,$symbol,$last  
     [int]$answer = Read-Host $ansString  
     [int]$correctAnswer = Switch($symbol)  
       "+" {$first + $last}  
       "-" {$first - $last}  
       "*" {$first * $last}  
       "/" {$first / $last}  
   write-host "correct" $correctAnswer " " $answer  
   If($correctAnswer -eq $answer)  
     $cont = read-host "Correct. Do you want to continue? (y/n)"  
    Write-Host "Incorrect. Answer is " $correctAnswer " Do you want to continue? (y/n)"  
 while($cont -eq "y")  

Once their math is in good order, you can head to the woods to work on their tracking skills.



  1. Thanks for the information, I've been looking into getting a math tutor in San Jose to help me with one of my college classes that I cant seem to understand. Math has always been a really hard subject for me. Have you ever needed any kind of tutoring?

  2. Needed tutoring? sure. We all need help once in a while. The https://www.khanacademy.org/ has some great stuff to help that I have used for doing statistical analysis with my job on occasion.

  3. Math is indeed an important thing, but many students find it hard to understand its principles. In this case, they need a passionate mentor who'll motivate them to study harder. Many tutors give various hints so that memorizing math formulas will be easier.


  4. Kudos to teachers who put much effort to make Math lessons interesting! You are an amazing Dad for trying to help your son understand the Mathematical concept in a manner that you know that will keep interested. Sometimes, parents do make the best tutors. Sarah @ GradePower Learning