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 sklearn.metrics.pairwise import cosine_similarity | |
import pandas as pd | |
basetext = """ | |
Quantum computers encode information in 0s and 1s at the same time, until you "measure" it | |
""" | |
text1 = """ | |
A qubit stores "0 and 1 at the same time" in the same way how a car travelling north-west travels north and west at the same time | |
""" | |
text2 = """ |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
def predict(X, w, b): | |
return X * w + b | |
def loss(X, Y, w, b): | |
return np.average((predict(X, w, b) - Y) ** 2) |
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 gen_file_reader(file_path): | |
for row in open(file_path, "r"): | |
yield row | |
def gen_print_row_count(): | |
count = 0 | |
for row in gen_file_reader("large_file"): | |
count += 1 | |
print(f"Total count is {count}") | |
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
$ python large_file_example.py | |
Total count is 72456321 |
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 file_reader(file_path): | |
rows = [] | |
for row in open(file_path, "r"): | |
rows.append(row) | |
return rows | |
def print_row_count(): | |
count = 0 | |
for row in file_reader("large_file"): | |
count += 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
$ python /Users/viniciusmonteiro/hello_world.py | |
Hello World | |
$ |
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
$ python | |
>>> print('Hello World') | |
Hello World | |
>>> |
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
>>> print(923125123133123123163123193133193122123923123177 + 5) | |
923125123133123123163123193133193122123923123182 |
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
>>> squares = {i:i*i for i in range(6)} | |
>>> squares | |
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25} |
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
>>> squares = {i*i for i in range(6)} | |
>>> squares | |
{0, 1, 4, 9, 16, 25} |