Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def int_to_roman(input):
- """
- Code from http://code.activestate.com/recipes/81611-roman-numerals/
- Changes made to raise statements for Python 3 compatibility
- """
- if type(input) != type(1):
- raise TypeError("expected integer, got %s" % type(input))
- if not 0 < input < 4000:
- raise ValueError("Argument must be between 1 and 3999")
- ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
- nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
- result = ""
- for i in range(len(ints)):
- count = int(input / ints[i])
- result += nums[i] * count
- input -= ints[i] * count
- return result
- names = ['Suleiman',
- 'Osman',
- 'Bayezid',
- 'Mehmed',
- 'Orhan',
- 'Murad',
- 'Selim']
- suffixes = [' the Magnificent',
- ' the Lawgiver',
- ' the Conqueror',
- ' the Terrible',
- ' the Stammerer',
- ' the Fair',
- ' the Great',
- ' the Silent']
- full_names = []
- for i in range(10):
- full_names.append('Sultan ' + random.choice(names))
- for j in reversed(range(len(full_names))):
- occurences = full_names.count(full_names[j])
- if occurences > 1:
- full_names[j] += ' ' + int_to_roman(occurences)
- already_used = []
- already_used2 = []
- for k in range(3):
- # full_name = random.choice(full_names) + random.choice(suffixes)
- # full_names[random.randint(0, len(full_names) - 1)] = full_name
- num = random.randint(0, len(full_names) - 1)
- while num in already_used:
- num = random.randint(0, len(full_names) - 1)
- already_used.append(num)
- num2 = random.randint(0, len(suffixes) - 1)
- while num2 in already_used2:
- num2 = random.randint(0, len(suffixes) - 1)
- already_used2.append(num2)
- full_names[num] += suffixes[num2]
- print('\n'.join(full_names))
Add Comment
Please, Sign In to add comment