blob_id
large_string
repo_name
large_string
path
large_string
src_encoding
large_string
length_bytes
int64
score
float64
int_score
int64
detected_licenses
large list
license_type
large_string
text
string
download_success
bool
302feb5b3451a319bb046e4182632bb4420504e1
SPTime19/data-scraper
/scraper/utils/util.py
UTF-8
972
2.921875
3
[]
no_license
import os import json from pathlib import Path def check_folder(base) -> str: base_path = base if base is str else str(base) if not os.path.isdir(base_path): print("{} not found! Creating folder...".format(base_path)) try: if len(base_path.split("/")) == 1: os.mkdir...
true
23159a415f418d603e8a9a001ee4cbafe883bb73
FabioFernandesCosta/HanoiTowerCommandLine
/JogadoresAutomatizados/dfs.py
UTF-8
5,411
3.03125
3
[]
no_license
from Jogo.torre import torre from Jogo.game import game from JogadoresAutomatizados.node import node from Jogo.regras import regras from copy import deepcopy class dfs: #espacos_ja_visitados = None estado_atual, pilha_de_decisoes, caminho_da_vitoria, jogo = None, None, None, None # espacos_ja_visitad...
true
b6f70802ac1e20946f7cd36f48eb4121fbc24ba9
yangzongwu/mynote
/04 Django/教程二/006 Models-Templates-Views.py
UTF-8
1,804
2.796875
3
[]
no_license
''' how to connect Models-Templates-Views we call "MTV" 1.In the views.py file we import any models that we will need to use 2.Use the view to query the model for data that we will need 3.Pass results from the model to the template 4.Edit the template so that it is ready to accept and display the data from the model 5....
true
870f950b4ea090eb70f16986c066d44bab2a215d
ufv-ciencia-da-computacao/CCF110
/lista1/ex15.py
UTF-8
112
3.875
4
[]
no_license
num = int(input()) if num > 0: print("Positivo") elif num < 0: print("Negativo") else: print("Nulo")
true
95201f951a060064ba67a2669743f28728ca2408
MariusR96/SaaS-Flask-App
/lib/money.py
UTF-8
219
3.703125
4
[]
no_license
def cents_to_dollars(cents): """ Convert cents to dollars """ return round(cents/100.0, 2) def dollars_to_cents(dollars): """ Convert dollars to cents. """ return int(dollars * 100)
true
a48e6c1e386b8dd58f336e32b90703bd16e43a4c
NREL/Industry-energy-data-book
/code/Get_GHGRP_data_IEDB.py
UTF-8
4,289
2.5625
3
[]
no_license
# -*- coding: utf-8 -*- """ Last updated 7/27/2017 by Colin McMillan, colin.mcmillan@nrel.gov """ # import pandas as pd import requests import xml.etree.ElementTree as et import sys def xml_to_df(xml_root, table_name, df_columns): """ Converts elements of xml string obtained from EPA envirofact (GHGRP) to ...
true
9460fab1c53e565fe9534687f08e6277b93abcf8
sabsolle/U3-Data-Analysis
/DataPreparationFunS1/main.py
UTF-8
4,454
3.6875
4
[]
no_license
import math import numpy as np # warmup task def get_column(table, header, col_name): col_index = header.index(col_name) col = [] for row in table: # ignore missing values ("NA") if row[col_index] != "NA": col.append(row[col_index]) return col def get_min_max(values): ...
true
b27f983f3a7cb363b219b3e764a6ca1695f4baaa
CS-Capstone-Fall-2020-AU/Grapevine
/backend/api/model/data/dataset_building.py
UTF-8
1,277
2.65625
3
[]
no_license
import pandas as pd from os import listdir, path def build_positive(p): p = p + 'positive_polarity/' t = p + 'truthful/' pos_true = listdir(t) f = p + 'deceptive/' pos_false = listdir(f) tru = [] dec = [] for x in pos_true: n = open(path.join(t, x), 'r') tru.append((n...
true
ccb7bd9339ba612ea814e2ce95c995c8cd8e5fcd
vonalan/Deep-Encoder-Decoder-Networks
/keras-dcgan/extractor.py
UTF-8
2,817
2.515625
3
[]
no_license
import os import sys import numpy as np import cv2 import tensorflow as tf # import tensorflow.gfile as gfile def create_video_lists(video_dir): if not tf.gfile.Exists(video_dir): tf.logging.error("Video directory '" + video_dir + "' not found. ") return None results = dict() sub_dirs = ...
true
69277a28f1475b6f9251aa368065ea302fd81395
tungsteen/minimal-django-site
/todo/tests.py
UTF-8
1,581
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
from django.test import TestCase from django.test import Client from .models import Todo class TodoModelTests(TestCase): def setUp(self): Todo.objects.create(text='First Todo', done=False) Todo.objects.create(text='Second Todo', done=True) def test_full_todo(self): todo1 = Todo.obje...
true
f85028b667172a9b56f0c6f0ad42c4f2982664fd
SiGae/DnF_searchbot
/app/AuctionSearch.py
UTF-8
2,389
2.875
3
[]
no_license
import json import urllib.request import urllib.parse import ssl import app.bot_private as code def NumberSlice(number) -> str: return format(number, ",") def SearchAuction(itemName, search_type) -> str: item_name = itemName if search_type == 'full' and " " in item_name: item_name = "\'" + item_na...
true
a33c46fdcab0b9f48894147b1d9f7161286a1d44
mboker/HackerrankProblems
/HR_Bit_Manip/TheGreatXOR.py
UTF-8
347
3.40625
3
[]
no_license
def theGreatXor(x): values = 0 index = 0 while x > 0: if not x & 1: values += 2**index x = x >> 1 index += 1 return values file = open('TheGreatXOR.txt', 'r') q = int(file.readline().strip()) for a0 in range(q): x = int(file.readline().strip()) result = theGr...
true
3d31922c31e38ec893651f160f0f724e43399450
cruizperez/Bioinformatic_Tools
/02.Scripts/table_dereplication.py
UTF-8
2,948
2.921875
3
[]
no_license
#!/usr/bin/env python """ # ============================================================================== # Author: Carlos A. Ruiz-Perez # Email: cruizperez3@gatech.edu # Institution: Georgia Institute of Technology # Version: 0.1 # Date: April 30, 2021 # Description: # =============================...
true
fbed42fe5f737566528c87b5bb87b46949df78b7
mskoko/Voice-assistant
/services/speech/stt_service.py
UTF-8
2,681
2.96875
3
[]
no_license
import speech_recognition as sr from config.config import * from services.common.action_result import ActionResult class SpeechRecognizer: def __init__(self, recognition_api="google", language="en-us"): self._recognizer = sr.Recognizer() # below energy_threshold is considered silence, above speec...
true
54ecfa382f889e30ea5b514568043b27e450d6c3
fugufisch/hu_bp_python_course
/Project/model.py
UTF-8
4,026
2.640625
3
[ "MIT" ]
permissive
import processes as proc import molecules as mol import logger as loggy import visualization as vis import replication as rep import random import Input.KnowledgeBase as know class Model(object): """ Initializes the states and processes for the model and lets the processes update their corresponding states. ...
true
4465f6ded8bbb4fb42474e7d5a87500feba0f9e4
aaaaaachen/PY1901_0114WORK
/days06/demo05.py
UTF-8
1,720
3.4375
3
[]
no_license
''' ''' import random cards = [] while True: print("********************************") print(" 1.註冊") print(" 2.登錄") print(" 3.退出") print("********************************") choice = input("請輸入選項") if choice == "1": while True: ...
true
ea5ac4c9502226bdddf4e0c29af5cc92fab5ebb4
alvaro-root/pa2_2021
/tk_temp_converter.py
UTF-8
3,367
3.28125
3
[ "MIT" ]
permissive
from tkinter import * from tkinter import ttk from tkinter import messagebox class GUI: def __init__(self, parent): self.parent = parent self.parent.title("Temperature Converter") self.parent.protocol("WM_DELETE_WINDOW", self.catch_destroy) self.main_frame = Frame(self.parent, pad...
true
12466779cbe7054936545829c1f5d83ca54e905b
sethgraceb/ML-Week-4-Assignment
/as4q2c1.py
UTF-8
1,872
3.203125
3
[]
no_license
#Q(ii)(c) - logistic regression final import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rc('font', size=18); plt.rcParams['figure.constrained_layout.use'] = True plt.rcParams['figure.figsize'] = (10.0, 5.0) df = pd.read_csv("week4.csv", comment = '#') #feature values X1 = np.array(df.il...
true
4de4df3b91dc0db32b8f13ffd0e4e4d5c444baf9
yoonkh2000/ncaacheck
/Test.py
UTF-8
1,525
2.796875
3
[]
no_license
import pandas as pd from os import listdir from os.path import isfile, join import scipy as sp import operator import csv mypath = "./Data/pred" onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ] def llfun(act, pred): epsilon = 1e-15 pred = sp.maximum(epsilon, pred) pred = sp.minimum(1-e...
true
19ad5e99e482d995c7b7dd1068eb5d16461b9484
TechnionYearlyProject/SummitBTW
/statistics/statistic_printer.py
UTF-8
604
3.359375
3
[]
no_license
from prettytable import PrettyTable class StatisticsPrinter(object): def print(self, *args): pass class NormalPrinter(StatisticsPrinter): def __init__(self, statistics): self._stats = statistics def print(self): for s_key, s_val in self._stats.items(): print(s_ke...
true
3dfa7e211fdd1a4f7ee0602448b9ab9841d38500
goranobad1407/python_learn
/4_2048.py
UTF-8
2,514
3.421875
3
[]
no_license
#Felix Bittmann, 2020 import random import itertools def combine(numbers): numbers = [z for z in numbers if z != 0] for z in range(0, len(numbers) - 1): if numbers[z] == numbers[z + 1]: numbers[z] = numbers[z] * 2 numbers[z + 1] = 0 numbers = [z for z in numbers if z != 0] return numbers + [0 for z i...
true
e69b7eeea70b399803eeb403863bc502449ebc37
santoscaj/CSEC-Final-Project-
/Python/myGUI.py
UTF-8
736
2.78125
3
[]
no_license
import sys from tkinter import * from PyQt4 import QtGui class myGUI(): #myAttributes def __init__(self, master): buttonsize = 16 self.master = master master.title('Password Generator: Select your character') header = StringVar() #Frame self.topframe = Frame(maste...
true
a4d7cf082a8bb31a403af6287e23ae0e5e8f0a5a
Min-Hae/django_test6
/myguest/models.py
UTF-8
753
2.625
3
[]
no_license
from django.db import models # Create your models here. class Guest(models.Model): # myno = models.AutoField(auto_created = True, primary_key = True) ==> 해당 컬럼때문에 id가 생성되지않는다. title = models.CharField(max_length=50) content = models.TextField() regdate = models.DateTimeField() de...
true
6e9a07f38a8a7a0de08aca8aa25625500564ad1d
glkclass/scrpt
/log_util.py
UTF-8
1,707
3.015625
3
[]
no_license
import logging """Logging util""" # create formatter formatter = logging.Formatter('%(asctime)s %(levelname)s : %(name)s - %(message)s : %(filename)s, %(lineno)d', datefmt='%Y/%m/%d %H:%M:%S') loggers = {} def get_logger(logger_name='root', file_name=None, level=None): if logger_name not in loggers: logg...
true
f14493a15082a1ee760c25761a41d87df2f50dfa
pyj4104/LeetCode-Practice
/Python/files/IntToRoman.py
UTF-8
915
3.28125
3
[]
no_license
class Solution: ROSSETTA_STONE = {\ 1: ["I", "X", "C", "M"],\ 2: ["II", "XX", "CC", "MM"],\ 3: ["III", "XXX", "CCC", "MMM"],\ 4: ["IV", "XL", "CD"],\ 5: ["V", "L", "D"],\ 6: ["V...
true
106b7442f76cc2a36c63d62ed48874dcf467b4bd
paultorre/Daily_Coding_Problem
/85.py
UTF-8
700
4.09375
4
[]
no_license
# This was a tricky problem that relied on a flash of insight. In this case, I was more or less thinking heuristaclly # about solving this problem. I thought a lot about bitwise operations and eventually realized # that somehow I should be adding the two numbers together, and that one of them should be 0 and one shou...
true
d53de36742df5ce037dd46920e057aaf5aa35b44
halimahbukirwa/Http-Requests-python-
/post.py
UTF-8
689
3.265625
3
[]
no_license
# HTTP POST REQUEST # used when submitting data from an html form or uploading files # A post request is designed for creating or updating resources # And allows larger amounts of resources to be sent in a single request compared to a get request import requests payload = {"First Name": "John", "Last Name": "Smith...
true
07be2b3a9d0d67321dc68890efe424619c3f6095
JerrySmithLu/Missing-value-processing
/Missing_value_processing.py
UTF-8
1,213
3.4375
3
[]
no_license
#Missing value processing import pandas as pd import numpy as np from sklearn.preprocessing import Imputer # Generate missing data out_dir = 'data/' df = pd.read_csv(out_dir + 'StackOverFlow_2017.csv', skiprows=1, low_memory=False) # Check which values are missing nan_all = df.isnull() # Get the Null value in...
true
49d5998e54bb96e1115b2a0ae79c1cd2c92ef9a6
rkane22/routeSchedulingSimulator
/Graph.py
UTF-8
3,993
3.328125
3
[]
no_license
import numpy import copy DEFAULT = 0 CUMULATIVE = 1 MAX_REWARD = 100 def gen_random_aisle_graph(aisles=1, rows=5, cols=5, theta=2): # use Zipf distribution new_graph = AisleGraph() aisle = [] for row in range(rows): r = [] for col in range(cols): if col == 0: ...
true
17f757a3dc87cb8f5428e9197d610738529d2ff4
mahesh1271457/IntroML
/Code/Version1.2/functions_loss.py
UTF-8
250
2.609375
3
[]
no_license
# functions_loss.py import numpy as np def loss(loss_fun,A,Y): m = A.shape[1] if loss_fun == "meansquarederror": return np.sum(np.square(A-Y))/m def loss_der(loss_fun,A,Y): m = A.shape[1] if loss_fun == "meansquarederror": return 2*(A-Y)/m
true
3134278eccdd7d89bef5548a594f28f253fe7a15
mcs356/ece5745-tut3-pymtl
/sim/tut3_pymtl/regincr/RegIncr2stage.py
UTF-8
1,125
2.859375
3
[]
no_license
#========================================================================= # RegIncr2stage #========================================================================= # Two-stage registered incrementer that uses structural composition to # instantitate and connect two instances of the single-stage registered # increment...
true
0d70be037804c3dbf84fdb66c600cc66cb66dff9
weichen-liao/HackerRank
/arrays/New_Year_Chaos.py
UTF-8
629
3.484375
3
[]
no_license
# -*- coding: utf-8 -*- # Author: Weichen Liao # https://www.hackerrank.com/challenges/new-year-chaos/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=arrays # Complete the minimumBribes function below. def minimumBribes(q): move = 0 for i, item in enumerate(q): ...
true
3137e9c31a66d12bc08dc8fd148c48a3231fcbab
imerfanahmed/TopH
/icpc comming hot.py
UTF-8
58
3.0625
3
[]
no_license
x=input() m=0 for i in x: m=max(x.count(i)) print(m)
true
8edb9e09689119e82b5e127eb09dc76e2e987ffe
AlexanderGrigoryev/webtesting
/bi-zone-test/bizone/app_pages/controls/base_control.py
UTF-8
622
2.546875
3
[]
no_license
from selenium.webdriver.remote.webelement import WebElement from webium.base_page import is_element_present class BaseControl(WebElement): """ общая логика для элементов управления web-приложения """ @property def drv(self): return self.parent @property def text(self): return sel...
true
3f22565605f162e1255c85099b5f333205ffecdd
jiaxionglee/Python
/base/str/strUse.py
UTF-8
725
3.703125
4
[]
no_license
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2019-01-02 22:52 # @Author: jiaxiong # @File : strUse.py s = 'I Love Python' s1 = " , and you ?" # 串联多个字符串 print(s + s1) # 快速复制字符串 print(s * 2) # 分割字符串 s2 = s.split(' ', 2) print(s2) # 替换字符串 s_replace = s.replace('Python', 'Java') print(s_replace) # 转大写 s_upper...
true
d505f60df42552c366efd459a05caa3f9b398688
tf-encrypted/federated
/tensorflow_federated/python/research/utils/adapters.py
UTF-8
1,646
2.6875
3
[ "Apache-2.0" ]
permissive
# Copyright 2020, The TensorFlow Federated Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
true
497416a7015695bd56a5ed4c00ab919301983a03
UltraStars3000/ProjetPython
/gamedata/afficheur.py
UTF-8
2,875
2.859375
3
[]
no_license
#! usr/bin/python from tkinter import * class Afficheur(Frame): code={1:(2,3),2:(1,2,7,5,4),3:(1,2,7,3,4),4:(6,7,2,3),5:(1,6,7,3,4),6:(1,6,5,4,3,7), 7:(1,2,3),8:(1,2,3,4,5,6,7),9:(6,1,2,3,4,7),0:(1,2,3,4,5,6)} def __init__(self, tk, column, size=1, nCadrans=3, visible=False): ...
true
0cd2e4bb1ea8caefe52294bc3e3bcae5120f14c5
Sujjzit/Codefights
/sumUpNumbers.py
UTF-8
334
3.90625
4
[]
no_license
""" Example For inputString = "2 apples, 12 oranges", the output should be sumUpNumbers(inputString) = 14. """ def sumUpNumbers(inputString): s=0 z=0 for i in inputString: if '0'<=i and i<='9': s = s*10 + (ord(i)-ord('0')) else: z+=s s=0 z+=s ...
true
8747bc3c8638c7d053aa917ecdf0e513005b2ad9
breakanalysis/graph-tycoon
/src/domain/world.py
UTF-8
4,590
3.296875
3
[]
no_license
from .car import * from .node import * from .edge import * from collections import deque import random from typing import Dict, Tuple CAR_LENGTH = 0.1 CROSSING_MARGIN = 0.75 class World: """Abstract graph world with Nodes, Edges and Cars. Attributes: nodes (dict): dict from node name to node c...
true
9839706404995328d22234396ca0b484ec5af719
TunaHG/TIL
/Python/Python_Chatbot/Basic/02_Strings.py
UTF-8
573
5.25
5
[]
no_license
''' String 조작하기 1. 글자 합체 2. 글자 삽입(수술) 3. 글자 자르기 ''' # 1. 글자 합체 hphk = "happy" + " " + "hacking" print(hphk) # 2. 글자 삽입 name = "Tuna" age = 26 text = "제 이름은 {}입니다. 나이는 {}살 입니다.".format(name, age) print(text) f_text = f"제 이름은 {name}입니다. 나이는 {age}살 입니다." print(f_text) # 3. 글자 자르기 # String > "어떠한 글자들"[start : end] ...
true
6f1b8b7b0f73f735c932c96bb8e3f7fccd7b338e
lydia0423/Machine_Learning
/Python/Python Basic/w3resources/basic_practice_part1/Q29.py
UTF-8
413
3.75
4
[]
no_license
#?29. Write a Python program to print out a set containing all the colors from color_list_1 which are #?not present in color_list_2. Go to the editor #?Test Data : #?color_list_1 = set(["White", "Black", "Red"]) #?color_list_2 = set(["Red", "Green"]) #?Expected Output : #?{'Black', 'White'} color_list_1 = set(["Whit...
true
3febd5fcbdbf57c3d339e604a1f54d95b7a19df9
Vaidehithakur/Hackerrank
/StrongPassword.py
UTF-8
1,289
3.234375
3
[]
no_license
#!/bin/python3 import math import os import random import re import sys # Complete the minimumNumber function below. def minimumNumber(n, password): # Return the minimum number of characters to make the password strong # pass = set(password) count=0 flag=0 special_characters = "!@#$%^&*()-+" ...
true
c3534209584e4a4c8303e8bb74d4c14b46c1dde3
masun/SpamDetection
/addReTweetAndFav.py
UTF-8
1,049
2.6875
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- import csv # Input file donde está la data. ifile1 = open("datasets/dumpCaraotaDigitalCNNELaPatilla.csv", "rb") reader1 = csv.reader(ifile1) ifile2 = open("datasets/datos_separados/featureVectorsEntrenamientoWithTopic.csv", "rb") reader2 = csv.reader(ifile2) # Output fi...
true
960e6d8695a7f3d03ebef023e00ebc0d61a83306
SoloTodo/storescraper
/storescraper/stores/motorola_shop.py
UTF-8
3,209
2.53125
3
[]
no_license
import json import re from decimal import Decimal from storescraper.categories import CELL from storescraper.product import Product from storescraper.store import Store from storescraper.utils import session_with_proxy class MotorolaShop(Store): @classmethod def categories(cls): return [ ...
true
9486a63f3e32309c372c9f621084bac740a1c8ed
mishutka200101/Python-Practice-3-4
/task_18.3.py
UTF-8
203
3.015625
3
[]
no_license
def golden_ratio(i): a, b = 0, 1 n = 1 while n <= i: a, b = b, a + b n += 1 if n == i - 1: b1 = b return(b1 / b) print(golden_ratio(int(input())))
true
b3fc34e58ec618b0a2750999d13fbcd8c4e40d6c
Z3a1ot/PanPal
/core/unittests/test_nutritionAPI.py
UTF-8
732
2.765625
3
[ "MIT" ]
permissive
from unittest import TestCase from core.recipe_sources.NutritionAPI import NutritionAPI class TestNutritionAPI(TestCase): def test_search_recipe(self): napi = NutritionAPI() result = napi.search_recipe("burger", 1) self.assertEqual(len(result), 1) self.assertIs(type(result[0]....
true
55dbace86b2f247ed865971d02489011857f5453
Acrelion/various-files
/Python Files/se63.py
UTF-8
1,055
3.9375
4
[]
no_license
class Animal(object): is_alive = True def __init__(self, name, age): self.name = name self.age = age # Add your method here! def description(self): print self.name print self.age hippo = Animal("Sam", 3) hippo.description() print hippo.is_alive class Car(obj...
true
152cbfaf2f0a86606533dea606ec1a3ae836844d
templeblock/pytoolkit
/pytoolkit/ml.py
UTF-8
9,479
2.84375
3
[ "MIT" ]
permissive
"""機械学習関連。""" import pathlib import typing import joblib import numpy as np import sklearn.base import sklearn.metrics import sklearn.model_selection import sklearn.utils import tensorflow as tf import pytoolkit as tk def listup_classification( dirpath, class_names: typing.Sequence[str] = None, use_tqdm...
true
5d12f5a1c76734d347d309eff2098af9a257e062
adrianmfi/ProjectEuler
/python/P57.py
UTF-8
127
2.9375
3
[]
no_license
##Get number as a fraction 1/(2+.5) = 2/5 def P57(): fractions = [] for i in range(1,1000): fractions.append(
true
f2b33985f07202002be277f3b78a3b46b0bb54dd
SandaoTu/myday100
/day1-15/day9_object/01_property.py
UTF-8
921
4.15625
4
[]
no_license
#使用@property装饰器# # @property装饰器将一个方法变为属性调用 #@property装饰器,同时会产生一个@ .setter装饰器 class Student(object): def __init__(self,name,age): self._name = name self._age = age #访问器getter方法 @property def name(self): return self._name #访问器 getter方法 @property def age(self): ...
true
63816e2de15b4c448e890595136c98bb89b8e362
kibo35/AtCoder
/ABC043/Unbalanced.py
UTF-8
221
3.140625
3
[]
no_license
s = list(raw_input()) unbalanced = False for c in set(s): if s.count(c) >= len(s) / 2 + len(s) % 2: print s.index(c) + 1, len(s) - s[::-1].index(c) unbalanced = True if not unbalanced: print -1, -1
true
996dd6bb77a483d652b331b70832355502b9efbb
cmkwong/EntNet
/MemeryNet/lib/criterions.py
UTF-8
1,572
3.25
3
[]
no_license
import torch import torch.nn as nn class CosineLoss(nn.Module): def __init__(self): super().__init__() def forward(self, predict, ans): """ :param predict: torch.tensor(size=(n,1)) :param ans: torch.tensor(size=(n,1)) :return: torch.tensor(scalar) """ # ...
true
5fa134486e0069188f85c1025e19a36cee666668
ShawnKenley/StockSentimentCapstone
/Scraping/Scraping Investagrams/Scraping Each News Sites Using Newspaper3k/Article_Body_Scraper_4.py
UTF-8
1,046
2.78125
3
[]
no_license
import pandas as pd import numpy as np from newspaper import Article from newspaper import Config import time user_agent = 'Mozilla/5.0 (X11; Linux x86_64)' config = Config() config.browser_user_agent = user_agent config.request_timeout = 10 def getArticle_Body(dataframe, filename): total = len(datafr...
true
f2c1dec84e641c7371e5b06b28a0426e4909f867
augustogoulart/iws-feature-request
/tests/test_models.py
UTF-8
1,188
2.515625
3
[ "MIT" ]
permissive
from unittest import TestCase from feature_request.app import create_app from feature_request.models import FeatureRequest, Client from feature_request.models import db, Manager class TestFeatureRequestResource(TestCase): """ Manager.add() is a wrapper for db.session.add() and db.session.commit() db.sess...
true
b546f2e6881fa9330cfbc651b4b8c802c8adf922
mariamnaqvi/predicting_property_values
/acquire.py
UTF-8
3,298
3.171875
3
[]
no_license
import pandas as pd import numpy as np import os # use get_db_url function to connect to the codeup db from env import get_db_url import matplotlib.pyplot as plt def get_zillow_data(cached=False): ''' This function returns the zillow database as a pandas dataframe. If the data is cached or the file exist...
true
f3deda62caf65e1116e43cf8b2f745e97ee34b5a
erikbrorson/one_odd_out_game
/word_game.py
UTF-8
1,008
4.125
4
[]
no_license
class Word_game: """ An instance of the odd one out game """ def __init__(self, file_path): with open(file_path, 'r') as file: self.words = file.readline().rstrip().split(' ') self.odd_one_out = file.readline().rstrip() def print_words(self): print('The words...
true
b48cd381f3e03e6febb49a89b8178dd4e30b298c
bakunobu/exercise
/1400_basic_tasks/chap_7/7_67.py
UTF-8
225
2.90625
3
[]
no_license
from main_funcs import get_input def before_zero() -> int: counter = 0 while True: a = get_input('Введите число: ') if a == 0.0: break counter += 1 return(counter)
true
e987a5031518981ea85aed7c2187f3ef159218e9
duanwandao/PythonBaseExercise
/Day08(文件)/Test05.py
UTF-8
864
3.5
4
[]
no_license
""" 统计所有的代码 1.统计单个文件中的代码 a.单行注释的排除 b.多行注释的排除 2.找出某文件夹中所有的文件(.py文件) """ #统计指定文件中代码的行数 def irisCodeCounter(filePath): #记录代码的总行数 lines = 0 #打开文件 file = open(filePath,'r',encoding='utf-8') #读取内容 content = file.readline() #用来记录多行注释的开关 add = True while content != "...
true
1da065ff763fb56fdab3370892c5b9cb47487f00
raymondhehe/Georgia-Tech-course-work
/CS3600/project5/question6_car.py
UTF-8
648
2.75
3
[]
no_license
import Testing import NeuralNetUtil import NeuralNet n = 0 print "~~~~~~~~~~~~~~~~~~~~~~~TestCarData~~~~~~~~~~~~~~~~~~~~~~~" while n <= 40: c = 0 carList = [] print "------- #", n, "neurons per hidden layer -------" while c < 5: print "Iteration #", c + 1 car_Net, car_test = Testing.bui...
true
27f947e29c704d2991208d22419f1a667622bc56
kaio358/Python
/Mundo3/Tuplas/Desafio#72.py
MacCentralEurope
350
3.484375
3
[ "MIT" ]
permissive
numero = ('zero','um','dois','trs','quatro','cinco','seis','sete', 'oito','nove','dez','onze','treze','catorze','quinze','dezesseis', 'dezessete','dezoito','dezenove','vinte') valor = -1 while True: valor = int(input('Insira o numero : ')) if 0 <= valor <=20: break print(f'O valor di...
true
5de07b1eab0777cfeb2d1638a1031f258ec40b50
SeanUnland/Python
/Python Day 6/main.py
UTF-8
85
2.546875
3
[]
no_license
# FUNCTIONS def my_function(): print("Hello") print("Bye") my_function()
true
fad3cf1b6c3d55f81b3e31291c422544f8f29c37
Kalliojumala/School-Work
/Week 8/8.4.py
UTF-8
382
3.796875
4
[]
no_license
from functools import reduce #join and casting prac #long str string = "01234567890123456789" #cast as list string_list = list(string) #one liner to get list sum instead of for loop list_sum = reduce(lambda x, y: int(x) + int(y), string_list) #join it with '+' and print it with list_sum print(f"\n{'+'.join(string_...
true
8ed480a3b1013786b300b3090660592fdef8069f
Aasthaengg/IBMdataset
/Python_codes/p02572/s886591328.py
UTF-8
130
2.78125
3
[]
no_license
N = int(input()) A = list(map(int, input().split())) M = 10 ** 9 + 7 T = sum(map(lambda x: x**2, A)) print (((sum(A)**2-T)//2)%M)
true
5d73f57329db497f97ed5be8c479adb4f99218d0
dotgourav/Competitive-Programming
/test_file.py
UTF-8
836
3.203125
3
[]
no_license
# URL: http://www.spoj.com/problems/CPTTRN4/ from __future__ import print_function from datetime import datetime as dt t = input() while t: t1 = dt.now() inputVar = [eval(x) for x in raw_input().split()] dict_prime = {} for i in xrange(2, inputVar[0]+1): dict_prime[i] = True print("Origi...
true
4e2398fc0604b08e6ec955d13dd26671defcec56
Satya191/blackjack_project
/blackjack_package/deck_class.py
UTF-8
789
3.453125
3
[]
no_license
from blackjack_package.card_class import Card from random import randint class Deck: suits = ['heart', 'diamonds', 'spades', 'clubs'] values = ['ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'jack', 'queen', 'king'] deck_list = [] def __init__(self): for suit in Deck.suits: for value in Deck.values: Deck.deck_list...
true
3dcfa159a306535276bc1541c4333b0bde03c00b
asharron/BlogChain
/blockchain/oldblockchain.py
UTF-8
536
3.4375
3
[]
no_license
from block import Block from genesis import create_genesis_block from new_block import next_block #Create the blockchain blockchain = [create_genesis_block()] previous_block = blockchain[0] num_of_blocks_to_add = 20 #Add blocks to the chain for i in range(0, num_of_blocks_to_add): block_to_add = next_block(previo...
true
4158fb3f3a7c18d49b0897130acb1dce6068231c
Shivani2006/C125
/projectpred.py
UTF-8
1,548
2.6875
3
[]
no_license
import cv2 import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from sklearn.datasets import fetch_openml from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score from PIL import I...
true
dee7f25322ef5285c43c69a69679871397af2da0
rogerrendons/holbertonschool-higher_level_programming
/0x0B-python-input_output/9-add_item.py
UTF-8
518
3.203125
3
[]
no_license
#!/usr/bin/python3 """ Write a script that adds all arguments to a Python list, and then save them to a file """ save_json = __import__('7-save_to_json_file').save_to_json_file load_json = __import__('8-load_from_json_file').load_from_json_file if __name__ == "__main__": from sys import argv json_file...
true
3a4e0cd06fd668d32686c0b21b9c95d0bd717b0d
pydevjason/Python-VS-code
/intro_to_functions.py
UTF-8
347
4.0625
4
[]
no_license
# a function is a collection of 1 or more statements, a set of instructions that performs a single task which can be reused. A function is an object which takes inputs as parameters and returns outputs def output_text(): print("Welcome to the program!") print("It's nice to meet you.") print("Have a ...
true
96b83e15e64f1fac57c27e1a5337762f95eda9c2
Salmonpro/class_v1
/Button.py
UTF-8
170
2.78125
3
[]
no_license
class Button: def __init__(self): self.click_count = 0 def click(self): self.click_count += 1 def reset(self): self.click_count = 0
true
1b950bd668e5a4bec675c4b2222848b1d46f5d22
atulsingh0/Python
/Learn/python02_data-type_Strings.py
UTF-8
2,262
4.46875
4
[]
no_license
print "www.datagenx.net" print "Hello! Welcome to Python 2 tutorial Script" print "We will see how to determine data type and Strings" ### DATA TYPES ### ################## # determine the type of an object print type(5) # print 'int' print type(5.0) # print 'float' print type('two') # print 'str'...
true
4b0f46924700e8e0879d2ec06adc828621f34f66
skely/Sign-Language
/lib/BVH.py
UTF-8
8,371
2.625
3
[]
no_license
import numpy as np def load_raw(_in_file): """ Loads bvh file as text. :param _in_file: path :return: list of lines """ with open(_in_file, 'r') as f: content = f.readlines() headder = -1 for i, line in enumerate(content): if 'MOTION' in line: headder =...
true
c56d101b86cca71a6436589dcbd670047b253723
eleans412/dreams-backend
/tests/auth_passwordreset_email_test.py
UTF-8
1,461
2.734375
3
[]
no_license
from tests.fixture import channel_set_up, auth_set_up from src.auth import auth_passwordreset_request_v1 from src.error import AccessError, InputError from src.data import getData import pytest """ Will check that the email sent is a valid email and send a reset code to the user to change their password Arguments: ...
true
afa9ef7d77c6b23e4f52aec8553fd3778b157776
asaboveasbelow/task1
/py exercise3.py
UTF-8
245
4.03125
4
[]
no_license
print('What is your favourite number?') favNum = int(input()) if favNum > 0 and favNum % 2 == 0: print('Your favourite number '+str(favNum)+' is an even number.') else: print('You favourite number '+str(favNum)+' is an odd number.')
true
d58b3062935b258e02a73704a1e048b3e09ee19e
759796385/pythonDemo
/main/configParse/ConfigParseDemo.py
UTF-8
632
2.859375
3
[]
no_license
# coding: utf-8 import ConfigParser import os import numpy as np import pandas as pd # 2.x语法 def get_conf(section, key): conf_file = ConfigParser.ConfigParser() conf_file.read(os.path.join(os.getcwd(), 'config.ini')) return conf_file.get(section, key) print get_conf('local', 'name') print get_conf('loca...
true
d8fc55109e9c1d26e9c6bf1c2b90d6679b438386
theoboraud/Perceptron
/PPT.py
UTF-8
4,212
3.765625
4
[]
no_license
import numpy as np import matplotlib.pyplot as plt # ------------------------------------------- # # ---------------- VARIABLES ---------------- # # ------------------------------------------- # # Numpy seed np.random.seed(0) # Training loop learning_rate = 0.1 costs = [] # Number of trainings train_time = 100000 ...
true
ba310c72892a4b2cb251eb9e775c363669e39764
BrianUribe6/Google-Foobar-Challenge-2019
/Google Foobar/Lovely Lucky Lambs/test.py
UTF-8
339
3.453125
3
[]
no_license
from math import sqrt, log def fib(n): a, b = 1, 1 i = 1 n -= a while b <= n: n -= b a,b = b, a + b i += 1 return i def solution(total_lambs): generous = fib(total_lambs) stingy = int(log(total_lambs + 1, 2)) return abs(generous - stingy) prin...
true
883051fe7032f52b7e74ea708f0d0b4c56f85bf1
fab-bar/SpellvarDetection
/spellvardetection/test/generator/test_levenshtein_generator.py
UTF-8
1,611
2.859375
3
[ "MIT" ]
permissive
import unittest from spellvardetection.generator import LevenshteinGenerator class TestLevenshteinGenerator(unittest.TestCase): def test_without_dictionary(self): generator = LevenshteinGenerator() with self.assertRaises(RuntimeError): generator.getCandidatesForWords(['rat', 'dog']) ...
true
f955fe4d16613bce468f25c24a2fea9f20d5b972
infinitespace/LeetCode-2
/Python/tmp.py
UTF-8
2,556
3.1875
3
[]
no_license
# THRESHOLD between journey, if trip2.starttime - trip1.endtime < THRESHOLD, # trip1 and trip2 are in the same journey THRESHOLD = 1 day def find_journeys(trips): # Input: an iterator of trip records, not null # Output: an iterator of journey records journeys = [] journeys.append({starttime: trips[...
true
2665a1e6be71fbeed54a026aaf64b153845ec335
peterCcw/alien_invasion
/alien_bullet.py
UTF-8
1,233
3.484375
3
[]
no_license
import random import pygame from pygame.sprite import Sprite class AlienBullet(Sprite): """Manages bullets shot by the aliens""" def __init__(self, ai_game): """Create the bullet obj in the random alien's location""" super().__init__() self.ai_game = ai_game self.screen = ai_g...
true
f65cb7fbcaaba3d0d603ec972f29d04208775ef5
xinghuaman/OpenMV_Camera
/Software/Black Box/automatic_quality_test.py
UTF-8
2,225
3.671875
4
[]
no_license
''' ### Automatic Quality Test ## Allan Shtofenmakher # Spacecraft Design Lab # Uses the camera to take several photos in sequence, rendering # a different level of JPEG compression each time. Saves all # photos to the SD card. # The blue LED is used to signal camera activation; # the green LED signals successful co...
true
274a7213777b252eb7a1814e5a61510bf919e0a6
timichal/advent2017
/day02.py
UTF-8
362
3.203125
3
[]
no_license
numbers = [] with open("day02") as file: for line in file: numbers.append([int(x) for x in line.strip().split()]) # part 1 print(sum([max(row) - min(row) for row in numbers])) # part 2 result = 0 for row in numbers: for number in row: for number2 in row: if number % number2 == 0 and number/number2 > 1: r...
true
2c46758d72477821c6e6d1c9130dc5b4d887f5f1
ellynhan/challenge100-codingtest-study
/hall_of_fame/seunggil/python/소수 찾기.py
UTF-8
1,018
3.125
3
[]
no_license
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 import math visited = [] nums = set() def isprime(num : int): prime = True; for i in range(2,int(math.sqrt(num))+1): if num % i == 0: prime = False brea...
true
e99a6f31b244480a4d0a441ba6b4a93748daf346
Vesanys/UniProjects
/Python/New Rover & AStar/Astar.py
UTF-8
23,797
3.546875
4
[]
no_license
# A* Shortest Path Algorithm # http://en.wikipedia.org/wiki/A* # FB - 201012256 from heapq import heappush, heappop # for priority queue import math import time import random import serial class node: xPos = 0 # x position yPos = 0 # y position distance = 0 # total distance already travelled to reach the n...
true
0ac40cf91f3cacf4a95653f4707e3ce3e55c6f1e
mangalaman93/pstickle
/proxy.py
UTF-8
830
2.640625
3
[ "MIT" ]
permissive
import zmq class Proxy(object): """Centralized proxy (Hub) for relaying pub-sub messages""" def __init__(self, host="127.0.0.1", subport=8000, pubport=8001): super(Proxy, self).__init__() # zmq context self.ctx = zmq.Context() # proxy socket for subscribers to connect ...
true
d680c941c08b0efea4ee768d1ffabea10f0ac3b8
khushboo1510/leetcode-solutions
/30-Day LeetCoding Challenge/September/Medium/152. Maximum Product Subarray.py
UTF-8
673
3.328125
3
[]
no_license
# https://leetcode.com/problems/maximum-product-subarray/ # Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. class Solution: def maxProduct(self, nums: List[int]) -> int: if not nums: return 0...
true
87c405728ce43715549e0fca03b8374c72ea5ad8
environmentalomics/eos-agents
/eos_agents/db_client.py
UTF-8
4,616
2.84375
3
[]
no_license
""" db_api_client: Routines to call to the DB API, normally on port 6543 The most recent HTTP result code is held in the variable "last_status", which is initially set to -1. """ import sys import requests import logging #Clients can import and trap this without caring that it belongs to requests under #the hood. Co...
true
214edc7c3419a6906533b392e67593833e29aa13
biinggala/lunarchive-backend
/2021-python/bmi.py
UTF-8
416
4.21875
4
[]
no_license
# 과제 1 import random#주사위 랜덤 숫자 for i in range(7):#7번 반복 machine = random.randint(1,6)#random class 사용 human = random.randint(1,6) result = print(f"machine:{machine}, human:{human}") if (machine>human): print("You Lose") result elif (machine == human): print("Draw") ...
true
799e731bcd8ed09f8c75f674eab46f2f3d6e60d1
nttssv/daily_run
/daily_close_price_change.py
UTF-8
1,814
2.625
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 12 14:22:22 2020 @author: Tung """ # lấy data từ YF import time start_time = time.time() import matplotlib.pyplot as plt import pandas as pd import numpy as np from pandas_datareader import data #https://pandas-datareader.readthedocs.io/en/lates...
true
543013f8963e6ecd0203db530fb6262284f747c9
tmdenddl/Algorithm
/Python/Data Strucutre Related Questions/Backtracking & Recursion/Word Search - Medium #79.py
UTF-8
4,236
4.6875
5
[]
no_license
""" Word Search - Medium #079 Given a 2D board and a word, find if the word exists in the grid. - The word can be constructed from letters of sequentially adjacent cells. - "Adjacent" cells are those horizontally or vertically neighbouring. - The same letter cell may not be used more than once. How to solve the probl...
true
963ff35fb067ed41c5c46faa019b787b06dd0984
amitesh98/GaanaScraper
/Gaana_Scraper.py
UTF-8
8,183
2.953125
3
[]
no_license
from selenium import webdriver import requests import bs4 import os from pandas.core.dtypes.missing import isnull # radio, top, track, artist scraper from Gaana.com radio_mirchi = "https://gaana.com/radiomirchi" gaana_radio= "https://gaana.com/gaanaradio" top_album= "https://gaana.com/browse/albums" top_songs="https:/...
true
350361cebf23002146a5134f69f680b78573be53
axelFrias1998/Using-Python-with-Linux
/Fifth_week/Unit_tests/from.py
UTF-8
76
2.59375
3
[]
no_license
from unitTests import rearrange_name print(rearrange_name("Lovelace, Ada"))
true
31ffbd7566b1c7547664250b5eb634e0f320154d
sj26/spoj
/PRIME1.py
UTF-8
1,000
3.578125
4
[]
no_license
import sys, collections cases = int(sys.stdin.readline().strip()) for case in range(1, cases + 1): candidate_min, candidate_max = map(int, sys.stdin.readline().strip().split()) # Python is good at sparse dictionaries, so we'll use a bubbling # Sieve of Erastothenes to be memory efficient and fairly # computatio...
true
8859c1511db63e972d36e57f9547cf692754b0e6
ChungHaLee/BaekJoon-Problems
/BOJ 10814- Age Ain't Nothing But A Number.py
UTF-8
449
3.484375
3
[]
no_license
n = int(input()) import sys data = sys.stdin.readlines() data_lst = [] for idx, line in enumerate(data): # enumerate 함수의 기능 age, name = line.split() age = int(age) data_lst.append([age, name, idx]) sorted_data_lst = sorted(data_lst, key=lambda x: x[2]) real_sorted_data_lst = sorted(sorted_data_lst, key=...
true
5acd1700d13473783f748cd4f3c591cf94c15680
hsharma267/python_programs-with-w3school
/test.py
UTF-8
140
3.296875
3
[]
no_license
import re txt = "The rain in spain" x = re.findall("^The.*spain$", txt) if x: print("Yes,We have a match.") else: print("No match")
true
88f2aefb76e76d6ab5ea5cc784d67b2219928875
bencuben/Learning-Machine-Learning
/Lab 4.py
UTF-8
7,301
3.234375
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 29 16:27:19 2020 @author: user """ # import keras # keras.__version__ #Importando la base de datos de numeros escritos a mano from keras.datasets import mnist #Carga a la base de datos de entrenamiento y testeo (train_images, train_labels), (test...
true
c0e5f6c80947e557ce43e4eb1e4b7e28019f350c
jmarq76/Learning_Programming
/AulasPython/Parte1/Semana4/soma_digitos.py
UTF-8
195
3.8125
4
[]
no_license
n = int(input("Digite um número inteiro: ")) tamanho = len(str(n)) i = 0 total = 0 while i < tamanho: singleNum = n % 10 total += singleNum n = n // 10 i += 1 print(total)
true
0b8a0f5d5a54a6c38d7d5c80c122bd9729024e75
harsh8088/py_web_socket
/websocket.py
UTF-8
1,878
2.75
3
[]
no_license
import asyncio import logging import websockets logging.basicConfig(level=logging.INFO) class Server: clients = set() async def register(self, ws: websockets.WebSocketServerProtocol) -> None: self.clients.add(ws) logging.info(f"{ws.remote_address} connected.") async def unregister(self,...
true
48797b90bf87c2fa0a46f5f1892939d7b33ca134
campjordan/Python-Projects
/Numbers/flip.py
UTF-8
731
4.28125
4
[]
no_license
''' Coin Flip Simulation Write some code that simulates flipping a single coin however many times the user decides. The code should record the outcomes and count the number of tails and heads. ''' from random import randint def flip(): result = randint(0, 2) if result == 1: return True else: ...
true
325a9d435346c0f820d46296c362f2e740db1261
Sam-the-Unwise/Bot_Detector
/analyze_outputs.py
UTF-8
1,749
3.328125
3
[]
no_license
import csv dict_of_outputs = {} with open('top_50.csv', 'rt') as csv_file: csv_reader = csv.reader(x.replace('\0', '') for x in csv_file) line_count = 0 for row in csv_reader: if line_count > 0: author = row[1] percent = row[0] dict_of_outputs[autho...
true