This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Vigenère Cipher, by Lino Urdaneta and Al Sweigart al@inventwithpython.com | |
The Vigenère cipher is a polyalphabetic substitution cipher that was | |
powerful enough to remain unbroken for centuries. | |
More info at: https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher | |
Tags: short, cryptography, math | |
*/ | |
object Vigenere { | |
def main(): Unit = { | |
println("""Vigenère Cipher. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Bagels, by Lino Urdaneta based in al@inventwithpython.com | |
A deductive logic game where you must guess a number based on clues. | |
View this code at https://nostarch.com/big-book-small-python-projects | |
A version of this game is featured in the book "Invent Your Own | |
Computer Games with Python" https://nostarch.com/inventwithpython | |
Tags: short, game, puzzle*/ | |
object Main extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import pipeline | |
classifier = pipeline('sentiment-analysis', | |
model="nlptown/bert-base-multilingual-uncased-sentiment") | |
sentences = ["¡Me encantan los artículos de Medium, son lo máximo!", | |
"Odio los lunes, no sirven para nada.", | |
"El libro es medio bueno; me gustaron algunos personajes."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doc_review = nlp(review) | |
for sent in doc_review.sentences: # recorremos cada oración | |
for dep in sent.dependencies: # recorremos cada palabra | |
if dep[1] == 'amod': # el subíndice 1 indica que se trata de la clase funcional | |
print(dep[0].text, dep[2].text) # uso del atributo .text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doc_review = nlp(review) | |
for sent in doc_review.sentences: | |
for dep in sent.dependencies: | |
if dep[1] == 'amod': | |
print(dep[0].text, dep[2].text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y = 'high' if x > 6 else 'medium' if x == 6 else 'low' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decorator(inner_function): | |
def wrapper(*args, **kwargs): | |
# New wrapper stuff | |
inner_function(*args, **kwargs) | |
# New wrapper stuff | |
return inner_function(*args, **kwargs) | |
return wrapper | |
@decorator | |
def decorated_function(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
items_list = [a, b, b, c, c, c] | |
for i in items_list: | |
items_list.setdefault(i, 0) | |
items_list[i] += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dictionary = {'a': 1, 'b': 2, 'c': 3} | |
for k, v in dictionary.items(): | |
print(k, v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] | |
zipped_dict = dict(zip(keys, values)) |
NewerOlder