Salomé Veilleux

De {}
Aller à la navigation Aller à la recherche

code

100101001001111100001110100101000001110010110010111101101100101010000011100011110101110010101000001001010010011111000011110110110000111010011110011010000011101011101110010 00011000111101000110100111001011101110

weekend party

script de code qui compte combien de jours il reste avant le weekend

# -*- coding: utf-8 -*-
import time

print("le combientieme jour de la semaine est-ton (lundi=1, mardi=2, ...)") 

jour = raw_input()
jour = int(jour)

for compteur in range(1, jour + 1):
    print("jour" + str(compteur))
    time.sleep(1)

print("cool")

if jour == 1:
    print("il reste 4 jours avant le weekend")
    print(":•(")
if jour == 2:
    print("il reste 3 jours avant le weekend")
    print(":•|")
if jour == 3:
    print("il reste 2 jours avant le weekend")
    print(":•)")
if jour == 4:
    print("il reste 1 jour avant le weekend")
    print(":•)")
if jour == 5:
    print("le weekend c'est ce soir!!!!!!!")
    print(":•)")
if jour == 6:
    print("t en weekend gros veinard")
    print(":•)")
if jour == 7:
    print("t en weekend gros veinard")
    print("mais ya école demain rip")
    print(":•(")

bescherelle

script de code verificateur d'orthographe

# -*- coding: utf-8 -*-
import time

loop = True
 
while loop:
    print("comment tu écris amidale????")
    
    rep=raw_input()
    
    repLenght=len(rep) 
    
    print(rep[1])
    
    for compteur in range(0, repLenght):
        print("tu l'écrirais " + rep[compteur])
        time.sleep(1)
    
    if rep==("amygdale"):
        print("bingo!!!!!")
        loop = False
    
    else:
        print("raté!!!! essaies encore")

top secret

script de code de générateur de code secret

# -*- coding: utf-8 -*-
import time

print("écris ton message secret")

mess = raw_input()

mess = mess.replace("a","b")
mess = mess.replace("b","c")
mess = mess.replace("c","d")
mess = mess.replace("d","e")
mess = mess.replace("e","f")
mess = mess.replace("f","g")
mess = mess.replace("g","h")
mess = mess.replace("h","i")
mess = mess.replace("i","j")
mess = mess.replace("j","k")
mess = mess.replace("k","l")
mess = mess.replace("l","m")
mess = mess.replace("m","n")
mess = mess.replace("n","o")
mess = mess.replace("o","p")
mess = mess.replace("p","q")
mess = mess.replace("q","r")
mess = mess.replace("r","s")
mess = mess.replace("s","t")
mess = mess.replace("t","u")
mess = mess.replace("u","v")
mess = mess.replace("v","w")
mess = mess.replace("w","x")
mess = mess.replace("x","y")
mess = mess.replace("y","z")
mess = mess.replace("z","a")


print(mess)

time.sleep(1)
 
print("voilà, il est codé, fais en bon usage")

twittergate

Hello, I am a French code student and I would like to use the Twitter API to explore and learn the different modalities of the platform. This is a course where we have to generate a bot to improve the twitter experience that we can have on our daily life. For this purpose, I would like to be able to generate a bot that can inform users about their trip abroad by plane. This would be a bot that answers users's questions about any flight information, like the airport they need to go to or possible delays. My attention will be focused on transmitting verified information directly from airline websites.

I'm thinking of using the reply features, as my bot will need to answer questions when tagged in a tweet. He will need to understand the question and give the necessary information to the person, such as departure time or airport. I don't plan to use the other features.

motivational bot

un bot qui genere des "motivational quotes" absurdes a partir d'un site de phrases de motivation

- quelle(s) source(s) pour le texte

https://www.oberlo.com/blog/motivational-quotes extraire les phrases entre guillemets

- quels types de traitements sont utilisés pour générer le texte

coller deux phrases ensembles + essayer de garder du sens: identifier espace, virgule, point (les citations du site sont souvent en deux phrases ou plus), identifier mots de liaison comme "but"

- qu'est-ce qui déclenche le post?

??? soit daily en mode motivation du jour soit si quelqun tweet "i'm sad" ou quelque chose comme ça

bot

# coding=utf-8
import tweepy

#module pour séparer des chaines de charactères facilement

import random
#remplacer par api key et api secret key
auth = tweepy.OAuthHandler('iNuKORsrkmkRzBZkGBcEYGYiY', 'R4Rg9TZNNbnvpNXI2TtlVGRJTLds4qWIHzRiXEJsGVyIdQsyz9')
 
auth.set_access_token('1286210005998411776-FmP8aCEBXtvGCuoFsVZFB7Fqy1CdKF', 'GiwsU2GifgOL2QIqClMkuIZtQ88NamEVEyKbHBAHLkMyD')

api = tweepy.API(auth)


#un programmme qui récupère une motivational quote sur le site https://www.oberlo.com/blog/motivational-quotes

import mechanize
 
import lxml.html
 
import cssselect

#definition des mots de liaisons 
liaison = ["is",".", ",", ":", "or", "to", "and", "c'est", "are", "more than", "if", "when", "because", "unless", "after",]



 
#initialisation d'un objet "navigateur" avec la librairie mechanize
navigateur = mechanize.Browser()
 
navigateur.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
 
navigateur.set_handle_robots(False)
#fin de la configuration de mechanize
'''
try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
    # Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context
'''
 
data = navigateur.open('https://www.oberlo.com/blog/motivational-quotes', timeout=10.0)

#convertir la source en arbre html
source = data.read()
html = lxml.html.fromstring(source)
 
#convertir mon sélecteur css en objet cssselect
selecteurs = cssselect.parse('.single-post ol li span')

#[premier selecteur]
#selecteurs[0]
 
#convertir mon objet cssselect en objet xpath
chemin_xpath = cssselect.HTMLTranslator().selector_to_xpath(selecteurs[0], translate_pseudo_elements=True)

#on va appliquer le chemin xpath sur la source html
resultats = html.xpath(chemin_xpath)



#definition de la longueur des listes pour les boucles
nb_liaison = len(liaison)
nb_quotes = len(resultats)


#index pour former des phrases composées de deux parties de quotes originales
index1 = random.randint(0,500)
index2 = random.randint(0,500)
partie1=[nb_quotes]
partie2=[nb_quotes]

#boucle qui passe à travers toutes les quotes issue du scrapping
for j in range (0,nb_quotes):
    
    phrase = resultats[j]
    phrase = phrase.text_content()
    #boucle qui passe à travers tous les mots de liaisons contenus dans la liste définie manuellement pour generer les séparation logiques dans la phrase
    for i in range (0,nb_liaison):
        if liaison[i] in phrase :
         
            split_phrase = phrase.split(liaison[i])
            print("   PARTIE 1", split_phrase[0])
            print("PARTIE 2", split_phrase[1])
            partie1[j]=split_phrase[0]   # ------> IndexError: list assignment index out of range 
            partie2[j]=split_phrase[1]   
            break
            
phrasefinale = partie1[2]+partie2[4]
print (phrasefinale)