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
68d2b68cfddfc0596f84d582bd01bd397ff9e10c
matsushita-nagatoshi/Louds-Trie
/python/test.py
UTF-8
1,193
3.40625
3
[ "MIT" ]
permissive
from trie import Trie #constructs a tree of this shape ('*' means root) # # * # /|\ # a i o # / /|\ # n f n u # | |\ # e r t # #The LOUDS bit-string is then #[1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0] words = ['an', 'i', 'of', 'one', 'our', 'out'] test_set =...
true
9dc374702db864f1d11716f5eac9a70d5623de9d
rasql/cocos2d-tutorial
/examples/platformer.py
UTF-8
8,968
2.84375
3
[]
no_license
import cocos import pyglet import math from pyglet.window import key from cocos import layer, tiles, mapcolliders from cocos.director import director from cocos.layer import Layer, ColorLayer, ScrollableLayer, ScrollingManager, PythonInterpreterLayer from cocos.scene import Scene from cocos.sprite import Sprite from c...
true
31b2326a37e100ba243750d82707efbb988f6861
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/gjdsuv001/boxes.py
UTF-8
760
3.9375
4
[]
no_license
#Suvir Gajadhur #Function to create a hollow box comprimising of stars '*' def print_square(): print ("*****") print ("* *") print ("* *") print ("* *") print ("*****") def print_rectangle(width,height): print ("*"*width) for i...
true
b804526952de68cbf7707634c015197993477f88
ProgrammingBishop/python
/dataStructures/checkBrackets.py
UTF-8
2,545
4.875
5
[]
no_license
# ================================================================================ # This algorithm utilizes a stack data structure to check for balanced brackets # Given an input file: # Report 'success' if all brackets had been opened and closed properly # Report 1-based index if there is a unmatched opening bracket...
true
8c018a4773fc423751c8d5f1078676122b59730f
aswathnaray/assignment_algo
/simple_sort_fill/simple_sort_fill.py
UTF-8
5,385
3.09375
3
[]
no_license
import pandas as pd import argparse import sys # It is made sure that the program runs in any computer without the need for extensive libraries # Pandas and argparse is chosen for their effectiveness and ease of use, if these are not pre-installed with Py3, # kindly install it before running the code def get_invalid...
true
00afc06233d1a7b40a1606b186519dfacb75ab93
cryptocoinserver/jesse-indicators
/helpers.py
UTF-8
868
3.640625
4
[]
no_license
import numpy as np # The "Point-Slope Formula" # https://www.mathsisfun.com/algebra/line-equation-2points.html def point_slope(x1, y1, x2, y2, x): m = (y2 - y1) / (x2 - x1) x0 = y1 - (m * x1) return m * x + x0 # Make arrays the same lenght # https://docs.jesse.trade/docs/indicators/custom-indicators.htm...
true
0ed6b366f2d8708fa53eb27a27a6b0dcb327ec00
changrunner/zeppos_bcpy
/zeppos_bcpy/sql_configuration.py
UTF-8
2,182
2.859375
3
[ "Apache-2.0" ]
permissive
from zeppos_bcpy.sql_table import SqlTable from deprecated import deprecated import copy class SqlConfiguration: def __init__(self, server_type, server_name, database_name, schema_name, table_name, username=None, password=None): self.server_type = server_type self.server_name = se...
true
616d8c3d30094ccaf58cd34242535eff776c0cb8
zhangfeilynu/AppUiTest
/test.py
UTF-8
2,312
2.625
3
[]
no_license
#/usr/bin/env python3 import os import unittest import time from appium import webdriver # 获取设备SN列表 def getdevlist(): ''' 利用adb devices先输出所有已连接上的android devices,然后去掉输出中无用的字符,只保留devices SN ''' devlist = [] connectfile = os.popen('adb devices') list = connectfile.readlines() # print(list) ...
true
fe9f71b638fcf31abe460b92303a1e98e63679bd
iproduct/intro-python
/03-up-2022-lab/list_dir.py
UTF-8
277
2.96875
3
[ "Apache-2.0" ]
permissive
import os, fnmatch if __name__ == '__main__': # listOfFiles = os.listdir() listOfDirEntry = os.scandir() pattern = "*.py" for entry in listOfDirEntry: # if fnmatch.fnmatch(entry, pattern): print (entry.name, "DIR" if entry.is_dir() else "FILE")
true
6f29cfdfc431254f38bfcaa395da6594424e405f
nnyong/algorithm_ssafy
/swexpert/D1/자릿수더하기.py
UTF-8
106
2.75
3
[]
no_license
# 2058 import sys sys.stdin=open('2058','r') data=input() sum=0 for d in data: sum+=int(d) print(sum)
true
5dbf7ac589fabcfbea1d06d0f37b3181b8d6d77a
BarzelZipora/google-project-auto-complete
/auto_complete_data.py
UTF-8
478
3.015625
3
[]
no_license
class AutoCompleteData: def __init__(self, sentence, source): self.__completed_sentence = sentence self.__source_text = source self.__offset = None self.__score = None def set_offset(self, offset): self.__offset = offset def set_score(self, score): self.__sc...
true
a4cf9086df61ffa8806b86702919523f00c02485
kartoone/cosc470nn
/src/python/DeepLearningPython35/zerosandones-keras.py
UTF-8
2,138
3.046875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Thu Mar 18 12:00:12 2021 USES KERAS INSTEAD OF THE AUTHOR'S CODE ... MUST BE RUN FROM TFKERAS ENVIRONMENT @author: karto """ import network import network2 import random import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras i...
true
5c1f63f589769a6b81826959cf30be548fba8a12
066-darley/exercicioPython
/questao7.py
UTF-8
187
4.21875
4
[]
no_license
valor = float(input("Digite um valor: ")) if (valor == 0): print("Valor neutro") elif (valor < 0): print("Valor negativo") elif (valor > 0): print("Valor positivo")
true
423d7dc279a175edb561d227a64c32f4ba634082
GodspeedyJulian/1.3
/18.3.py
UTF-8
376
3.515625
4
[]
no_license
def GetTemp (SensorID): return 50 def Alarm(): print("Too hot") return HighTemp=100 LowTemp=10 SensorID=int(input("Input sensor ID")) while SensorID<1 or SensorID>10: SensorID=int(input("Input snesor ID")) Temp=GetTemp(SensorID) if Temp > HighTemp: Alarm() if Temp < LowTemp: ...
true
a9096c83c9d9662c2fa34ea8c323a2745ca0a4ed
LeenonGo/sklearn-learn
/03-ModelSelectionAndEvaluation/day28/day28-2-AdjustHyperparameter.py
UTF-8
3,238
3.234375
3
[]
no_license
# -*- coding: utf-8 -*- # @Author : Lee # @Time : 2021/8/10 17:24 # @Function: 3.2. 调整估计器的超参数 # # 超参数,即不直接在估计器内学习的参数。 # 典型的例子有:用于支持向量分类器的 C 、kernel 和 gamma ,用于Lasso的 alpha # estimator.get_params() 获取到给定估计器的所有参数的名称和当前值 # 搜索包括: # 估计器(回归器或分类器,例如 sklearn.svm.SVC()) # 参数空间 # 搜寻或采样候选的方法 # 交叉验证方案 # 计分函数 # 有些模型支...
true
86220406fde8f4d887b6b389a9a490297d9b4c3d
alcibiadesBustillo/resumen-news-api
/scrapping_resumen_news/load/main.py
UTF-8
1,014
2.53125
3
[ "MIT" ]
permissive
import argparse import logging logging.basicConfig(level=logging.INFO) import pandas as pd from article import Article from base import Base, engine, Session logger = logging.getLogger(__name__) def main(filename): Base.metadata.create_all(engine) session = Session() articles = pd.read_csv(filename) ...
true
b35ca1e7d13cb31f39480238c5897fed30b0a0e6
goodfax/Taekeun
/Modoo/lab07_1.py
UTF-8
2,947
2.828125
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt import tensorflow as tf tf.random.set_seed(777) # dataset xy = np.array([[828.659973, 833.450012, 908100, 828.349976, 831.659973], [823.02002, 828.070007, 1828100, 821.655029, 828.070007], [819.929993, 824.400024, 1438100, 818.97998, 824...
true
b56816dd33b5435007b9ab2fea8b7c89bfdf84bb
hemant29/python
/om.first.com/readfile.py
UTF-8
89
2.796875
3
[]
no_license
f=open("hemant.txt", "r") if f.mode == 'r': contents =f.read() print(contents)
true
e7475cb1274fbce6edfb6bd557898bcc3c63bcc7
takuan-osho/black-hat-python-jp-practice
/chapter-10/process_monitor.py
UTF-8
2,272
2.5625
3
[]
no_license
#!/usr/bin/env python3 import sys import os import win32con import win32api import win32security import wmi def get_process_privileges(pid): try: # 対象のプロセスへのハンドルを取得 hproc = win32api.OpenProcess( win32con.PROCESS_QUERY_INFORMATION, False, pid) # メインのプロセストークンを開く htok =...
true
9265c13c44ec82d15d437fe6b7e8d2967b42dfa5
IsraelCavalcante58/Python
/Aprendendo Python/exercicios/ex081.py
UTF-8
815
4.84375
5
[]
no_license
'''Crie um programa que vai ler vários números e colocar em uma lista. A) Quantos números foram digitados. B) A lista de valores, ordenada de forma decrescente C) Se o valor 5 foi digitado e está ou não na lista.''' lista = list() while True: n = int(input(f'Digite um número: ')) lista.append(n) opção =...
true
78916c194465a3781c0450c4d75156e9229b2f8c
esther4599/Python
/algorithm/01.파이썬기초문법/11.함수만들기.py
UTF-8
790
4.25
4
[]
no_license
# 함수 def add01(a,b): c = a+b print(c) add01(2,3) add01(3,5) ########################### # return def add02(a,b): c = a+b return c print(add02(2,3)) print(add02(3,5)) ########################### # return 여러개 = tuple로 반환 def cal(a,b): c = a+b d = a-b return c, d print(cal(5, 1)) # (6...
true
0a0a90b414e1887fd0fd13ae95a79d6b55301e33
RajrocksIT/python_parabola_functions
/parabola_functions23.py
UTF-8
1,628
4.0625
4
[]
no_license
# Instead of actually having to create a range on lines 47 to 50 every # time, we want to essentially by calling the parabola function we should be able to # just pass size and get it to do the work for us. try: import tkinter except ImportError: import Tkinter as tkinter def parabola(page, size): ...
true
a67873622132e95569d8c912b113e6a6ea908d13
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app69_converters.py
UTF-8
233
2.5625
3
[]
no_license
#modules # we use modules to better organize all out code, instead of writting all the code in one file , we break our code in multiple files def lbs_to_kgs(weight): return weight*.45 def kg_to_lbs(weight): return weight/.45
true
c30f96c4194f17830b7421f133b4d854d4c0296b
johnbachman/tBidBaxLipo
/tbidbaxlipo/plots/layout_130822.py
UTF-8
2,747
2.75
3
[]
no_license
from tbidbaxlipo.util.plate_assay import * import collections import sys import os import tbidbaxlipo.data # In the course of doing this experiment, I learned that trying to pipette 50 # uL into the half-well area plate leads to spillage and error. 20 uL had # no sign of spilling. well_names = ['%s%.2d' % (row, col) ...
true
ee3df39e425625c627ee79db3d731cff8b2d66bf
ralmn/compilation
/compile_exception.py
UTF-8
805
2.84375
3
[]
no_license
class CompileException(Exception): str = "" def __init__(self, message, token=None, line=None): # Now for your custom code... tmp_message = "" if token is not None: tmp_message += "Error line " + str(token.line) + ": \r\n" tmp_message += getLineError(token.line...
true
b3c6ca564856a9cdf92218e8c612043960953cf6
hyyc116/CDBoN
/cascades/tools/subgraphs.py
UTF-8
3,277
2.828125
3
[]
no_license
#coding:utf-8 ''' the algorithm of get all connected graph refers to https://stackoverflow.com/questions/18837026/an-algorithm-to-get-all-connected-subgraphs-from-graph-is-it-correct ''' from collections import defaultdict from basic_config import * import time def read_cascade(cascade_path): cc = json.loads(open...
true
f709cdaa0bcca032d766530802aa7e220ff6fc0a
uees/happyWork
/utils/pdf.py
UTF-8
1,710
2.78125
3
[ "Apache-2.0" ]
permissive
import os from reportlab.pdfgen import canvas from reportlab.lib.units import cm from PyPDF2 import PdfFileWriter, PdfFileReader def create_watermark(text, path=None): if path: f_pdf = os.path.join(path, 'mark.pdf') else: f_pdf = 'mark.pdf' w_pdf = 20 * cm h_pdf = 20 * ...
true
b21ad16a5c317c44521da6d57f2170efbb48af7a
borschtl21/UntitledGame
/player.py
UTF-8
386
2.703125
3
[]
no_license
import physik import pygame # hier alles was der player in game dann macht verusacht ereleidet class Player(physik.PhysicsObj): def __init__(self, x_global, y_global, vel, size): super().__init__(x_global, y_global, vel, size) # def move(self): # self.rect.x += self.vel.x # self.rect....
true
1bab7099b33d539b85b646cb561896b428f43f34
playfulMIT/kimchi
/dataprocessing/elo.py
UTF-8
40,818
2.546875
3
[ "MIT" ]
permissive
from datetime import datetime import json import numpy as np import pandas as pd from sklearn import metrics import math import csv import os import statistics from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler # USAGE EXAMPLE #path = '/Users/pedroantonio/Desktop/TFG/notebooks/anona...
true
0eaedcaf3f7400cb9946f76716330ca122b712f8
tn15aan/python-basics
/magic_number_game.py
UTF-8
584
4.6875
5
[]
no_license
# Magic number game # prompt the user for input # generate a random number using a python library (should be between 1-10) # check the the number against a magic number # let the user know if he/she won or # if the guess was above or under import random random_num = random.randint(1, 10) num = int while random_nu...
true
a91ef4a022a91535880b90e852f8249423b7bd94
GDN2/DL
/DeepLearning/tensorflow/tensorflow_Logistic_Regression_titanic.py
UTF-8
3,176
2.546875
3
[]
no_license
import tensorflow as tf import numpy as np import pandas as pd from datetime import datetime loaded_train_data = pd.read_csv('../data/train.csv').values loaded_test_data = pd.read_csv('../data/test.csv').values loaded_test_t_data = pd.read_csv('../data/gender_submission.csv').values x_train_data = loaded_train_data[...
true
363bde998c829b4cd3d1a33b123406d60149c159
sj-nv20/Python
/for반복문 - rangeg함수[실습과제].py
UTF-8
275
4.21875
4
[]
no_license
#range[실습과제] #numbers라는 리스트가 주어졌습니다. #for문과 range 함수를 사용하여, numbers의 인덱스와 원소를 출력해 보세요. numbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] for i in range(len(numbers)): print(i, numbers[i])
true
b2521907195ae85c556a16b321a6bf0140db3142
AccentsAMillion/Python
/Ten Real World Applications/Python Basics/Modules/BuiltInModules/ModulesBuiltIn.py
UTF-8
344
2.96875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sun May 3 09:32:22 2020 @author: Chris """ # BuiltIn Modules to utilize in code import time import os while True: if os.path.exists("fruit.txt"): with open("fruit.txt") as file: print (file.read()) else: print("File does not exist.") ...
true
d68fc85a60cae6ccc3746181cb2d081ec815f60c
pak21/aoc2018
/23/23-2.py
UTF-8
1,701
2.859375
3
[]
no_license
#!/usr/bin/python3 import math import matplotlib.pyplot as plt from operator import itemgetter import random import re import sys pattern = re.compile(r'pos=<([-\d]+),([-\d]+),([-\d]+)>, r=(\d+)') with open(sys.argv[1]) as f: bots = [[int(x) for x in pattern.match(line).groups()] for line in f] def distance(a, ...
true
86f6bd828d8f7c58c31635885a6ae875db77228e
Bhavaz/Big-Data-Programming
/LAB2/SOURCE/Task--1/facebooks_friends_mutual.py
UTF-8
1,079
2.703125
3
[]
no_license
from pyspark import SparkContext def mapping_eachline(each_line): each_line = each_line.split(" ") profile = each_line[0] friends = each_line[1] return profile, friends def reduce(accum, value): return list(set(accum) & set(value)) def map_mapped(tuple): key = tuple[0] ...
true
e3e33d8a33107818baa47c0cbd4066f95d42f347
kjnh10/pcw
/work/atcoder/arc/arc084/D/answers/745468_ahho.py
UTF-8
290
2.859375
3
[]
no_license
from collections import deque K = int(input()) Q = deque((1,)) inf = float('inf') L = [inf]*K L[1] = 1 while Q[0] != 0: n = Q.popleft() a = (n+1)%K if L[a] > L[n]+1: L[a] = L[n]+1 Q.append(a) b = (n*10)%K if L[b] > L[n]: L[b] = L[n] Q.appendleft(b) print(L[0])
true
d3e3e780d04a189244352249acee753261d11669
ryosakagami/gmcr-py
/frame_00_frameTemplate.py
UTF-8
3,390
2.734375
3
[]
no_license
# Copyright: (c) Oskar Petersons 2013 """Base class for frames to be loaded into the main window.""" from tkinter import Frame, PhotoImage, StringVar, N, S, E, W from tkinter import ttk NSEW = (N, S, E, W) class FrameTemplate(Frame): """Base class for frames to be loaded into the main window.""" # #########...
true
64c7d5c117f920911e9e1bf95b966f78a3ee7c67
seanchen513/leetcode
/array/0724_find_pivot_index.py
UTF-8
1,999
4.40625
4
[]
no_license
""" 724. Find Pivot Index Easy Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index. If no such index exists, we should re...
true
91beadd2cf2a7084847610ddfad2852e16a0642e
Oh-Joshua/UdemyPythonLessons
/Section_4/Section4_28-30.py
UTF-8
1,442
4.4375
4
[]
no_license
# 28.集合型 print('===============================') print('---------------') a = {1, 4, 5, 2, 3, 4, 4, 3, 5} # {}で括った、キーのない辞書的なもの print('集合a:', a) print(type(a)) b = {2, 3, 3, 6, 7} print('集合b:', b) print('a - b', a - b) # 集合の引き算(重複する値を取り除く) print('b - a', b - a) # 集合の引き算(重複する値を取り除く)...
true
f393d0e488e4e00114dfaf4a26aeff55491ff022
hamzaHMZ/projects-StudentManager
/Grade.py
UTF-8
2,156
3.78125
4
[]
no_license
import math class Grade : """ Grade class Attributes : - value """ #------------------------------------------------------------------------------------------------------------------- #CONSTRUCTOR def __init__(self, value=0.0): self.__value = float(math.fabs(valu...
true
9744470aa72e7ed1e5a4d43ecb81f2ce1526bc65
shadydealer/Dungeons-and-Pythons
/src/dungeon.py
UTF-8
14,188
3.359375
3
[]
no_license
from src.treasure import Treasure from src.weapon import Weapon from src.spell import Spell from src.hero import Hero from src.enemy import Enemy from src.fight import Fight from src.fight_status_bar import FightStatusBar import sys import os.path import csv import pdb DEFAULT_FILE_DIR = 'dungeon_maps/level_1/' DEFA...
true
2c1efaa993396879219b41b74c2293527f1ff1da
aniaHrrera4/Python-Projects
/Python_Projects/sybil5
UTF-8
291
3.484375
3
[]
no_license
#graph code 3 from igraph import * #importing igraph from library g=Graph(3) # number of nodes g.add_edge(0,1) g.add_edge(0,2) for i in range(0,g.vcount()): # g.vcount() counts print(g.degree(i)) summary(g) #print information about the g plot(g, "code1.pdf")
true
2599eceb0a742da3ddbf79eccd642895c84875b4
rorjackson/Jack
/tkinterfunctiongui.py
UTF-8
290
3.203125
3
[]
no_license
from tkinter import * win = Tk() win.geometry("100x100") def fun(event): print("welcome to knowledge shelf") button = Button(win,text="click me") # Command has been used to bind button with function named fun. button.bind("<Button-1>",fun) button.pack() win.mainloop()
true
91611efd9d22154bc2c23a43ea23559378f61c7f
metalbass/django3-collectionfield
/collectionfield/models/fields.py
UTF-8
9,614
2.578125
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db.models.fields import Field from django.core import exceptions from django.utils.functional import cached_property from django.utils.text import capfirst from collectionfield.converter import CollectionConverter from collectionfield.valida...
true
9004f88a017e0d02403d8ecaa2ae3557212b34cb
TianqiMikeHu/ece448
/mp2/transform.py
UTF-8
2,607
3.046875
3
[]
no_license
# transform.py # --------------- # Licensing Information: You are free to use or extend this projects for # educational purposes provided that (1) you do not distribute or publish # solutions, (2) you retain this notice, and (3) you provide clear # attribution to the University of Illinois at Urbana-Champaign # # Cr...
true
b50646362428794271da3b7ee395c16167377d82
nibbletobits/nibbletobits
/python/day 11 in class main.py
UTF-8
534
3.9375
4
[]
no_license
# ******************************************** # Program Name: Day 11, in class # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: 7 12, 2021 # Purpose: A program that sends a word and calls a function. # Modules used: def vert_word # Input Variables: (word) # Output: print statement calls function ve...
true
14335d231777fb64cb9d35cc1989f8480eaa56f5
phootip/advent-of-code-2019
/14/run-2.py
UTF-8
2,815
3.03125
3
[]
no_license
import copy def tokenize(filename): f = open(filename) data = {} for line in f: line = line.strip().replace(',', '').split(' ') line.pop(-3) total_gcd = int(line[0]) for i in range(0, len(line), 2): line[i] = int(line[i]) product = line[-2:] cost...
true
4aad163718fd4bb63d3a10e01dc6e986b7b3035b
liubenyuan/pyBSBL
/demo/bsbl_none_sparse_ecg.py
UTF-8
3,774
2.984375
3
[ "BSD-3-Clause" ]
permissive
# Example showing the ability of BSBL to recover non-sparse signals. # # The signal to recover is a real-world fetal ECG data, which consists two # peaks of fetal ECG and one peak of maternal ECG. # # The goal is to recover the signal without distorting the two peaks of fetal # ECG (the two peaks locate around at...
true
6d07c9e3d75ff36bc8ab7411179417df34b65a0d
fans656/eos-gui-prototype
/bitmap.py
UTF-8
898
2.859375
3
[]
no_license
from PySide.QtCore import * from PySide.QtGui import * from color import * from rect import Rect class Bitmap(object): def __init__(self, *args): if len(args) == 1: if isinstance(args[0], str): path = args[0] self.im = QImage(path) else: ...
true
1314cadcd2c7dfa108609e32f92985d37718a88b
gabriellaec/desoft-analise-exercicios
/backup/user_050/ch1_2019_02_26_20_40_13_113563.py
UTF-8
594
3.890625
4
[]
no_license
# -*- coding: utf-8 -*- """ Created on Tue Feb 26 09:28:16 2019 Desafios resolvidos (ou não) @author: Giovanni Rozatti """ """ Exercício 1: Cálculo de Juros Compostos Variáveis: V = valor devido C = capital inicial (Valor emprestado) i = taxa de juros t= período de tempo """ def Calcula_Valor_Dev...
true
83acebb680fba762d60efcfe37266b0c35704d38
knigawkl/treeseg
/segmenter/tree/test_tree_seg.py
UTF-8
3,397
2.734375
3
[]
no_license
from segmenter.tree.tree_seg import TreeSegmenter from segmenter.segmenter import Segmenter from segmenter.tree.enumerate_trees import Enumerator import numpy as np from numpy import zeros, ones, zeros_like, ones_like, log, exp, allclose, array NINF = -np.inf class TestTreeSegmenter(Segmenter): def test_enumerat...
true
b590ad190ccd01f6920958a21bbbcbcc46b781b5
olyweb/ProjetDeputes
/parite.py
UTF-8
1,283
2.84375
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 8 15:07:30 2018 @author: olivier """ from argparse import ArgumentParser import analysis.csv as c_an import analysis.xml as x_an import logging as lg def parse_arguments(): parser = ArgumentParser() parser.add_argument('-e', '--extension...
true
bd79d774fb977d680e31ab474c6ffb0022b0a340
lixiang2017/leetcode
/leetcode-cn/2395.0_Find_Subarrays_With_Equal_Sum.py
UTF-8
497
3.078125
3
[]
no_license
''' hash table 执行用时:40 ms, 在所有 Python3 提交中击败了56.55%的用户 内存消耗:15.1 MB, 在所有 Python3 提交中击败了40.48%的用户 通过测试用例:42 / 42 ''' class Solution: def findSubarrays(self, nums: List[int]) -> bool: seen = set() n = len(nums) for i in range(n - 1): s = nums[i] + nums[i + 1] ...
true
2918246ce7d62189d4b302cf5a35ca0fcabda3f2
aNLPer/AlgorithmNotes
/Algorithm/DynamicProgramming/intro.py
UTF-8
1,905
4.34375
4
[]
no_license
""" 动态规划要素: 重叠子问题、状态转移方程、最优子结构 本节使用斐波那契数列来介绍重叠子问题和状态转移方程 """ def fib_rec(n): """ 递归方法求斐波那契数列: 递归树 20 / \ 18 19 / \ / \ 16 17 17 18 从递归数我们可以看到17、18节点被重复计算(称为重叠子问题)。所以递归算法的时...
true
8fe4c50d5b5ada66cb0572909553e95de92f03e4
erichmatt/trainwreck-game
/trainwreck-eric.py
UTF-8
998
3.265625
3
[ "MIT" ]
permissive
import pygame import random from time import sleep from pygame.locals import * import sys pygame.init() white = (255,255,255) black = (0,0,0) red = (255, 0, 0) green = (0, 255, 0) blue = (0,0, 255) gray = (100, 100, 100) screen = pygame.display.set_mode((600, 600)) pygame.display.set_caption('TRAIN WRECK') def...
true
996e8acdb148f3fbf20a524ef093d6beec1d5005
ngonthier/Icono_Art_Analysis
/Classif_Paintings/Test_TimeDataset.py
UTF-8
9,847
2.5625
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 18 18:03:46 2018 @author: gonthier """ import tensorflow as tf import numpy as np import os, time, multiprocessing import matplotlib.pyplot as plt def _floats_feature(value): return tf.train.Feature(float_list=tf.train.FloatList(value=value.re...
true
d41c2d401143f06547f333235414855a2b26e131
Dominikmloy/syringe-pump-program
/main_double_meander_automated.py
UTF-8
6,078
2.984375
3
[ "CC-BY-4.0" ]
permissive
import ramping_class as r_c import mixing_class as m_c import setup # -- Program: -- # Usage: E.g., Formulation of core nanoparticles with the subsequent addition of an additional component. # The Double meander channel is washed with 1.0 ml Tuberkulin syringes in pumps LA120, LA122, and LA160. # LA160 is feeding the o...
true
d7c621d870b97480564a3aec6504dfaff35f77f2
Marco2018/leetcode
/kickstart/kickstart Round H 2018/algo-a.py
UTF-8
945
2.703125
3
[]
no_license
#input_file=open("test-a.txt","r") input_file=open("A-large.in","r") output_file=open("out_a_1.txt","w") times=int(input_file.readline()) print(times) for time in range(times): print(time) res=0 nums=[int(x) for x in input_file.readline().split()] n,p,pres=nums[0],nums[1],[] res=2**n ...
true
ca3d05dc7ef7a1d1a4dcbfc77c98ca703d5c02aa
Aasthaengg/IBMdataset
/Python_codes/p02756/s095947791.py
UTF-8
394
2.734375
3
[]
no_license
from collections import deque S = deque(list(input())) Q = int(input()) q = [list(input().split()) for _ in range(Q)] r = 0 for i in range(Q): if q[i][0] == "1": r += 1 else: if (q[i][1] == "1" and r%2==0)or (q[i][1] == "2" and r%2==1 ): S.appendleft(q[i][2]) else: ...
true
07b7d358a02a90abf1c4e8a9eec4e381d0d700da
fullywave/py-project
/CalPivi.py
UTF-8
168
3.046875
3
[]
no_license
#CalPivi.py pi =0 N =1000 for k in range(N): pi +=1/pow(16,k)*(\ 4/(8*k+1)-2/(8*k+4)-\ 1/(8*k+5)-1/(8*k+6)) print("圆周率值是:{}".format(pi))
true
0976e13990e4a421d2d9d7b1d1b6372750d063fe
konakallaANUSHA/python-deep-learning
/lab-1/CODE/task-3.py
UTF-8
3,339
3.828125
4
[]
no_license
'''Library Management System Classes : Person, Book Details, Librarian, Allotment, Student''' # Person Class class Person(): #defined constructor def __init__(self,full_name,emailaddress,std_id,phn_num): self.fname = full_name self.email = emailaddress self.id = std_id self.pnum = p...
true
babd3889d821e28e46c6f89ca3f3e73ea83eae1f
tex2e/mako-tls13
/crypto_hkdf.py
UTF-8
5,566
3.0625
3
[]
no_license
# ------------------------------------------------------------------------------ # Hash-Based Key Derivation Function # - RFC 5869 (HMAC-based Extract-and-Expand Key Derivation Function (HKDF)) # * https://datatracker.ietf.org/doc/html/rfc5869#section-2.2 # * https://datatracker.ietf.org/doc/html/rfc5869#sect...
true
512803dcdfad5d9154987d39ce8b03e2b11b78d8
crescent-igor/HackHub2019
/backupServer.py
UTF-8
7,185
2.640625
3
[]
no_license
import socket import select import math import time from ast import literal_eval BUFFER = 1024 data_list_count = {'1':[],'2':[]} #dict to check count against id data_list_cordinates = {'1':[],'2':[]} avg_dict = {'1':[],'2':[]} avg1, avg2 = 0,0 msg = {'1':"Go to floor 1",'2':"Go to floor 2"} #1:clean, 0: occupied and ...
true
a870db21b35b0eacd6d368a4c19a906af9b6ba50
flyingdp/python-project
/python-100-days/day06-函数/demo1.py
UTF-8
196
3.8125
4
[]
no_license
"""求阶乘""" def fac(num): result = 1 for n in range(1,num+1): result*=n return result m = int(input("请输入阶乘的数字:")) print("%d的阶乘是:" %(m),fac(m))
true
e5296a3d6aaeb9a9cf401e63a2520ba4b9dd134c
HaydenWolff/Tetris
/Tetris/tetris_classes.py
UTF-8
15,297
3.21875
3
[]
no_license
######################################### # Programmer: Hayden Wolff # Date: 04/7/2019 # File Name: tetris_classes.py ######################################### import pygame BLACK = ( 0, 0, 0) RED = (255, 0, 0) GREEN = ( 0,255, 0) ...
true
04d6983c07bdda340a070a99596ad6f793d9f003
HanaAuana/beginner-projects-python
/test_averages.py
UTF-8
1,542
3.28125
3
[]
no_license
import averages import unittest class KnownValues(unittest.TestCase): known_means = (([1, 2, 3, 4, 5], 3.0), ([4, 4, 4, 4, 4], 4.0), ([10, 10, 20, 60, 70], 34.0), ([6, 7, 8], 7.0), ([2, 1], 1.5), ) known_medians = ...
true
b7e5c740ba82a08cc3bb8efcca1c124768182ac5
gintian/iterAssAna
/main/recomputeSet.py
UTF-8
6,334
2.6875
3
[]
no_license
import numpy as np from functools import cmp_to_key def cmp2(a,b): min1 = min(a[0]) min2 = min(b[0]) return min1-min2 class recomputeSet(): def __init__(self,src_inter_list, num_dis, threshold): self.num_dis = num_dis self.threshold =threshold self.src_inter_list = src_inter_list...
true
2f9b8db5ffd69295a9efe32cc55398767257a2ed
oraby8/AI-learns-to-play-Google-Chrome-Dinosaur-Game-
/Dinosaur.py
UTF-8
792
2.90625
3
[]
no_license
from PIL import ImageGrab,ImageOps import pyautogui import time import numpy as np class Cordinates(): replay=(250,200)#GameOver cordinate dinosaur=(122,202)#dinosaur cordinate y=205 x=158 def replaygame(): #to repaly the Game pyautogui.click(Cordinates.replay) def jumping(): #to...
true
082f55759222da543a51ca4c2c3762899b30a36f
GHDDI-AILab/Rare-disease
/GDAs_KEGG_API.py
UTF-8
987
2.65625
3
[]
no_license
#This file for download DisGeNET database with API #build by XiaoyingLv at 2020.9.8 import requests import json import csv import datetime import argparse #get paramter from the external environment def get_parser(): """ Parameters Parser """ parser = argparse.ArgumentParser(description="Using the URL API to s...
true
71cd1df6bceb2da64cdd0b75ec52b2446c7de5c3
maryonella02/Codeforces-Laboratory
/9A.py
UTF-8
529
3.8125
4
[]
no_license
from fractions import Fraction """ Die Roll Here we have to give the probability that Dot will won, if other two will roll the dice first, knowing that if Dot will give the same number she will win. So the probability of Dot to win is max n number from them two + n + i till 6 on 6.""" y, w = map(int, input().split...
true
652efb1f59a314c538d544d949b7af2888c5adf3
MarcosAllysson/python-do-basico-ao-avancado
/Teste - Métodos Embutidos - Funções avançadas.py
UTF-8
2,382
4.5
4
[]
no_license
""" Problema 1 Use o map para criar uma função que encontre o tamanho de cada palavra na frase (quebrado por espaços) e retornar os valores em uma lista. A função terá uma entrada de uma string e exibirá uma lista de números inteiros. word_lengths('How long are the words in this phrase') saída: [3, 4, 3, 3, 5, 2, 4, 6]...
true
f2f5892948c3ba6a9a18615a68fa64545d5ad91a
kcyk01/AdventOfCode2018
/day6.py
UTF-8
2,040
3.203125
3
[]
no_license
import re from utils import get_input from collections import defaultdict size = 500 offset = size / 4 names = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' points = {} def find_closest(i: int, j: int) -> str: global points lowest, minimum = '.', size for name, point in points.items(): ...
true
46dc0ed92477fda2c75abf7315669644d4937b2c
Mcilie/psyonic-ygdrassil
/oldFiles/mpltest.py
UTF-8
2,444
2.890625
3
[]
no_license
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import PySimpleGUI as sg import matplotlib, time, threading matplotlib.use('TkAgg') import matplotlib.pyplot as plt import numpy as np def fig_maker(window): # this should be called as a thread, then time.sleep() here would not freeze the GUI plt.sca...
true
436d404988f00a2d61461add7eba188c5b072406
IgorGrafin/2048
/2048-3.py
UTF-8
12,455
3.390625
3
[]
no_license
import random import copy import os import tkinter from tkinter import messagebox class MyMatrix: def __init__(self): # Initialization of MyMatrix. GameField as list. ScoreStep - as int. GameOver as bool # self.GameField = [[1, 2, 2, 3], [5, 40, 4, 3], [3, 3, 3, 0], [0, 0, 0, 0]] ...
true
a927087b1c10e5888db824bed8be21e0e7fea950
INNOMIGHT/problem_solving
/codechef/atm.py
UTF-8
288
3.46875
3
[]
no_license
def atm(): withdrawal_amount = int(input()) initial_balance = float(input()) if withdrawal_amount <= initial_balance + 0.50 and withdrawal_amount % 5 == 0: return initial_balance - (withdrawal_amount + 0.50) else: return initial_balance print(atm())
true
2cf83a3d3e40de5c3df580f18daab90ee371b118
154King154/birth-nti
/commands.py
UTF-8
1,470
2.578125
3
[]
no_license
import telebot import markovify from misc import bot_db with open("parse_birth.txt", encoding='utf-8') as f: text = f.read() text_model = markovify.Text(text) last_mess = "" @bot_db.message_handler(commands=["birth"]) def start_message(message): global last_mess i = 0 mess = "" while i != 5: ...
true
b0a5220465a18eff748eb25baf0781e11b177600
zignig/gizmotron
/sim_data.py
UTF-8
1,121
2.53125
3
[]
no_license
# return simulator data from nmigen import * def char(c): d = "{:08b}".format(ord(c)) print(c, ord(c)) data = [] for i in d: data.append(int(i)) data.reverse() return data def str_data(s): data = [] for i in s: data.append(char(i)) return data def test_rx(data, ...
true
3c84becfe37e4edfbef8f25fc6548af779c570f0
CodeBall/Learn-Python-The-Hard-Way
/yanzilu/ex18.py
UTF-8
564
3.5625
4
[]
no_license
#Names,Variables,Code,Functions #This one is like your script with argv def print_two(*args): arg1,arg2 = args print"arg1:%r,arg2:%r" %(arg1,arg2) #ok,thst *args is actually pointless,we can just do this def print_two_again(arg1,arg2): print"arg1:%r,arg2:%r" %(arg1,arg2) #this jua=st takes one argument d...
true
9db47346ebe4ac8d67c9ef5c37e5200f8c2b2232
fatt21/fatt
/bin/classifier_mapper.py
UTF-8
5,429
2.578125
3
[]
no_license
from sklearn import svm from sklearn import tree from sklearn import ensemble from parse import parse import catboost import csv import json class ClassifierMapper: def create(self, classifier, file_path): if isinstance(classifier, svm.SVC): self.createSvm(classifier, file_path) elif is...
true
b11cbad667e727eb3f961cc85a2e9db6d246316d
vjern/toksic
/toksic/trie.py
UTF-8
11,454
3.15625
3
[]
no_license
from dataclasses import dataclass, field from typing import List, Any, Dict, Tuple, Optional, Set class _Any: def __str__(self): return 'ANY' def __repr__(self): return str(self) # from .tree import Node _any = _Any() _any_n = object() # 1 or n @dataclass class Trie: children: Dict...
true
70f31a8b212018480d075befd5f316e31570420b
lizhengxiang/Python_cookbook
/2.2.6.py
UTF-8
82
3.0625
3
[]
no_license
number = [12,31,23,5,6,4,6] print len(number) print min(number) print max(number)
true
946a0c6570c0d5e542fe1e9248e5b65ad389eb7f
lcyyzy/DDoS
/UdpFlood/udpFlood.py
UTF-8
706
2.96875
3
[]
no_license
import socket import random import os import nmap def attack(ip, lport): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Creates an IP UDP socket bytes = random._urandom(1460) # Create a packet while 1: for port in lport: sock.sendto(bytes, (ip, port)) def main(): nm...
true
d8545b24d0b10c7a995b18a23165c450ba39e74f
wachira90/python-pyautogui
/test_2.py
UTF-8
432
2.53125
3
[]
no_license
import pyautogui as pg import time def delete_for_everyone(): pg.click(807, 979) pg.typewrite("hello") pg.typewrite(["enter"]) time.sleep(2) pg.click(1621, 896) pg.click(1621, 896) # time.sleep(1) pg.click(1693, 859) # time.sleep(1) pg.click(1014, 669) # t...
true
602d800b429d26b2204ddfce733c2477fe214bca
HughLocke/Mechine-Learning-in_Action
/ch2/KNN.py
UTF-8
3,953
3.21875
3
[]
no_license
from numpy import * import operator import matplotlib import matplotlib.pyplot as plt def createDataset(): group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]]) labels = ['A','A','B','B'] return group,labels #dataSet:训练样本集合,labels:训练样本的分类,inX:用于分类的输入向量(一个测试数据) def classify0(inX,dataSet,labels,k): dataSetS...
true
3913d03d958727d2d1e7b678b2ddcb8616a436ff
somebody422/nypd_data_project
/test.py
UTF-8
673
2.90625
3
[]
no_license
import numpy as np import matplotlib import matplotlib.pyplot as pyplot from sklearn import cluster #as_array = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] as_array = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12] ] as_matrix = np.matrix(as_array) matrix_transposed = as_matrix.getT() data = np.matrix([ [1,...
true
08a12d18ae313454c5f29952f63de450f92566b3
Ciara-Lynch/Mass_Spec_Analysis
/Pathway_graphs.py
UTF-8
10,215
3.484375
3
[]
no_license
#!usr/bin/env python3 # by Ciara Lynch, 20/09/2020, last edit 11/10/2020 # Python can't read in files with gaps in the names, ensure to use a file name with no spaces, use _ instead # this code takes two command line arguments; # 2 INPUT.txt (as a tab delimited text file), one for up-regulated proteins and one for ...
true
d3377869699b2036d908cb444ecef6f7c903aded
jeremycurrygit/image-cropper
/imaging.py
UTF-8
11,225
2.53125
3
[]
no_license
# -*- coding: utf8 -*- """ imaging.py author: Septimus Liu Crop image automatically from either a remote address or base64 encoded stream. """ import argparse import cStringIO import cv2 import datetime import detector import httplib2 import httplib2 import cStringIO import cv2 import datetime import math import nump...
true
ab49582d8071fe0d10778650d41c6a045a85c6cc
sahiljain443/Python-mini
/ping_outputAvgTime.py
UTF-8
1,123
2.90625
3
[]
no_license
import schedule import subprocess import datetime import time def ping_host(): # ping host www.google.com (5 times) # store results of ping in ping_output ping_output = subprocess.Popen(['ping', '-c 5', 'www.google.com'], stdout=subprocess.PIPE).communicate()[0] #extract min/avg/max/stddev time values...
true
f3673d0defc4a480fd00bb55b6a2a7a3da1ad91d
AndyDeany/sunni-remake
/lib/mouse.py
UTF-8
1,286
3.265625
3
[]
no_license
import pygame class Mouse: def __init__(self): self.x = 0 self.y = 0 self.left = 0 self.middle = 0 self.right = 0 self.left_held = 0 self.middle_held = 0 self.right_held = 0 @staticmethod def get_mouse_state(): return pygame.mouse....
true
d46b8e65fc37374d798c783a2303cb66aa827229
Gobdev/Rouglet-SDL
/src/images/compileImages.py
UTF-8
1,223
2.59375
3
[]
no_license
#! python from PIL import Image import os, re path = re.match('(.*?)(/src(/images)?)?$', os.getcwd()).group(1) path += "/src/images/" dirs = [directory for directory in os.listdir(path) if os.path.isdir(path + directory)] for directory in dirs: images = {} pngFiles = [file for file in os.listdir(path + directory) if...
true
bd5b6c09fa0289f4f7498a234563db8269885c0f
robsws/aoc
/2016/13_2.py
UTF-8
2,706
3.0625
3
[]
no_license
#!/usr/local/bin/python import sys from copy import deepcopy from functools import reduce import time input_value = int(sys.argv[1]) target = [31, 39] def is_wall(coord): (x, y) = coord value = x*x + 3*x + 2*x*y + y + y*y + input_value one_bits = 0 for i in reversed(range(32)): bit_value = 2 ** i if b...
true
eaabfe75da2c748ccf5b29687d1dbbd26e6c19e5
mulefish/map_notes_to_syllables
/test.py
UTF-8
5,650
3.421875
3
[]
no_license
import unittest from main import get_syllables, collect_syllables, shuffle_array_of_objects, find_budget, wavs_buy_syllables, display_to_stout class TheTests(unittest.TestCase): def test_display(self): wav_files = ['a', 'b', 'c'] syllables_cost_map = { 'a':1, 'b':1, ...
true
07b9fa4cdbe2848af8f29e634d5213e15a967291
Lixinran1213/python
/Chapter 4/qiepian2.py
UTF-8
88
3.046875
3
[]
no_license
plays = ['bob','jack','allen','hellen'] for player in plays[:3]: print(player.title())
true
19b82e2047482d54d4a715f9d900a0f7a5ad3092
BaylorBower/sortingTests
/test.py
UTF-8
9,588
3.125
3
[]
no_license
import unittest from Main import bubbleSort from Main import mergeSort from Main import heapSort from Main import insertionSort from Main import radixSort from Main import quickSort from Main import cocktailSort # Format # class MyTestCase(unittest.TestCase): # def test_something(self): # self.as...
true
f2524405d0572eafa0d9eda7051fac7a23c9d783
LuisReyes98/python_bases_course
/introduccion_probabilidad/sintomas.py
UTF-8
802
3.25
3
[]
no_license
def calc_bayes(prior_A, prob_B_given_A, prob_B): return (prior_A * prob_B_given_A) / prob_B if __name__ == "__main__": prob_cancer = 1 / 100000 # prob_cancer = 0.09 # para dado un segundo test prob_sintom_given_cancer = 1 prob_sintom_given_no_cancer = 10 / 99999 prob_no_cancer = 1 - pr...
true
96e40b0e09dfe9361385e3deead98bc43227b0b1
olomix/unit-testing-samples
/webapp/__init__.py
UTF-8
1,126
2.78125
3
[]
no_license
from collections import namedtuple import sqlite3 from time import sleep from flask import Flask, render_template_string, g app = Flask(__name__) app.config["DB"] = "/Users/alek/Documents/src/testing-222/webapp/db.sqlite" User = namedtuple("User", ("id", "name")) Ad = namedtuple("Ad", ("title", "url")) ## BD def ...
true
e7a85343301801071295858a4476dac4d12ea604
Markvy/idenfac
/src/resources.py
UTF-8
1,006
2.59375
3
[]
no_license
# micro-optimization: CPython local vars are faster than globals; thus we get a # small but easily measurable speedup by wrapping the whole thing in a function def main(): from collections import Counter from time import time pages = Counter() bad_requests = [] begin = time() # poor man's benchmarking for l...
true
9fe0d5329b8b7f53c465e96416841b1b2250600e
imperialite/interpreting-complexity
/scripts/evaluate_garden_paths.py
UTF-8
5,141
2.6875
3
[ "Apache-2.0" ]
permissive
# Using SyntaxGym classes to estimate how eye-tracking metrics training affects language models import argparse import logging import os from lingcomp.metrics import confidence_intervals from lingcomp.script_utils import save_tsv from lingcomp.syntaxgym import compute_suite_et_metrics, evaluate_suite logging.basicC...
true
3a8d99b002a41c1316091043cd3dfc0054197176
BorislavaSh/SoftUni-Exercises
/ReverseNwithStack.py
UTF-8
143
3.296875
3
[]
no_license
numbers = input().split(" ") s = [] for i in numbers: s.append(i) result = " " while s: result = s.pop() print(result, end=" ")
true
f6d7ef3655b9a9da5fb71dd673ad17bd21e799ff
zzz686970/leetcode-2018
/33_search.py
UTF-8
456
3.6875
4
[]
no_license
def search(nums, target): l, h = 0, len(nums) while l < h: mid = (l+h) // 2 ## mid in the middle, if mid and target < nums[0] if (nums[mid] < nums[0]) == (target < nums[0]): ## mid val < target, look right if nums[mid] < target: l = mid + 1 elif nums[mid] > target: h = mid else: return...
true