-
Notifications
You must be signed in to change notification settings - Fork 0
/
voting eligibility class.py
37 lines (31 loc) · 1.16 KB
/
voting eligibility class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Thu May 5 13:35:54 2022
@author: sneha
"""
import datetime
class person:
def __init__(self,name,dob):
self.name=name
self.dob=dob
def check(self):
today=datetime.date.today()
age=today.year-self.dob.year
if today<datetime.date(self.dob.year,self.dob.month,self.dob.day):
print(" INVALID DOB ")
if age>=18:
print("\n\t\t\t\t\t You are Eligible to Vote. (Age : ", age,")")
else:
print("\n\t\t\t\t\t You are Not Eligible to Vote. (Age : ", age,")")
while True:
print("\n\n\n\n\n\t\t\t\t\t VOTING ELIGIBILITY")
print("\t\t\t\t\t ------------------")
name=input("\n\t\t\t\t\t Enter the Name : ")
year=int(input("\n\t\t\t\t\t Enter the year : "))
month=int(input("\n\t\t\t\t\t Enter the month : "))
day=int(input("\n\t\t\t\t\t Enter the day : "))
p1=person(name,datetime.date(year,month,day))
p1.check()
if input("\n\n\n\t\t\t\t\t Do you want to continue :")!='y':
print("\n\n\n\t\t -----------------------------------------------------------------")
break