Exp-1 Python
Exp-1 Python
Experiment No.01
A.1 Aim:
To implement Python Program to Find the Sum of Natural Numbers using while loop.
A.2 Prerequisite:
1. python basics and control structures
A.3 Outcome:
After successful completion of this experiment students will
be able to
1 while loop
2 for loop
Executes a sequence of statements multiple times and abbreviates the code that
manages the loop variable.
3 nested loops
You can use one or more loop inside any another while, for or do..while loop.
1 break statement
2 continue statement
Causes the loop to skip the remainder of its body and immediately retest its
condition prior to reiterating.
3 pass statement
FOR LOOP -
For loops are used for sequential traversal. For example: traversing a list or
string or array etc. In Python, there is no C style for loop, i.e., for (i=0; i<n; i++).
There is “for in” loop which is similar to for each loop in other languages. Let us
learn how to use for in loop for sequential traversals.
Syntax:
Syntax:
while expression:
statement(s)
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)
Grade :
This Python program uses a while loop to find the sum of natural
numbers up to a user-input limit. It provides a hands-on
understanding of loop structures, variable manipulation, and user
interaction or learning programming fundamentals.
B.4 Conclusion:
Expected Output:
2. Write a Python program to check whether an alphabet is a vowel or
consonant.
Expected Output:
Expected Output