0% found this document useful (0 votes)
2 views3 pages

Python Programming Lab Manual

The Python Programming Lab Manual focuses on teaching students the while loop through simple programs. It includes tasks such as printing numbers, calculating sums, and generating multiplication tables, all using Python in Visual Studio Code. The manual provides software requirements and instructions for running the programs effectively.

Uploaded by

hina shafi
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)
2 views3 pages

Python Programming Lab Manual

The Python Programming Lab Manual focuses on teaching students the while loop through simple programs. It includes tasks such as printing numbers, calculating sums, and generating multiplication tables, all using Python in Visual Studio Code. The manual provides software requirements and instructions for running the programs effectively.

Uploaded by

hina shafi
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

Python Programming Lab Manual

Course Title
Data Structure

Lab Objective
This lab manual is designed to help students understand the while loop in
Python through very simple programs. Students will be able to write, run,
and understand basic while-loop-based programs using Visual Studio Code
(VS Code).

Software Requirements
 Python 3.x
 Visual Studio Code (VS Code)
 Python Extension for VS Code

Lab 1: While Loop in Python (All Tasks)


Aim
To understand and implement the while loop in Python for repetition and
iteration.

Task 1: Print Numbers from 1 to 5


Program
i = 1
while i <= 5:
print(i)
i = i + 1

Task 2: Print Numbers from 1 to 10


Program
i = 1
while i <= 10:
print(i)
i += 1
Task 3: Print Even Numbers up to 10
Program
i = 2
while i <= 10:
print(i)
i += 2

Task 4: Print a Message 5 Times


Program
i = 1
while i <= 5:
print("Welcome to Python Lab")
i += 1

Task 5: Sum of First 5 Natural Numbers


Program
i = 1
sum = 0

while i <= 5:
sum = sum + i
i += 1

print("Sum is:", sum)

Task 6: Table of a Number


Program
num = int(input("Enter a number: "))
i = 1

while i <= 10:


print(num, "x", i, "=", num * i)
i += 1

Lab Instructions for Students


 Save the file with .py extension.
 Run the program using VS Code terminal.
 Observe the output.
 Do not forget to update the loop variable.

You might also like