Beginner_Python_Programs_Lab_Manual
Beginner_Python_Programs_Lab_Manual
Programs
Experiment 1: Program to Demonstrate Operations on Lists
Aim/Problem Statement:
To demonstrate basic operations on lists such as adding, removing, and accessing elements.
Theory:
In Python, lists are used to store multiple items in a single variable. Lists are ordered,
changeable, and allow duplicate values. Operations such as appending, removing, and
accessing elements are common.
Program:
# Creating a list
numbers = [10, 20, 30, 40, 50]
# Adding an element
numbers.append(60)
# Removing an element
numbers.remove(30)
# Accessing elements
print("First element:", numbers[0])
# Slicing
print("List from index 1 to 3:", numbers[1:4])
Output:
First element: 10
List from index 1 to 3: [20, 40, 50]
Updated List: [10, 20, 40, 50, 60]
Conclusion:
This program demonstrates how to perform various operations on lists, such as appending
elements, removing elements, and slicing.
Aim/Problem Statement:
To check if a person is eligible to vote based on their age.
Theory:
A person is eligible to vote if their age is 18 or above. This is the voting age limit in most
countries, including India.
Program:
Output:
Conclusion:
This program takes the user's age as input and checks whether the age is greater than or
equal to 18, determining their eligibility to vote.
Experiment 3: Program to Find Whether the Given Number is Even or Odd
Aim/Problem Statement:
To determine whether a given number is even or odd.
Theory:
A number is even if it is divisible by 2 with no remainder. A number is odd if the remainder
when divided by 2 is 1.
Program:
if num % 2 == 0:
print(num, "is Even")
else:
print(num, "is Odd")
Output:
Enter a number: 7
7 is Odd
Conclusion:
This program checks whether a number is even or odd using the modulus operator.
Aim/Problem Statement:
To determine whether a given year is a leap year.
Theory:
A year is a leap year if it is divisible by 4, but not divisible by 100 unless it is also divisible by
400.
Program:
Output:
Conclusion:
This program correctly identifies leap years based on the given conditions.
Aim/Problem Statement:
To determine whether a character entered is a vowel or not.
Theory:
Vowels are the characters "a", "e", "i", "o", "u" in both lowercase and uppercase. This
program checks if the entered character belongs to the set of vowels.
Program:
Output:
Enter a character: A
A is a Vowel
Conclusion:
The program successfully checks whether the entered character is a vowel or not by
comparing it with the list of vowels.