What will be the output of the following Python code? x = “abcdef” i = “a” while i in x: print(‘i’, end = “ ”)

Question: What will be the output of the following Python code?

x = “abcdef” 

i = “a” 

while i in x: 

    print(‘i’, end = “ ”)


(a) No output 

(b) i i i i i i ... 

(c) a a a a a a... 

(d) a b c d e 

Ans: (b) i i i i i i ... 

Here i i i i i i ... printed continuously because as the value of i or x is not changing, the condition will always evaluate to True. But also here we use a quotation marks on “i”, so here i treated as a string, not like a variable.

Comments

Popular posts from this blog

Changing Trends And Career in Physical Education Solutions || Objective Type Questions || Objective Answers Chapter 1 Class 11 Solution || Physical Education ||

Vistas Chapter-2 The Tiger King || Revision Notes Class 12 Board Exams

Kinematics Important Questions Of Physics

Three oxides of lead on analysis were found to contain lead as under:(i) 3.45 g of yellow oxide contains 3.21 g of lead. (ii) 1.195 g of brown oxide contains 1.035 g of lead. (iii) 1.77 g of red oxide contains 1.61 g of lead. Show that these data illustrate law of multiple proportions.

Test and Measurement in Sports Case Study Based Questions Chapter 6 Class 12 Physical education