0% found this document useful (0 votes)
33 views20 pages

Sample Questions - Past Tests

This document contains 25 multiple choice questions about computer programming concepts like program output, variables, data types, loops, conditional statements, functions and methods. Each question is followed by 5 possible answer choices in A-E format with one being the correct answer. The questions cover topics like string indexing, built-in functions, data structures, conditionals, loops and basic syntax.

Uploaded by

saad.hansrod3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views20 pages

Sample Questions - Past Tests

This document contains 25 multiple choice questions about computer programming concepts like program output, variables, data types, loops, conditional statements, functions and methods. Each question is followed by 5 possible answer choices in A-E format with one being the correct answer. The questions cover topics like string indexing, built-in functions, data structures, conditionals, loops and basic syntax.

Uploaded by

saad.hansrod3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Question 1

A program source code refers to ____

A) a file containing a sequence of 0s and 1s


B) the requirements specification of a problem
C) a text file that contains an English narrative describing the program’ functional behavior
D) a text file containing instructions written in a computer programming language
E) none of the above

Question 2
What is the output resulting from the complete execution of the following program?

A) EFAB
B) EA
C) AA
D) ABAB
E) None of the above

1
Question 3
What is the output resulting from the complete execution of the following program?

A) 1
B) 2
C) 3
D) 4
E) None of the above

2
Question 4
What is the output resulting from the complete execution of the following program?

A) 1
B) The program has an infinite loop.
C) -1
D) 0
E) None of the above

Question 5
What is the output resulting from the complete execution of the following program?

A) 11
B) 10
C) 3
D) The program will have a compilation error
E) None of the above

3
Question 6
What is the output resulting from the complete execution of the following program?

A) 3
B) 1
C) 2
D) -2
E) None of the above

Question 7

What is the output resulting from the complete execution of the following program?

A) 29
B) 4
C) 1
D) 2
E) None of the above

4
Question 8

What is the output resulting from the complete execution of the following program?

A) -1
B) 6
C) 4
D) 0
E) None of the above

5
Question 9
What is the output resulting from the complete execution of the following program?

A) -3
B) -1
C) -7
D)The program has an error and can't run
E) None of the above

6
Question 10

What is the output resulting from the complete execution of the following program?

A)1.0
B)2.0
C)3.0
D)6.0
E) None of the above

Question 11
Given the data assigned to the string variable y shown below, which of the following statements
will assign the value THIS to the string variable x?

y = "I like THIS film"

A) x = y[7:10]
B) x = y[:10]
C) x = y[7:]
D) x = y[7:11]
E) None of the above

7
Question 12

What is the output resulting from the complete execution of the following program?

A) true
B) false
C) yes
D) no
E) None of the above

8
Question 13

What is the output resulting from the complete execution of the following program?

A) one
B) two
C) five
D) seven
E) None of the above

Question 14

What is the output resulting from the complete execution of the following program?

A) 11
B) 12.5
C) 12
D) The code will not compile because it includes a syntax error
E) None of the above

9
Question 15

What is the output resulting from the complete execution of the following program?

A) 21
B) 20
C) 22
D) The program will have a runtime error
E) None of the above

Question 16

What is the output resulting from the complete execution of the following program?

A) 8
B) 18
C) 64
D) 72
E) [None of the above

10
Question 17
What is the output resulting from the complete execution of the following program?

A) 0
B) 1
C) 2
D) 3
E) None of the above

11
Question 18
What is the output resulting from the complete execution of the following program?

12
A) 2
B) 5
C) 10
D) 12
E) None of the above

13
Question 19
What should the comment line #TODO be replaced with for the following program to display
the highest number in the list B? Note: random( ) is a function of the random module that
returns a random real number between 0 and 1.

A) max(B)
B) max(self.B)
C) max(cls.B)
D) B.max()
E) None of the above

14
Question 20
What should the comment line #TODO be replaced with for the following program to display
the following pattern?

0 00
1 0011
2 001111
3 00111122
4 0011112222
5 001111222233
6 00111122223333

A) k_ = k_ + 11
B) k_ = k_ + 1
C) if flag_:
k_= k_ + 1
D) if flag_:
k_= k_ + 11

E) None of the above

15
Question 21
What is the output resulting from the complete execution of the following program?

A) 0
B) 3
C) 4
D) 5
E) None of the above

16
Question 22
What is the output resulting from the complete execution of the following program?

A) 2
B) 1
C) X 35 Y 11
D) Error
E) None of the above

17
Question 23
What should the comment line #TODO be replaced with for the program t95.py, given below, to
compute and output the average vehicle price?

A) a.append(value.price)
B) a.append(value[key].price)
C) a[int(key)] = value[key].price
D) a[int(key)] = value.price
E) None of the above

18
Question 24
What does the following program do?

A) Finds and displays the sum of numbers in the list w


B) Finds and displays the mean of numbers in the list w
C) Finds and displays the highest number in the list w
D) Finds and displays the lowest number in the list w
E) None of the above

19
Question 25
What will be the output resulting from the execution of the following
program?

A) 1
B) 2
C) 3
D) 12
E) None of the above

20

You might also like