pip3 install pipenv
pipenv shell
def numbertoordinal(number): | |
number_string = str(number) | |
SUFFIXES = {1: '1st', 2: '2nd', 3: '3rd'} | |
# Checking for 11-14 because those are akward | |
if int(number_string[-2:]) > 10 and int(number_string[-2:]) < 14: | |
return number_string + 'th' | |
else: | |
suffix = SUFFIXES.get(int(number_string[-1:]), number_string + 'th') |
def myFunc(e): | |
return len(e) | |
states = ["Abia", "Adamawa", "Anambra", "Akwa Ibom", "Bauchi", "Bayelsa", "Benue", "Borno", | |
"Cross River", "Delta", "Ebonyi", "Enugu", "Edo", "Ekiti", "Gombe", "Imo", "Jigawa", | |
"Kaduna", "Kano", "Katsina", "Kebbi", "Kogi", "Kwara", "Lagos", "Nasarawa", "Niger", | |
"Ogun", "Ondo", "Osun", "Oyo", "Plateau", "Rivers", "Sokoto", "Taraba", "Yobe", "Zamfara"] | |
states.sort(reverse=True,key=myFunc) | |
print(states[5]) |
def number_game(x,y): | |
if x > y: | |
return [n for n in range(y,x) if n%2==0] | |
elif y==x: | |
return [] | |
else: | |
return [n for n in range(x,y) if n%2!=0] |
def digitize(n): | |
return [int(s) for s in str(n)][::1] | |
print(digitize(123)) |
def my_sort(numbers): | |
odd = [n for n in numbers if n % 2 != 0] | |
even = [n for n in numbers if n % 2 == 0] | |
return sorted(odd) + sorted(even) | |
print( my_sort([60, 25, 88])) |
def power(a,b): | |
if b == 0: | |
return 1 | |
else: | |
return eval(((str(a)+"*")*b)[:-1]) |
def resolve(n, coins, k): | |
if k < 0 or n < 0: | |
return 0 | |
if n == 0: | |
return 1 | |
count = resolve(n, coins, k - 1) + resolve(n - coins[k], coins, k) |
def numbertoordinal(number): | |
if number < 0 or number > 10001: | |
return None | |
if number < 20: #determining suffix for < 20 | |
if number < 10: | |
if number == 0: | |
suffix ='' | |
elif number == 1: | |
suffix = 'st' |
In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc
Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server
Use this link and get $10 free. Just select the $5 plan unless this a production app.