import random vowels=["a","e","i","o","u"] consonants=["b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","y","z"] governments=["empire","kingdom","republic","state","federation"] government_adjectives=["federal","united","democratic","people's"] title1=["great","supreme","immortal","eternal","arch","prime"] title2=["emperor","king","president","minister","consul","leader"] def generate_country(): output="" length=random.randint(3,5) t=random.choice([True,False]) for z in range(length): if t==True: output+=random.choice(vowels) else: output+=random.choice(consonants) t = not t return output.capitalize() def combine_fluently(string1,string2): if string1[-1] in vowels and string2[0] in vowels: return random.choice([string1[:-1]+string2,string1+string2[1:]]) if string2[-1] in consonants and string2[0] in consonants: return random.choice([string1[:-1]+string2,string1+string2[1:]]) return string1+string2 def adjectivize(country): return combine_fluently(country,random.choice(["an","ian","ese","er"])) def generate_title(): return random.choice(title1).capitalize()+" "+random.choice(title2).capitalize() def generate_state(noun,adjective): return random.choice(["The "+adjective+" "+random.choice(governments),"The "+random.choice(governments).capitalize()+" of "+noun,"The "+random.choice(government_adjectives)+" "+random.choice(governments).capitalize()+" of "+noun]) class Country: def __init__(self): self.name = generate_country() self.adjective = adjectivize(self.name) self.title = generate_title() self.full_name = generate_state(self.noun,self.adjective) def show_information(self): input("Welcome to "+self.full_name+".") input("It is led by the "+self.title+".") print("yello!") empire = Country() input(empire.name)) print(empire.adjective) print(empire.title) print(empire.full_name)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question