<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0  -->
  <question type="category">
    <category>
        <text>Simple demo questions</text>

    </category>
  </question>

<!-- question: 2922  -->
  <question type="coderunner">
    <name>
      <text>C function: print string lengths</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a C function with signature <i>void printStringLengths(int numStrings, char **strings) </i>that takes an array of strings <i>strings</i>&nbsp;of length <i>numStrings &gt;= 0</i>&nbsp;and prints the length of each string, one length per line.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>c_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0, 10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>12</answerboxlines>
    <answerboxcolumns>90</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer><![CDATA[void printStringLengths(int numStrings, char **strings) {
    for (int i = 0; i < numStrings; i++) {
        printf("%zu\n", strlen(strings[i]));
    }
}]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[char *s[4] = {"x", "yy", "zzz", "1234"};
printStringLengths(4, s)]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1
2
3
4</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[char *s[1] = {"12345678910"};
printStringLengths(1, s);]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>11</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>printStringLengths(0, NULL);</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text></text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[char *ss[2] = {"", ""};
printStringLengths(2, ss);]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>0
0</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[char *ss[2] = {"x", "y"};
printStringLengths(2, ss);]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1
1</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2923  -->
  <question type="coderunner">
    <name>
      <text>C function: sqr</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a C function with signature <i>int sqr(int n)</i>&nbsp;that returns the square of its parameter <i>n</i>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p><br></p><p>&nbsp; &nbsp;&nbsp;</p>]]></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>c_function</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0, 10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>8</answerboxlines>
    <answerboxcolumns>60</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer>int sqr(int n) {
    // Return n squared
    return n * n;
}</answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[printf("%d\n", sqr(-11))]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>121</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[printf("%d\n", sqr(9))]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>81</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[printf("%d\n", sqr(-1000))]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1000000</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[printf("%d\n", sqr(0))]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>0</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[printf("%d\n", sqr(8))]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>64</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2924  -->
  <question type="coderunner">
    <name>
      <text>C Program: reversing lines</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a C program that repeatedly reads a line from standard input and prints it in reverse until end-of-file occurs. You may assume lines are at most 80 characters in length and that lines are terminated by newline characters ('\n') with no return characters present.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>c_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0,10,...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>20</answerboxlines>
    <answerboxcolumns>80</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer><![CDATA[// Program to read lines from standard input and print them in reverse
#include <stdio.h>
char buffer[81];
int readline() {
    // Read a line into global buffer. Return length of line or -1 if EOF.
    int c = 0;
    int i = 0;
    while ((c = getchar()) != '\n' && c != EOF) {
        buffer[i++] = c;
    }
    return i > 0 || c == '\n' ? i : -1;
}
int main() {
    // Read and print lines reversed
    int numRead = 0;
    numRead = readline();
    while (numRead >= 0) { // Print line backwards
        for (int i = numRead - 1; i >= 0; i--) {
            putchar(buffer[i]);
        }
        putchar('\n');
        numRead = readline();  // Next line
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>Line 1
Line 2
Another line
Boring!</text>
      </stdin>
      <expected>
                <text>1 eniL
2 eniL
enil rehtonA
!gniroB</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>abcdefghijklmnopqrstuvwxyz012345

Yes, that was a blank line there</text>
      </stdin>
      <expected>
                <text>543210zyxwvutsrqponmlkjihgfedcba

ereht enil knalb a saw taht ,seY</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>wow</text>
      </stdin>
      <expected>
                <text>wow</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>oxen
nexo</text>
      </stdin>
      <expected>
                <text>nexo
oxen</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text><![CDATA[~!@#$%^&*()_]]></text>
      </stdin>
      <expected>
                <text><![CDATA[_)(*&^%$#@!~]]></text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2925  -->
  <question type="coderunner">
    <name>
      <text>Java Class: bod</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a Java class Bod, representing a person, to satisfy the following requirements:</p><p></p><ol><li>There is a constructor that takes two parameters: a <i>String </i>name, being the name of the person, and an <i>int</i>&nbsp;age, being the age of the person.</li><li>There are getter methods <i>getName()</i>&nbsp;and <i>getAge() </i>that return the person's name and age respectively.</li><li>This is a method <i>growOlder(nYears)</i>&nbsp;that increments the persons age by <i>nYears</i>&nbsp;(an integer).</li></ol><p></p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_class</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0,10,20,...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>25</answerboxlines>
    <answerboxcolumns>80</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer>public class Bod {
    private String name;
    private int age;
    
    public Bod(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
    public String getName() {
        return this.name;
    }
    
    public int getAge() {
        return this.age;
    }
    
    public void growOlder(int nYears) {
        this.age += nYears;
    }
}</answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[Bod bod = new Bod("James", 23);
System.out.println(bod.getName() + " " + bod.getAge());
bod.growOlder(13);
System.out.println(bod.getName() + " " + bod.getAge());]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>James 23
James 36</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[Bod bod = new Bod("Angus McGurkinshaw", 99);
System.out.println(bod.getName() + " " + bod.getAge());
bod.growOlder(2);
System.out.println(bod.getName() + " " + bod.getAge());]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>Angus McGurkinshaw 99
Angus McGurkinshaw 101</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text><![CDATA[Bod bod = new Bod("Angus McGurkinshaw", 99);
System.out.println(bod.getName() + " " + bod.getAge());
bod.growOlder(3);
System.out.println(bod.getName() + " " + bod.getAge());]]></text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>Angus McGurkinshaw 99
Angus McGurkinshaw 102</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2929  -->
  <question type="coderunner">
    <name>
      <text>Java method: sum of squares</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a Java method with signature&nbsp;<tt>int sumSquares(int[] data) </tt>that returns the sum of the squares of the elements in a given array of integers. The method must return 0 if the array is empty.<br></p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0,10,20,...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>8</answerboxlines>
    <answerboxcolumns>80</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer><![CDATA[// The sum of the squares of the elements of array data
int sumSquares(int[] data) {
    int total = 0;
    for (int i = 0; i < data.length; i++) {
        total += data[i] * data[i];
    }
    return total;
}]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>int total = sumSquares(new int[] {2, 3, 5});
System.out.println(total);
</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>38</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>int total = sumSquares(new int[] {-2, -3, 4, 1});
System.out.println(total);
</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>30</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>int total = sumSquares(new int[] {});
System.out.println(total);</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>0</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>int total = sumSquares(new int[] {100});
System.out.println(total);</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>10000</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>int total = sumSquares(new int[] {-9});
System.out.println(total);</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>81</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2926  -->
  <question type="coderunner">
    <name>
      <text>Java program: file reader</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a Java program&nbsp;that reads and processes standard input. Each input line is a sequence of one or more integers, separated by commas. For each line of input the program should print the total of the integers in the input line. The program terminates if a blank line is read or if end-of-file occurs.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0, 10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>25</answerboxlines>
    <answerboxcolumns>80</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer><![CDATA[import java.util.Scanner;
public class FileReader {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.hasNextLine() ? scanner.nextLine() : "";
        while (line.length() != 0) {
            String[] numbers = line.split(",");
            int total = 0;
            for (int i = 0; i < numbers.length; i++) {
                total += Integer.parseInt(numbers[i]);
            }
            System.out.printf("%d\n", total);
            line = scanner.hasNextLine() ? scanner.nextLine() : "";
        }
    }
}]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>10,20,30
99

shouldn't get here</text>
      </stdin>
      <expected>
                <text>60
99</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>10,20,30
99</text>
      </stdin>
      <expected>
                <text>60
99</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>1,2,3,4,5,6,7,8,9,10,11,12</text>
      </stdin>
      <expected>
                <text>78</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>
[NB: line above is empty!]</text>
      </stdin>
      <expected>
                <text></text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>1</text>
      </stdin>
      <expected>
                <text>1</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>7</text>
      </stdin>
      <expected>
                <text>7</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2930  -->
  <question type="coderunner">
    <name>
      <text>Python function that prints: print_squares</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<h4 style="margin-bottom: 0cm;">A function that prints</h4><p><br></p><p>A common problem for students learning Python is the distinction between functions that return a value ("true" functions) and functions that print output and (preferably) don't return a value ("procedures"). This is an example of the latter.</p><p style="margin-bottom: 0cm;">Write a Python3 function <span style="font-family: 'courier new', 'courier', monospace;">print_sqrs_1_to_n(n)</span>&nbsp;that takes <span style="font-style: normal;">a single positive integer as a parameter and <strong>prints</strong> a table of all integers and their squares from 1 up to and including <span style="font-family: 'courier new', 'courier', monospace;">n</span>, formatted as below. The output from your function, when called with the code in the Test column, should be exactly as shown in the Result column.</span></p><p>The penalty regime for this question is 5, 15, 25, ... i.e., there is a 5% penalty for the first wrong submission but the penalty thereafter rises by 10% for each wrong submission.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>python3</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>5, 10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer><![CDATA[def print_sqrs_1_to_n(n):
    """ Print a display of the squares of all numbers from 1 to
        the given parameter n.
    """
    for i in range(1, n + 1):
        print("{0} * {0} = {1}".format(i, i * i))]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print_sqrs_1_to_n(5)</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1 * 1 = 1
2 * 2 = 4
3 * 3 = 9
4 * 4 = 16
5 * 5 = 25</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print_sqrs_1_to_n(3)</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1 * 1 = 1
2 * 2 = 4
3 * 3 = 9</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print_sqrs_1_to_n(1)</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1 * 1 = 1</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print_sqrs_1_to_n(10)</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>1 * 1 = 1
2 * 2 = 4
3 * 3 = 9
4 * 4 = 16
5 * 5 = 25
6 * 6 = 36
7 * 7 = 49
8 * 8 = 64
9 * 9 = 81
10 * 10 = 100</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2928  -->
  <question type="coderunner">
    <name>
      <text>Python function: sqr</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a Python3 function <i>sqr(n) </i>that returns the square of its numeric parameter <i>n</i>.</p><p>For those who don't know Python, one possible answer is:<br></p>
<pre style="background-color:#DDD">def sqr(n):
    return n * n</pre><p>Copy that answer into the answer box and click <i>Check</i>&nbsp;to see how CodeRunner questions behave. Then try changing the answer in various ways and re-checking.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>python3</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0, 10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>5</answerboxlines>
    <answerboxcolumns>70</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer>def sqr(n):
    '''The generic sqr function'''
    return n * n</answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print(sqr(-3))</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>9</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print(sqr(11))</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>121</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print(sqr(-4))</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>16</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print(sqr(0))</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>0</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text>print(sqr(-100))</text>
      </testcode>
      <stdin>
                <text></text>
      </stdin>
      <expected>
                <text>10000</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 2927  -->
  <question type="coderunner">
    <name>
      <text>Python program: print welcoming messages</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a Python3 program that repeatedly uses the <i>input()</i>&nbsp;function without a prompt string to read a person's name from standard input and prints a corresponding welcome message until the input line is the string <i>bye</i>, at which point the program exits. The test for <i>bye</i> should be case-insensitive. The welcome message depends only on the first name and whether or not that first name is&nbsp;<i>Richard</i>&nbsp;(case insensitively) as shown in the example table below. The first name is defined to be all text up to but not including the first space or the entire line if no space is present in the line. You may assume the line <i>bye</i>&nbsp;is always present in the input.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>python3</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>0, 10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <answer><![CDATA['''Simple script solution - not pylint compliant'''
name = input()
while name.lower() != 'bye':
    bits = name.split()
    if len(bits) < 2:
        bits = [name]
    if bits[0].lower() == 'richard':
        print('Welcome', bits[0])
    else:
        print('Hi', bits[0])
    name = input()]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>Angus McGurkinshaw III
Richard McClashan
Richardo McClashan
McClashan Richard
RICHARD
Peter Potter
Bye
More rubbish</text>
      </stdin>
      <expected>
                <text>Hi Angus
Welcome Richard
Hi Richardo
Hi McClashan
Welcome RICHARD
Hi Peter</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>Bye</text>
      </stdin>
      <expected>
                <text></text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>x

y
richarD Blogg
101 Dalmations
BYE</text>
      </stdin>
      <expected>
                <text>Hi x
Hi
Hi y
Welcome richarD
Hi 101

</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>Bonk
Bye</text>
      </stdin>
      <expected>
                <text>Hi Bonk</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>HIDE</text>
      </display>
    </testcase>
    </testcases>
  </question>

</quiz>