wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Perl and Tcl Quiz

Total questions: 40

Worksheet time: 34mins

Name
Class
Date
1.

What is the correct way to define an array in Perl?

a)

$data = (1,2,3);

b)

@data = (1,2,3);

c)

%data = (1,2,3);

d)

array data = (1,2,3);

2.

The keyword used to exit a loop in Perl is ___________.

a)

break

b)

exit

c)

stop

d)

last

3.

Which of the following correctly assigns a variable in Tcl?

a)

x = 10

b)

set x 10

c)

$x = 10

d)

assign x 10

4.

Which operator is used for string comparison in Perl?

a)

==

b)

=

c)

eq

d)

!=

5.

What is the correct way to call a subroutine named display?

a)

display;

b)

call display;

c)

sub display;

d)

@display();

6.

Which function in Perl terminates the program after printing an error message?

a)

exit()

b)

die()

c)

stop()

d)

quit()

7.

Which symbol is used to prefix hash variables in Perl?

a)

$

b)

@

c)

%

d)

&

8.

In Perl, which symbol is used to prefix scalar variables?

a)

@

b)

%

c)

$

d)

&

9.

Which data structure in Perl supports key-value mapping?

a)

Array

b)

Hash

c)

Scalar

d)

List

10.

Given the code snippet in Tcl: if { $n == 0 } { puts "Zero" } ______ { puts "Non-zero" } Which keyword should fill the blank to execute the "Non-zero" block when $n is not zero?

a)

else

b)

elseif

c)

otherwise

d)

default

11.

11.  Tcl stands for ________________________________________________

4 lines
12.

11.  The command used to append elements to a list is ________________________.

4 lines
13.

Event-driven programming in Tcl/Tk is supported through (a)   .

14.

Perl-Tk is an extension that allows creating (a)   interfaces in Perl

15.

The last keyword in a loop is equivalent to the (a)   statement in C.

16.

The chmod() function changes file (a)   .

17.

The security feature -T in the shebang line enables (a)   mode.

18.

Complete the given code snippet.

set name "TCL"

puts "Hello (a)   "

19.

Hash variables in Perl are prefixed by the symbol (a)   .

20.

The die() function terminates the program after printing an (a)   message.

21.

In Tk, events and user interactions are handled by (a)   .

22.

The “Nuts and Bolts” Internet programming in Tcl refers to low-level (a)   handling.

23.

The command to assign a value to a variable is (a)   .

24.

The function stat() retrieves file (a)   information.

25.

(a)   keyword is used to associate a reference with a class.

26.

(a)   data structure supports the key-value mapping in PERL.

27.

Scalar variables in Perl start with the symbol (a)   .

28.

The split() function divides a string into a (a)   .

29.

(a)   keyword used to exit a loop in PERL.

30.

The loop keyword used to skip to the next iteration is (a)   .

31.

Which function can be used to find the length of a string?

a)

strlen()

b)

length()

c)

size()

d)

count()

32.

Which command is used to print output to the console in Python?

a)

echo

b)

print()

c)

output()

d)

write()

33.

What is the correct way to create a list in JavaScript?

a)

var list = list();

b)

var list = new List();

c)

var list = {};

d)

var list = [];

34.

In Perl, which operator is used for string concatenation?

a)

||

b)

+

c)

.

d)

&

35.

What is the purpose of the 'use strict;' pragma in Perl?

a)

To optimize performance

b)

To enable warnings

c)

To enforce variable declaration

d)

To import modules

36.

Which function is used to read a line from a file in Perl?

a)

fetchLine

b)

lineRead

c)

getLine

d)

readline

37.

Which operator is used to access elements in an array in Perl?

a)

{}

b)

[]

c)

!

d)

->

38.

What is the correct way to declare a hash in Perl?

a)

declare %hash = (key => value);

b)

%hash = (key => value);

c)

hash = (key => value);

d)

hash %hash = (key => value);

39.

Which function is used to split a string into a list in Perl?

a)

separate()

b)

divide()

c)

break()

d)

split()

40.

What is the output of $x = 5 + "10cats"; ?

a)

15

b)

Error

c)

510cats

d)

510