0% found this document useful (0 votes)
15 views1 page

Python Loop Examples and Identifier Rules

1. Prints increasing even numbers from 2 to infinity using a while loop. 2. Prints increasing numbers divisible by 3 from 3 to infinity using a while loop with a continue statement. 3. Prints False repeatedly in a while True loop that immediately breaks. 4. Prints "bad" as the conditional statements evaluate to False. 5. Prints the name variable if it starts with 't', else prints "finished". 6. Prints the characters of x and y in nested for loops using their indexes. 7. Prints the rules for identifiers in Python. 8. Prints "no" as x or y or z evaluate to False. 9. Asks to mention the rules for identifiers.

Uploaded by

Taru Goel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Python Loop Examples and Identifier Rules

1. Prints increasing even numbers from 2 to infinity using a while loop. 2. Prints increasing numbers divisible by 3 from 3 to infinity using a while loop with a continue statement. 3. Prints False repeatedly in a while True loop that immediately breaks. 4. Prints "bad" as the conditional statements evaluate to False. 5. Prints the name variable if it starts with 't', else prints "finished". 6. Prints the characters of x and y in nested for loops using their indexes. 7. Prints the rules for identifiers in Python. 8. Prints "no" as x or y or z evaluate to False. 9. Asks to mention the rules for identifiers.

Uploaded by

Taru Goel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

i=1
while True:
if i%2 == 0:
break
print(i)
i += 2
2.
i=2
while True:
if i%3 == 0:
continue
print(i)
i += 2
3.
true = False
while True:
print(true)
break
4.
if (9 < 0) and (0 < -9):
print("hello")
elif (9 > 0) or False:
print("good")
else:
print("bad")
5. print(name)
for i in range(-1,-7,-3): if name[0]=='t':
for j in range(1,3): break
print(i,j) else:
6. print("finished")
x='one' print("got it...")
y='two' 8.
counter=0 x,y,z=True,False,False
while counter<len(x): if not(x or y or z):
print(x[counter],y[counter]) print("yes")
counter+=1 else:
7. print("no")
for name 9.
in["jay","ram","tom","sur","sam"]: Mention the Rules for identifiers?

You might also like