0% found this document useful (0 votes)
16 views6 pages

Exp 2

The document outlines an experiment aimed at teaching students how to implement a Python program to check if a number is positive, negative, or zero using various decision-making structures. It includes prerequisites, expected outcomes, theoretical background on if statements, and nested if statements, as well as practical tasks for students to complete. Additionally, it provides specific programming exercises for students to further their understanding of Python control structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Exp 2

The document outlines an experiment aimed at teaching students how to implement a Python program to check if a number is positive, negative, or zero using various decision-making structures. It includes prerequisites, expected outcomes, theoretical background on if statements, and nested if statements, as well as practical tasks for students to complete. Additionally, it provides specific programming exercises for students to further their understanding of Python control structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PART A

(PART A : TO BE REFFERED BY STUDENTS)

Experiment No.02
A.1 Aim:
To implement python Program to Check if a Number is Positive, Negative or 0 using if...elif...else
and nested if...else statement.

A.2 Prerequisite:
1. python basics and control structures

A.3 Outcome:
After successful completion of this experiment students will
be able to

To demonstrate basic concepts in python looping.

A.4 Theory& Procedure:


Decision making is anticipation of conditions occurring while execution of the program and
specifying actions taken according to the conditions.

Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome.
You need to determine which action to take and which statements to execute if outcome is TRUE
or FALSE otherwise.

Sr.No Statement & Description


.

1 if statements

An if statement consists of a boolean expression followed by one or more statements.

2 if...else statements

An if statement can be followed by an optional else statement, which executes


when the boolean expression is FALSE.
3 nested if statements

You can use one if or else if statement inside another if or else if statement(s).

The if statement alone tells us that if a condition is true it will execute a block of
statements and if the condition is false it won’t. But what if we want to do
something else if the condition is false. Here comes the else statement. We can
use the else statement with if statement to execute a block of code when the
condition is false.

Syntax:
if (condition):
# Executes this block if
# condition is true
else:
# Executes this block if
# condition is false
A nested if is an if statement that is the target of another if statement. Nested if
statements means an if statement inside another if statement. Yes, Python
allows us to nest if statements within if statements. i.e, we can place an if
statement inside another if statement.
Syntax:
if (condition1):
# Executes when condition1 is true
if (condition2):
# Executes when condition2 is true
# if Block is end here
# if Block is end here

if-elif-else ladder
Here, a user can decide among multiple options. The if statements are executed
from the top down. As soon as one of the conditions controlling the if is true, the
statement associated with that if is executed, and the rest of the ladder is
bypassed. If none of the conditions is true, then the final else statement will be
executed.
Syntax:-
if (condition):
statement
elif (condition):
statement
.
.
else:
statement
PART B
(PART B : TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments within two
hours of the practical. The soft copy must be uploaded on the Blackboard
or emailed to the concerned lab in charge faculties at the end of the
practical in case the there is no Black board access available)

Roll No.: 33 Name: Ashish Bhosale

Class :C Batch :C2

Date of Experiment: 9-01-2024 Date of Submission:

Grade :

B.1 Document created by the student:

B.3 Observations and learning:


(Students are expected to understand the selected topic. Have to list out the
components & functionality. Prepare a flow of the algorithm defined in the
paper. List the performance metrics that is used)

B.4 Conclusion:
(Students must write the conclusion as per the attainment of individual
outcome listed above and learning/observation noted in section B.3)
B.5 Question of Curiosity
1). Write a Python program to find those numbers which are
divisible by 7 and multiple of 5, between 2500 and 3600 (both
included)

2.Write a Python program to count the number of even and odd


numbers from a series of numbers.
Sample numbers : numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)
Expected Output :
Number of even numbers : 5
Number of odd numbers : 4

3. Write a Python program that prints all the numbers from 0 to 6


except 3 and 6.
Note : Use 'continue' statement. pp
Expected Output : 0 1 2 4 5

You might also like