Program1(b)
1. 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.
Objective of the Program
To read string and numeric input from the keyboard
To perform age calculation using the current year
To apply conditional statements for decision making
To display meaningful output based on logical conditions
Logical Construction (Think Before You Code)
Let us clearly understand the logic before writing the program.
The program must read the name of the person.
The program must read the year of birth.
The current year is required to calculate age.
Age is calculated using the formula: age = current_year – year_of_birth
If the calculated age is greater than or equal to 60, the person is a Senior Citizen.
Otherwise, the person is not a Senior Citizen.
The program displays the result with the person’s name.
👉 The decision is based purely on the age condition.
Flowchart
Algorithm
Start
Read the name of the person
Read the year of birth
Set current year
Calculate age
If age ≥ 60
Display “Senior Citizen”
Else
Display “Not a Senior Citizen”
Stop
Python Program
⚠️ Students must complete the missing statements
# Program to check whether a person is a Senior Citizen
name = input("Enter name: ")
year_of_birth = int(input("Enter year of birth: "))
current_year = ____________
age = ____________ - ____________
if age >= ____________:
print(name, "is a Senior Citizen")
else:
print(name, "is not a Senior Citizen")
Probable Output
Case 1: Senior Citizen
Case 2: Not a Senior Citizen
Important Concepts Used
input()functionType conversion using
int()Arithmetic operation
Conditional statement (
if–else)Relational operator (
>=)
Viva Voce Questions
How is age calculated in this program?
Why is the year of birth converted to integer?
What happens if the current year is changed?
Why is
>= 60used instead of> 60?Can this program work for future years?
What data type is used to store the name?
How can the current year be taken dynamically?
Procedure to Execute the Program
Open Python IDLE / VS Code / Google Colab
Create a new Python file
Type the program
Save the file with
.pyextensionRun the program
Enter inputs when prompted
Google Colab – Online Execution
👉 Click the link below to execute the complete working version of this program:
[https://colab.research.google.com/drive/1ID5DKz9uNmquANwdFiI75yWrsGAWVpyK?usp=sharing]
Program Explanation
Assignment for Students
Modify the program to take current year from the system
Extend the program to classify:
Child
Adult
Senior Citizen
Validate input to avoid invalid year values
Lab Record Instructions
Right Side of the Record
1. Problem Statement
2. Python Program
Write the following neatly on the right-hand side page:
Left Side of the Record
Write the following neatly on the left-hand side page:
3. Flowchart
4. Algorithm
5. Output
⚠️ Students must write ALL possible outputs.

Comments
Post a Comment