Tutor Marked Assignment PL TMA-02
In a Nutshell - CIW Course Section 2 Part B
PL TMA-02 - CD Access Code: 5235
Q1. Which of the following symbols are used to compare two numeric values?
- a) =
- b) ==
- c) !=
- d) >=
Q2. What would be displayed by the following Perl statements?
$A = 100;
$B = 100;
print ($A != $B);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q3. What would be displayed by the following Perl statements?
$A = (12 * 3) + 4;
$B = 12 * 3 + 4;
print ($A >= $B);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q4. What would be displayed by the following Perl statements?
$A = 12 * (3 + 4);
$B = 12 * 3 + 4;
print ($A <= $B);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q5. What would be displayed by the following Perl statements?
$A = (12 - 3) + 4;
$B = 12 - 3 + 4;
print ($A > $B);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q6. What would be displayed by the following Perl statements?
$A = (12 * 3) + 4;
$B = 12 * 3 + 4;
$C = - ($A - $B);
print ($A < $C);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q7. What would be displayed by the following Perl statements?
$A = "John";
$B = "James";
print ($A eq $B);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q8. What would be displayed by the following Perl statements?
$A = "John";
$B = "James";
print ($A gt $B);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q9. What would be displayed by the following Perl statements?
$A = "John";
$B = "James";
$C = $A;
print ($A ge $C);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q10. What would be displayed by the following Perl statements?
$A = "John";
$B = "James";
$C = 8 / 4 + 2;
$D = (8 / 4) + 2;
print ($A lt $B || $C == $D);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q11. What would be displayed by the following Perl statements?
$A = 19;
$B = 29;
$C = $B - $A + 6;
$D = $C - $A;
print ($B > $A xor $D <= $A);
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q12. What would be displayed by the following Perl statements?
$A = "March";
$B = "May";
$C = 12;
$D = $C + ($A gt $B);
print (!($C == $D));
- a) 1
- b) 0
- c) Nothing
- d) True
- e) False
Q13. What would be displayed by the following Perl statements?
$counter = 0;
while ($counter < 10)
{
$counter++;
print ($counter);
print (" ");
}
- a) 12345678910
- b) 1 2 3 4 5 6 7 8 9 10
- c) 123456789
- d) 1 2 3 4 5 6 7 8 9
Q14. What would be displayed by the following Perl statements?
$counter = 1;
while ($counter < 10)
{
print ($counter);
print (" ");
$counter++;
}
- a) 12345678910
- b) 1 2 3 4 5 6 7 8 9 10
- c) 123456789
- d) 1 2 3 4 5 6 7 8 9
Q15. What would be displayed by the following Perl statements?
$counter = 0;
print ($counter);
until ($counter < 10)
{
$counter++;
print ($counter);
print (" ");
}
- a) 12345678910
- b) 1 2 3 4 5 6 7 8 9 10
- c) 123456789
- d) 1 2 3 4 5 6 7 8 9
- e) 0
Q16. What would be displayed by the following Perl statements?
$counter = 0;
do
{
print ($counter);
$counter++;
} while ($counter < 10);
- a) 12345678910
- b) 1 2 3 4 5 6 7 8 9 10
- c) 123456789
- d) 1 2 3 4 5 6 7 8 9
- e) 0
Q17. What would be displayed by the following Perl statements?
for ($counter = 10; $counter >= 1; $counter--)
{
print ($counter);
print (" ");
}
- a) 10 9 8 7 6 5 4 3 2 1
- b) 10987654321
- c) 9 8 7 6 5 4 3 2 1
- d) 987654321
Q18. What would be displayed by the following Perl statements?
for ($counter = 1; $counter < 10; $counter++)
{
if ($counter % 3)
{
print ($counter);
print (" ");
}
}
- a) 3 6 9
- b) 1 2 4 5 6 7 8 9
- c) 2 3 4 5 7 8
- d) 1 2 6 8 9
Q19. What would be displayed by the following Perl statements?
MYLOOP: for ($i = 1; $i < 10; $i ++)
{
if ($i < 3)
{
print ($i);
print (" ");
}
else
{
last MYLOOP;
}
}
- a) 1 2
- b) 1 2 3
- c) 1 2 4 5 6 7 8 9
- d) 1 2 3 4 5 6 7 8 9
Q20. Which of the following lines has the correct syntax for appending the output from Perl script script.pl to output file script1output.txt?
- a) perl script1output.txt > script1.pl
- b) perl script1output.txt >> script1.pl
- c) perl script1.pl > script1output.txt
- d) perl script1.pl >> script1output.txt
