0% found this document useful (0 votes)
14 views2 pages

Practical 3 PQC

The document outlines an experiment for students at G H Raisoni College of Engineering & Management to demonstrate control structures in Python programming. It includes objectives to understand and implement conditional statements and looping structures, along with a problem statement requiring the creation of a program that utilizes these concepts. The document also details the theory behind control structures, an algorithm for the program, and the necessary tools for execution.

Uploaded by

Atharv Bhavsar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Practical 3 PQC

The document outlines an experiment for students at G H Raisoni College of Engineering & Management to demonstrate control structures in Python programming. It includes objectives to understand and implement conditional statements and looping structures, along with a problem statement requiring the creation of a program that utilizes these concepts. The document also details the theory behind control structures, an algorithm for the program, and the necessary tools for execution.

Uploaded by

Atharv Bhavsar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

G H Raisoni College of Engineering & Management, Pune

NAAC Accredited A+ Grade


(An Empowered Autonomous Institute Affiliated to Savitribai Phule Pune University)

Department of CSE Artificial Intelligence and Machine Learning

Experiment No.3
Title: Write a program to demonstrate working of control structures.
Objectives:
1. To understand the concept and significance of control structures in programming.
2. To implement conditional statements like if, if-else, and elif.
3. To utilize looping structures, like for and while loops.
4. To demonstrate the use of break, continue, and pass statements.
5. To enhance decision-making and flow control in Python programs.
Problem Statement:
Write a Python program that demonstrates the use of various control structures such as conditional statements
(if, if-else, elif) and looping constructs (for, while). The program should include real-life scenarios like
checking whether a number is positive or negative, printing even numbers within a range, and summing natural
numbers using loops.
Outcomes:
1. Understand the use and syntax of different control structures in Python.
2. Apply conditional logic to make decisions in code.
3. Use loops to repeat blocks of code effectively.
4. Differentiate between entry-controlled and exit-controlled loops.
5. Improve problem-solving skills using control flow statements.
Tools Required: 8GB RAM, Anaconda, Notebook, python
Theory:
Control structures are the building blocks of logic in programming. They determine the flow of control in a
program. Python supports three types of control structures:
1. Sequential – Executes statements in sequence.
2. Conditional/Decision-Making – Used to execute specific blocks of code based on conditions.
o if
o if-else
o if-elif-else
3. Looping/Iteration – Used for executing a block of code multiple times.
o while loop
o for loop
Additional statements:
• break: Terminates the loop.
• continue: Skips the current iteration and continues with the next.
• pass: Does nothing; a placeholder.

Algorithm:
Step 1: Start the program.
Step 2: Accept a number from the user.
Step 3: Use an if-else structure to check whether the number is positive, negative, or zero.
Step 4: Use a for loop to display all even numbers from 1 to 10.
Step 5: Use a while loop to calculate the sum of first 'n' natural numbers.
Step 6: Demonstrate use of break and continue in loop.
Step 7: End the program.
Conclusion:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________

You might also like