β’π¨βπ»ππprogram to read the name and year of birth of a person. display whether the person is a senior citizen or not #python #Techlearning #vtustudent #codinglife
name = input("enter your name: ") year_of_birth = int(input("enter your year_of_birth:"))
from datetime import date current_year = date.today().year age = current_year-year_of_birth
print("/n hello",name)
if age>=60: print("you are senior citizen")
else: print("you are not senior citizen")
Hi @ayyanagoud12
It's recommended to write your code inside triple backticks to display it better Example:
name = input("enter your name: ")
year_of_birth = int(input("enter your year_of_birth:"))
from datetime import date
current_year = date.today().year
age = current_year-year_of_birth
print("/n hello",name)
if age>=60:
print("you are senior citizen")
else:
print("you are not senior citizen")
Senior Citizen Checker Program
π Perfect for #vtustudent #codinglife #Techlearning
def check_senior_citizen(): """ Program to read name and year of birth of a person. Displays whether the person is a senior citizen or not. """
# Attractive header with hashtags
print("=" * 60)
print("π¨βπ» SENIOR CITIZEN CHECKER PROGRAM π")
print("=" * 60)
print("π Perfect for #vtustudent #codinglife #Techlearning")
print("-" * 60)
try:
# Get user input
print("\nπ ENTER PERSON'S DETAILS:")
print("-" * 30)
# Read name
name = input("π€ Enter your name: ").strip()
# Read year of birth with validation
while True:
try:
birth_year = int(input("π
Enter your year of birth (e.g., 1950): "))
current_year = 2024 # You can update this or get current year dynamically
# Validate year input
if birth_year < 1900 or birth_year > current_year:
print(f"β οΈ Please enter a valid year between 1900 and {current_year}")
continue
break
except ValueError:
print("β Invalid input! Please enter a valid year (numbers only)")
# Calculate age
age = current_year - birth_year
# Display results with attractive formatting
print("\n" + "=" * 60)
print("π RESULTS")
print("=" * 60)
print(f"π€ Name: {name}")
print(f"π
Year of Birth: {birth_year}")
print(f"π Current Age: {age} years")
# Check if senior citizen (typically 60+ years in many countries)
senior_citizen_age = 60
print("\n" + "-" * 60)
print("ποΈ SENIOR CITIZEN STATUS")
print("-" * 60)
if age >= senior_citizen_age:
print(f"β
{name}, you ARE a SENIOR CITIZEN! π")
print(f" (Age {age} is β₯ {senior_citizen_age} years)")
# Additional fun facts
if age >= 80:
print(" π Extra special status: Octogenarian or above!")
elif age >= 70:
print(" π Extra special status: Septuagenarian!")
else:
years_left = senior_citizen_age - age
print(f"β³ {name}, you are NOT a senior citizen yet.")
print(f" Only {years_left} more years to go! πͺ")
# Display hashtags for social media
print("\n" + "-" * 60)
print("π± Share your result with:")
print("#python #Techlearning #vtustudent #codinglife #seniorcitizen")
# ASCII art celebration for seniors
if age >= senior_citizen_age:
print("\nπ CELEBRATION TIME! π")
print("""
.-""-.
/ .--. \\
/ / \\ \\
| | | |
| |.-"-.|
///`.::::.`\\
||| ::/ \\:: ;
||; ::\__/:: ;
\\\\ '::::' /
`=':-..-'`
""")
except Exception as e:
print(f"\nβ An error occurred: {e}")
print("Please try again!")
Function to get current year dynamically
import datetime def get_current_year(): return datetime.datetime.now().year
Main program execution
if name == "main": # Run the program check_senior_citizen()
# Option to run multiple times
while True:
print("\n" + "=" * 60)
run_again = input("\nπ Do you want to check another person? (yes/no): ").strip().lower()
if run_again in ['yes', 'y']:
# Update current year if needed
check_senior_citizen()
else:
print("\n" + "=" * 60)
print("π Thank you for using the Senior Citizen Checker!")
print("π Keep learning! #python #vtustudent #codinglife")
print("=" * 60)
break
Hi, I would like to work on this issue.
I plan to take user input for name and year of birth, calculate age using the current year, and then check if the age is 60 or above to determine senior citizen status.
Please assign this issue to me.