Powerpoint Python
Powerpoint Python
Content
I. Intro,variables, operators
3. Conditional statement
4. Loop Structure
5. Jump Statements
Introduction
Python is a high level programming language which is open source and
object oriented. It is an interactive language with simple syntax that
allows developers to write robust programs easily and effectively.
Python is an interpreter - based scripting language which can be used:
Here's a list of different types of Python operators that we will learn in this tutorial.
1.Arithmetic Operators
2. Assignment Operators
3. Relational Operators
4. Logical Operators
Input /Output Function in Python
In Python, the input() and print() functions are commonly used for handling input
and output, respectively.
Input Function - input(): Output Function - print():
● if statement
● if - else statement
● if - elif - else statement
if Statement
if Statement is used to run a
statement conditionally i.e. if given
condition is true then only the
statement given in if block will be
executed.
Syntax:
If <condition>:
statement(s)
if Statement Example :
if - else Statement
In the case of if - else statement If given
condition is true then the statement given
in if block will be executed otherwise(else)
the statements written in else block will be
executed
Syntax:
if <condition>:
statement(s)
else:
statement(s)
if - else Statement Example :
if - elif - else Statement
if elif is used for execution of statements based on
several alternatives. Python evaluates each condition
in turn and executes the statements corresponding to
the first if that is true. If none of the expressions are
true, and an else clause will be executed
Syntax:
if <condition>:
statement(s)
elif<condition>:
statement(s)
elif <condition>:
statement(s)
else:
statement(s)
if - elif - else Statement Example :
Loop Structure
What Are Python loops?
Type of Loops:
1. FOR … Loop
2. WHILE … Loop
SYNTAX:
statements(s)
Example
count=0
for count in range(0,10):
print("Hello")
OR
count=0
for count in range(0,10,2):
print("Hello")
WHILE . . . Loop
The WHILE Loop is to be used in situations where
the number of iterations is unknown at first. In
Python, the while loop executes the statement or
group of statements repeatedly while the given
condition is True. And when the condition becomes
false, the loop ends and moves to the next
statement after the loop.
SYNTAX:
while condition:
statements(s)
Example
A=0
while A !=6 :
print(“hello”)
A=A+1
OR
pwd=0
while pwd!=123:
pwd=int(input("Enter Password : "))
print("Password Accepted")
JUMP Statements
As the name suggests, a JUMP Statement is used to break the normal flow of
the program and jump onto a specific line of code in the program if the specific
condition is true.
SYNTAX:
Loop{
Condition:
break
}
Types of JUMP Statements - Break Example
OUTPUT:
2
Types of JUMP Statements
● CONTINUE Statement:
The continue statement is somewhat similar to the break statement but there is one
significant difference between them. A break statement terminates the entire loop but
the continue statement skips only the current iteration and continues with the rest steps.
So, if we use the continue statement in a loop, it will only skip one iteration when the
associated condition is true and then continue the rest of the loop unlike the break
statement.
SYNTAX:
Loop{
Condition:
Continue
}
Types of JUMP Statements - Continue Example
OUTPUT:
1
3
4