Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
ZTE MF283U 4G Unlocked Router (Used)
ayanthamaxi
Updated:
Sunday at 8:26 PM
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Saturday at 8:07 AM
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Jul 15, 2026
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Jul 15, 2026
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Jul 15, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
NEW NIC ALGORITHM [PYTHON]
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="MihiCherub" data-source="post: 26666048" data-attributes="member: 238676"><p>අලුත් NIC එකට පොඩි කෝඩ් කෑල්ල්ක් ලිව්ව. ඕනෙ විදියට වෙනස් කරගෙන පොඩ්ඩක් ටෙස්ට් කොරල බලල කියන්න හරිද කියල. ඕනෙ ප්රොජෙක්ට් වලට ගෙඩිය පිටින්ම උස්සල පාවිච්චි කරන්න. වැරදි අඩුපාඩු සහිත නම් දැනුවත් කරන්න. input nic number validation එකක් කරල නෑ.</p><p></p><p>[CODE=python]from datetime import datetime, timedelta</p><p></p><p></p><p>class NicDetails:</p><p></p><p> def __init__(self, nic_number: str):</p><p></p><p> self.birthday = None</p><p> self.gender: str = ""</p><p> self.age: int = 0</p><p></p><p> self.__set_details(nic_number)</p><p></p><p> def __set_details(self, nic_number):</p><p></p><p> if len(nic_number) == 10: # OLD NIC Including 'v' or 'x'</p><p> year = int("19" + nic_number[:2])</p><p> days = int(nic_number[2:5])</p><p></p><p> else: # New NIC After 2000</p><p> year = int(nic_number[:4])</p><p> days = int(nic_number[4:7])</p><p></p><p> self.birthday = datetime(year, 1, 1) + timedelta(days - 2) # All the years are leap years, NIC coding</p><p></p><p> if days > 500:</p><p> self.gender = "Female"</p><p> days -= 500</p><p> else:</p><p> self.gender = "Male"</p><p></p><p> today = datetime.today()</p><p> self.age = today.year - self.birthday.year - (</p><p> (today.month, today.day) < (self.birthday.month, self.birthday.day))[/CODE]</p><p></p><p>usage</p><p>[CODE=python]nic = NicDetails("952453462v")</p><p>print(nic.birthday)</p><p>print(nic.gender)</p><p>print(nic.age)[/CODE]</p></blockquote><p></p>
[QUOTE="MihiCherub, post: 26666048, member: 238676"] අලුත් NIC එකට පොඩි කෝඩ් කෑල්ල්ක් ලිව්ව. ඕනෙ විදියට වෙනස් කරගෙන පොඩ්ඩක් ටෙස්ට් කොරල බලල කියන්න හරිද කියල. ඕනෙ ප්රොජෙක්ට් වලට ගෙඩිය පිටින්ම උස්සල පාවිච්චි කරන්න. වැරදි අඩුපාඩු සහිත නම් දැනුවත් කරන්න. input nic number validation එකක් කරල නෑ. [CODE=python]from datetime import datetime, timedelta class NicDetails: def __init__(self, nic_number: str): self.birthday = None self.gender: str = "" self.age: int = 0 self.__set_details(nic_number) def __set_details(self, nic_number): if len(nic_number) == 10: # OLD NIC Including 'v' or 'x' year = int("19" + nic_number[:2]) days = int(nic_number[2:5]) else: # New NIC After 2000 year = int(nic_number[:4]) days = int(nic_number[4:7]) self.birthday = datetime(year, 1, 1) + timedelta(days - 2) # All the years are leap years, NIC coding if days > 500: self.gender = "Female" days -= 500 else: self.gender = "Male" today = datetime.today() self.age = today.year - self.birthday.year - ( (today.month, today.day) < (self.birthday.month, self.birthday.day))[/CODE] usage [CODE=python]nic = NicDetails("952453462v") print(nic.birthday) print(nic.gender) print(nic.age)[/CODE] [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom