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
bff71b929a12918e827332bbee331eedfb14136e
root12321/data-structure
/Dijkstra算法.py
UTF-8
702
3.078125
3
[]
no_license
G = {1:{1:0, 2:1, 3:12}, 2:{2:0, 3:9, 4:3}, 3:{3:0, 5:5}, 4:{3:4, 4:0, 5:13, 6:15}, 5:{5:0, 6:4}, 6:{6:0}} def Dijkstra(G, v0, inf=999): book = set() minv=v0 dis=dict((k,inf)for k in G.keys()) dis[v0]=0 while len(book)<len(G): ...
true
fa3e5483f077fde4609d51186fe41f7e67c7cd93
daniel-reich/ubiquitous-fiesta
/iBqJcagS56wmDpe4x_20.py
UTF-8
252
2.84375
3
[]
no_license
import math def vol_shell(r1, r2): result = 0 if r1 >= r2: result = (4/3)*math.pi*(r1 ** 3 - r2 ** 3) return round(result, 3) if r1 <= r2: result = (4/3)*math.pi*(r2 ** 3 - r1 ** 3) return round(result, 3)
true
ebf897ba52eebcd815cb8ece7ec516ffd378b670
digorithm/coding_practice
/hackerrank/stairs.py
UTF-8
122
3.21875
3
[]
no_license
def func(levels): for i in xrange(1,levels+1): print ("#" * i).rjust(levels) n = int(raw_input()) func(n)
true
8181d1fede42e40baa812a826ada84e1ec4a09c3
TaoCurry/Basic_Python3
/递归例子/迭代求Fibo.py
UTF-8
567
4.125
4
[]
no_license
#!/usr/bin/env python 3 # -*- coding: utf-8 -*- def fibo(max): n, a, b = 0, 0, 1 while n < max: print(b) a, b = b, a+b n += 1 return 'done' for n in fibo(10): print(n) # Update 更简单的方法计算斐波拉契数列: >>> fibs = [0, 1] >>> for i in range(8): # fibs.append(fibs[-2] + fibs[-1]) >>> fibs [0, 1, 1, 2, 3, 5, 8, 13,...
true
94acf15bd372d85865284de7df2b0fb1df2de370
bussy-lere/Cleaning-US-Census-Data
/Census_data.py
UTF-8
1,630
2.890625
3
[]
no_license
import pandas as pd import numpy as np import matplotlib.pyplot as plt import codecademylib3_seaborn import glob us_census = glob.glob("states*.csv") df_list = [] for filename in us_census: data = pd.read_csv(filename) df_list.append(data) us_census = pd.concat(df_list) us_censu...
true
d97cf2dabb08135f38adaf2f662d33bd96d080c3
omeraydmr/pythonExamples
/Prime Number Finder.py
UTF-8
703
4.28125
4
[]
no_license
#Prime Number Finder 26.05.2020 written by omeraydmr def prime_number(number): if (number == 1): return False elif (number == 2): return True else: for i in range (2 , number): if (number % i == 0): return False return True ...
true
56a810c19c44ffa5773e8f33e4c50f19061943bb
amansinclair/RL
/RL/solvers/mc.py
UTF-8
3,113
2.6875
3
[]
no_license
import numpy as np class MCOnPolicy: def __init__(self, Q, env, discount_rate=1, e=0.1): self.Q = Q self.env = env self.e = e self.discount_rate = discount_rate self.N = np.zeros(Q.shape, dtype="int") self.n_actions = Q.shape[1] self.action_space = np.arange...
true
3486c2d0ab6866970fe6ef7aac07b1463b911949
amirGaouaou/3dshopicruit
/app.py
UTF-8
1,101
2.53125
3
[]
no_license
import os import uuid import urllib,json from flask import Flask, render_template, redirect, request,jsonify app = Flask(__name__) app.debug = True url = "http://shopicruit.myshopify.com/products.json?page=" prodType = ['Clock', 'Watch'] @app.route('/') def index(): return render_template('index.html') @app.ro...
true
a65f9062112b6350c3c81b5ca77f99b4225171f7
imos/icfpc2019
/tos/puzzle_vis.py
UTF-8
1,121
2.578125
3
[ "MIT" ]
permissive
import sys import numpy as np import matplotlib.pyplot as plt def plot_sqs(xys): xs, ys = np.array(xys).T + 0.5 plt.scatter(xs, ys, s=3) def plot_ans(path): with open(path) as f: s = f.read() po = s.split('#')[0] po = eval('[{}]'.format(po)) po.append(po[0]) xs, ...
true
0b1ef1807a9f45e562208d9c0719a704b4d043a4
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3_neat/16_0_3_dakura_C-CoinJam.py
UTF-8
1,197
2.90625
3
[]
no_license
#! /usr/bin/env python # -*- coding:utf-8 -*- import sys sys.setrecursionlimit(1100) #sys.maxint #-sys.maxint-1 def get_nontrivial_diviser(x): if x <= 2: return 0 if x&1 == 0: return 2 i = 3 #while i**2 <= x: while i <= 100: if x%i == 0: return i i += 2 return 0 def solve(N, J...
true
85027c6b0f32889f3b22544b6e3e03f3a24f3f4b
emersonsrv/topicosIC
/rosenbrock.py
UTF-8
363
3.28125
3
[]
no_license
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np def rosen(parametros): x1, x2 = parametros return 100.0 * (x1 - x2 ** 2) ** 2.0 + (x2 - 1) ** 2 a = np.arange(-2, 3) b = np.arange(-2, 3) y = rosen([a, b]) print(a) print(b) print(y) fig = plt.figure() ax = fig.gca(pr...
true
fcde7d3f37f253043c6660f9abfe309513d66e15
tawateer/leetcode
/621-任务调度器.py
UTF-8
2,440
3.53125
4
[]
no_license
#!/bin/env python # -*- coding:utf-8 -*- """ 给定一个用字符数组表示的 CPU 需要执行的任务列表。其中包含使用大写的 A - Z 字母表示的26 种不同种类的任务。任务可以以任意顺序执行,并且每个任务都可以在 1 个单位时间内执行完。CPU 在任何一个单位时间内都可以执行一个任务,或者在待命状态。 然而,两个相同种类的任务之间必须有长度为 n 的冷却时间,因此至少有连续 n 个单位时间内 CPU 在执行不同的任务,或者在待命状态。 你需要计算完成所有任务所需要的最短时间。 示例 1: 输入: tasks = ["A","A","A","B","B","B"], n = 2 输出...
true
05f45a44a37f4327bee7953af79c98bb4bb42433
ivan-yosifov88/python_advanced
/multidimensional_lists_exercise/miner.py
UTF-8
2,217
3.921875
4
[]
no_license
def read_matrix(size): matrix = [] for _ in range(size): row = input().split() matrix.append(row) return matrix def get_commands_as_indices(command_list): """ :param command_list: :return: new list with row and col tuples """ new_command_list = [] for command in com...
true
2f210fb5903b55e0167c6fd320ee3f93c216cdb9
rainstar2/leetcode
/[212]单词搜索 II.py
UTF-8
3,714
3.375
3
[]
no_license
# 给定一个 m x n 二维字符网格 board 和一个单词(字符串)列表 words,找出所有同时在二维网格和字典中出现的单词。 # # 单词必须按照字母顺序,通过 相邻的单元格 内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母在一个单词中不允许被重复使 # 用。 # # # # 示例 1: # # # 输入:board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f", # "l","v"]], words = ["oath","pea","eat","rain"] # 输出:["e...
true
c249c622db6760c616e9d632f23da9781eb40c56
elishalmon/URL-Shortener
/main/generator.py
UTF-8
829
3.453125
3
[]
no_license
import random import string CHARACTERS = string.ascii_letters + string.digits LENGTH = 10 def generate_random_string(): """ Generates a random 10 characters string from 62 possible characters, (Capital letters, lowercase letters and digits) This allows us to store a very huge number of s...
true
47df085fbec87148cbd1d86f73394467872b1b61
zwjyyc/Pretrained-Language-Model
/HyperText/hyperbolic/math_utils.py
UTF-8
1,658
2.515625
3
[ "MIT" ]
permissive
#-*- coding:utf-8 -*- #The MIT License (MIT) #Copyright (c) 2021 Huawei Technologies Co., Ltd. # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limita...
true
e077265dd3ec64acfabcb7ac8896393fd9983341
cpatinof/quantEconWork
/piApproxMonteCarlo.py
UTF-8
396
3.390625
3
[]
no_license
## 2. pi approximation with MonteCarlo import numpy as np def approxPi(reps): U = [np.random.uniform(0,1,2) for item in range(reps)] D = [np.sqrt(((item[0]-0.5)**2)+((item[1]-0.5)**2)) for item in U] C = [item <= 0.5 for item in D] return (sum(C)/reps)/(1/4) mcpi = [approxPi(1000) for item in range(...
true
647ace7e576bd32d2a520be78b0457b3b3e2f065
iamvickypedia/vickypedia-lab
/python-lab/opposite-pair-check.py
UTF-8
934
4.0625
4
[]
no_license
import random print("This Program checks for the occurence of any pairs whose sum is 0") choice = input( "1. Generate Random array and show result\n2. Enter array elements yourself\n" ) def check_opp_pair(arr): uniq_arr = [] for i in range(len(arr)): if -arr[i] in arr[i:]: if abs(arr[...
true
fc71aa94b1b0d13a73595f74ac043d514bfd7974
daominhkhanh20/NameEntityRecognition
/data.py
UTF-8
3,093
2.515625
3
[]
no_license
import torch from torch.utils.data import Dataset from torch.nn.utils.rnn import pad_sequence class EntityDataset(Dataset): def __init__(self,texts,pos,tags,config): self.texts=texts self.pos=pos self.tags=tags self.pos_pad=config.POS_PAD self.tag_pad=config.TAG_PAD ...
true
818878200fa59672998c174fb1e8ae3ad4e503b4
ykhan1998/for2019421contest
/find_car.py
UTF-8
1,206
2.84375
3
[ "MIT" ]
permissive
from collections import deque import numpy as np import imutils import cv2 import time def color_car(center_car): #设定红色阈值,HSV空间 blueLower = np.array([100, 100, 160]) blueUpper = np.array([105, 165, 200]) #读取图片 frame = cv2.imread('image.jpg') #转到HSV空间 hsv = cv2.cvtColor(frame, cv2.COLOR_BGR...
true
0bf9827c7c581dba92f98d9d6cf9556122761bd2
Poludzku/master
/PythonExerciseFolder/WearwolfForest.py
UTF-8
1,558
3.640625
4
[]
no_license
# -*- coding: utf-8 *-* from WearwolfForestLeft import wolf_follow from WearwolfForestLeft import deer_follow def left(): print """You chose to go left and spoted a white wolf, there are dear furthur of in the distance which do want to stalk, the 'wolf' will be very hard to and is likel to be trecking b...
true
b9d91365c4d576750fcaf1d36000638377dc0d71
HoldenCaulfieldRye/python
/ipython/test_mistake.py
UTF-8
84
2.515625
3
[]
no_license
if __name__ == '__main__': print "%i+%i is %i and my name is %i"%(2,5,9,"myname")
true
8a799c61cdde4935c048db6917713ee431bb7c0a
explosion/prodigy-recipes
/tutorials/progress-update/recipe.py
UTF-8
2,181
2.875
3
[ "MIT" ]
permissive
import time from typing import List from rich import box from rich.table import Table from rich.console import Console import prodigy from prodigy.components.loaders import CSV class ProgressTable: def __init__(self): self.start_time = time.time() self.n_examples = { "n_accept": 0, ...
true
d9caea55f885b0711abbbf624d65288a0283de43
K1sna/Minist-with-HoldOn-K-Fold-CV
/hk_function.py
UTF-8
7,152
2.90625
3
[]
no_license
import numpy as np import random def get_label(label): # 将label从长度10的one hot向量转换为0~9的数字 return np.argmax(label) def cross_validation(images, labels, k): X_train_images = [] #大小为k-1 y_train_labels = [] X_test_images=[] #大小为1 y_test_labels = [] zero_images =[] ...
true
eb5a2869fd611b0f9dad2434016a45707bc19249
cuiboautotest/learnpython3
/pytest_test/test_fixt1.py
UTF-8
328
2.75
3
[]
no_license
import pytest @pytest.fixture() def user(): print("获取用户名") a="cuibo" return a def test_1(user):#fixture作为参数传入,直接把fixture的函数名当成变量名称 assert user=="cuibo" def test_2(user): assert user=="yoyo" if __name__=="__main__": pytest.main(["-s","test_fixt1.py"])
true
b5812443a12e263a7ea55913d6414e5b3390a741
dilwaria/mythologger
/images.py
UTF-8
891
2.875
3
[]
no_license
from PIL import Image import sys def convertImage(): argv=[]; argv.append('') argv.append(sys.argv[1]) argv.append(sys.argv[2]) pathArr=argv[2].split(',') if(argv[1]=="author"): for path in pathArr: path="public"+path file=Image.open(path) file=file.resize((50,50),Image.ANTIALIAS) pathArr=path.s...
true
a21921013890d6016267fe7e18512dc1479ab5ba
coocos/asgi-http-server
/tests/fakes.py
UTF-8
754
3
3
[ "MIT" ]
permissive
"""Fakes used by tests""" class StreamReader: """Fake implementation of asyncio.streams.StreamReader""" def __init__(self, stream: bytearray): self._stream = stream async def read(self, bytes_: int = 0) -> bytes: next_bytes = self._stream[:bytes_] self._stream = self._stream[byte...
true
54e84028c94cddb54542ddc241947ca1a98e636b
cpeck1/tempmonPython
/bin/infrastructure/usb_bus.py
UTF-8
7,587
3
3
[]
no_license
import usb.core # pyusb import usb1 # libusb1 import pyudev # duh import json from bin.models.singleton import Singleton from bin.services.usb_library_translator import ( PyudevDevice, Libusb1Device, PyusbDevice ) from bin.services.hex_manipulation import hex_zpadded from bin.models.exceptions import ( ...
true
00f90e7f9f98b24cf057ee948d39da5cb9782a0b
rvasen/plex-youtube-download
/plexYTdownload.py
UTF-8
7,362
2.796875
3
[]
no_license
import sqlite3 import sys import getpass import platform import os import pafy from PySide.QtCore import * from PySide.QtGui import * class MainPage(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) temp = QWidget() mainLayout = QVBoxLayout() temp.setLayout(mainLayout) self.setGeome...
true
81ec6de44b489a78d7dcb1334c30db20e9b08261
Lokeshwarrobo/LeetCode
/Strings/Reverse_String.py
UTF-8
1,274
4.46875
4
[]
no_license
''' Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii characters. Example 1: ...
true
5d9bc589c70d76f7aeef4ccfb7959a254fb4cad8
jakebildy/TimeIIController
/Simulator/launch.py
UTF-8
19,170
2.609375
3
[]
no_license
import serial import time from tkinter import * import random import sys import glob from PIL import Image, ImageTk i = 0 root = Tk() # Colors darkish = '#%02x%02x%02x' % (29, 30, 38) whitish = '#%02x%02x%02x' % (214, 216, 218) code_green = '#%02x%02x%02x' % (80, 200, 70) code_green_light = '#%02x%02x%02x' % (170, 20...
true
5696326baf343501e54a44eedf334f4127600747
zoulida/matplotForPaper
/test/bar.py
UTF-8
1,034
2.921875
3
[]
no_license
__author__ = 'zoulida' import pandas as pd import numpy as np import matplotlib.pyplot as plt def bar(): df = pd.DataFrame( {'HEIGHT': [175, 165, 162, 158, 180], 'AGE': [23, 30, 27, 21, 35], 'SCORE': [80, 100, 70, 85, 65]}, columns = ['HEIGHT', 'AGE', 'SCORE'], index = ['jack', 'leo', 'jame...
true
1bf74718f06b6bb8aefd27f89f3d5478325758e5
gwyrwch/security_basics_labs
/lab456/db.py
UTF-8
4,776
2.625
3
[]
no_license
import sqlite3 from app import * from hashlib import md5 as md5 from time import time, sleep conn = sqlite3.connect("my.db") print('loaded db') class UserModel: def __init__(self, data_tuple): self.id = data_tuple[0] self.username = data_tuple[1] self.password_hash = data_tuple[2] ...
true
a638f40f4a21199fb8fb0fcefc368650f5a07628
giphahne/gen
/modules/RNA/__init__.py
UTF-8
119
2.5625
3
[]
no_license
def main(inf): dna_string = inf.read() rna_string = dna_string.replace("T", "U") return rna_string
true
9e686755e9363e621688fa182c35f7bbeede7f79
sananand007/RandomCompetitiveCoding
/pramp/Salespath.py
UTF-8
871
3.609375
4
[]
no_license
def get_cheapest_cost(rootNode, visited, sum_): if not rootNode: return 0 if not rootNode.children:visited.append(sum_) for c in rootNode.children:get_cheapest_cost(c, visited, sum_+c.cost) return min(visited) ########################################## # Use the helper code below to implement # # and test you...
true
bd9287a9b33593717dbb4bacfc953b1b20e11ce4
dbarsam/python-vsgen-ptvs
/vsgenptvs/interpreter.py
UTF-8
15,631
2.65625
3
[ "MIT", "Python-2.0" ]
permissive
# -*- coding: utf-8 -*- """ This module provides the necessary definitions to generate a Python Interpreter object. """ import os import re import csv import site import io import fnmatch import uuid import subprocess import configparser try: import winreg except ImportError: import _winreg as winreg from vsge...
true
245c7fe943f601474c925293b14f7dbd5087df80
XVs32/LeetCode
/30_days_challenge/day_11/30_11.py
UTF-8
1,264
3.53125
4
[]
no_license
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: max_level = 0 def traverse(self, root, level): flag = 0 left_level = 0 right_level = 0 ...
true
8422a1f688d6559de9184b3a0b09b4319bf71fe7
msobroza/apnea_detection
/modules/dataset.py
UTF-8
2,060
2.984375
3
[]
no_license
import numpy as np from keras.utils import Sequence, to_categorical import glob class DataGenerator(Sequence): ''' Class inheriting from keras.utils.sequence used to generate the dataset for training and validation''' def __init__(self, list_IDs, db_part='train', dim=(10, 128), batch_size=16, n_class...
true
5b629212a54b943e9266f8f8cdde5ce06e81fe44
Youngiyong/Python
/aBasic/c_module_class/mypack/exam/exmodule.py
UTF-8
136
3.015625
3
[]
no_license
''' deohagi 함수 선언 ''' def deohagi(a, b): if type(a) == type(b): return a+b else: print("메롱")
true
3ce5b46f5b71e94c4d24f963288dc37926ea8321
FelixEbobo/PythonProjects
/simpleEmailSmtp.py
UTF-8
1,234
2.9375
3
[]
no_license
import smtplib from email.mime.text import MIMEText from collections import defaultdict def send_mail(subject, message, from_addr, *to_addr, host="localhost", port=1025, headers=None): email = MIMEText(message) email['Subject'] = subject email["Frome"] = from_addr headers = {} if headers is Non...
true
fe14f1631c8960836ed103bab4e6294342d219d0
Aasthaengg/IBMdataset
/Python_codes/p03043/s417161757.py
UTF-8
146
2.734375
3
[]
no_license
N, K = map(int, input().split()) P = [1/N] * N for i in range(N): score = i+1 while score < K: score *= 2 P[i-1] /= 2 print(sum(P))
true
80663bc945c015104f3ab6e5051db6b42cec5a41
Kiranshankarbhat007/Python-basic-
/lcm.py
UTF-8
311
3.640625
4
[]
no_license
x= int(input("enter the first number:")) y= int(input("enter the second number :")) if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater = greater + 1 print ("Lcm of given numbers is", lcm)
true
a13cf987d38cec0066e53a742f81fd729c45a838
zelenyid/medicine_center
/app/data/database/hospital.py
UTF-8
562
2.65625
3
[]
no_license
from app.data.database.database import MongoBase from typing import Sequence, Tuple from bson.objectid import ObjectId from bson.errors import InvalidId class HospitalCollection(MongoBase): collection_name: str = 'hospital' db_fields: Sequence[Tuple[str]] = ('_id', 'name', 'address', 'phone_number') if __na...
true
67bf12c3e87f7b91f8c425951275e30957ff28f9
PGGokhale/Web-Visualization-Homework
/plot1.py
UTF-8
2,150
2.71875
3
[]
no_license
import datetime import sqlalchemy from sqlalchemy import and_, func, create_engine from sqlalchemy import Column, Integer, String, Float from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import Session import pandas as pd import os import json import plotly import plotly.graph_objects as go ...
true
4ad531f2bd4da899881dc071a5cbc619d5d73d59
labsyspharm/basic-illumination
/imagej_basic_ashlar_filepattern.py
UTF-8
7,753
2.65625
3
[ "MIT" ]
permissive
# @String(label="Enter a filename pattern describing the TIFFs to process") pattern # @File(label="Select the output location", style="directory") output_dir # @String(label="Experiment name (base name for output files)") experiment_name # @Float(label="Flat field smoothing parameter (0 for automatic)", value=0.1) lamb...
true
4deab3e248eaeba6d22c5f014b1ca424c30aea1a
SBoulanger/conservator-cli
/test/integration/test_collections.py
UTF-8
9,325
2.546875
3
[ "MIT" ]
permissive
import pytest from FLIR.conservator.connection import ConservatorGraphQLServerError from FLIR.conservator.wrappers.collection import ( RemotePathExistsException, InvalidRemotePathException, ) def test_create_child(conservator): project = conservator.projects.create("Root") parent_collection = project...
true
b5dde59024d2d5751f57b35f1bf489ff34f100b4
ssw1991/Python-Practice
/Module 3 - Shilo Wilson/Level 3.1/3.1.2/assets/Car.py
UTF-8
416
2.53125
3
[]
no_license
from asset import Asset as Asset class Car(Asset): def __init__(self, init): super(Car, self).__init__(init) class Civic(Car): def __init__(self, init): super(Civic, self).__init__(init) def yearlyDepreciation(self): return .08 class Lexus(Car): def __init__(self, init):...
true
65912f6fc43a6965031f7ccf813a7f93063bb7cf
bishkou/leet-code
/Linked list/palindrome.py
UTF-8
530
3.578125
4
[]
no_license
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def isPalindrome(self, head: ListNode) -> bool: if head is None: return True tab = [] while head: tab.append(head.val) ...
true
da6f2d46fe59adb666bfc68e30120bdc65dca5b6
antoinemcgrath/contact_removal
/contact_remover.py
UTF-8
19,827
2.90625
3
[ "Artistic-1.0" ]
permissive
# -*- encoding: utf-8 -*- #!/usr/bin/python #### Single file run: # python contacts-remover.py input_file.pdf output_file.pdf #### Run on an entire directory: # python3 contacts-remover.py input_directory/ output_directory/ #### This script will remove author contacts (telephone numbers and emails) from CRS PDFs # ...
true
991e94373ac8dc66033b2060a7c53310ff4caba0
ADSL-Plucky/learngit
/homework-3/1.py
UTF-8
817
3.4375
3
[]
no_license
# -*- encoding: utf-8 -*- ''' @File : 1.py @Time : 2020/03/20 20:45:12 @Author : 黎淞 @Version : 3.7.0 @Contact : 836046238@qq.com ''' ''' 1 写一个程序, 读取键盘输入的任意行文字信息, 当输入空行时结束输入,将读入的字符串存于列表; 然后将列表里面的内容写入到文件input.txt中; ''' Lines = [] Line = input("请输入任意行文字信息,当输入空行时结束输入:").strip() while Line != '': Line = ...
true
b9674000227877ae899fed434c8d464dcb101a7e
hoangtran74/repo1
/WriteFile.py
UTF-8
474
3.203125
3
[]
no_license
class WriteFileClass(object): def FileWrite(self, _offset, _input, _format): if _offset > 0: print 'Writing new file...' file('C:\\Temp\\output\\'+ _input[1]+'.'+_format,'wb').writelines(_input[0][_offset[0]:_offset[1]]) print 'Creating file i...
true
837cc11f29db889edbe69f0e81f6307d684453a0
Drizzle-Zhang/practice
/Eigenface/eigenface.py
UTF-8
16,174
2.5625
3
[]
no_license
#!/usr/bin/env python # _*_ coding: utf-8 _*_ # @author: Drizzle_Zhang # @file: eigenface.py # @time: 2019/7/3 15:39 from time import time import numpy as np import pandas as pd from PIL import Image import os from sklearn.metrics import accuracy_score import matplotlib.pyplot as plt def min_distanc...
true
6bb8839cfc597532e19854142e7fd3786858503b
dmitrytyutryumov/Instagram-Blogger-Bot
/etc/likes.py
UTF-8
833
2.796875
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
# -*- coding: utf-8 -*- import logging from instabot import Bot class Likes(object): def __init__(self, username, password, tags, max_likes): self.username = username self.password = password self.tags = tags self.max_likes = max_likes def run_like_round(self, tag): b...
true
c7534e53f4c04f257f367e8813244a468ade637b
yangwei07/pymc3_mcmc
/example2/markov_chain.py
UTF-8
1,799
3.296875
3
[]
no_license
'''This example1 illustrates how to run a Markov Chain using pypmc''' import numpy as np import pypmc # define a proposal prop_dof = 1. prop_sigma = np.array([[0.1 , 0. ] ,[0. , 0.02]]) prop = pypmc.density.student_t.LocalStudentT(prop_sigma, prop_dof) # define the target; i.e., the functio...
true
5ecdd888c0f5012958fad3deb50f0ec300cd232e
milesmcc/pactf-2018
/ctfproblems/Hopper/90_hash_master/grader.py
UTF-8
441
2.953125
3
[ "MIT" ]
permissive
def hash_it(string): q = 0 z = 127 for i in [int(byte) for byte in bytearray(string, "utf-8")]: q += i z *= i return (((q << 3)+1)*z) % (2**32 - 1) def grade(key, submission): try: if hash_it(submission) == 293366475: return True, "You killed the hash!...
true
61bea37c9a621fd24e79f9755bbb2f300f29bd58
weiang/baike
/main.py
UTF-8
739
2.765625
3
[]
no_license
#!/usr/bin/env python # -*- encoding=utf-8 -*- import os import sys from baike import * def load_files(dir): r = [] for root, dirs, files in os.walk(dir): for f in files: file_path = os.path.join(root, f) r.append(file_path) for d in dirs: dir_path = os.pa...
true
0ae6af3c8497a82f12a6bb78938234724af3b7d8
MMiartoteo/SimProj
/results/stability_merge_runs.py
UTF-8
4,791
2.515625
3
[]
no_license
import math import scipy as sp import numpy as np from scipy import stats from subprocess import call import glob from pprint import pprint ## FIRST: Gather data from each run (I don't know why they are called "repetitions" by Omnet...) # Dictionaries indexed by repetition number repentions_hops = {} repentions_stab ...
true
09014fa2f937d0eb225caa540a6474d6ad5509d6
nixis-institute/practice
/python/sql/csql.py
UTF-8
267
2.703125
3
[]
no_license
import sqlite3 as sq data = [['Ajay',1,98],['Arun',2,78],['anil',3,76]] file = sq.connect("abc.db") for i in data: command = "insert into student values('"+i[0]+"',"+str(i[1])+","+str(i[2])+")" file.execute(command) file.commit() file.close() print("sucess!")
true
8d860456c97b06cb4b84049ebaf597a5d549d034
kidword/package
/fileprocess.py
UTF-8
1,315
3.375
3
[]
no_license
""" 文件处理排序 """ import datetime import os def order_by_time(file_path): """ 根据数据的时间,对数据进行排序 :param file_path: 文件路径 :return: 排序后结果 """ f = open(file_path, encoding='utf-8') data = f.readlines() lis = [] for i in range(len(data)): s = data[i].split(' ') s1 = [j.replac...
true
e55957a04b9cdb001ce0e04112b3b5512872937c
jhkennedy/python-advanced-pandas
/code/historical_co2_emissions_05.py
UTF-8
3,082
3.1875
3
[ "LicenseRef-scancode-public-domain", "CC-BY-4.0", "MIT" ]
permissive
# # Program to manage the CMIP5 emissions dataset # import pandas as pd import netCDF4 as nc # # Constants # MOLAR_MASS_AIR = 28.966 # g/Mol MEAN_MASS_AIR = 5.1480e21 # g MOLAR_MASS_C = 12.01 # g/Mol PPM_C_1752 = 276.39 # Mol/(Mol/1e6) class HistoricalCO2Emissions(): ''' Class that represents historical C02 emiss...
true
e6bee6c84e304859a4e1eb46736e25f782528300
neillc/infrastructure
/roles/slg.galaxy_stats/files/monthly_stats_collector.py
UTF-8
6,088
2.515625
3
[ "MIT" ]
permissive
#!/usr/bin/env #Imports import subprocess from collections import defaultdict import re import os import string import sys import argparse import datetime def transform_groups(blob): lines = blob.stdout.decode('utf-8').split('\n') stat = defaultdict(lambda: defaultdict()) months = [] for line in line...
true
c0401597cf26d32d45de0816208f4b6fdab7b382
m-jarmula/python-websocket-server
/lib/message.py
UTF-8
403
2.875
3
[]
no_license
import json class Message: def __init__(self, message_type, val=None): self.type = message_type self.val = val def to_json(self): return json.dumps({ 'type': self.type, 'val': self.val }) class MessageDecoder: def __init__(self, message): sel...
true
998acd0df0cdee7adfe906670f7c0ee0c58596e2
HymEric/LeetCode
/python/7/7.py
UTF-8
1,606
3.65625
4
[ "Apache-2.0" ]
permissive
# -*- coding: utf-8 -*- # @Time : 2020/1/30 0030 17:46 # @Author : Erichym # @Email : 951523291@qq.com # @File : 7.py # @Software: PyCharm """ 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: 输入: 123 输出: 321  示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 注意: 假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围...
true
10866f85e2a861fdb0150add897edbb75b5b5751
pipoteam/pipobot
/tests/test_utils.py
UTF-8
4,154
2.546875
3
[]
no_license
import unittest import pipobot.lib.utils as utils from pipobot.lib.module_test import create_test_bot class TestUtils(unittest.TestCase): def test_xhtml2text(self): ret = utils.xhtml2text("<b>bold</b>") self.assertEqual(ret, "*bold*") ret = utils.xhtml2text("<strong>bold</strong>") ...
true
cc550b6dee359792aacb1f8c12fbab3824468964
Akshat1276NSP/CBJRWDhome_assignment
/Time Pass Projects/06_03_2021.py
UTF-8
1,174
2.921875
3
[]
no_license
import pyautogui # pip install pyautogui from PIL import Image, ImageGrab # pip install pillow #from numpy import asarray import time def hit(key): pyautogui.keyDown(key) def isCollide(data): for i in range(340, 415): for j in range(410, 563): if data[i, j] < 100: hit("down...
true
b7c96dbb7627bf82a12954460a02fbdc04c473e4
dMedinaO/peptideDB
/scripts/clustering/community_search.py
UTF-8
3,408
2.96875
3
[]
no_license
import pandas as pd import sys import numpy as np import networkx as nx import community as community_louvain def get_quartiles(list_data): response = [] for quartil in [0.25, 0.75]: response.append(np.quantile(list_data, quartil)) return response def get_outlier(quartile_list): iqr = quartile_list[1] - qua...
true
6749e2898d417d33c06215ae0291e74acca42ec5
BrianARuff/Intro-Python
/src/day-1-toy/dicts.py
UTF-8
831
3.96875
4
[]
no_license
# Make an array of dictionaries. Each dictionary should have keys: # # lat: the latitude # lon: the longitude # name: the waypoint name # # Make up three entries of various values. waypoints = [ { "lat": 43, "lon": -121, "name": "a place" }, { "lat": 41, "lon": -123...
true
dae61d0e15266923116eb31f93fcbb1c2a88601f
polyaD/VSCode
/ItemProgramming/python/array/63_Maximum_Subarray.py
UTF-8
1,925
3.296875
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ############################################################################ #Author:polya polyaluthor@gmail.com #Maximum_Subarray.py #Last updated:2019.4.8 #Version: 0.1 #Purpose: Plus One from array #Main logic principle: # #convert the math format to get the index...
true
1ed444c41fe580a75ae0102bedc319004ecf13c6
MykytaYarokhno/ICS-18.09.20
/Лабораторна робота 6/Lab6.3.py
UTF-8
799
3.71875
4
[]
no_license
class MyStr(str): def replies_of_queue(self, s): for id, char in enumerate(s): if(id <= len(s)-2): if(char == s[id+1] and char == s[id+2]): return True return False def is_palindrom(self, raw): if(raw == ''): return True ...
true
9fde6dbd04f3cad240db614463860f8b9e705a0b
Yangnnnn/Statistical-Machine-Translation
/A2code/log_prob.py
UTF-8
2,153
2.859375
3
[]
no_license
from preprocess import * from lm_train import * from math import log def log_prob(sentence, LM, smoothing=False, delta=0, vocabSize=0): """ Compute the LOG probability of a sentence, given a language model and whether or not to apply add-delta smoothing INPUTS: sentence : (string) The PROCESSED sentence whos...
true
7768ed9122d31e86bcfc9619be82277500dfe29d
yantanglife/Interest
/clock/digit_clock.py
UTF-8
5,252
3.765625
4
[]
no_license
import turtle from datetime import datetime class DigitalTube: def __init__(self, pos, digit=0): """ pos: the start pos of this digit(the begin point of "a" tube). digit : number for showing. """ self.__digit = digit self.__pos = pos ''' __changed: i...
true
6759059f7065132e36febab0bb310813542d03de
Traverse-Technology/python_basic
/Python File/file_write.py
UTF-8
82
2.546875
3
[]
no_license
f = open("file2.txt", "a") f.write("Now the file has more content!\n") f.close()
true
43c8d06a6788d8707fd9389392454bb52777d33a
vercesig/RuggianoProsdocimiVercesi
/implementation/endpoint/flexible_lunch.py
UTF-8
3,635
2.625
3
[ "Apache-2.0" ]
permissive
import rethinkdb as r from tokenDB import token_query from datetime import time, datetime, timedelta import rt_server as rts r.connect(rts.ip, rts.port, rts.db_name).repl() # standard flexible event lunch_event = {"alarm": False, "color": "#536DFE", "editable": False, "even...
true
91e10e2c942eaad35b45c49f8444c08bda603df3
hyh29467305/spider_try
/spider/daili_pool/crawler.py
UTF-8
3,064
2.859375
3
[]
no_license
import json from pyquery import PyQuery as pq import requests def get_page(url): response = requests.get(url) return response.text class ProxyMetaclass(type): def __new__(cls,name,bases,attrs): count = 0 attrs['__CrawlFunc__'] = [] for k,v in attrs.items(): if ...
true
d9646389d94a77a36ad22c14d95846ce16be2b94
Club-de-Software-EPN/tournaments
/devsu/2021/classification/02.py
UTF-8
2,072
2.578125
3
[]
no_license
import math import traceback import time import random import sys import copy sys.setrecursionlimit(10000000) debug = True def test(): test_cases = [ [-1, 3, -5, 7, 8, 8, -1], [1, 1, 2, 3, 4, 5, 5, 5, 6], [2,-10,0,-8,4,-5,10,0,8,-9,4,-6,3,4,8,10,6,-5,2,-6,9,-10,4,-1,6,-1,7,10,-10,-3,-6,...
true
7fe9fd109f3a98bbe1326f84a146e4e080675acb
Yazid-Charef/programmation
/project Euler/exercice_13.py
UTF-8
225
3.09375
3
[]
no_license
p=open("exercice_13_nombres.txt","r") a=p.read() p.close() a=a.replace(' ','') c=0 r=0 b=list() for e in range(50,5001,50): c=a[e-50:e] b.append(c) for n in b: r=r+int(n) r=str(r) print(r[:10])
true
d94bd88b073f45e399218a02532228c1644a7243
tejaspant390/python_assignment_dec22
/question1.py
UTF-8
391
3.90625
4
[]
no_license
#To Ask for a number (n) as an input from user. Using the use input (n), write a program to generate a dictionary that contains # (i, i*i) where i is key and i*i is a value for numbers between the range 1 and n (both included). and then the program should # print the dictionary. num = input("Enter the number: ") dic...
true
5ca3f2630d67615ac085e5d0fabecdc3e1b6b0a2
mnoko33/algo
/python/kakao대비/징검다리_건너기.py
UTF-8
1,033
3.328125
3
[]
no_license
def solution(stones, k): # n명의 니니즈 친구들이 돌다리를 건널 수 있는지 def is_possible(n, k): # n - 1명이 건너고 난 후 1개 이상인 돌들의 idx remain_stones = [0] for idx, stone in enumerate(stones): if stone > n-1: remain_stones.append(idx+1) remain_stones.append(len(stones)+1) ...
true
3fe4fc3282f0aded2701ea83ae5f8fe0121f1a02
esrasking/python
/Chapter 2/numbers.py
UTF-8
496
4.6875
5
[]
no_license
#20191201 #Chapter 2: Numbers #Start Program print(" ") print("2 + 3 =") print(f"{2+3}\n") print("0.2 * 0.2 =") print(f"{0.2*0.2}\n") print ("4 / 2 =") print(f"{4/2}\n") print ("3.0 ** 2 =") print(f"{3.0**2}\n") universe_age=14000000000 print(f"The age of the universe is {universe_age}.\n") #Initializing multipl...
true
70e6fe735bef2d2165e36c0cc4817fca3c911b7a
Linwenye/daily_training
/leetcode/smallest_range.py
UTF-8
346
2.9375
3
[]
no_license
class Solution(object): def smallestRange(self, nums): """ :type nums: List[List[int]] :rtype: List[int] """ # sort all list into one list lenth = len(nums) sortedlst = [] queuenum = [0] * lenth # TODO for queue_index, alst in enumerat...
true
b6615f9a1204d55687031e36c758fc90f0bf97f7
lfdyf20/Leetcode
/Is Subsequence.py
UTF-8
598
3.421875
3
[]
no_license
from tryFunc import timer class Solution(object): @timer def isSubsequence(self, s, t): """ :type s: str :type t: str :rtype: bool """ for i in s: for ind, j in enumerate(t): if j == i: t = t[ind+1:] ...
true
0bf49ce497476497a78c09f1175d9b88a2258899
joselsantospqt/Python
/Desenvolvimento_Python_para_Sistemas_Operacionais_e_Redes/AT/main.py
UTF-8
10,032
3.4375
3
[]
no_license
import concurrent import multiprocessing import os import random import threading import time from concurrent.futures import ProcessPoolExecutor from concurrent.futures.thread import ThreadPoolExecutor import psutil def rodar(func): if __name__ == '__main__': print('-' * 10, func.__name__, '-' * 10) ...
true
c13a45dcb28a6764bb2cc72c29cec85d85d66971
CharlesBird/Resources
/coding/py_partterns/creation/builder.py
UTF-8
1,376
3.953125
4
[]
no_license
"""建造者""" class Director(object): def __init__(self): self.builder = None def construct_building(self): self.builder.new_building() self.builder.build_floor() self.builder.build_size() def get_build(self): return self.builder.building class Building(object): ...
true
49faeb6129d2fabe7688de26934436cd0cafd476
shawn-stovall/Python-Files
/parsingquiz.py
UTF-8
356
3.328125
3
[ "Giftware" ]
permissive
def balanced(string): openers = "{[(" closers = "}])" place = -1 flag = False for c in string: if c in openers: place = openers.index(c) flag = False if c in closers: if closers.index(c) == place: flag = True else: ...
true
26067cf7d092cc9372b326149612a386259bcbce
threecourse/rl-connect4-alpha-zero
/src/c4_zero/env/c4_environment.py
UTF-8
9,108
2.53125
3
[]
no_license
from logging import getLogger from typing import Optional, List import numpy as np import pyximport from c4_zero.env.c4_util import BLACK, WHITE, BLACK_STR, WHITE_STR, EMPTY_STR from c4_zero.env.c4_util import Player, another_player, CounterKey, BH, BW, MOVES, A from c4_zero.env.c4_util import Winner from c4_zero.env...
true
674f6c83c7b11e4b20695bb56d946bbd224c1dba
sunaymehta/Options_Self_Invest
/main.py
UTF-8
2,553
3.546875
4
[]
no_license
import all_imports as ai current_security_price = float(input('Enter the current value of underlying security: ')) min_option_strike_ticker = 50 print('Pick a direction amongst these 4 by entering the option number associated with it: ') print('1. Security WILL BE ABOVE...') print('2. Security WILL BE BELOW...') d...
true
853e3030fd167ce91d376bf786f2dc75a6be36b6
k3sh4vk/py-modular
/py_modular/time/events.py
UTF-8
837
3.28125
3
[ "MIT" ]
permissive
import random class Event: """ :param nodes: An array of nodes that should have events triggered :type nodes: array """ def __init__(self, nodes=None): self.nodes = nodes def event_callback(self, node, time): """ :param node: A node for which an event should be called ...
true
4d0a98397f27b778418385f59cc45ebd2c716a22
dengyungao/python
/老男孩python全栈开发第14期/python基础知识(day1-day40)/python协程+多路复用机制/控制单线程内切换任务的模块.py
UTF-8
644
3.96875
4
[]
no_license
from greenlet import greenlet import time # greenlet 只是可以实现一个简单的切换功能,还是不能做到遇到IO就切换 # g1 = greenlet(func) 实例化一个对象 # g1.switch() 用这种方式去调用func函数 # 当使用switch调用func的时候,什么时候func会停止运行? # 1 要么return # 2 要么在func内部又遇到switch def eat(name): print('%s吃炸鸡' % name) time.sleep(2) f2.switch('小雪2') print('%s吃雪糕' % name) f...
true
2d22dd3cb9781ca40ff1ccc7dcf3334f9aadccbf
samdson171/shiyanlou-code
/jump7.py
UTF-8
117
3.03125
3
[]
no_license
a = 0 while a <=99: a=a+1 if a % 7==0 : pass elif a % 10==7: pass elif a // 10==7: pass else: print(a)
true
918f73ff00927ccf6993572dda94060ce7ed7553
dylan-cancelliere/advent-of-code-2019
/day8/day8.py
UTF-8
977
3.1875
3
[]
no_license
def main(): width = 25 height = 6 with open("input.txt", "r") as file: string = file.read() zeros = (9999999, None) layer = "" while len(string) > width * height: num = layer = string[:width * height] string = string[width * height:] for i in layer: ...
true
7e4b1aae58c449c4b6637d528ed097cbcb40d896
mateen91/python-bootcamp
/P13_Final.py
UTF-8
970
3.875
4
[]
no_license
# FINAL # Car Model { 'Brand': 'Honda', 'Model': 'Accord EX', 'Make': '2012' } import csv import unittest class CarFinder: cars = [] def __init__(self, *args, **kwargs): with open('cars.csv') as f: self.cars = list(csv.DictReader(f)) def find_car_by_year(self, year): for ca...
true
27e938d8e6440e410f82573361c8c981e05b0508
extrenight/JiyuanZhang1941310209
/test_fixture.py
UTF-8
524
2.6875
3
[]
no_license
import pytest #fixture类似setuo和teardown # 但是可以使我们自定义测试用例的前置条件 #并且可以跨文件使用 #fixture也可以卸载conftest.py文件里面 @pytest.fixture() def myfixture(): print("执行myfixture") class Test_firstFile(): def test_one(self): print("执行test one") assert 2+3==5 def test_two(self,myfixture): print("执行test two")...
true
431368ae2372e58a3abedb044ac94a36b146e007
greenmapc/cryptopals-tasks
/homework_1/T34_mitm.py
UTF-8
1,880
2.734375
3
[]
no_license
import hashlib from binascii import unhexlify from os import urandom from Crypto.Cipher import AES import encryption_func from homework_1.T33_diffie_hellman import diffie_hellman def parameter_injection_attack(alice, bob): alice_public = alice.public bob_public = bob.public plain_text_message = b'My se...
true
f3f5b956b4bf63a015a410f5ea6bcc89c16826ed
augustelalande/dynamic-connect-3
/naive_agent.py
UTF-8
7,507
3.3125
3
[]
no_license
from utils.interface import action_string from utils.state import get_actions, is_winning from utils.runs import num_runs action_mappings = {'N': (0, -1), 'E': (1, 0), 'S': (0, 1), 'W': (-1, 0)} class NaiveAgent(object): """Dynamic connect-3 game playing agent. Args: color (int): Piece color ...
true
e4db76561523db0a69e11ecff9218c38d0aba3ba
GlassyYang/ComputerNetworkLab
/GBN/sr_sender_test.py
UTF-8
2,630
2.984375
3
[]
no_license
from socket import * from lib import SrRecver, checksum, SrSender from random import shuffle from threading import Thread """ 文件测试接收方功能是否正常 """ addr = ('localhost', 9090) # 发送seq打乱的数据包,观察recver接收到的数据包的顺序是否正常 def test1(): global addr t = Thread(target=test1_thread) t.start() seqs = [1, 2, 3, 4, 5,...
true
23176048fdc7af0367094fe89809d74402dd25e7
trevorbergstrom/HAR_Project
/confusion_matrix.py
UTF-8
1,494
3.125
3
[]
no_license
import numpy as np import copy from sklearn.metrics import precision_recall_curve from sklearn.metrics import average_precision_score import math class confusion_matrix(): def __init__(self, num_classes): self.num_classes = num_classes self.mtx = np.zeros((num_classes, 4)) self.labels = [x+1 for x in range(self...
true
153e7ebeb8760156d7595534952ad404330b3a8a
RavenBP/GAME3110-Final-Project-Lambda-Functions
/AccountLogin.py
UTF-8
1,198
2.84375
3
[]
no_license
import json import boto3 from boto3.dynamodb.conditions import Key, Attr username = ' ' password = ' ' def lambda_handler(event, context): http_method = event['httpMethod'] if http_method== "GET": username = event['queryStringParameters']['username'] password = event['queryStringPara...
true
0ef1ea6fdccd2bad6ddeea3dd64d95c570d13df1
Nitikan/Studies
/circle/circle_rand_and_bounce.py
UTF-8
1,202
3.359375
3
[]
no_license
import arcade from random import randint SCREEN_WIDTH = 600 SCREEN_HEIGHT = 600 vxs = [] vys = [] xs = [] ys = [] n = 20 def initialize(): for i in range(n): xs.append(randint(100, SCREEN_WIDTH-100)) ys.append(randint(100, SCREEN_HEIGHT-100)) vxs.append(randint(-3,3)) vys.append...
true
726992cc8afe4025aeeebfc5344b74468f9b0d0d
gcwngo/K-NearestNeighbor
/K-NearestNeighbor.py
UTF-8
6,331
3.59375
4
[]
no_license
import fileinput import math from copy import copy, deepcopy ''' Parse through the dataset, use python dict (hashmap) to store each document. Use class label and words as key value pairs Hashtable for storage, spit out matrix seperately Key: Line number Value: Tuple {Class Label, List of words} fileinput used for ease...
true
b63d5154190ca1dc6559d53745f5c1b762139ddd
zoro6908/PY_acamedy
/ExPy73402.py
UTF-8
654
3.03125
3
[]
no_license
from flask import Flask from flask import request from datetime import datetime # 사용자 정의 함수 : 특정 날짜 형식을 지정 def userDateType(date_format): def changeFormat(date_string): # strptime(date_string, fortmat) : format에 맞게 date_string을 datetime객체로 리턴 return datetime.strptime(date_string, date_format) r...
true