in Others edited by
142 views
0 votes
0 votes

IB JIO Grade-2 Tech 2023 part-2-17

Q.17 What is the output of the following part of python program?
\[
\begin{array}{l}
\mathrm{s}=\text { "india" } \\
\mathrm{l}=0
\end{array}
\]
for $\mathrm{x}$ in $\mathrm{s}$ :
\[
\begin{array}{l}
\text { if(x!="i"): } \\
\mathrm{l}=\mathrm{l}+1
\end{array}
\]
else:
pass
print(1)
Ans
1. 5
$\times 2.6$
3. 3
$\times 4.1$
Question ID : 630680278530
Option 1 ID : 6306801082405
Option 2 ID : $\mathbf{6 3 0 6 8 0 1 0 8 2 4 0 7}$
Option 3 ID : $\mathbf{6 3 0 6 8 0 1 0 8 2 4 0 6}$
Option 4 ID : 6306801082408
Status : Answered
Chosen Option : 4

in Others edited by
by
142 views

1 Answer

0 votes
0 votes
here for(x in s) work as for loop here they count the no of character which are not equal to i.

first(x=0) if condition fail so else condition will run which is pass  when x=1 if condition true due to i!=n it increment in l so it will count all char which are not equal to i

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true