List of Topics:
Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

What is Control Flow Statements in Python?

Control Flow Statements in Python

Condition for Control Flow Statements in Python

  • Description: Control flow statements in Python are used to control the flow of execution of a program. They determine the order in which different statements or blocks of code are executed based on certain conditions or loops.
Step-by-Step Process
  • Control flow modifiers: These statements are used to alter the flow of loop.
    Break statement: Exits the current loop (either for or while) entirely, regardless of the loops condition.
    continue statement: Skips the current iteration of the loop and moves to the next iteration
    Pass statement: It is Used as a placeholder when no action is required.
Sample Code
  • #Condition Statement
    print("Output for condition statement:")
    a = 10
    if a > 5:
    print("a is greater than 5")
    else:
    print("a is not greater than 5")
    print()
    #Control flow modifiers
    #Break
    print("Output for break statement:")
    for i in range(10):
    if i == 5:
    break
    print(i)
    print()
    #Continue
    print("Output for continue statement:")
    for i in range(10):
    if i == 5:
    continue
    print(i)
    print()
    #Pass Statement
    print("Output for pass statement:")
    for i in range(5):
    if i == 3:
    pass
    print(i
Screenshots
  •  control flow statement