0% found this document useful (0 votes)
2 views

Introduction to Python Programming Lab Programs Draft 1

The document is a lab manual for Python programming, specifically designed for a Physics cycle in 2025 at MVJCE. It includes two programming exercises: one for reading student details and calculating total marks and percentage, and another for determining if a person is a senior citizen based on their year of birth. Each part contains a detailed algorithm and sample output for clarity.

Uploaded by

angelotommy006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction to Python Programming Lab Programs Draft 1

The document is a lab manual for Python programming, specifically designed for a Physics cycle in 2025 at MVJCE. It includes two programming exercises: one for reading student details and calculating total marks and percentage, and another for determining if a person is a senior citizen based on their year of birth. Each part contains a detailed algorithm and sample output for clarity.

Uploaded by

angelotommy006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

INTRODUCTION TO PYTHON PROGRAMMING

LAB MANUAL
For Physics cycle in 2025 MVJCE
Programs along with output
LAB-1
Part A
Develop a program to read the student details like name, USN and marks in 3 subjects.
Display the student details, total marks and percentage with suitable messages.
USN=input(" Enter Usn ")
name=input(" Enter Name:")
print(" Enter Marks Of 3 Subjects ")
marks=[] # define an Empty list marks
for i in range(3):
m=int(input(" Enter The Marks :"))
marks.append((m)) # load the values to list marks using append method
print(marks)
total=sum(marks) # calculate the total by using sum() function and store it in variable total
per=int(100*total)/300 # calculate the percentage and store it in variable per
print(USN,name,total,per)

Algorithm:
1. Start
2. Input USN
• Prompt the user to enter the USN and store it in a variable USN.

3. Input Name
• Prompt the user to enter their Name and store it in a variable name.

4. Initialize an Empty List


• Create an empty list marks to store marks of three subjects.

5. Loop for Inputting Marks


• Repeat the following steps three times (for three subjects):
• Prompt the user to enter marks.
• Convert the input into an integer.
• Append the marks to the marks list.

6. Display the Marks List


• Print the list marks to show entered marks.

7. Calculate Total Marks


• Use the sum() function to calculate the total marks and store the result in total.

8. Calculate Percentage
• Compute the percentage using the formula:
• Store the result in the variable per.

9. Display the Result


• Print the USN, Name, Total Marks, and Percentage.
10.End

Output:
Enter USN: 1ABC24XY123
Enter Name: Ralph
Enter Marks of 3 Subjects
Enter The Marks: 30
Enter The Marks: 40
Enter The Marks: 50
Marks: [30, 40, 50]
USN: 1ABC24XY123
Name: Ralph
Total Marks: 120
Percentage: 40.0
Part B
Develop a program to read the name and year of birth of a person. Display whether the
person is a senior citizen or not.
import datetime

# Read the name and year of birth from the user


name = input("Enter your name: ")
year_of_birth = int(input("Enter your year of birth: "))

# Get the current year


current_year = datetime.datetime.now().year

# Calculate the age of the person


age = current_year - year_of_birth

# Check if the person is a senior citizen


if age >= 60:
print(f"{name}, you are a senior citizen")
else:
print(f"{name}, you are not a senior citizen")

Algorithm:
Algorithm to Determine Senior Citizen Status
1. Start
2. Input: Prompt the user to enter their name.
3. Input: Prompt the user to enter their year of birth and store it as an integer.
4. Process: Get the current year using the system's date.
5. Calculate Age:
• Subtract the year of birth from the current year to find the age.
6. Decision: Check if the age is greater than or equal to 60.
• If True: Print "{name}, you are a senior citizen."
• If False: Print "{name}, you are not a senior citizen."
7. End

Output:
Enter your name: Ralph
Enter your year of birth: 1951
Ralph, you are a senior citizen

You might also like