Author Topic: Basic maths with Python -- Times tables quiz  (Read 4524 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Basic maths with Python -- Times tables quiz
« on: May 09, 2015, 03:17:17 PM »
"Fun" for the kids. You must have VC's Python plugin enabled.

Quiz them on their multiplication tables (currently the command will test them on their 1 to 15 times tables -- easy to change):

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<commandGroup open="True" name="math magic the Python way" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="681" name="Kids quiz -- 15 times tables" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.SpeakSync</cmdType>
      <params>
        <param>Great idea. How about this one?|OK. Are you ready?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>question</param>
        <param>{Rnd.1.15} * {Rnd.1.15}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>What is {var.question}?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>What is {var.question}?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>result={var.question}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>answer</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Give me a math challenge, I want to practice my times tables</phrase>
    <phrase optional="true">please.</phrase>
  </command>
  <command id="693" name="Here is my answer" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.SpeakSync</cmdType>
      <params>
        <param>Your answer was {1}.|You think the answer is {1}?|Sounds like your response was {1}.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Your response: {1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{1}&amp;&amp;{var.answer}</ifParams>
      <then>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <params>
            <param>That's right! {var.question} = {var.answer}. </param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>{var.question} = {var.answer}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Great job!|Nice work.|Good stuff.|You're on a roll.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <params>
            <param>Oops. {var.question} = {var.answer}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Whoops.|Not quite.|That's incorrect, unfortunately.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>{var.question} = {var.answer}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>My answer is, The answer is</phrase>
    <payloadRange>1,225</payloadRange>
  </command>
</commandGroup>
« Last Edit: May 09, 2015, 04:47:19 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

tobiastobindev

  • $upporter
  • Jr. Member
  • *****
  • Posts: 33
  • Karma: 1
    • View Profile
Re: Basic maths with Python -- Times tables quiz
« Reply #1 on: May 09, 2015, 11:10:22 PM »
Cool :)  Thanks nime5ter!

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Re: Basic maths with Python -- Times tables quiz
« Reply #2 on: May 12, 2015, 10:53:30 PM »
It's the little things like this (not to say it wasn't work to make it) that makes "Alexander" seem more real...  ^-^