Você está na página 1de 7

Rajiv Gandhi University of Knowledge Technologies

Conceptual Test- Advanced Programming


Date: 04.06.2014 Time: 30 Min
Course: M.Tech Max Marks: 30


1. In Perl, a/n ________ is a special character or a sequence that will define the number of
times the previous character or sequence appears.

a Character class
b Meta Character
c Assertion
d Quantifier

2. In Perl, the following will result in which of the following, if the prize is currently "5 dollars"
print 'You won $prize';

a You won $5.00
b You won 5 dollars
e You won $prize
c You won $5

3. In Perl, the words function and subroutines are used interchangeably.

a True
b False

4. In Perl, which of the following are file handles?

a Stdquit
b Stdend
c stdin
d stdout
e both c & d



5. In Perl, which switch is used for printing out warnings about typographical errors in your
script?

a P
b -W
c -p
d w

6. In Perl, "stat" returns a thirteen element array with which of the following values?

a Perl Version ID
b Web Server ID
c Last access
d Inode Number
e Both c & e

7. CGI is a programming language.

a True
b False

8. In Perl, scalar variables always begin with a ________ sign.

a #
b @
c %
d $

9. What will be printed by the code below?
my $val = 'x';
print ref($val);

a Scalar
b Empty Value
c String
d Not a reference




10. What will be printed by the code below?
my @a = (0, 1, 2);
my $b = @a;
print $b;

a 0
b 1
c 2
d 3
e 0 1 2

11. What will be the value of $1 after execution of the following code?
my $txt = 'I am learning Perl';
$txt =~ /(\w+)$/;

a Perl
b I
c I am learning Perl
d Undef
e Empty string

12. What will be the size of the @fields array?
my $record = ':a:b:c:';
my @fields = split(':', $record, -1);

a 0
b 1
c 3
d 5

13. The following operator will collapse all duplicate spaces into single spaces in the string $str?
$str =~ s/\s+/ /;

a True
b False




14. Which of the following mathematical operations has the highest precedence in Perl?
a **
b ++
c +
d -
15. Which of the following commands should be used to open a filehandle named KAREN to an
existing file named sw?
a open KAREN ">sw";
b open KAREN, ">sw";
c open "sw" KAREN;
d open ">sw", KAREN;


16. If PYTHONPATH is set in the environment, which directories are searched for modules?

A PYTHONPATH directory
B current directory
C home directory
D installation dependent default path

a A only
b A & D
c A,B & C
d A,B & D
e A, B, C & D

17. What gets printed?
kvps = {"user","bill", "password","hillary"}
print kvps['password']

a User
b Bill
c Password
d Hillary
e Nothing. Python syntax



18. True or false? Code indentation must be 4 spaces when creating a code block?
if error:
# four spaces of indent are used to create the block print "%s" % msg

a True
b False

19. What will be the output of the following command?
print(type(1/3))

a class float
b class int
c class complex
d None of the above
20. what will be the output of the following code?
x=0
for i in range(2, 10, 2):
x = x + i
print(x)
a 10 11
b 2 6 12 20
c 2 4 6 8 10
d None
21. Which of the following statement is wrong?
a x:y:z: = 1, 2, abcd
b x = y = z =1
c x, y, z = 1, 2, abcd
d All the above are correct
22. What gets printed?
def f(): pass
print type(f())

a type function
b type tuple
c type None type
d type str
e type type

23. The three types of error that might be contained in a Python program are syntax, logic and
run-time.
a True
b False

24. What does this expression match?
/^[abcd]/

a Any string with an a, b, c or d in it
b Any string that begins with a, b, c, or d
c Any string that begins with lowercase a, b, c, or d
d None of the above

25. Which of the following regular expressions will match this string:
AaZzXzY

a /x/
b /^[a-z]*$/
c /^\w*$/
d None

26. What does the code below do?
sys.path.append('/root/mods')

a Changes the location that the python executable is run from
b Changes the current working directory
c Adds a new directory to search for python modules that are imported
d Removes all directories for mods
e None of the above

27. What does this line do?
while(<>) { /^(from|subject):/i and print }

a Removes the headers from your email and prints out the body
b Removes the headers from your email and prints a blank line
c Prints out all the From: and Subject: lines from mailbox
d None
28. Grep function requires a comma separation between the arguments irrespective of the first
argument being a block or an expression?

a True
b False

29. Which of the following is used to create a reference to a variable?
a /
b \
c -
d &

30. To avoid using two users opening the same file in read/write mode, use

a Filelock()
b Lock()
c Flock()
d Lockf()

Você também pode gostar