Différences entre les versions de « Utilisateur:LiloJoris »
Aller à la navigation
Aller à la recherche
Ligne 1 : | Ligne 1 : | ||
+ | ''' | ||
+ | == Poésie algorithmique - Script de Moi == | ||
+ | ''' | ||
+ | <syntaxhighlight lang="HTML5"> | ||
+ | #!python | ||
+ | # -*- coding: utf-8 -*- | ||
+ | |||
+ | import string | ||
+ | import unicodedata | ||
+ | import time | ||
+ | |||
+ | with open('Poetry.txt', 'r') as tete: | ||
+ | poeme = tete.read() | ||
+ | |||
+ | lines = poeme.splitlines() | ||
+ | |||
+ | print('If you want to know what sentence fits best with your personality, tell me where you were born.') | ||
+ | city=input() | ||
+ | city=unicodedata.normalize('NFD', str(city)).encode('ascii','ignore') #ignorer accents + convertir lettres | ||
+ | city=str(city).lower() #ignorer maj | ||
+ | asciiChars=list(string.ascii_lowercase) | ||
+ | |||
+ | cityNbr = 0 | ||
+ | for counter in range(0, len(city)): | ||
+ | letterSearch=city[counter] | ||
+ | for counter2 in range(0,len(asciiChars)): | ||
+ | theLetter=asciiChars[counter2] | ||
+ | #print("looking for" + letterSearch + "current letter :" +theLetter) | ||
+ | if(theLetter == letterSearch): | ||
+ | cityNbr = cityNbr + counter2 | ||
+ | break | ||
+ | |||
+ | #print(cityNbr) | ||
+ | |||
+ | while cityNbr >= 14: | ||
+ | cityNbr = cityNbr-14 | ||
+ | |||
+ | print('The sentence that fits you most is : ' + lines[cityNbr]) | ||
+ | |||
+ | |||
+ | print('Now, if you want to know what your astrological word is, tell me how old you are.') | ||
+ | age=input() | ||
+ | wordNbr=int(age)*int(cityNbr) | ||
+ | #print(cityNbr) | ||
+ | #print(wordNbr) | ||
+ | |||
+ | f = open('Poetry.txt') | ||
+ | |||
+ | words = poeme.split() #séparer poème en mots | ||
+ | |||
+ | #wordNbr = wordNbr % len(age) | ||
+ | while wordNbr >= 48: | ||
+ | wordNbr = wordNbr-48 | ||
+ | #print(wordNbr) | ||
+ | |||
+ | print('Your astrological word is : ' + words[wordNbr]) | ||
+ | time.sleep(2) | ||
+ | print('Now please leave.') | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ''' | ||
+ | == Poésie algorithmique - Script de Simon == | ||
+ | ''' | ||
+ | <syntaxhighlight lang="HTML5"> | ||
+ | #!python | ||
+ | # -*- coding: utf-8 -*- | ||
+ | |||
+ | import random | ||
+ | |||
+ | lines = open('Poetry.txt').read().splitlines() | ||
+ | |||
+ | random.shuffle(lines) #changer ordres lignes | ||
+ | |||
+ | for line in lines: #écrire ligne par ligne | ||
+ | print(line) | ||
+ | </syntaxhighlight> | ||
+ | |||
''' | ''' | ||
== Poésie algorithmique - Script en FR == | == Poésie algorithmique - Script en FR == |
Version du 2 novembre 2019 à 15:17
Poésie algorithmique - Script de Moi
#!python
# -*- coding: utf-8 -*-
import string
import unicodedata
import time
with open('Poetry.txt', 'r') as tete:
poeme = tete.read()
lines = poeme.splitlines()
print('If you want to know what sentence fits best with your personality, tell me where you were born.')
city=input()
city=unicodedata.normalize('NFD', str(city)).encode('ascii','ignore') #ignorer accents + convertir lettres
city=str(city).lower() #ignorer maj
asciiChars=list(string.ascii_lowercase)
cityNbr = 0
for counter in range(0, len(city)):
letterSearch=city[counter]
for counter2 in range(0,len(asciiChars)):
theLetter=asciiChars[counter2]
#print("looking for" + letterSearch + "current letter :" +theLetter)
if(theLetter == letterSearch):
cityNbr = cityNbr + counter2
break
#print(cityNbr)
while cityNbr >= 14:
cityNbr = cityNbr-14
print('The sentence that fits you most is : ' + lines[cityNbr])
print('Now, if you want to know what your astrological word is, tell me how old you are.')
age=input()
wordNbr=int(age)*int(cityNbr)
#print(cityNbr)
#print(wordNbr)
f = open('Poetry.txt')
words = poeme.split() #séparer poème en mots
#wordNbr = wordNbr % len(age)
while wordNbr >= 48:
wordNbr = wordNbr-48
#print(wordNbr)
print('Your astrological word is : ' + words[wordNbr])
time.sleep(2)
print('Now please leave.')
Poésie algorithmique - Script de Simon
#!python
# -*- coding: utf-8 -*-
import random
lines = open('Poetry.txt').read().splitlines()
random.shuffle(lines) #changer ordres lignes
for line in lines: #écrire ligne par ligne
print(line)
Poésie algorithmique - Script en FR
Le script decidera quelle phrase va le mieux avec la personalité de l'utilisateur en fonction de sa ville de naissance (addition de la valeur de chaque lettre). Si la valeur numérique de la ville est plus grande que le nombre de phrases disponibles, le compteur 'recommence'. Si l'utilisateur veut connaitre son mot préféré, il peut le faire en fonction de son âge multiplié par sa ville.