Posts by @Jasper_Holton (335)


My name is Jasper Camber Holton. I write, code, make music, and I am the developer of Uglek.com.

Has 335 posts, follows 17 users and is followed by 12 users.

Last seen at May 24, 2022 10:44



@Jasper_Holton's profile photo

How to Generate a String from a Number in Python I use the following code to generate a string from a number under 1000. It is using simple arrays and if statements to generate a compound number as a string.


import math
n = ['one','two','three','four','five', 'six', 'seven', 'eight', 'nine', 'ten']
tn = ['eleven','twelve','thir','four','fif','six','seven','eigh','nine']
nn = ['teen','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety','hundred']
def number_to_string(num):
    if num < 11:
        return n[num-1]
    if num < 20:
        if num < 13:
            return tn[num-11]
        return tn[num-11] + 'teen'
    if num < 100:
        extra = '-'+n[num%10-1]
        if num%10 == 0:
            extra = ''
        return nn[math.floor(num/10)-1]+extra
    if num < 1000:
        extra = '-'+n[num%10-1]
        if num%10 == 0:
            extra = ''
        return n[math.floor(num/100)-1]+'-hundred-'+nn[math.floor((num%100)/10)-1]+extra
    return 'number too large to compute!'

for x in range(1,1000):
    print(number_to_string(x))


@Jasper_Holton's profile photo

Flowers by Greenlake Now is a beautiful time of year to walk around Greenlake in Seattle. It's really warm and sunny and the lake is beautiful.

View the photo from a post by @Jasper_Holton

@Jasper_Holton's profile photo

An evening walk around Greenlake in Seattle The spring colors are beautiful this time of year. I'm looking forward to an awesome summer in Seattle.

View the photo from a post by @Jasper_Holton

@Jasper_Holton's profile photo

Busking by Greenlake in Seattle I busk sometimes by the northwest part of the lake and make a little bit of money in tips from my website and my violin case. I recorded a little bit of sound from my busking today to share with you here.

View the photo from a post by @Jasper_Holton

@Jasper_Holton's profile photo

Out hiking in Washington There's often a lot of logs like these to cross leading up to the front of an alpine lakebed.

View the photo from a post by @Jasper_Holton

© Uglek, 2022

Terms of Use and Privacy Policy