484647789 by Unknown
Author:Unknown
Language: eng
Format: epub
In the following example, the loop continues if the number is 0 but stops (break) if it is 5, so we get 1 2 3 4.
n = list(range(10))
for x in n:
if x == 5: break
elif x == 0 : continue
else: print(x)
The âWhileâ keyword also creates a loop, which break only if the condition is false. This may create a perpetual loop if the condition is always true.
n = 10
while n:
print(n)
n = n-1
In the above example, the while keyword evaluates the number to check if it is True, i.e. not 0 or None, print the number and reduce it by 1.Notice that any object in Python is True, except False, None or Zero.
The "and", "or" , "not" Keywords
Those logical operators are used with the âifâ and other conditional statements to compare expressions against given conditions.
And : executes an expression if both the operands are true
Or : executes an expression if either of the operands is true
Not : executes an expression if an operand is false
Here is an example of using the three keywords:
Username = "Suresh"
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Twisted Games: A Forbidden Royal Bodyguard Romance by Ana Huang(3674)
Den of Vipers by K.A Knight(2568)
The Push by Ashley Audrain(2565)
Win by Harlan Coben(2514)
Echo by Seven Rue(2140)
Beautiful World, Where Are You: A Novel by Sally Rooney(2038)
Leave the World Behind by Rumaan Alam(1984)
Iron Widow by Xiran Jay Zhao(1970)
Baby Bird by Seven Rue(1943)
Midnight Mass by Sierra Simone(1901)
A Little Life: A Novel by Hanya Yanagihara(1752)
Undercover Threat by Sharon Dunn(1680)
The Four Winds by Hannah Kristin(1672)
Bridgertons 2.5: The Viscount Who Loved Me [Epilogue] by Julia Quinn(1669)
The Warrior's Princess Prize by Carol Townend(1545)
Sister Fidelma 07 - The Monk Who Vanished by Peter Tremayne(1496)
Snowflakes by Ruth Ware(1483)
Dark Deception by Rina Kent(1432)
Facing the Mountain by Daniel James Brown(1429)
