from random import shuffle

class Mot:
	def __init__(self,m):
		self.m = m
	
	def doReverse(self):
		self.m = self.m[::-1]
		
	def doShuffle(self):
		L = list(self.m)
		shuffle(L)
		self.m = ''.join(L)
		
	def value(self):
		return self.m

		
class Phrase:
	def __init__(self,phrase):
		L = phrase.split()
		self.mots = []
		for m in L: 
			self.mots.append(Mot(m))
	
	def doReverse(self):
		self.mots = self.mots[::-1]
		
	def doShuffle(self):
		shuffle(self.mots)
	
	def motAt(self,pos):
		return self.mots[pos]
		
	def insert(self,pos,chaine):
		self.mots.insert(pos,Mot(chaine))
	
	def remove(self,pos):
		self.mots.pop(pos)

	def value(self):
		result	= ''
		for m in self.mots:
			result += m.value() + ' '
		return result
			

def fctA():
	m = Mot("Socrate")
	m.doReverse()
	print(m.value())

def fctB():
	m = Mot("Socrate")
	m.doShuffle()
	print(m.value())

def fctC():
	p = Phrase("Tous les hommes sont mortels")
	p.doReverse()
	print(p.value())
	
def fctD():
	p = Phrase("Tous les hommes sont mortels")
	p.doShuffle()
	print(p.value())
	
def fctE():
	p = Phrase("Tous les hommes sont mortels")
	m = p.motAt(3)
	m.doReverse()
	print(p.value())

def fctF():
	p = Phrase("Tous les hommes sont mortels")
	p.insert(3,"ne")
	p.insert(5,"pas")
	print(p.value())
	
def fctG():
	p = Phrase("Tous les hommes sont mortels")
	m = p.motAt(4)
	m.doShuffle()
	p.remove(2)
	p.insert(2,m.value())
	print(p.value())


# --- Tests ---
	
print("Fonction A:")
fctA()	

print("Fonction B:")
fctB()	

print("Fonction C:")
fctC()	

print("Fonction D:")
fctD()	

print("Fonction E:")
fctE()	

print("Fonction F:")
fctF()	

print("Fonction G:")
fctG()	




	