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
2c970f4cfcb8da7269e48510d14168a87a787be6
wufulin/AdvancePython
/chapter01/type_object_class.py
UTF-8
435
3.765625
4
[]
no_license
# encoding: utf-8 a = 1 b = 'abc' print(type(1)) print(type(int)) print(type(b)) print(type(str)) # type->int # ->str # type->class->obj # object是最顶层的基类 # type也是一个类,同时type也是一个对象 class Student: pass stu = Student() print(type(stu)) print(type(Student)) print(Student.__bases__) print(int.__bases__) print(str.__ba...
true
ac7d35583b9c69e0122701c25a97613c11c56c9b
Xequals0/hw1
/modelsim.py
UTF-8
8,829
3.25
3
[]
no_license
''' CS 425: Brain Inspired Computing ~ hw 1 Professor Michmizos Spring 2019 Anirudh Tunoori netid: at813 modelsim.py is a python script that simulates the firing of three different neuron models, under varying parameters. Interpreting these models, in the form of the outputted plots can help distinguish the key featur...
true
0ac8db6d10f28dbec2d939691ded8f37aeaadddd
Researchnix/HackThe6ix
/RoutePlanner.py
UTF-8
2,408
3.046875
3
[ "MIT" ]
permissive
# # RoutePlanner.py # HackThe6ix # # Created by Jeffrey, Maliha, Justin and Lennart on 2016-08-06. # Copyright 2016 Researchnix. All rights reserved. # import Map class RoutePlanner: """ Class that find the route that each car should take """ m = Map.Map() graph = {} def setMap(self, m): ...
true
7d904693980a2a08086259e6a1548a965ccc4933
jesmaelnezhad/market-physics
/package/predict_for_mql.py
UTF-8
2,302
2.984375
3
[]
no_license
#!/bin/python import requests import json import time import chartslib import numpy as np import cmath from numpy import linalg as LA def prepare_chart(data): if len(data) == 0: return None #################################################### Prepare chart chart = chartslib.Chart(1) # always usin...
true
8822c3382c673b76d8838bebf24ff25a262a85e7
evansmj1/networks-final-project-5
/Client.py
UTF-8
5,365
2.96875
3
[]
no_license
import cv2 import numpy as np import pyaudio import socket import threading #Sockets for easy access throughout client_socket1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #The arrays we store the data into vidBuffer = [] audioBuffer = [] #Ind...
true
24575e89f32ef2ade8ccc32b890b5992612381ad
sftcd/rdbd-deebeedeerrr
/keytag3.py
UTF-8
1,488
2.75
3
[ "BSD-2-Clause" ]
permissive
#!/usr/bin/env python3 import struct, hashlib, base64, os, sys, argparse, gc, json # from https://gist.github.com/wido/4c6288b2f5ba6d16fce37dca3fc2cb4a def calc_keyid(flags, protocol, algorithm, dnskey): st = struct.pack('!HBB', int(flags), int(protocol), int(algorithm)) st += base64.b64decode(dnskey) cnt...
true
9320bba7fcede5c0084526af2c20a82af1c8707d
AlertCommander/Python
/__main__.py
UTF-8
1,225
2.625
3
[]
no_license
recipients = ['+436503552474'] tokens = ['abc123'] device = "/dev/ttyUSB0" escalation_levels = ["Emergency", "Alert", "Critical", "Error", "Warning", "Notice", "Informational", "Debug"] import serial import time from flask import Flask, request app = Flask(__name__) modem = serial.Serial(device, 9600, ti...
true
785f71d68ec8cec4ad58fd9679b60f0b9b00c48e
VIAME/netharn
/netharn/initializers/_nx_ext_v2/utils.py
UTF-8
9,745
3.90625
4
[ "Apache-2.0" ]
permissive
import networkx as nx from networkx.utils import py_random_state @py_random_state(1) def random_tree(n, seed=None, create_using=None): """Returns a uniformly random tree on `n` nodes. Parameters ---------- n : int A positive integer representing the number of nodes in the tree. seed : int...
true
ed1c422edc87c83ef03778cb39949072481e6d3d
DSK2012/DOCA
/doca/consumer.py
UTF-8
837
2.546875
3
[]
no_license
import asyncio import json from django.conf import Settings from channels.consumer import AsyncConsumer from channels.generic.websocket import AsyncJsonWebsocketConsumer class Cities(AsyncConsumer): async def websocket_connect(self,event,): print("connected",event) await self.send({ "ty...
true
2926bb475a73039e00deb20e7e9cdf545c4069f7
TimvandenBelt/AdventCode2020
/days/day2.py
UTF-8
2,412
3.5625
4
[]
no_license
from util import file import re class PasswordLine: parameters = [] character = '' password = '' line = '' def __init__(self, line): self.line = line self.parameters = self.getParameters(line) self.character = self.getCharacter(line) self.password = self.getPassword(line) @staticmethod def getParamet...
true
97378946b8187681e7dd5bbf26792cb16f09ed81
molcay/varmilik
/asset_manager.py
UTF-8
2,783
3.171875
3
[]
no_license
import json from typing import Dict, Type from functools import reduce from tabulate import tabulate from currency_checker import CurrencyChecker class Asset: def __init__(self, name: str, amount: float or int, price: float or int, unit_price: float or int): self.name = name self.amount = float(am...
true
7bfa34e3deb3c17f72f292445c6edb553bd735ed
todpunk/nsc-site
/content/pages/index.py
UTF-8
2,880
2.734375
3
[]
no_license
# -*- coding: utf-8 -*- import os from pydozer import Page index_page = Page() index_page.data['filename'] = os.path.basename(__file__).replace('.pyc', '').replace('.py', '') index_page.data['title'] = "Network Sanitation Committee - Clean up the Net" index_page.data['is_home'] = True index_page.data['banner'] = """ ...
true
aa09591aec528726da0933a8d61f5771053741f8
misook-git/lect_cloudplatform
/hands-on/crawl.py
UTF-8
270
2.875
3
[]
no_license
#!/usr/bin/env python3 from bs4 import Beautifulsoup from urllib.request import urlopen with urlopen('https://en.wikipedia.org/wiki/Main_Page') as response: soup= Beautifulsoup(response, 'html.parser') for anchor in soup.find_all('a'): print(anchor.get('href','/'))
true
90ea6f52efa50a4a7ec27bb3f5d6dffdc34db423
diyanefdo/StatsTemperatureMeasurement
/Main.py
UTF-8
2,362
3.0625
3
[]
no_license
import smbus import time import math import RPi.GPIO as GPIO from PCF8574 import PCF8574_GPIO from Adafruit_LCD1602 import Adafruit_CharLCD from time import sleep, strftime from datetime import datetime address = 0x48 #default address of PCF8591 bus=smbus.SMBus(1) cmd=0x40 #command PCF8574_address = 0x27 # I2C ad...
true
fe71fd64f8cf014439a830bc49a55c1ee0273baf
max98hash/ReversiV2
/myPlayerABS.py
UTF-8
3,761
3.28125
3
[]
no_license
# -*- coding: utf-8 -*- import time import Reversi from random import randint from playerInterface import * class myPlayer(PlayerInterface): def __init__(self): self._board = Reversi.Board(10) self._mycolor = None self._tour = 0 def getPlayerName(self): return "MiniMax Player...
true
a9d4f925b3dccd310cf39def1ce61fc14db5776d
S-aiueo32/ai_for_toto
/ichiyo-master/simulator/annealing.py
UTF-8
2,871
2.875
3
[]
no_license
from simulator import simulate, simulateP from random import randint, random, uniform import math import matplotlib.pyplot as plt iteration = 10000 best_parameters = [] best_benefit = 0 alpha = 0.999 #イテレーション毎の温度降下の割合 tempreture = alpha regularization = None #'log' に設定すると利益の対数をスコアに用いる mobility_of_rate = 0.2 #買い閾値, 売り閾...
true
fadb4b7d9e978850b32a05153a8b745404e1eb71
yarnspinnered/algorithms
/tests/bst_tests.py
UTF-8
270
3.125
3
[]
no_license
import unittest from algorithms.my_bsts import * class TestBST(unittest.TestCase): def test_simple_bst(self): bst = SimpleBST() for i in range(10): bst[i] = i * 10 for i in range(10): self.assertEqual(bst[i], i * 10)
true
a291fe7848df53f51922d2c7eb83046ea93a1bc3
nikkon404/chatterX
/other files/oldConsoleUI.py
UTF-8
3,598
2.796875
3
[]
no_license
from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer from chatterbot.response_selection import get_random_response from scripts.customer import Customer import win32com.client import time import sys import logging logging.basicConfig(level=logging.CRITICAL) speaker = win32...
true
2ef28778a69e1c5f970e54337b2f989f1c424fec
pymft/mft-01
/S06/functions.py
UTF-8
108
3.078125
3
[]
no_license
def factorial(n): pass def combination(n, m): return factorial(n) / (factorial(m) * factorial(n-m))
true
b0cb24f6561af4d9d3d3810c3d80619be9148fea
lingram96/Day_4_Lab
/modules/input.py
UTF-8
295
3.3125
3
[]
no_license
def get_option(): response = input("Select an option 1, 2, 3, 4, 5 or (Q)uit: ") return response def get_description(): response = input("Enter task description to search for: ") return response def get_time(): response = int(input("Enter a time")) return response
true
54f6d808aa6ebb4395a630cbdcd094914a2a0d32
jbderoo/Homework-Files
/CBE210Last.py
UTF-8
4,833
2.75
3
[]
no_license
import os import numpy as np import math as m import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages pdf_filename = os.path.expanduser('~') + '/Desktop/Spring_2016/CBE_210_last_prob.pdf' # Finds saturation pressures for a given species at temperatures def Psat(A, B, C, temp): Psat = A - ...
true
aa0308fec2ebd5a9e2828204fb7742a8e334b093
alexandraback/datacollection
/solutions_5658282861527040_0/Python/anb/b-lot.py
UTF-8
663
3.328125
3
[]
no_license
from sys import stdin def read_str(): return stdin.readline().rstrip('\n') def read_int(): return int(stdin.readline()) def read_ints(): return map(int, stdin.readline().split()) def read_floats(): return map(float, stdin.readline().split()) def solve_case(): a, b, k = read_ints() if b < a:...
true
e397a3e841841b796865d100623dd5ae9d0c539f
SamuelSTPL/PY4E
/Chpt_10/ex_10.2.py
UTF-8
1,276
3.8125
4
[]
no_license
#Write a program to read through the mbox-short.txt and figure out the distribution by hour #of the day for each of the messages. #You can pull the hour out from the 'From ' line by finding the time #and then splitting the string a second time using a colon. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008...
true
b98360fb925c0653555a5c33f2bc75aef3ea25c8
Nguyen-Tien-1994/Btvn_05
/Btvn_05.py
UTF-8
2,018
3.6875
4
[]
no_license
# Bài 01: # Viết chương trình thay thế tất cả các ký tự giống ký tự đầu tiên của một Chuỗi thành $. # Bài làm: ''' s = input("nhập kí tự s là:") n = input("nhập kí tự n là:") print(s.replace(s[0], n)) ''' # Bài 2: ''' Bài 02: Viết chương trình để xóa bỏ ký tự thứ m trong chuỗi không rỗng, với m là số không âm, nhập từ...
true
5bd1ff8880560a7cad551b6e30a4884890c439f6
GabrielMajeri/tutoriat-pa-2019-2020
/tutoriat3/282a.py
UTF-8
143
3.75
4
[ "MIT" ]
permissive
n = int(input()) x = 0 for _ in range(n): operation = input() if '+' in operation: x += 1 else: x -= 1 print(x)
true
c99b435bb71d5ca60f12247e60b8f6cdb3925c48
vincepmartin/leetcode
/python/589-n-ary-pre-order-traversal-easy/solution.py
UTF-8
515
3.578125
4
[]
no_license
from typing import List # Definition for a Node. class Node: def __init__(self, val, children): self.val = val self.children = children class Solution: def __init__(self): self.values = [] def preorder(self, root: 'Node') -> List[int]: if not root: return [] ...
true
ddf35a6504ab8e2e53100f046f413f03f6519a9e
romanpras/InvadersGame
/utils/font.py
UTF-8
679
3.34375
3
[]
no_license
import pygame, os, sys class FontType: def __init__(self, fontName, fontSize, color): self.font = pygame.font.SysFont(fontName, fontSize) self.color = color def draw(self, surface, msg, x, y): title_text = self.font.render(msg, True, self.color) width = title_text.get_width()...
true
be150b48d2600c36d060245b7f6eb2bb5adb60e2
asherguedalia/WhatsApp-Scraping
/src/whatsapp_scrapper.py
UTF-8
8,002
3.0625
3
[ "Apache-2.0" ]
permissive
""" Importing the libraries that we are going to use for loading the settings file and scraping the website """ import os import time import random from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from selenium.common.exceptions import (NoSuchElementException, ...
true
eb8237ebe988f588f8ecd071425f73df07386afb
nmalhotra24/LeetCode
/Python/add_digits.py
UTF-8
742
4
4
[]
no_license
""" Given a non-negative integer num, repeatedly add all its digits until the result had only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. """ class Solution: def addDigits(self, num): number_size = str(num) ...
true
b6e54f2a63506529bbcb52ee87492c6a5a65c831
NandaCj/Machine_Learning1
/collectiveintelligence_book_master/drawtree.py
UTF-8
1,484
3.25
3
[]
no_license
import Image, ImageDraw def getwidth(tree): if tree.tb == None and tree.fb == None: return 1 # leaf return getwidth(tree.tb) + getwidth(tree.fb) # XXX: why does `tree` have a value in this function? #def getdepth(clust): #print tree #return 0 def getdepth(tree): if tree.tb == None and tree.fb == None: re...
true
bbbfd08d31395b230493f0ac75b6b8fc686cc01d
Swafox/reverse-shells
/revshells.py
UTF-8
2,280
2.671875
3
[]
no_license
# Written in Python 3 by @Swafox # CH Credit: http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet import os,sys import optparse import socket # Setting colors class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' BOLD = '\033[1m' ENDC = '\033[0m' print(f"{bc...
true
923ce9012e3347a4b7a85410149a6f8a6311010d
prokarius/hello-world
/Python/Catalan.py
UTF-8
212
3.421875
3
[]
no_license
catalan = [1] new = 1 for i in range (5000): new *= (4*i +2) new /= (i+2) catalan.append(new) numcase = int(raw_input()) while numcase > 0: Q = int(raw_input()) print catalan[Q] numcase -= 1
true
1085bf893d100a0ac3cb3a7b565bf9c9dc111af3
wzzMSc/project_final
/03statistical_methods.py
UTF-8
4,772
2.6875
3
[]
no_license
# %% import matplotlib.pyplot as plt import pandas as pd import os import seaborn as sns from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt from sklearn.metrics import mean_squared_error,mean_absolute_error import statsmodels.api as sm prediction_targets = ['BEAMS','BEAMT','BEAMT2'] # %% ...
true
1a571ff38c3ab45601c40047e7004f51c0949830
zeffii/BlenderSciViz
/node_connection_grammar.py
UTF-8
1,792
3.046875
3
[]
no_license
# full runnable example https://gist.github.com/zeffii/5885538 """ mat: is a reference to a material ( mat = bpy.data.materials[some_material_name] ) it must be a : - cycles material (and render engine) - use_nodes = True link_str: 'node_name_origin|o...
true
881b8003bb15e10a79ad8a69a1eb0d2b20d52630
gobixm/learn
/python/5/5.3.py
UTF-8
113
3.046875
3
[]
no_license
tuple = (1, 3, 5) print(tuple, tuple[1:-1][0]) single = 'tuple', print(single) x, y, z = tuple print(x, y, z)
true
3a1513428865ab2a9dc0ecdcaff9eea4c8982c84
bvande/Plico
/common/navpane.py
UTF-8
890
2.59375
3
[]
no_license
#!/usr/bin/env python from selenium import webdriver from selenium.webdriver.common.keys import Keys def getFolders(pdriver): return pdriver.find_elements_by_css_selector("a.navLink") def addFolder(pdriver): return pdriver.find_element_by_css_selector("a.navAddF") def cabHome(pdriver): return pdr...
true
cfe9cd6c8f056036072174bf5d28488a515b2ec2
caberlong/macaron
/model/linear_model.py
UTF-8
1,257
2.765625
3
[]
no_license
import sys import os import tensorflow as tf from model.model_input import ModelInput class LinearModel(): def __init__(self, model_input: ModelInput): self._model_input = model_input self._input_layers = [] def categoricalModel(self): self._input_layers.extend(self._model_input.categoricalFeatureIn...
true
0fff1a0a2e908a293d99758b79783a46505f8224
beethree/pp4e
/ex13a.py
UTF-8
188
3.078125
3
[]
no_license
# learn python the hard way : exercise 13 from sys import argv script, first, second = argv print "The script is called:", script print "You like:", first print "And, you like:", second
true
a1442327966bcfe000379677d03576028940a455
jannamamer/python-crash-course-programs
/chapter_4/one_million.py
UTF-8
51
3.109375
3
[]
no_license
for value in range(1, 1_000_001): print(value)
true
cee3fcaa66e33f18181ff74db737d0d701d9d9c9
NidhiRj/Python
/CO1/prgm9.py
UTF-8
177
3.75
4
[]
no_license
str=input("Enter a string:") newlist=list(str) store= newlist[0], newlist[-1] newlist[0]=store[1] newlist[-1]=store[0] print("String after replacement:") print(''.join(newlist))
true
16f54880e58776884e0b6200043baadf9d95c8f3
shirsho-12/Machine-Learning-Basics
/blobs_k_means.py
UTF-8
2,940
3.421875
3
[]
no_license
""" Unsupervised learning. Finding clusters of data using the K-Means algorithm and comparing the results by different number of clusters selected using the elbow method. """ from sklearn.datasets import make_blobs from sklearn.cluster import KMeans from sklearn.metrics import silhouette_samples from matplotlib import...
true
e14cc504081d0b57bc7a0cb0e20e31a51dca2ae6
weissab/coursera_genomics
/Reading_frames_and_repeasts/BLAST.py
UTF-8
1,066
2.515625
3
[]
no_license
#!/c/Users/Andrea/Anaconda3/python """ add annotation here """ import sys import getopt def usage(): print""" BLAST.py [-h <help>] [-e <>] <filename> -h prints this message - <filename> the file name to be in FASTA format """ import Bio #BLAST sequence: blastn - search nucleotide vs nucleotide, nt is nonred...
true
5ea7550c1d244b52bc4ebcb7b6ef9c48552ea030
yannickkiki/programming-training
/Leetcode/python3/80_remove_duplicates.py
UTF-8
707
3.140625
3
[]
no_license
class Solution: def removeDuplicates(self, nums): current, count, n_removed, i, n = None, 0, 0, 0, len(nums) while i < n-n_removed: if nums[i] != current: current, count = nums[i], 1 i += 1 elif count==2: del nums[i] ...
true
ab8686ae4687d268e606df1baad4c0992741d5ba
Gungh/exercise_for_py104
/exforpy104_xlyy.py
UTF-8
15,122
3.890625
4
[]
no_license
# coding: utf-8 # In[ ]: # # ex1 # In[1]: print("hello world") print("hello again") print("i like typing this") print("This is fun") print("Yay! Printing") print("I'd much rather you 'not'.") print("I 'said' do not touch this.") # In[ ]: #附加题 #1 print("hello world") print("hello again") print("i like typing ...
true
e057b1e1bc730d7be1de8b04090213b9b8e2baf2
wuduozhi/software-engineering
/two/File.py
UTF-8
1,093
2.59375
3
[]
no_license
# -*- coding:utf-8 -*- import sys import json import io import random import os import time class File: def creatDir(self,name): file_dir = os.getcwd() name_dir = name file_abs = file_abs = os.path.join(file_dir, name_dir) if os.path.exists(file_abs) == False: os.mkdir(file_abs) return file_abs #写入试...
true
c6853c006250dcf2a5aedb35557c512588c92a7a
gems-uff/sms
/app/main/models.py
UTF-8
8,108
2.65625
3
[ "MIT" ]
permissive
import jsonpickle from datetime import datetime from sqlalchemy import (Column, Integer, String, DateTime, UniqueConstraint, ForeignKey, Date, Numeric, Boolean, CheckConstraint) from sqlalchemy.orm import relationship, backref from flask_sqlalchemy import Model from app.extensions import db fr...
true
a0202e20657c44ee9209664c5b05b5a1b0403f64
pjlohr/practical_python_for_data_science
/ch04-python-intro/exercises/hello_a/test.py
UTF-8
699
2.953125
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 """tests for hello.py""" from subprocess import getstatusoutput, getoutput import os.path import re prg = './hello.py' def test_usage(): """usage""" (retval, out) = getstatusoutput(prg) assert retval > 0 assert re.match("usage", out, re.IGNORECASE) def test_runs(): """ru...
true
72a05c48c5549d1321229d68542c0a921f309dbf
NormanZhou123/Reinforcement_Learning_Practice
/A5/part1/Dyna_agent.py
UTF-8
3,905
2.75
3
[]
no_license
from utils import rand_in_range, rand_un import numpy as np import pickle Q = None epsilon = 0.1 alpha = 0.1 gamma = 0.95 n = None model_dic = {} last_action = None last_state = None def agent_init(): global Q, last_action, last_state, n, model_dic """ Hint: Initialize the variables that need to be reset...
true
622114f1ced726b380d04e52936a195998631cad
dennybritz/deepdive
/src/test/resources/logistic_regression/word_extractor.py
UTF-8
547
2.796875
3
[ "Apache-2.0" ]
permissive
#! /usr/bin/env python import fileinput import json # For each tuple.. for line in fileinput.input(): # From: titles(id, title, has_extractions) # To: words(id, title_id, word) row = json.loads(line) # We are emitting one variable and one factor for each word. if row["title"] is not None: # print json.d...
true
ff8f902bb8c2958883c97d36a14d8e7e12f20430
smidm/iihf-ice-rink-definition
/ice_rink.py
UTF-8
2,349
2.703125
3
[ "MIT" ]
permissive
#!/usr/bin/env python import numpy as np # all dimensions in meters w = 30. h = 60. blue_line_h = 7.14 face_off_neutral_zone_h = 1.5 face_off_w = 7. face_off_end_zone_h = 10. goal_crease_h = 4. curvature_begin_h = 8. # positive direction - x to right, y to top (see image for ice rink orientation) ice_rink = np.array(...
true
a56e3efb11d2755e168fbfdef8bbeac37b4088cb
fangjiegao/ocr_cptn_crnn
/ocr_util/grabCut.py
UTF-8
3,750
2.78125
3
[]
no_license
import numpy as np import cv2 as cv import os from matplotlib import pyplot as plt test_box_path = "/Users/sherry/work/pycharm_python/reconstruction_ctpn/data/res/0.txt" test_img_path = "/Users/sherry/work/pycharm_python/reconstruction_ctpn/data/test/0.png" def get_box_by_file(box_path): def takeSecond(elem): ...
true
b616b3614356dc907d7a43bf235d01b6a032efdc
romeorizzi/bianco_e_nero
/evaluator.py
UTF-8
5,610
2.859375
3
[]
no_license
import random import turingarena as ta def evaluate_testcase(input_necklace_colors): #print(f"Testing with n = {len(input_necklace)} necklace = {input_necklace} ...", end=" ") print(f"Testing with a necklace of {len(input_necklace)} beads ...", end=" ") def num_breakpoints(necklace_colors): risp ...
true
e8b262983f6ae1b7406eb532c2c4fe030c1afb27
GreyLove/DataStructureAndAlgorithm
/19.py
UTF-8
2,732
3.75
4
[]
no_license
# // 面试题19:正则表达式匹配 # // 题目:请实现一个函数用来匹配包含'.'和'*'的正则表达式。模式中的字符'.' # // 表示任意一个字符,而'*'表示它前面的字符可以出现任意次(含0次)。在本题 # // 中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a" # // 和"ab*ac*a"匹配,但与"aa.a"及"ab*a"均不匹配。 def match(string, pattern): if string == None or pattern == None: return False if len(string) == 0 and len(pat...
true
b7df556e33e7bb2a198d39a1ba6becff1fe24ccf
sornas/aoc
/22/d06.py
UTF-8
348
3.40625
3
[]
no_license
import sys def main(): line = sys.stdin.read() d1 = None d2 = None for i in range(3, len(line)): if d1 and d2: break if not d1 and len(set(line[i:i+4])) == 4: d1 = i+4 if len(set(line[i:i+14])) == 14: d2=i+14 print(f"Part 1: {d1}") pri...
true
55f9e6a25e45af985ac9c7b40d4561b427fcf4a8
Holly-E/Citation_Graphs
/In_degrees.py
UTF-8
2,468
3.625
4
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 3 15:21:35 2018 @author: hollyerickson Includes functions that compute information about the distribution of the in-degrees for nodes in graphs. """ # 3 Constants representing graphs EX_GRAPH0 = {0: set([1, 2]), 1: set([]), 2: set([])} EX_GRAP...
true
71df0616e54966027f35e74a677e745a69b49eb1
albertkao227/LokiHub
/BeautiBot/Discord/botREF.py
UTF-8
1,575
2.796875
3
[ "MIT" ]
permissive
userDefinedDICT = {"bodypart": ["毛", "腋", "腋下", "腿", "小腿", "大腿", "膝蓋", "腳", "腳趾", "腳背", "比基尼線", "私密處", "手", "手臂", "上手臂", "下手臂", "全手", "手指", "手背", "臉", "全臉", "鬍子", "眉心", "唇周", "下巴", "頸", "前頸", "後頸", "胸", "胸部", "腹", "腹部", "子母線", "背", "上背", "下背", "臀", "臀部", "乳暈", "胳肢窩"], "location": ["忠孝敦化", "中山"], "doctorName": ["王經凱", ...
true
53f5a35f302a2fcc3e987017f229c66a4e4feec9
cschreep/dug
/src/dug/core/crawler.py
UTF-8
7,125
2.671875
3
[ "MIT" ]
permissive
import json import logging import os import traceback from dug.core.parsers import Parser, DugElement, DugConcept logger = logging.getLogger('dug') class Crawler: def __init__(self, crawl_file: str, parser: Parser, annotator, tranqlizer, tranql_queries, http_session, exclude_id...
true
9aa673e2dd62b85dd8e8ac318f304862601a3b78
osu28/kaggle-digit-1
/classifier.py
UTF-8
3,011
3.578125
4
[]
no_license
# Classify MNIST handwritten digit images as 0 - 9 # Import dependencies import numpy as np import matplotlib.pyplot as plt from keras.models import Sequential from keras.layers import Dense from keras.utils import to_categorical import mnist # Load the data train_images = mnist.train_images() # training data images ...
true
f706177c7a714827b88ae0b98712e646eb562c85
antonku/ncssl_api_client
/tests/unit/console/parsers/test_create_parser.py
UTF-8
845
2.65625
3
[ "MIT" ]
permissive
import unittest import argparse from ncssl_api_client.console.parsers.create_parser import CreateParser class CreateParserTest(unittest.TestCase): def setUp(self): self.parser = argparse.ArgumentParser() self.subparsers = self.parser.add_subparsers(help='Available commands:', dest='command') ...
true
508be5f0a40fa26a1ffaba8180547702a79b344b
MayankKr8/AI_lab-codes
/POS-tagging(HunPos and CRF++)/data_splitter.py
UTF-8
962
2.65625
3
[ "MIT" ]
permissive
import sys if len(sys.argv) != 2: print("Enter the model option.") exit() if sys.argv[1] == "--hunpos": check = 0; elif sys.argv[1] == "--crf++": check = 1 else: print "Enter correct option." exit() dir_path = "./" clean_data_file = dir_path + "en_clean_train_data.txt" train_data_file_with_labels = dir_path + ...
true
33b99e1ddcc5876c57b0b37211553b03fae16ee1
richardsunny2015/Algorithms-Practice
/leetcode/univalTree.py
UTF-8
1,706
4.46875
4
[]
no_license
# A binary tree is univalued if every node in the tree has the same value. # Return true if and only if the given tree is univalued. # Example 1: # Input: [1,1,1,1,1,null,1] # Output: true # Example 2: # Input: [2,2,2,5,2] # Output: false # Note: # The number of nodes in the given tree will be in the range...
true
7044bd200aa356bd69860c2aac4e2097b53f9b7f
kshitijalwadhi/COL100
/Test_2/q2aliter.py
UTF-8
957
4.21875
4
[]
no_license
def groupNumbers(arr): # assert: arr[1..n] of size N is establised having elements as 1, 2, 3 only N = len(arr) cur_ini = 0 cur_end = N-1 i = 0 # INV: In every iteration, # if the element is equal to 1, it is pushed/swapped to the left side of the array(position maintained by cur_ini) ...
true
96ec060e7c5c66c662b8c96efee3925eff1c90ea
ai-kmu/etc
/algorithm/2020/0824/seongsil.py
UTF-8
554
3.25
3
[]
no_license
class Solution: def convert(self, s: str, numRows: int) -> str: if numRows == 1: return s answer = "" for i in range(numRows): ind = i while ind < len(s): answer += s[ind] ind += (numRows*2 -2) # 가장 많은 column에 있는...
true
9991ae9b3c12b6763090919026b05444a2a68038
MKASAGAR/Informationlab
/Run_Length.py
UTF-8
731
2.9375
3
[]
no_license
#d = "000000111111111111110000000000000111111111" d=str(input('Enter the message:')) print('Message: ', d) d = d + "." data = [i for i in d] run_list = [] data_list = [] run = 0 for i in range(0,len(data)-1): if data[i] == data[i+1]: run = run + 1 else: run_list.append(format(run...
true
6b4b02a8fab5ac33938b447485501804c61e1669
jraysparks/Macintosh-HD-Users-jakesparks-PycharmProjects-Challenges
/challenge6/challenge6.py
UTF-8
2,350
2.625
3
[]
no_license
import time import unittest from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import ...
true
d31e11cc2b4826f2f865f4205c1b00c58aafe539
Mike-Stupich/crypto-scripts
/exchangeAPIscripts/cryptopia.py
UTF-8
1,898
2.515625
3
[]
no_license
""" wrapper for using Cryptopia.co.nz API """ import time import hmac import urllib import requests import hashlib import base64 import sys import json PUBLIC_SET = {'GetCurrencies', 'GetTradePairs', 'GetMarkets', 'GetMarketHistory', 'GetMarketOrders'} PRIVATE_SET = {'GetBalance', 'GetDepositAddress', 'GetOpen...
true
b6ce087b643b27cf153b1fcc3e493f11afd67229
srinidhiprabhu96/crypto
/LAT_DDT/tables.py
UTF-8
3,138
3.171875
3
[]
no_license
import numpy as np def binary(n,s): """n - num s - no. of bits""" st = bin(n) out = np.zeros(s); for i in range(len(st)-1,1,-1): out[len(st)-1-i] = int(st[i]) return out def dec(a,s): """a - bit array of the form arr[x] s - no. of bits""" n = 0 for i in range(0,len(a...
true
37fadc89d81a52087cad72b283a3f58ae71d09aa
juzen2003/seti-api-testing
/test.py
UTF-8
6,397
2.640625
3
[]
no_license
import json import requests import re class Api_test: file_format = ["json", "html","zip", "csv"] def __init__(self): pass # unit test: test return of single api call for ONE format (need to pass in format) # check see if the response is ok def test_api_single_return_format(self, api_url_...
true
19957d2800a041bbbd8c66f85fe0744c65b7d1cd
duchoa117/VuDucHoa-Fundamentals-C4E13
/s4/turtle1.py
UTF-8
202
3.34375
3
[]
no_license
from turtle import* n=int(input('How many squares do you want? ')) speed(-100) color('blue') for i in range(n): for j in range(4): forward(100) left(90) left(360/n) mainloop()
true
32435d7770407d7f96dd6abae02d3a70d9e09693
gwy15/leetcode
/src/972.equal-rational-numbers.py
UTF-8
976
3.71875
4
[]
no_license
# # @lc app=leetcode id=972 lang=python3 # # [972] Equal Rational Numbers # # @lc code=start from fractions import Fraction class Solution: def isRationalEqual(self, S: str, T: str) -> bool: return self.str2fraction(S) == self.str2fraction(T) def str2fraction(self, s: str) -> Fraction: brack...
true
ee4514174b9167a57430a84bad13ee4958184665
imdevskp/python-notes
/nielit-notes/day_3_strings/2_reverse_string.py
UTF-8
141
3.9375
4
[]
no_license
word = raw_input('Please enter the word: ') reverse = '' for i in word: reverse=i+reverse print('reverse of the word '+word+' is '+reverse)
true
03e92bbffcb29392560a9e7e48f04833a56160df
uwaisiqbal/Placenta-Project-Code
/single_centrality.py
UTF-8
2,815
2.515625
3
[]
no_license
import LoadCode as lc import networkx as nx import matplotlib.pyplot as plt import numpy as np import generations as g colors = ['b','g','r','c','m','y','k'] def get_color(i): if i>=len(colors): return colors[i-len(colors)] else: return colors[i] def degree_centrality(G): """...
true
583164acf98fc37c912cd7c6de82fab2f8ba5c6d
chenyaotie/excel_tools
/excel/util/Util.py
UTF-8
1,359
2.875
3
[]
no_license
# coding=utf-8 import operator from excel.util.log import get_logger import sys reload(sys) sys.setdefaultencoding('utf8') LOG = get_logger(__name__) def get_costitem_en(name, costitem_dict): costitem_en = [costitem_en for costitem_en, costitem_zh in costitem_dict.items() if name == costitem_zh] if not costit...
true
71d7c314918fbcc2131ba1e6d68a01c93a770c63
guang-yu-zhu/DNN-MYK
/core_codes/DeepYknock.py
UTF-8
7,423
2.5625
3
[]
no_license
import numpy as np import torch import torch.nn as nn #from knockoff_threshold import knockoff_threshold from knockpy.knockoff_stats import data_dependent_threshhold class DeepYknock(nn.Module): def __init__(self, Xfeatures, Yfeatures, hidden_sizes=[32,32], ...
true
76356de5ef90f0c7d23346decbab3c6599acdd55
florespadillaunprg/t07_flores.padilla
/flores/para/ejercicio04.py
UTF-8
541
3.609375
4
[]
no_license
# Decodificar el nombre completo del presidente del peru y el anio que terminara su mandato # n=nombre # p= apellidp paterno # m=apellido materno # a=anio import os # input n=os.sys.argv[1] p=os.sys.argv[2] m=os.sys.argv[3] a=os.sys.argv[4] datos_del_presidente="npma" # Iterador for letra in datos_del_presidente: ...
true
d7ae42e12d9d7944960a85dd7656384ed6cbc876
mike-chesnokov/leetcode
/array/medium/0739_daily_temperatures.py
UTF-8
2,834
4.3125
4
[]
no_license
""" 739. Daily Temperatures Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead. ...
true
72dcc6bd79fac6d9636ab17d9db3c8d21b11d2ca
bnadlerjr/tavi
/tavi/test/integration/user_test.py
UTF-8
7,868
2.578125
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- import unittest from integration import BaseMongoTest from tavi import fields from tavi.documents import Document class User(Document): email = fields.StringField("email", required=True, unique=True) first_name = fields.StringField("first_name", required=True) last_name = fields.St...
true
0f82d3860782e46090e55952cd9f37b485dc0b26
zgcgreat/rtb-unbiased-learning
/python/test_full_win_prob.py
UTF-8
1,793
2.5625
3
[ "Apache-2.0" ]
permissive
def get_bid_landscape(mps): upper = 301 init_val = 1 mp_num = 0 mp_dict = {} for i in range(0, upper): mp_dict[i] = init_val mp_num += init_val winfun = {} for mp in mps: if mp in mp_dict: mp_dict[mp] += 1 mp_num += 1 else:...
true
484f1e40a90126bd3fe1c3f370e42eb86645c7bf
muthuishere/rxpython-sessions
/session-3/code/fpdemo_full_items/fpdemo/reactive/scheduler/scheduler_example_1.py
UTF-8
2,002
2.765625
3
[]
no_license
import sys import threading import rx from rx import operators as ops from rx.scheduler import ThreadPoolScheduler, NewThreadScheduler import logging from reactive.scheduler.PrintNamedObserver import PrintNamedObserver from shared.users import get_users thread_pool_scheduler = ThreadPoolScheduler(2) ...
true
d9591f2e684973ba1d6bb4a35e3054d969138f71
weshack/WesPartyMap
/server/database/database.py
UTF-8
1,910
2.703125
3
[]
no_license
import sqlite3 import re from datetime import datetime import time import logging import json import math #user = {'name':'John', 'homeLat':'46', 'homeLong':'46'} def connect_database(): return sqlite3.connect('database/database.db') #conn = connect_database() def add_user(conn, user): # User is a dictionary {'na...
true
6ffac6d9916f9f36a9ac198526b85f2cc0e629e4
Miguel-Fuentes/Spam_Ham_ML
/parse_txt.py
UTF-8
844
2.53125
3
[]
no_license
import os import pandas as pd #note that this assumes that this script is run from the base Spam_Ham_ML directory and that the filestructure has not been modified os.getcwd() for dataset in ['dataset 1','dataset 2','dataset 3']: os.chdir(dataset) for folder in ['train','test']: os.chdir(folder) ...
true
53e83118e044c0b8c6fe34333dc997ad8fa159fd
ShowLo/SimpleDFS
/DFS/myDFS.py
UTF-8
1,475
2.78125
3
[]
no_license
# -*- coding: UTF-8 -*- import os import sys import ConfigParser import subprocess import json #保存到分布式系统中去 def saveToDFS(fileName, master): subprocess.call(['scp', fileName, master + ':' + fileName]) #从分布式系统中下载文件 def loadFromDFS(fileName, destFileName, master): subprocess.call(['ssh', master, 'python', 'mast...
true
ae6d83a94ab6e1db3b505f373ddb34d980fab329
jillnguyen/Python-Stack
/flask_fundamentals/great_number_game/great_number.py
UTF-8
1,107
2.5625
3
[]
no_license
from flask import Flask, render_template, redirect, session, request import random app = Flask(__name__) app.secret_key="MySecretIsSafe" @app.route('/') def index(): session['mykey'] = random.randrange(0,100) session['win'] = False return render_template('index.html') @app.route('/1', methods =["POST"]) ...
true
520304272b3552b0876fe664895daafe4acec92a
adityaranjan/KattisSolutions
/justaminute.py
UTF-8
654
3.0625
3
[]
no_license
observations = input() minuteonestore = [None] * int(observations) minutetwostore = [None] * int(observations) minuteonesum = 0 minutetwosum = 0 time = [None] * int(observations) for i in range(int(observations)): minutes = input() minuteone,minutetwo = minutes.split(" ") minuteonestore[i] = int(mi...
true
aefdafcd30af50da7ccc0154c0c10124d3485462
SteelColossus/sppc-tool
/ml_models.py
UTF-8
4,837
2.8125
3
[]
no_license
import numpy as np from enum import Enum, auto from sklearn import linear_model, svm, tree from sklearn.ensemble import BaggingRegressor from sklearn.model_selection import GridSearchCV cross_folds = 10 scoring = 'neg_mean_squared_error' class RegressionType(Enum): LINEAR = 'Linear Regression' LINEAR_BAGGING...
true
b2ea16ff829cabad0076055d00b3199afe4ca52d
DHLeipzig-CurrentTopics-SS2014/shakespeare_project
/src/django/libs/stemming_lib/setup.py
UTF-8
2,518
2.640625
3
[]
no_license
#!python import os.path, sys from setuptools import setup, find_packages setup( name = "stemming", version = "1.0", #package_dir = {'': ''}, packages = ["stemming"], author = "Matt Chaput", author_email = "matt@whoosh.ca", description = "Python implementations of various ...
true
8e34c6ba21a8ee19cb1f3281ebdf704a9c729064
gammay/nltk_building_blocks
/nltk_building_blocks/01_nltk_tokenize.py
UTF-8
609
3.515625
4
[]
no_license
text = "Computers don't speak English. So, we've to learn C, C++, ,C#, Java, Python and the like! Yay!" from nltk.tokenize import sent_tokenize sentences = sent_tokenize(text) print(len(sentences), 'sentence(s): ', sentences) from nltk.tokenize import word_tokenize words = word_tokenize(text) print(len(words)...
true
737e6bfa868d54916666c1f029304ab5d1d26c6f
robertpfeiffer/reservoircomputing
/reservoircomputing/data_normalizer.py
UTF-8
527
2.890625
3
[]
no_license
class DataNormalizer(object): """ Z-Score-normalization """ def init_with_data(self, data): self.means = data.mean(0) self.stds = data.std(0) self.stds[self.stds == 0] = 1 #um NaN zu verhindern data -= self.means data /= self.stds return data def...
true
4bcdd261c33629c25178b7119d6b60ccea257543
sue0805/Algorithm_BJ_Python
/ilovecroatia.py
UTF-8
393
3
3
[]
no_license
from itertools import cycle cy = cycle(range(1, 9)) player = 0 k = int(input()) while player != k: player = next(cy) end_time = 210 time = 0 prev = [0, player-1] for i in range(int(input())): t, answer = input().split() t = int(t) time += t if time > end_time: break if answer in ['N', ...
true
f364c054d5da1a32966993708f4e0281ac023e56
mouse-reeve/allalonenow
/scripts/maincolor.py
UTF-8
536
2.703125
3
[ "MIT" ]
permissive
''' Extract the dominant color in an image ''' import cv2 import glob import numpy as np for filename in glob.glob('fermi/static/images/rooms/full/*.jpg'): img = cv2.imread(filename) Z = img.reshape((-1, 3)) Z = np.float32(Z) criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0) ...
true
8a4269f2094fa8ab8f6a93e653183dafb141232e
rajat08/NLP_projects
/text_processing_basics/code/cs505_a1_rajat08/regex.py
UTF-8
1,526
3.515625
4
[]
no_license
import re from pathlib import Path RAW_DUMP_XML = Path("raw_data/Wikipedia.xml") def count_regexp(): """Counts the occurences of the regular expressions you will write. """ # Here's an example regular expression that roughly matches a valid email address. # The ones you write below should b...
true
8bb4ac21050e02898254ed360ff85534d70fa753
snmendoza/Eric
/uix/mytogglebutton.py
UTF-8
943
2.96875
3
[]
no_license
from kivy.properties import ListProperty from kivy.uix.togglebutton import ToggleButton class MyToggleButton(ToggleButton): background_down_color = ListProperty([1, 1, 1, 1]) def __init__(self, **kwargs): super(MyToggleButton, self).__init__(**kwargs) self.border = 0, 0, 0, 0 self.or...
true
52c701aeadefddcc389e19b20f490f0f4620872c
gabriellaec/desoft-analise-exercicios
/backup/user_186/ch24_2020_09_29_01_55_49_079002.py
UTF-8
238
3.359375
3
[]
no_license
def calcula_aumento(salario): taxa=1 aumento=salario*taxa if salario>1250: aumento=salario*1/10 return ("aumento de ", aumento) else : aumento=salario*15/100 return ("aumento de ", aumento)
true
dcbbe783c05adead5c2660146928abcdc62bdbe0
2KAbhishek/Solutions
/SoloLearn/alienSays.py
UTF-8
65
3.03125
3
[ "MIT" ]
permissive
humanSays = input() alienSays = humanSays[::-1] print(alienSays)
true
b1fffe4c0ecc2508a1a76750ef5eaee787a8e45d
hausdorf/bregman
/nielsen_nock.py
UTF-8
1,309
3.078125
3
[]
no_license
#!/usr/bin/python import sys import random import argparse from kl import KL # Smallest Enclosing Right Ball (Nielsen & Nock approx) # div must be convex in both arguments # dataiter is an iterator over the data points # T is the number of iterations to run def SERB(div, dataiter, T): data = tuple(dataiter) ...
true
42ce7cb118211f3ef0260970f224940b1487d497
Prathamesh99/Income-Predictor
/Flask_app/app.py
UTF-8
926
2.640625
3
[]
no_license
import os import numpy as np import flask import pickle from flask import Flask, render_template, request app=Flask(__name__) @app.route('/') @app.route('/index') def index(): return flask.render_template('index.html') def Value_predictor(predict_list): to_predict = np.array(predict_list).reshape(1,12) l...
true
1beadeea30a3cf79b37d8683eae99113f844c016
ForbiddenDevil/Hackerrank_Algorithms
/Sherlock and Array.txt
UTF-8
489
3.1875
3
[]
no_license
#!/bin/python3 import sys def solve(a): # Complete this function i = 0 j = len(a) - 1 ans = 0 while(i != j): if ans >= 0: ans -= a[j] j -= 1 else: ans += a[i] i += 1 if ans == 0: return("YES") else: return("NO"...
true
9864e821b5625459eab4fba74eb5f96830df91c1
param211/url-shortner
/shortner.py
UTF-8
1,292
2.625
3
[]
no_license
import uuid import os import redis from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel from starlette.responses import RedirectResponse # Start app and server app = FastAPI() # r = redis.Redis() r = redis.from_url(os.environ.get("REDIS_URL")) app.add_middlewa...
true
3ce388191a5594b499d4eab569a07ecc25dc8691
rijobro/monai-test-data
/create_data.py
UTF-8
1,732
3.015625
3
[ "Apache-2.0" ]
permissive
import json from typing import Any, Callable, Dict, Tuple import torch def create_model_test_data( model_class: Callable, model_params: Dict[str, Any], input_shape: Tuple[int], out_path_no_ext: str, ) -> None: """ Create test data to check model consistency Args: model_class: Cla...
true
35832f715e4eaf683020e5538b178e6ead641a59
thomasyu888/oncotree
/integration-tests/verify_oncotree_code_converter_output.py
UTF-8
1,949
2.875
3
[ "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#!/bin/python import os import sys import linecache import csv oncotree_code_converter_output = sys.argv[1] if not os.path.exists(oncotree_code_converter_output): print "Error, specified file not found: " + oncotree_code_converter_output sys.exit(1) REQUIRED_HEADERS = ["ONCOTREE_CODE", "CANCER_TYPE", "CANCER...
true