Python Tutorial ( PDFDrive )
breakFlow Diagram: Example: #!/usr/bin/pythonfor letter in 'Python': # First Exampleif letter == 'h':breakprint 'Current Letter :', lettervar = 10# Second Examplewhile var > 0:print 'Current variable value :', varvar = var -1if var == 5:breakprint "Good bye!"When the above code is executed, it produces the following result:Current Letter : PCurrent Letter : yCurrent Letter : tCurrent variable value : 10Current variable value : 9Current variable value : 8Current variable value : 7Current variable value : 6Good bye!TUTORIALS POINT Simply Easy Learning
continue statement The continue statement in Python returns the control to the beginning of the while loop. The continue statementrejects all the remaining statements in the current iteration of the loop and moves the control back to the top of theloop.The continue statement can be used in both while and for loops.Syntax: The syntax for a continue statement in Python is as follows:continueFlow Diagram: Example: #!/usr/bin/pythonfor letter in 'Python': # First Exampleif letter == 'h':continueprint 'Current Letter :', lettervar = 10# Second Examplewhile var > 0:var = var -1if var == 5:continueprint 'Current variable value :', varprint “Good bye!”When the above code is executed, it produces the following result:Current Letter : PTUTORIALS POINT Simply Easy Learning
- Page 39 and 40: Example: ..........................
- Page 41 and 42: CHAPTER1Python OverviewPython is a
- Page 43 and 44: CHAPTER2Python EnvironmentBefore we
- Page 45 and 46: • To use this installer python-XY
- Page 47 and 48: -c cmd run Python script sent in as
- Page 49 and 50: This will produce the following res
- Page 51 and 52: file_name = raw_input("Enter filena
- Page 53 and 54: $ python -husage: python [option] .
- Page 55 and 56: print 'Input file is "', inputfilep
- Page 57 and 58: Here, an integer object is created
- Page 59 and 60: Python Lists: Lists are the most v
- Page 61 and 62: FunctionDescriptionint(x [,base])Co
- Page 63 and 64: CHAPTER5Python Basic OperatorsWhat
- Page 65 and 66: Line 4 - Value of c is 2Line 5 - Va
- Page 67 and 68: Line 5 - a is greater than bLine 6
- Page 69 and 70: | Binary OR Operator copies a bit i
- Page 71 and 72: else:print "Line 3 - a and b are tr
- Page 73 and 74: if ( id(a) == id(b) ):print "Line 2
- Page 75 and 76: When you execute the above program,
- Page 77 and 78: if statementsif...else statementsne
- Page 79 and 80: Example: #!/usr/bin/pythonvar1 = 10
- Page 81 and 82: else:print "Could not find true exp
- Page 83 and 84: Loop Typewhile loopfor loopDescript
- Page 85 and 86: num = raw_input("Enter a number :")
- Page 87 and 88: Good bye!Iterating by Sequence I
- Page 89: 11 is prime13 is prime17 is prime19
- Page 93 and 94: CHAPTER8Python NumbersNumber data t
- Page 95 and 96: max(x1, x2,...)min(x1, x2,...)modf(
- Page 97 and 98: Syntax Following is the syntax for
- Page 99 and 100: import math# This will import math
- Page 101 and 102: import mathmath.log10( x )Note: Thi
- Page 103 and 104: modf(x) Description The method modf
- Page 105 and 106: round( x [, n] )Parameters • x --
- Page 107 and 108: Return Value This method returns a
- Page 109 and 110: seed([x]) Description The method se
- Page 111 and 112: Syntax Following is the syntax for
- Page 113 and 114: asin(x)Note: This function is not a
- Page 115 and 116: print "atan2(-10,10) : ", math.atan
- Page 117 and 118: Note: This function is not accessib
- Page 119 and 120: import mathprint "degrees(3) : ", m
- Page 121 and 122: CHAPTER9Python StringsStrings are a
- Page 123 and 124: + Concatenation - Adds values on ei
- Page 125 and 126: TAB ( \t ) and they will show up th
- Page 127 and 128: 14151617181920212223242526272829303
- Page 129 and 130: str = "this is string example....wo
- Page 131 and 132: Return Value This method returns a
- Page 133 and 134: Description The method expandtabs()
- Page 135 and 136: Traceback (most recent call last):F
- Page 137 and 138: Let us compile and run the above pr
- Page 139 and 140: str = "This is string example....wo
break
Flow Diagram:
Example:
#!/usr/bin/python
for letter in 'Python': # First Example
if letter == 'h':
break
print 'Current Letter :', letter
var = 10
# Second Example
while var > 0:
print 'Current variable value :', var
var = var -1
if var == 5:
break
print "Good bye!"
When the above code is executed, it produces the following result:
Current Letter : P
Current Letter : y
Current Letter : t
Current variable value : 10
Current variable value : 9
Current variable value : 8
Current variable value : 7
Current variable value : 6
Good bye!
TUTORIALS POINT
Simply Easy Learning