, , , ,

[SOLVED] COMP1117A LOOPS AND ITERATIONS Tutorial 4

$25

File Name: COMP1117A_LOOPS_AND_ITERATIONS_Tutorial_4.zip
File Size: 386.22 KB

5/5 - (1 vote)

COMP1117A Tutorial 4

LOOPS AND ITERATIONS

Q1

What is the output of the following program?

for i in range(5):

print(i, end=’,’)

A. 1,2,3,4,5,

B. 0,1,2,3,4,

C. 0,1,2,3,4,5,

D. 0 1 2 3 4

Q2

What is the output of the following program?

x =
‘abcd’

while j in x:

print(j, end=’ ‘)

A. abcd

B. a b c d

C. abcdabcdabcdabcd

D. Error

Q3

What is the output of the following program?

x =
‘abcd’

j = ‘j’

while j in x:

print(j, end = ‘ ‘)

A. no output

B. j j j j j…(never stop)

C. a b c d

D. abcd

Q4

What is the output of the following program?

x =
‘abcd’

j = ‘a’

while j in x:

print(j, end = ‘ ‘)

A. no output

B. j j j j j…(never stop)

C. a a a a…(never stop)

D. a

Q5

What is the output of the following program?

i = 1

while (i < 12):

print(i, end = ‘ ‘)

i += 2

A. 1

B. 2 4 6 8 10

C. 1 2 3 4 5 6

D. 1 3 5 7 9 11

Q6

What is the output of the following program:

for i in range(0,5,-1):

print(i,end = ‘ ‘)

A. Error: invalid syntax

B. Nothing will be printed

C. 5 4 3 2 1

D. 0 -1 -2 -3 …(never stop)

Q7

What is the output of the following program?

x=2

for i in range(x):

x+=1

print(x, end = ‘ ‘)

A. 0 1 2 3 4 …(never stop)

B. 0 1 2 3

C. 0 1

D. 3 4

Q8

What is the output of the following program?

for i in range(1,4):

print(i,end = ‘ ‘)

i = i-1

A. 1 2 3

B. 1 0 -1

C. 1 0 -1 …(never stop)

D. Nothing is printed

Q9

What is the output of the following program?

x =
‘abcd’

for i in range(x):

print(i, end=’ ‘)

A. a b c d

B. abcd

C. abcdabcdabcdabcd

D. Error

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] COMP1117A LOOPS AND ITERATIONS Tutorial 4[SOLVED] COMP1117A LOOPS AND ITERATIONS Tutorial 4
$25