Course: BCA Year/Semester: 2/IV
Subject code: BCA 412
Session: 2025-26
Subject Name: Python Programming Lab
Name of the faculty: Dr. Peeyush Kumar Pathak
EXPERIMENT 03
Program to demonstrate branching statement.
Theory:
Branching statements are used to control the flow of a program by making decisions based
on conditions.
They help a program choose different paths of execution.
Python supports the following branching statements:
if statement
if-else statement
if-elif-else statement
Python uses indentation to define blocks of code.
Algorithm:
1. Start
2. Accept a number from user
3. Check if number is positive, zero or negative
4. Display result
5. Stop
PROGRAM: -1
num = int(input("Enter a number: "))
if num > 0:
print("Number is Positive")
elif num == 0:
print("Number is Zero")
else:
print("Number is Negative")
PROGRAM-2: greatest of among three Numbers and Arithmetic operator
# Program to find the greatest among three numbers
# Input three numbers
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
c = float(input("Enter third number: "))
# Compare the numbers
if a >= b and a >= c:
greatest = a
elif b >= a and b >= c:
greatest = b
else:
greatest = c
# Output the result
print("The greatest number is:", greatest)
# Arithmetic operator
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
op = input("Enter operator (+, -, *, /): ")
if op == '+':
print("Result =", a + b)
elif op == '-':
print("Result =", a - b)
elif op == '*':
print("Result =", a * b)
elif op == '/':
print("Result =", a / b)
else:
print("Invalid Operator")
PROGRAM 3: Grade System
marks = int(input("Enter marks: "))
if marks >= 80:
print("Grade A")
elif marks >= 60:
print("Grade B")
elif marks >= 40:
print("Grade C")
else:
print("Fail")