wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Revision tour Quiz

Total questions: 180

Worksheet time: 2hrs 33mins

Name
Class
Date
1.

Full Form of IDLE

a)

INDUSTRIAL DEVELOPMENT LEARNING ENVIRONMENT

b)

INTEGRATE DRIVE LEARNING ENVIRONMENT

c)

INTEGRATED DEVELOPMENT LEARNING ENVIRONMENT

d)

INTEGRATED DEVELOPMENT LEARNING ENGINEERING

2.

Python is ...................language

a)

High level language

b)

Low level language

c)

Medium level language

d)

Machine language

3.

Which statement is correct

a)

Python is Upper case sensitive

b)

Python is Case-Sensitive

c)

Python is Lower case sensitive

d)

Python is Case-Insensitive

4.

Which statement is correct

a)

It is free language

b)

It is open source language

c)

It is free and open source language

d)

None of the above

5.

Tick the correct statement to print hello.

a)

print(hello)

b)

print("hello")

c)

Print("hello")

d)

Print(hello)

6.

Python programs are executed by which language processor?

a)

Compiler

b)

Interpreter

c)

Assembler

d)

All of the above

7.

Which of the statement is correct?

a)

Python is not portable and platform independent.

b)

Python is portable and platform dependent.

c)

Python is portable and platform independent.

d)

Python is not portable and platform dependent.

8.

Which of the following is not high level programming language?

a)

JAVA

b)

Visual basic

c)

Python

d)

Machine language

9.

Which of the following is not compiler based programming language.

a)

Python

b)

C

c)

C++

d)

JAVA

10.

Find the output of the following program A=0 print(a)

a)

A.A

b)

a

c)

0

d)

error

11.

What is a program?

a)

A set of rules.

b)

A set of ordered instructions.

c)

A set consist of 0 and 1.

d)

A set of unordered instructions.

12.

Computer understands a low level language. A low level language consist of a set of digits

a)

(1,2,3,4)

b)

(0,1,2,3,4,5,6,7,8,9)

c)

(0,1)

d)

(0,1,2,3,4,5,6,7)

13.

Which function can be used to display the output in python

a)

show()

b)

print()

c)

display()

d)

output()

14.

Tick the correct statement to print Hello World.

a)

print(hello)(world)

b)

Print("hello world")

c)

Print(hello world)

d)

print("Hello World ")

15.

Find the output of the following program A=0 print(A)

a)

A.A

b)

a

c)

0

d)

1

16.

Python uses____to convert its instructions into machine language.

a)

Interpreter

b)

Compiler

c)

Both of the above

d)

None of the above

17.

Which of the following is not the feature of python language?

a)

Python is proprietary software.

b)

Python is not case-sensitive.

c)

Python uses brackets for blocks and nested blocks.

d)

All of the above

18.

By default, the Python scripts are saved with____________extension.

a)

.pyp

b)

.pys

c)

.py

d)

None of the above

19.

Which of the following is String literal?

a)

"ABC"

b)

"123"

c)

Both of the above

d)

None of the above

20.

print("I" + "am" + "in" + "school") display

a)

I am in school

b)

I Am In School

c)

Iaminschool

d)

iaminschool

21.

print("I" , "am" , "in" , "school") display

a)

I am in school

b)

I Am In School

c)

Iaminschool

d)

iaminschool

22.

Which of the following is parameter of print( ) function?

a)

sep

b)

end

c)

Both of the above

d)

None of the above

23.

The process of removing errors from programs is called __

a)

Programming

b)

Documentation

c)

Debugging

d)

None of the above

24.

IDLE stands for__________

a)

Integrated Development LEarning

b)

Integrated Development Learning Environment

c)

Intelligent Development Learning Environment

d)

None of the above

25.

Which of the following statement is correct syntactically?

a)

print("Hello" , sep == '@' , end = ' ')

b)

print("Hello" , sep = '@' , end = ' ')

c)

Print("Hello" , sep = '@' , end = ' ')

d)

print("Hello" , sep = '@' , end = ' '

26.

Who developed the Python language?

a)

Zim Den

b)

Wick van Rossum

c)

Guido Van Rossum

d)

NieneStom

27.

In which year was the Python language developed?

a)

1990

b)

1989

c)

1971

d)

1975

28.

Which of the following is an escape sequence for a newline character?

a)

\a

b)

\t

c)

\n

d)

\b

29.

Which of the following functions print the output to the console?

a)

Output( )

b)

Print( )

c)

Echo( )

d)

print( )

30.

The default separator character of print( ) is ..........

a)

tab

b)

space

c)

newline

d)

dot

31.

Which of the following is correct about python?

a)

Python is an open source language.

b)

Python is not based on ABC language.

c)

Python is not a case sensitive

d)

All of the above

32.

Which two languages contributed to Python as a Programming Language?

a)

C++ and ABC language

b)

BASIC and Modula 3

c)

ABC language and Modula 3

d)

None of the Above

33.

When was Python released?

a)

Python was released in September 1991.

b)

Python was released in February 1991.

c)

Python was released in February 1990.

d)

Python was released in March 1991

34.

Python code can run on a variety of platforms, it means Python is a .......... language.

a)

Graphical

b)

Cross-platform

c)

Independent

d)

All of these

35.

Python uses a/an .......... to convert source code to object code.

a)

Interpreter

b)

Compiler

c)

Combination of Interpreter and compiler

d)

Special virtual engine

36.

The interpreter is also called ........................

a)

Python Editor

b)

Python Kernel

c)

Python shell.

d)

None of the Above

37.

In the Python prompt, which symbol indicates that the interpreter is ready to take instructions.

a)

>>

b)

>>>

c)

<<>

d)

>>>>

38.

What is the output after executing the following code: Print("Hello World!")

a)

>>>Hello World!

b)

Hello World

c)

Hello World!

d)

Error

39.

What is the result after executing the following: >>>print(20/4 *5+8-10)

a)

1

b)

23

c)

23.0

d)

24

40.

What will be the output of the following code ? print("150+300")

a)

450

b)

150300

c)

150+300

d)

300

41.

What do we use to define a block of code in Python language?

a)

Key

b)

Brackets

c)

Indentation

d)

None of these

42.

Python interpreter executes............................statement (Command) at a time.

a)

Two

b)

Three

c)

One

d)

All command

43.

Which one is not the feature of Python?

a)

Cross-platform

b)

Interpreted

c)

Free and Open source

d)

Not a case-sensitive

44.

A program written in a high-level language is called ..................

a)

Compile code

b)

Object code

c)

Source code

d)

Binary Code

45.

IDLE stands for

a)

Integrated Development or Learning Environment

b)

Integrated Development and Learning Environment

c)

Integrate Development and Learning Environment

d)

Integrated Development and Learned Environment

46.

What is the maximum possible length of an identifier in python?

a)

16

b)

32

c)

64

d)

None of these

47.

Which of the following is not a keyword in python?

a)

eval

b)

assert

c)

nonlocal

d)

pass

48.

All keywords in python except TRUE and FALSE are in ________?

a)

Lower case

b)

Upper case

c)

Capitalized

d)

None of the above

49.

In which year was the python language developed?

a)

1995

b)

1972

c)

1989

d)

1981

50.

Which one of the following is the correct extension of the python file?

a)

.py

b)

.p

c)

.python

d)

.pyt

51.

Which of the characters is used in python to make a single line comment?

a)

/

b)

//

c)

#

d)

!

52.

Which of the following is not a core data type in python?

a)

List

b)

Dictionary

c)

Tuple

d)

Class

53.

What data type is the object listed below? L=[1,3,"Hello",5]

a)

List

b)

Tuple

c)

Class

d)

Dictionary

54.

Which one of these is the floor division operator?

a)

/

b)

//

c)

%

d)

*

55.

Which of the following has the highest precedence in python?

a)

Exponential

b)

Addition

c)

Parenthesis

d)

Division

56.

What will be the output of the following statement? >>>a+bc

a)

a

b)

b

c)

ab

d)

abc

57.

What is math.factorial(4.0)?

a)

20

b)

24

c)

16

d)

64

58.

Which of the following belongs to integer datatype

a)

-12

b)

4.0

c)

3+4J

d)

-2.05

59.

Which of the following belongs to float datatype

a)

-12

b)

-14.0

c)

3+4J

d)

4

60.

Which of the following belongs to complex datatype

a)

-12

b)

4.0

c)

3+4J

d)

-2.05

61.

An ordered collection of items, where each item is indexed by an integer is called:

a)

MAPPING

b)

SEQUENCES

c)

SETS

d)

NUMBERS

62.

_______ is a sequence of items separated by commas and the items are enclosed in square brackets [ ]

a)

LIST

b)

DICTIONARY

c)

STRING

d)

TUPLE

63.

_______ is a sequence of items separated by commas and the items are enclosed in parenthesis ()

a)

LIST

b)

DICTIONARY

c)

STRING

d)

TUPLE

64.

_______ holds data items in key-value pairs.

a)

LIST

b)

DICTIONARY

c)

STRING

d)

TUPLE

65.

None is a special datatype with a single value. It is used to signify the absence of value in a situation

a)

TRUE

b)

FALSE

c)

NONE

d)

NULL

66.

Datatype conversion can happen :

a)

ONLY EXPLICITLY

b)

ONLY IMPLICITLY

c)

BOTH EXPLICITLY AND IMPLICITLY

d)

NONE OF THE ABOVE

67.

Which of the following is mutable datatype:

a)

INTEGER

b)

FLOAT

c)

STRING

d)

LIST

68.

Which of the following is immutable

a)

LIST

b)

DICTIONARY

c)

STRING

d)

NONE OF THE ABOVE

69.

A list can contain the following:

a)

ONLY NUMBERS

b)

ONLY STRINGS

c)

BOTH NUMBERS AND STRING

d)

ONLY INTEGERS

70.

String is a group of characters. These characters may be

a)

ALPHABETS,

b)

DIGITS

c)

SPECIAL CHARACTERS INCLUDING SPACES.

d)

ALL OF THE ABOVE

71.

Numbers = [ 4, 8, 9, 2.6, 5 ] is a type of which data type in python?

a)

List

b)

Tuple

c)

Set

d)

None of these

72.

If x=3.123, then int(x) will give ?

a)

3.1

b)

0

c)

1

d)

3

73.

Which of the following is not a data type in python?

a)

List

b)

Tuple

c)

Dictionary

d)

Book

74.

Which one of the following is False regarding data types in Python?

a)

In python, explicit data type conversion is possible

b)

Mutable data types are those that can be changed.

c)

Immutable data types are those that cannot be changed.

d)

None of the above

75.

Which of the following function is used to know the data type of a variable in Python?

a)

datatype()

b)

typeof()

c)

type()

d)

vartype()

76.

If we change one datatype to another, then it called

a)

Type Casting

b)

Type Conversion

c)

Both of the above

d)

None of the above

77.

Consider the following sequence of statements : A=100 B=A Following the execution of above statements, python has created how many objects and how many references?

a)

One object Two reference

b)

One object One reference

c)

Two object Two reference

d)

Two object One reference

78.

What data type is the object below? L = {1:"One",2:"Two"}

a)

list

b)

dictionary

c)

array

d)

tuple

79.

Find Example of sequence datatype.

a)

List

b)

Tuple

c)

Both of them

d)

None of them

80.

Which of these about a dictionary is false?

a)

The values of a dictionary can be accessed using keys

b)

The keys of a dictionary can be accessed using values

c)

Dictionaries aren’t ordered

d)

Dictionaries are mutable

81.

Can tuple be used as dictionary key in python?

a)

True

b)

False

c)

Tuple is not used in python

d)

None of the above

82.

Which statement is correct?

a)

List is immutable && Tuple is mutable

b)

List is mutable && Tuple is immutable

c)

Both are Mutable.

d)

Both are Immutable

83.

Which of the following option is a core data type in the python language?

a)

Dictionary

b)

List

c)

String

d)

All of the above

84.

In order to store values in terms of key and value we use that core data type in python?

a)

List

b)

Class

c)

Dictionary

d)

Tuple

85.

In which data type, indexing is not valid?

a)

List

b)

String

c)

Dictionary

d)

None of the above

86.

Which of the following operator can be classified as unary operator?

a)

+

b)

or

c)

not

d)

and

87.

Which of the following operator has lowest precedence?

a)

()

b)

or

c)

not

d)

and

88.

What is the output of the following code? a,b=8/4/2, 8/(4/2) print(a,b)

a)

Syntax error

b)

1.0,4.0

c)

4.0,4.0

d)

4,4

89.

Predict output for following code v1= True v2=1 print(v1==v2, v1 is v2)

a)

True False

b)

False True

c)

True True

d)

False False

90.

Evaluate the following expression and identify the correct answer. 16 // (4 + 2) * 5 + 2**3 * 4

a)

42

b)

46

c)

18

d)

32

91.

Find output of following given program : str1_ = "Aeiou" str2_ = "Machine learning has no alternative" for i in str1_: if i not in str2_: print(i,end='')

a)

Au

b)

ou

c)

Syntax Error

d)

Value Error

92.

Which of the following operator can not be used with string value

a)

-

b)

is

c)

+

d)

*

93.

Find output for following given program a=10 b=20 c=1 print(a !=b and not c)

a)

10

b)

20

c)

True

d)

False

94.

Find output for following given program : a=2 b=3 print( a*b**2)

a)

18

b)

16

c)

64

d)

12

95.

Observe the presence of operator * in following program and predict the output: list1=[10,20] list2=[2,3] list1= list1*list2[0] print(list1)

a)

Error

b)

[20,40]

c)

[10,10,20,20]

d)

[10, 20, 10, 20]

96.

Find output for following given code a=12 print(not(a>=0 and a<=10))

a)

True

b)

False

c)

0

d)

1

97.

Evaluate expression in following given program and find the output : a=56 b=a//7//4 print(b)

a)

0

b)

2

c)

0.0

d)

2.0

98.

What output following program will produce a=12 b=a%10 c=a%100 print(b,c)

a)

2 12

b)

12 2

c)

0 0

d)

Error

99.

What will be value of diff c1='A' c2='a' diff= ord(c1)-ord(c2) print(diff)

a)

Error : unsupported operator ‘-’

b)

32

c)

-32

d)

0

100.

What output following program will produce v1='1' v2= 1 v3= v1==v2

a)

Type Error

b)

Value Error

c)

True will be assigned to V3

d)

False will be assigned to v3

101.

What will be the value of the expression 13+12%14

a)

14

b)

25

c)

13

d)

27

102.

What will be the value of x? x= int(12.5 + 4/2)

a)

14

b)

15

c)

Error

d)

14.5

103.

Which of the following operators has highest precedence: +,-,/,*,%,<<,>>,( ),**

a)

**

b)

( )

c)

%

d)

-

104.

Which of the following results in an error?

a)

float(‘12’)

b)

int(‘12’)

c)

float(’12.5’)

d)

int(‘12.5’)

105.

Which of the following is an invalid statement?

a)

xyz=1,000,000

b)

x y z = 100 200 300

c)

x,y,z=100,200,300

d)

x=y=z=1,000,000

106.

What is the output of the following statements: A=5 B=6 print(A,B)

a)

5 6

b)

5,6

c)

5 6

d)

none of the above

107.

What is the value of the expression 32% 3.0?

a)

2

b)

2.0

c)

10.6666

d)

10

108.

What is the output of the expression print(4.00/(2.0+2.0))?

a)

1

b)

1.0

c)

Error

d)

1.00

109.

What is the output of the following: print(“Hello\nWorld”)

a)

Hello World

b)

Hello World

c)

Hello World

d)

None of the Above

110.

Which of the following is an example of type casting?

a)

3.2+5.3

b)

2.0+5

c)

int(4.7)+3

d)

all of the above

111.

What is the output of the following? S1=”my” S2=”string” print (int(s1+s2))

a)

my string

b)

mystring

c)

2563859

d)

Error

112.

What is the output of the following? print(“Python “, end= “ “) print(“world”)

a)

Python world

b)

Python world

c)

Python end world

d)

Python end world

113.

Evaluate the expression 6*2/5+5*2

a)

2.4

b)

2

c)

12.4

d)

12

114.

Which of the following defines SyntaxError?

a)

It is raised when the file specified in a program statement cannot be opened.

b)

It is raised when there is an error in the syntax of the Python code.

c)

It is raised when the requested module definition is not found.

d)

It is raised due to incorrect indentation in the program code.

115.

Which of the following defines ValueError?

a)

It is raised when the file specified in a program statement cannot be opened.

b)

It is raised when there is an error in the syntax of the Python code.

c)

It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.

d)

It is raised due to incorrect indentation in the program code.

116.

Which of the following defines IOError?

a)

It is raised when the file specified in a program statement cannot be opened.

b)

It is raised when there is an error in the syntax of the Python code.

c)

It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.

d)

It is raised due to incorrect indentation in the program code.

117.

Which of the following defines KeyboardInterrupt?

a)

It is raised when the file specified in a program statement cannot be opened.

b)

It is raised when the user accidentally hits the Delete or Esc key while executing a program due to which the normal flow of the program is interrupted.

c)

It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.

d)

It is raised due to incorrect indentation in the program code.

118.

Which of the following defines ImportError?

a)

It is raised when the file specified in a program statement cannot be opened.

b)

It is raised when there is an error in the syntax of the Python code.

c)

It is raised when the requested module definition is not found.

d)

It is raised due to incorrect indentation in the program code.

119.

Which of the following defines EOFError?

a)

It is raised when the file specified in a program statement cannot be opened.

b)

It is raised when there is an error in the syntax of the Python code.

c)

It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.

d)

It is raised when the end of file condition is reached without reading any data by input().

120.

It is raised when the denominator in a division operation is zero.

a)

IndexError

b)

IndentationError

c)

ZeroDivisionError

d)

TypeError

121.

It is raised when the index or subscript in a sequence is out of range.

a)

IndexError

b)

IndentationError

c)

ZeroDivisionError

d)

TypeError

122.

It is raised when a local or global variable name is not defined.

a)

IndexError

b)

IndentationError

c)

ZeroDivisionError

d)

NameError

123.

It is raised due to incorrect indentation in the program code.

a)

IndexError

b)

IndentationError

c)

ZeroDivisionError

d)

NameError

124.

It is raised when an operator is supplied with a value of incorrect data type.

a)

IndexError

b)

TypeError

c)

ZeroDivisionError

d)

NameError

125.

It is raised when the result of a calculation exceeds the maximum limit for numeric data type.

a)

OverFlowError

b)

TypeError

c)

ZeroDivisionError

d)

NameError

126.

ZeroDivisionError is a type of:

a)

SyntaxError

b)

Logical Error

c)

Runtime Error

d)

Other

127.

IndentationError is a type of:

a)

SyntaxError

b)

Logical Error

c)

Runtime Error

d)

Other

128.

KeyboardInterrupt is a type of:

a)

SyntaxError

b)

Logical Error

c)

Runtime Error

d)

Other

129.

Which of following is not a decision-making statement.

a)

if-elif statement

b)

for statement

c)

if -else statement

d)

if statement

130.

In Python, ...................... defines a block of statements.

a)

Block

b)

loop

c)

indentation

d)

{}

131.

if 4+5==10: print(“TRUE”) else: print(“false”) print (“True”)

a)

False True

b)

True True

c)

false

d)

none

132.

Predict the output of the following code: X=3 if x>2 or x<5 and x==6: print(“ok”) else: print(“no output”)

a)

ok

b)

okok

c)

no output

d)

none of above

133.

The for loop in Python is an _____________

a)

Entry Controlled Loop

b)

Exit Controlled Loop

c)

Both of the above

d)

None of the above

134.

The .............statement terminates the execution of the whole loop.

a)

continue

b)

exit

c)

breake

d)

break

135.

An empty /null statement in Python is ................

a)

pass

b)

none

c)

null

d)

none

136.

The ........... operator tests if a given value is contained in a sequence or not.

a)

In:

b)

in

c)

not in

d)

none

137.

The order of statement execution in the form of top to bottom is known as ___________________________ construct.

a)

alternate

b)

sequence

c)

flow of data

d)

flow chart

138.

What will be the output of given Python code? str1="hello" c=0 for x in str1: if(x!="l"): c=c+1 else: pass print(c)

a)

2

b)

0

c)

4

d)

3

139.

State which of the following statement are true . 1.If,elif ,else are not compound statement. 2.Else if can be used in python. 3.Indentation while working with blocks is not necessary in python. 4.A pass statement is a null operation;it does nothing.

a)

1

b)

2,3

c)

3

d)

4

140.

In a Python program, a control structure:

a)

Defines program-specific data structures

b)

Directs the order of execution of the statements in the program

c)

Dictates what happens before the program starts and after it terminates

d)

None of the above

141.

Which of the following is False regarding loops in Python?

a)

Loops are used to perform certain tasks repeatedly.

b)

while loop is used when multiple statements are to executed repeatedly until the given condition becomes true.

c)

while loop is used when multiple statements are to executed repeatedly until the given condition becomes false

d)

for loop can be

142.

Why is iteration important?

a)

It determines the order in which instructions are carried out

b)

It allows multiple paths through a program

c)

It allows code to be simplified by removing repeated steps

d)

It ensures the code works correctly

143.

To access a list which contains ten elements, which of the following uses of range() would produce a list of the desired indexes?

a)

range(1,10)

b)

range(0,9)

c)

range(10)

d)

range(1,11)

144.

Which statement is used to iterate itself over a range of values or a sequence

a)

if

b)

while

c)

do-while

d)

for

145.

What abandons the current iteration of the loop?

a)

continue

b)

break

c)

stop

d)

infinite

146.

Which of the following is not a loop statement in python?

a)

do-while

b)

while

c)

for

d)

all of these

147.

Which of the following is a valid keyword?

a)

IF

b)

if

c)

If

d)

None of them

148.

Symbol used to end the if statement is:

a)

;

b)

:

c)

_

d)

#

149.

A graphical representation of an algorithm to solve a given problem:

a)

Flow chart

b)

Pie Chart

c)

Bar chart

d)

Column Chart

150.

Which of the following is not a decision making statement?

a)

if-elif

b)

for

c)

if-else

d)

if

151.

A loop that never ends is called as

a)

infinite loop

b)

continue

c)

break loop

d)

none of them

152.

Find the output of the following: if True: print(101) else: print(202)

a)

101

b)

202

c)

303

d)

102

153.

Which of the following is false?

a)

oval shape in flowchart shows start or end point.

b)

Rectangle shows process

c)

Arrow shows connection between different parts of the code

d)

diamond shows input/output

154.

Which of the following is used as a dummy statement?

a)

pass

b)

pie

c)

if

d)

else

155.

If and else are____

a)

literals

b)

operators

c)

keywords

d)

none of them

156.

How many statements must be present in a loop body.

a)

at least 2

b)

at least 1

c)

at least 4

d)

no required

157.

Which is a jump statement?

a)

break

b)

commit

c)

reflect

d)

do

158.

____________loop is best when the no of iterations is known

a)

for

b)

if

c)

if else

d)

all of them

159.

In a Python program, a control structure:

a)

Defines program-specific data structures.

b)

Directs the order of execution of the statements in the program

c)

Dictates what happens before the program starts and after it terminates.

d)

None of the above.

160.

Can we write if/else into one line in Python?

a)

No

b)

Yes

c)

if/else not used in Python

d)

None of the above.

161.

What keyword would you use to add an alternative condition to an if statement?

a)

else if

b)

elseif

c)

elif

d)

None of the above

162.

Which one of the following is a valid Python if statement?

a)

if a>=9:

b)

if (a>=9)

c)

if (a=>9)

d)

if a>=9

163.

Which statement will check if a is equal to b?

a)

if a=b:

b)

if a==b:

c)

if a===b:

d)

if a==b

164.

What does the following source code print? if 4+5 == 10: print (“True”) else: print (“False”) print (“True”)

a)

True

b)

True False

c)

False True

d)

True False True

165.

What does the following source code print? x = -100 if x < 100: print (“The negative number”,x,”is not print here”) print (“It is always printed”)

a)

It is always printed

b)

The negative number -100 is not print here It is always printed

c)

The negative number -100 is not print here

d)

It will cause an error.

166.

Given the nested if-else below, what will be the value x when the source code executed successfully: x=0 a=5 b=5 if a>0: if b<0: x=x+5 elif a>5: x=x+4 else: x=x+3 else: x=x+2 print (x)

a)

0

b)

4

c)

2

d)

3

167.

Which code segment will NOT reach its print() function?

a)

if ‘yes’!=’no’: print (“Condition met”)

b)

if ‘yes’ != ‘yes’: print (“Condition met”)

c)

if not ‘yes’ = = ‘no’: print (“Condition met”)

d)

if ‘yes’ = = ‘yes’: print (“Condition met”)

168.

What will be the output of following code fragment: a=input(“Enter a number”) if (a = = 5): print (“Five”) else: print (“Not Five”) If input given is (i) 99 (ii) 5

a)

Not Five

b)

Five

c)

Cause error

d)

None of the above

169.

What does the following Python program display? x=3 if x = = 0: print (“Am I here?”,end=’ ’) elif x = = 3: print (“Or here?”, end=’ ‘) else: pass print(“Or over here?”)

a)

Am I here ?

b)

Am I here ? Or here ?

c)

Or here ? Or over here?

d)

Am I here ? Or over here?

170.

Which of the following is a pictorial representation of an algorithm?

a)

Pseudocode

b)

Program

c)

Flowchart

d)

Algorithm

171.

Terminal symbol in a flowchart indicates:

a)

End

b)

Processing

c)

Input and Output

d)

Decision

172.

In flowchart, diamond shaped symbol is used to represent:

a)

Decision box

b)

Statement box

c)

Error box

d)

if-statement box

173.

Symbol used in flowchart such as rectangle with the horizontal lines on two sides is used for:

a)

Defined statement

b)

Predefined process

c)

Error fix

d)

Variables defined

174.

What is the result of executing the following code? number = 5 while number <= 5: if number < 5: number = number + 1 print(number)

a)

The program will loop indefinitely

b)

The value of number will be printed exactly 1 time

c)

The while loop will never get executed

d)

The value of number will be printed exactly 5 times

175.

What will the following code print? counter = 1 sum = 0 while counter <= 6: sum = sum + counter counter = counter + 2 print(sum)

a)

12

b)

9

c)

7

d)

8

176.

What will be printed by the following code when it executes? sum = 0 values = [1,3,5,7] for number in values: sum = sum + number print(sum)

a)

4

b)

0

c)

7

d)

16

177.

What is the last thing printed when the following code is run? number = 0 while number <= 10: print("Number: ", number) number = number + 1

a)

Number: 10

b)

Number: number

c)

Number: 0

d)

Number: 11

178.

How many asterisks will be printed when the following code executes? for x in [0, 1, 2, 3]: for y in [0, 1, 2, 3, 4]: print('*')

a)

0

b)

4

c)

20

d)

This is an infinite loop, so nothing will be printed

179.

The following code contains an infinite loop. Which is the best explanation for why the loop does not terminate? n = 10 answer = 1 while n > 0: answer = answer + n n = n + 1 print(answer)

a)

n starts at 10 and is incremented by 1 each time through the loop, so it will always be positive.

b)

answer starts at 1 and is incremented by n each time, so it will always be positive.

c)

You cannot compare n to 0 in the while loop. You must compare it to another variable.

d)

In the while loop body, we must set n to False, and this code does not do that.

180.

Which type of loop can be used to perform the following iteration: You choose a positive integer at random and then print the numbers from 1 up to and including the selected integer.

4 lines