Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Nth/Python/nth-1.py
Normal file
8
Task/Nth/Python/nth-1.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
_suffix = ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th']
|
||||
|
||||
def nth(n):
|
||||
return "%i'%s" % (n, _suffix[n%10] if n % 100 <= 10 or n % 100 > 20 else 'th')
|
||||
|
||||
if __name__ == '__main__':
|
||||
for j in range(0,1001, 250):
|
||||
print(' '.join(nth(i) for i in list(range(j, j+25))))
|
||||
15
Task/Nth/Python/nth-2.py
Normal file
15
Task/Nth/Python/nth-2.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
def ord(n):
|
||||
try:
|
||||
s = ['st', 'nd', 'rd'][(n-1)%10]
|
||||
if (n-10)%100//10:
|
||||
return str(n)+s
|
||||
except IndexError:
|
||||
pass
|
||||
return str(n)+'th'
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(*(ord(n) for n in range(26)))
|
||||
print(*(ord(n) for n in range(250,266)))
|
||||
print(*(ord(n) for n in range(1000,1026)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue