Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
com.pptx
1. PHYTON
• Python is a dynamic, high-level, free open source, and
interpreted programming language .
• It supports object-oriented programming as well as procedural-
oriented programming.
• In Python, we don't need to declare the type of variable
because it is a dynamically typed language.
• Python is commonly used for developing websites and
software, task automation, data analysis, and data visualization.
2. CONTROL FLOW STATEMENT
Python statements do not have a return value and are used to
perform actions and control the flow of the program
Control flow statements in Python are used to control the order in
which statements are executed in a program. They allow you to
make decisions, repeat actions, and create more complex logic in
your code. The primary control flow statements in Python include:
3. Conditional Statements (if, elif, else):
•if: Executes a block of code if a condition is true.
•elif (short for "else if"): Allows you to specify additional conditions to
check if the preceding if condition is false.
•else: Executes a block of code if no previous if or elif conditions are
true.
EX:
x = 10
if x > 0:
print("x is positive")
elif x == 0:
print("x is zero")
else:
print("x is negative")
4. Loops (for and while):
•for: Iterates over a sequence (e.g., a list, tuple, or string) or any iterable
object and executes a block of code for each item in the sequence.
•while: Repeats a block of code as long as a given condition is true.
Example (for loop):
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)
Example
(while loop):
count = 0
while count < 5:
print(count)
5. Control Flow Keywords:
•break: Terminates the current loop and resumes
execution at the next statement after the loop.
•continue: Skips the rest of the current iteration of a loop
and continues with the next iteration.
•pass: Used as a placeholder for code that has no effect.
It is often used to create empty code blocks.
6. Example (break and continue):
• for i in range(1, 10):
if i == 5:
break # exit the loop when i equals 5
• elif i == 3:
continue # skip the rest of the current iteration when i equals 3
print(i)
7. Exception Handling (try, except, finally):
•try: Defines a block of code to be tested for exceptions.
•except: Specifies the block of code to be executed if an exception occurs
within the try block.
•finally: Specifies a block of code that will be executed regardless of
whether an exception occurs.
8. • try:
result = 10 / 0
• except ZeroDivisionError:
print("Division by zero error!")
• finally:
print("Execution completed.")