blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
133
path
stringlengths
2
333
src_encoding
stringclasses
30 values
length_bytes
int64
18
5.47M
score
float64
2.52
5.81
int_score
int64
3
5
detected_licenses
listlengths
0
67
license_type
stringclasses
2 values
text
stringlengths
12
5.47M
download_success
bool
1 class
64cd27cc57a80f9af66e5e39f0f60650684352cb
Python
gareth-lloyd/python-geodata-talk
/api/reporting/plot_outbreak.py
UTF-8
1,769
2.65625
3
[]
no_license
import geopandas import matplotlib import shapely from matplotlib import pyplot from reporting import simulation from reporting.simulation import NORTH, EAST, SOUTH, WEST def plot_outbreak(): from psycopg2 import connect connection = connect(dbname='johnsnow') cases = geopandas.read_postgis( "sel...
true
b230f88533ebca51d145d79702ea58e4f60e578f
Python
iSeaSoul/codechef
/201311/CHEFGM.py
UTF-8
1,188
2.796875
3
[]
no_license
def judge(frac): max_non_zero_bit_flag = 0 for i in xrange(45, 0, -1): flag = 1 if frac[i] >= 0 else -1 frac[i - 1] += flag * (abs(frac[i]) / 2) frac[i] = flag * (abs(frac[i]) % 2) if frac[i] != 0: max_non_zero_bit_flag = frac[i] if frac[0] =...
true
64a478da8683f5f004498dfe430fb608b72640fd
Python
minskeyguo/mylib
/python-edu/snake/03-snake.py
UTF-8
4,171
3.390625
3
[]
no_license
#!/usr/bin/python3 import sys import time import random import pygame from pygame.locals import * SCREEN_WIDTH, SCREEN_HEIGHT = 800, 600 BOX_SIZE = 44 class Apple: def __init__(self, x, y): self.step = BOX_SIZE self.x = x * self.step self.y = y * self.step def draw(self, surf, ...
true
a368c3bce2d5ba7c98e8ed223e3d2904cada4407
Python
sdfgeoff/godot-boat
/Tools/export_png.py
UTF-8
1,171
2.6875
3
[]
no_license
# This file is run inside blender, it opens each of the passed in files and # exports it to the type specified in the render output panel import sys sys.dont_write_bytecode = True import bpy import os import argparse import logging import time def export_png(out_file, res_percent): bpy.context.scene.render.resol...
true
07709d54faaf5e5d553324297262936042b7f568
Python
valmenucerri/probleme_sac_a_dos
/remplir_sac/creer_resultat.py
UTF-8
1,061
3.375
3
[]
no_license
def resul(nb_objet, objets_ajoutes, valeur, poidscourant,pd_max,nbr_obj): ''' Créer le fichier résultat :param nb_objet: le nombre d'objets ajoutés. type : int :param objets_ajoutes: la liste des objets ajoutés . type : list :param valeur: la valeur finale de tous les objets du sac réunis. type : in...
true
7921646ec589b02924d8b7ada520b204d09ada38
Python
unsortedtosorted/FastePrep
/Trees/populate_sibling_pointers.py
UTF-8
702
3.46875
3
[]
no_license
""" Connect Same Level Siblings 1. save all nodes to dict with nodes with same level at same key 2. go to each node in all level and connect them """ from collections import deque,defaultdict def populate_sibling_pointers(root): #TODO: Write - Your - Code level = defaultdict(list) q = deque() q.append((root,...
true
12db5925604c876928f620377640ee60a6b3f320
Python
choyeaeun/Python_study
/second_syntax/2_6list_string.py
UTF-8
494
4.4375
4
[]
no_license
# list와 string은 밀접 characters = list('abcdef') print(characters) # 문자열을 특정 기호를 기준으로 쪼개 리스트화 words = 'Hello World는 프로그래밍을 배우기 아주 좋은 사이트입니다.' words_list = words.split() print(words_list) nowDate = '19:10:11' nowDate_list = nowDate.split(':') print(nowDate_list) # 리스트를 문자열로 만들기 words_str = ' '.join(words_list) print(w...
true
15cd6eafd2ebf428e4a5debb2a6f97f6fb163b2f
Python
dusty-phillips/pyjaco
/tests/dict/del_dict.py
UTF-8
409
3.34375
3
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
mydict = {} mydict["abc"] = "def" mydict["def"] = "abc" mydict["xyz"] = "rst" print mydict["abc"] print mydict["def"] print mydict["xyz"] del mydict["def"] if "abc" in mydict: print "abc in mydict" else: print "abc not in mydict" if "def" in mydict: print "def in mydict" else: print "def not in my...
true
f7b2c9ab7841b8509dffb7d2eb0b7845472d2d10
Python
orchsik/jhpar
/python/grammar/lambda.py
UTF-8
153
3.171875
3
[]
no_license
# # # lambda # 익명함수: heap 영역에서 사용되므로 다음줄로 넘어가면 증발 sum = lambda a, b: a+b result = sum(3,4) print(result)
true
69356627f7557149442ad50f6885b9a89d64c50e
Python
unit-team-spbu/backend
/logger/logger.py
UTF-8
1,668
2.65625
3
[ "MIT" ]
permissive
from nameko_mongodb import MongoDatabase from nameko.rpc import rpc from nameko.web.handlers import http import json from datetime import datetime class Logger: """Microservice for system logging""" # Vars name = 'logger' db = MongoDatabase() # Logic def _save_log(self, log): collec...
true
466ee256216f723bc2c37aca666fd746f01e9edc
Python
atbrandao/OpenPulse_f
/pulse/uix/vtk/actor/actorSquare2D.py
UTF-8
1,832
2.515625
3
[]
no_license
import vtk from pulse.uix.vtk.vtkActorBase import vtkActorBase class ActorSquare2D(vtkActorBase): def __init__(self, posA, posB): super().__init__() self.color = [1,0,0] self.normalizedColor = [1,0,0] self._actor = vtk.vtkActor2D() self.posA = posA self.posB = pos...
true
9ee2df308e0117ff71ad58e415d3a177e49e8d4d
Python
YicongCao/ZhihuJokesBot
/spider.py
UTF-8
3,184
2.609375
3
[]
no_license
# coding=utf-8 import requests import json import datetime import time import utils DAILY_NEWS_API = "http://news-at.zhihu.com/api/4/news/latest" JOKES_SECTION_API = "http://news-at.zhihu.com/api/4/section/2" JOKES_HISTORY_API = "http://news-at.zhihu.com/api/4/section/2/before/{0}" JOKES_ARTICLE_URL = "http://daily....
true
81a2c8d402c7484f488c863d17a21b3afd870bb1
Python
kahvel/VEP-BCI
/src/gui/windows/VideoStream.py
UTF-8
656
2.65625
3
[ "MIT" ]
permissive
import cv2 from PIL import Image, ImageTk import Tkinter import MyWindows class StreamWindow(MyWindows.TkWindow): def __init__(self): MyWindows.TkWindow.__init__(self, "Stream") self.image_label = None def setup(self): self.image_label = Tkinter.Label(self) self.image_label.p...
true
8642f72e59cc1f1097c36f0168a17727804c5de2
Python
CristobalME96/Universidad
/estructura/proyecto/rapiditotiti.py
UTF-8
2,115
2.78125
3
[]
no_license
import functools def leerArchivo(archivo): with open(archivo,'r') as f: for line in f.readlines(): yield line.split("\n")[0].split(",") def generarGrafo(origen): grafo = [] pos = 0 estaciones = leerArchivo('metro_neo_santiago.csv') for est in estaciones: existe = False for i in range(len(grafo)): i...
true
45f0ee19b4226622a04d595e81151452860f074c
Python
Cjkkkk/data_mining_homework
/hw1/gaussian_discriminant/gaussian_pos_prob.py
UTF-8
2,124
2.703125
3
[ "MIT" ]
permissive
import numpy as np import math def gaussian_pos_prob(X, Mu, Sigma, Phi): ''' GAUSSIAN_POS_PROB Posterior probability of GDA. Compute the posterior probability of given N data points X using Gaussian Discriminant Analysis where the K gaussian distributions are specified by Mu, Sigma and Phi. In...
true
9a0a60eb55579f552b13411933e39e879950bd77
Python
markpbaggett/trace_migrater
/app/check_deleted.py
UTF-8
545
2.5625
3
[]
no_license
import csv def get_deleted_or_unpublished(csv_name: str) -> list: with open(csv_name) as csvfile: reader = csv.DictReader(csvfile, delimiter='|') return [row['DELETE_original_uri_from_utk'].split("object/")[1].replace("/datastream/PDF", "") for row in reader if row['embargo_date'].startswith("9999...
true
6542a83783fd1424ed9316a6e9a8ffe6b7f6e654
Python
onionys/python_code
/code/socket/udp/server/01.py
UTF-8
236
2.6875
3
[]
no_license
#!/usr/bin/env python3 import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind(("192.168.0.4",8001)) while(True): msg, addr = sock.recvfrom(1024) print("addr: ", addr) print("msg: ", msg.decode())
true
f8c04e71d7d38a02936e2fe2d8489ef107fcf6c0
Python
ChrisProgramming2018/algoritm
/Arrays/LargestRange/python/program.py
UTF-8
874
3.640625
4
[]
no_license
def largestRange(array): """ Return the start number and number of the end of the largest Range in an Array Args: param1(list): array with int Return: list length 2 first element start sec end """ min_value = min(array) max_value = max(array) min_value hashTable = {} ...
true
090b73baa836acc294dbcf3109b934289ea8614d
Python
ksmenzingen/Battleship
/Battlefield.py
UTF-8
2,608
3.140625
3
[]
no_license
class BattleField: def __init__(self, width, height): self.width = width self.height = height self.ships = [] self.missedShots = [] self.field = [] def updateField(self): field = [] for i in range(self.width): a = [] for j in rang...
true
1266e352ec4b214bb4b1cbaf6378f0f17e5ecbd7
Python
lucastheis/django-publications
/publications/utils.py
UTF-8
624
2.734375
3
[ "MIT" ]
permissive
from publications.models import CustomLink, CustomFile def populate(publications): """ Load custom links and files from database and attach to publications. """ customlinks = CustomLink.objects.filter(publication__in=publications) customfiles = CustomFile.objects.filter(publication__in=publications) publicatio...
true
97f4355c38b8851c3e4dd27dc77ae7de179a47ce
Python
XHJ-TS9527/MCM-algorithms
/Optimization/Animals.py
UTF-8
5,036
3.03125
3
[]
no_license
import copy import numpy as np import pandas as pd class PSO: def __init__(self, max_iteration=50, swarm_num=20, c1=2, c2=2, w_ini=0.9, w_end=0.4): """ The setting of PSO algorithm :param max_iteration: max iteration of PSO algorithm, with default as 50, positive int ...
true
f2dfb9b05f6bd8d58dd2e13b3c7bd250f92cd4d7
Python
KrishPatel414/Vampire-Game-CS-Assignment
/Final/FINAL COPY OF FINAL CULMINATING.py
UTF-8
43,484
2.9375
3
[]
no_license
#Krish Patel #Tuesday, January 22 2019(Due Date) #Dracula's Forest #Survival Vampire Game import pygame pygame.init() from random import randint WIDTH=1000 #1200 is the biggest allowed for this assignment HEIGHT=700 #700 is the biggest height allowed #Create my game screen game_window=py...
true
c9b3c99080e9bd1c0abef367b9709161a7fd8034
Python
oszn/rengongzhineng_zuoye
/k/xixi/xxxx.py
UTF-8
122
3.078125
3
[]
no_license
f=open("1","r") p=f.readlines() x=[] print(p) for i in p: print(i) x.append(i.replace('\n','')) print(",".join(x))
true
a10f6314c6d3121866926dea4c12d96a929ad54c
Python
pinyo1999/workshop2
/lists/sort_list.py
UTF-8
370
4.0625
4
[]
no_license
# Example 1 thislist = [100, 50, 65, 82, 23] thislist.sort() print(thislist) # output : [23, 50, 65, 82, 100] # Example 2 thislist = [100, 50, 65, 82, 23] thislist.sort(reverse=True) print(thislist) # output : [100, 82, 65, 50, 23] # Example 3 thislist = ["asdas", "cxsdfcas", "sadasdew", "ab", "a"] thislist.sort() ...
true
de3d421f057f496ef3a2772a0a8940ca35ccd523
Python
BrunoScaglione/Willump
/tests/stacking_node_tests.py
UTF-8
8,296
2.8125
3
[ "MIT" ]
permissive
import unittest import numpy import pandas as pd import scipy.sparse import scipy.sparse.csr import sklearn.linear_model from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text import TfidfVectorizer import willump.evaluation.willump_executor as wexec with open("tests/test_re...
true
8db77c8c5ab1930f2b83ed4f00e56d79b92abafb
Python
Jacob-xu/pythontest
/字符串反序.py
UTF-8
102
3.328125
3
[]
no_license
list1 = [1,2,3] list2 = [3,4,5] set1 = set(list1) set2 = set(list2) print(set1&set2) print(set1^set2)
true
13c7dbd9f09ee1cd18e413b48b1a645245b578c4
Python
Zhanibek6/Medieval-chat
/medieval.py
UTF-8
1,728
3.59375
4
[ "MIT" ]
permissive
import random import re import json class Medieval: def __init__(self, data): self.data = data def printData(self): print(self.data) def translate(self, inp): result = inp.lower() result = self.single_words(result) result = self.prepend_and_append(result) result = self.change_tags(result) pri...
true
2a6f880caf654a32ce5f7b36e7f74af846f5501d
Python
rrutz/Learning
/Machine Learning(python)/Bias, Var, Complexity Tradeoff illustration.py
UTF-8
1,795
3.046875
3
[]
no_license
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import linear_model from scipy import stats from sklearn.utils import shuffle def generateDate( n ): d = pd.DataFrame( { 'x' : np.linspace(-25, 25, num = n) }) d = pd.concat( [d, pd.DataFrame( { 'y' :4.0*np.sin(d.x) + np.rando...
true
d3c090d6a20d629094a2bbc9e95a3c8835eeb19e
Python
ccrabbai/Practice_Pyhon
/Divisors_Of_Any_Number.py
UTF-8
251
4.09375
4
[]
no_license
num = int(input("Enter a number: ")) for i in range(1,num+1): if num == 1: print(num, "has ony one divisor which is ", num) elif num == 0: print("Number must be greater than zero") elif num%i == 0: print(i)
true
eec05188f3b48915ea5de4a130c7422fd73efb28
Python
University-Projects-UH/physical-layer
/mac_attribute.py
UTF-8
239
3.046875
3
[]
no_license
class Mac(): def __init__(self, _mac = 'none'): assert len(_mac) == 4, "Longitud de mac incorrecta" self.mac = _mac def show(self): return self.mac def seter(self, new_mac): self.mac = new_mac
true
916de8d1ed7fc055661d20287d0b4b5aa5fd1ffd
Python
RanjaniMK/Python-DataScience_Essentials
/slice_a_list_OR_to_get_multiple_elements.py
UTF-8
471
4.5
4
[]
no_license
my_list = [2, "Ranjani", 4, "Age", 8, "Data", 10] #get all the elements in a list: my_list[:] #get 2nd to 4th element: my_list[1:4] i.e. my_list[index1 is 2nd element, mentioning index 4 - but except for index 4, all elements preceding it is printed] # 4th element is index 3 in the array. Elements to be retrieved---> t...
true
da53158b3ebcc0c07e13c7e906152388d79f9f27
Python
RavenPack/python-api
/ravenpackapi/examples/entity_reference_get_sedols.py
UTF-8
1,775
2.953125
3
[]
no_license
import os import datetime from ravenpackapi import RPApi PRODUCT = "rpa" # Or PRODUCT = "edge" api = RPApi(product=PRODUCT) def download_or_read_reference_file(reference_filename="reference.csv"): if os.path.isfile(reference_filename): # use the locally saved reference file if it exists referen...
true
4024d6b551a72efe26147fd9a18b54166c89498e
Python
zjgbz/img_cls
/datasets/cifar_longtail.py
UTF-8
4,167
3.09375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """ # @file name : cifar_longtail.py # @author : https://github.com/zjgbz # @date : 2021年4月22日 # @brief : cifar 10数据集读取 """ import os import random from PIL import Image from torch.utils.data import Dataset class CifarDataset(Dataset): names = ('plane', 'car', 'bird', 'cat...
true
427cad9c08aa2205595f4d392e18cd3fee5b66ff
Python
tejasree0328/assign8
/w2.py
UTF-8
413
2.75
3
[]
no_license
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> def remove(string,i): for j in range(len(string)): if j==i: string=string.replace(string[i], " ",1) return string ...
true
3db57d644cc076d63687049a3dfe608a93b78e2d
Python
FEARtheRATTATA/AoC
/2022/day8/day8.py
UTF-8
2,185
3.046875
3
[]
no_license
from math import prod visible = set() def check(grid, direction, pos): global visible largest = -1 #print(direction) while True: #print(pos) try: if grid[int(pos.real)][int(pos.imag)] > largest: visible = visible.union({pos}) largest = gr...
true
94dbb4e41c4ab3d671f07dc19517aaed1d1c1e8a
Python
mehmetkarayel18/16.Hafta-Odevler
/16. hafta 3. ödv çorap renkleri.py
UTF-8
355
2.6875
3
[]
no_license
def fonnk(s,k): renk={} #her renk kodundan kaç tane olduğunu belirten bir sözlük sonuc=0 for i in s: if i in renk: renk[i]=1+renk[i] else: renk[i]=1 print(renk) for k in renk: sonuc+=renk[k]//2 return sonuc print(fonnk([2,2,2,4,6,6,6,6,7,7]...
true
38612771cc230e5bb2118ef6054f02fb2ad5bc7a
Python
opennars/OpenNARS-for-Applications
/misc/Python/distributedNAR.py
UTF-8
2,958
3
3
[ "MIT" ]
permissive
import NAR import multiprocessing from joblib import Parallel, delayed #Node graph: master = "narMaster" nodes = [master, "narSlave1", "narSlave2"] edges = [("narSlave1", master), ("narSlave2", master)] priorityThresholdGoals = 0.1 #priority needed for communication of a task priorityThresholdBeliefs = 0.1 #priority n...
true
8a0dcfca4ea4ccd0aa4d34f73fe02edd9538d864
Python
PytlaaS/Python-Project-Spring-2019
/Main.py
UTF-8
602
3.0625
3
[]
no_license
from matrix.Calcul import * from numpy import * print("Bienvenue sur le programme de calcul matriciel made in AtlaaS\n") while 1 == 1: bouclage = True while bouclage == True: wrt = str(input("Voullez vous enregistrer les valeurs de matrices ? o/n\n")) if wrt == 'o' or wrt == 'O': b...
true
c87aae66502edd55cdd9f8b35e00564ce5940056
Python
gieoon/NZ-STATS-Commuter-Competition
/server/main.py
UTF-8
16,699
2.625
3
[]
no_license
import ast from flask import Flask from flask_cors import CORS from flask import Response from flask import make_response, request, jsonify import pandas as pd import matplotlib.pyplot as plt import descartes import geopandas as gpd from shapely.geometry import Point, Polygon from math import radians, cos, sin, asin, ...
true
8483e37436a425c0296829aea799c8bf1830c321
Python
dark4igi/atom-python-test
/coursera/Chapter_6.py
UTF-8
146
4.09375
4
[]
no_license
### Data type ##string (str) x = 'abcdefg' print (x) print (type(x)) print (len(x)) for i in x: print ('letter in this itteration is :',i)
true
9922bb5f154db2af4432f6001e373e89acfd3a44
Python
jiangm18/leetcode
/subset/subset.py
UTF-8
594
3.125
3
[]
no_license
import copy class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] out = [] if nums == None or len(nums) == 0: return res self.helper(nums, 0, out, res) return res def hel...
true
dcfd384d190c3d8f1253e4235eb11488f598e4db
Python
shortthirdman/code-eval-challenges
/hard/find_min.py3
UTF-8
455
2.84375
3
[ "MIT" ]
permissive
import fileinput, heapq for line in fileinput.input(): n, k, a, b, c, r = [int(i) for i in line.split(',')] m = [a] for _ in range(k-1): m.append((b * m[-1] + c) % r) h = [i for i in range(k+1) if i not in m[-k:-1]] heapq.heapify(h) while len(m)+1 < n: o = heapq.heappop(h) ...
true
fa2f7ab21267f4b592eb0ab22aaff4273f4b7198
Python
kishan811/Hello-world
/Python/helenk.py
UTF-8
139
3.375
3
[ "MIT" ]
permissive
# Printing my github handle in Python github = ["helenking029"] for name in github: print("My Github handle is: " + github[0])
true
c080e9a587df58a8d72cbccb1ef71c6fc5c373ab
Python
lunarknight00/algorithm_challenges
/hacker_rank/wordParse.py
UTF-8
988
3.125
3
[]
no_license
import sys, re, string data = sys.stdin.readlines() # if it is not working then using # data = [line for line in sys.stdin] # data =list(map(int,sys.stdin.read().split())) tmp = [] findNonWord = False wordList = [] for line in data: findNonWord = False for idx in range(len(line)): iChar = line[idx] if re.mat...
true
3746e02669b748fae0d0414c12218328831a4b71
Python
adatechschool/ateliers
/20210707_demineur/correction/level4Graphic/minesweeper.py
UTF-8
10,361
3.0625
3
[]
no_license
''' Vikram Somu Section A4 902829100 vs19@gatech.edu ''' import turtle import csv import random import math class Sprite(object): def __init__(self, pixels): self.pixels = pixels def draw(self, turt, x, y): for col in range(len(self.pixels[0])): for row in range(len(self.pixels)...
true
520b189bd6e4f6165eb60aea98ab0967f9363829
Python
heliojscoutinho/Python-AnaliseExcelSMS
/main.py
UTF-8
1,040
2.859375
3
[]
no_license
# Importar o pandas(pip install pandas) / open py xl(pip install openpyxl) / twilio(pip install twilio) import pandas as pd from twilio.rest import Client # Twilio account. account_sid = "AC44e3a52c2c2531432bc994b3a9e2c99b" auth_token = "cf95d42b8a0562b516677d5104c4653c" client = Client(account_sid, auth_toke...
true
becb6f357187c3a5fa1c18bb5e19764da9ea9190
Python
ljchan1/SoHPC_19
/sortfile.sh
UTF-8
1,289
3.0625
3
[]
no_license
#!/bin/python #Written by Li Juan Chan in 15th August 2019 for the Summer of HPC 2019 program. #This code sorts the time compilation file based on the type of catalyst pipeline and number of cores. catalyst = ['no', 'oneslice', 'threeslices', 'clip', 'region', 'glyph_3D', 'glyph_front', 'glyph_top', 'streamline_front...
true
e6d7e66103903aa76504ec681e881da06951caec
Python
FebruaryRain/sysdev2coursework
/src/modules/data/search.py
UTF-8
763
3.734375
4
[]
no_license
def search_list_dict(postcodes, search, key): """ Searches a list of dictionaries Three variables: a list of dictionaries, search value and key to search Return array containing -1 if not found, and -2 if multiple results found """ result = [] count = 0 #Make sure the key exists in dicti...
true
16f37fb9a48b1152db319a9852eb35a6349e49f1
Python
puebla93/pitch-training
/get_results.py
UTF-8
3,346
2.65625
3
[]
no_license
import os import cv2 import numpy as np import json from util.parse_args import args import math drawing = False # true if mouse is pressed strike = False # if True, draw rectangle. Press 'm' to toggle to curve fx, fy = -1,-1 sx, sy = -1,-1 frame = None showed_frame = None def save(data, file_path): with open(fil...
true
03c251bc5fea2468da254bf729832e70b4099102
Python
Humberto59/codesignal-challenges
/reverseNodesInKGroups.py
UTF-8
1,411
3.53125
4
[]
no_license
#!/usr/bin/env python import sys from Common import build_linked_list, print_linked_list #reverseNodesInKGroups #Linked List def reverseNodesInKGroups(l, k): """ Main method """ if k == 1: return l # root r = ListNode(None) r.next = l # previous p = r # prev source, source -> t...
true
0dfcc82698034124de031e1a8fb8ce2f98eddb2f
Python
flamestream/demo-black-jack
/command/hit.py
UTF-8
466
2.90625
3
[]
no_license
from command._base import Command class ImplementedCommand(Command): aliases = [ 'hit', 'hit me', 'card', 'give card', 'request card', 'draw' ] def execute(self, player, game, params): lastCards = game.dealCards(player) lastCardStrings = [] for c in lastCards: lastCardStrings.append(str(c)) ...
true
af59a1be5a0c7d3e9a10bfaa489e8a9880302a6f
Python
swejunhyeok/jun_experiment
/model/resnet.py
UTF-8
5,910
2.640625
3
[]
no_license
'''ResNet18/34/50/101/152 in Pytorch.''' import numpy as np import torch import random import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable def conv3x3(in_planes, out_planes, stride=1): Weights = torch.zeros((out_planes, in_planes, 3, 3)) torch.nn.init.xavier_uniform_(Wei...
true
463782272117426b9821230eb2c87d84cd1948fb
Python
iamlockelightning/Docs
/grammar.py
UTF-8
551
3.09375
3
[]
no_license
#coding=utf-8 grammar = {} grammar['S'] = [['NP', 'VP']] grammar['VP'] = [['B', 'NP'], ['B']] grammar['NP'] = [['A'], ['A', 'A']] grammar['A'] = [[u'小花猫'], [u'老鼠'], [u'爪子']] #N->A grammar['B'] = [[u'抓'], [u'叫']] #V->B all_sen = [] def www(sen): words = sen.split(' ') ch = True for w in words: if w in grammar: ...
true
0f8b6c7a69f769a0b2b2e8db87dc6201c07e5911
Python
TimurShaykhiev/hockeystats
/server/app/models/player.py
UTF-8
3,412
2.65625
3
[]
no_license
from datetime import date from marshmallow import fields from flask import current_app from app.api.response_utils import ApiError from app.database import get_db from data_models.player import Player as PlayerDm from . import ModelSchema, get_locale, DEFAULT_LOCALE class Player: def __init__(self): sel...
true
625d85000d93ab0966b057af2e7642eb9d1f582d
Python
Vinecreeper888/python-material
/Assignments/assignment.py
UTF-8
2,738
4.0625
4
[]
no_license
""" #1. write a program which can compute the fact of given number using function #using recursion, separated val in console #n = int(input("Enter a number:")) n = int(input("Enter a number:")) def computeFact(n): fact = 1 for i in range(1,n+1): fact = fact * i print(fact) computeFact(n) """ """ #2. With a gi...
true
4c01d608eac91c4f2668734c606ca85a85796946
Python
booyoungxu/python-learning
/practice/test_collections.py
UTF-8
973
3.640625
4
[]
no_license
# -*- coding: utf-8 -*- from collections import namedtuple from collections import deque from collections import defaultdict from collections import OrderedDict from collections import Counter # create a tuple named Point Points = namedtuple('Point', ['x', 'y']) p = Points(1, 2) print(p, p.x, p.y) # Point(x=1, y=2) 1...
true
ffd6d45f9e98411c4d5286838b120b1740d7a4e5
Python
MoazMansour/data-structures
/binary_search.py
UTF-8
534
3.390625
3
[]
no_license
#!/usr/bin/env python3 def binarySearch(arr, value): if not arr: return -1 start = 0 end = len(arr)-1 mid = int((start+end)/2) if arr[mid] == value: return mid if arr[mid] > value: start = start end = mid else: start = mid + 1 end = end + 1 ...
true
a770b4ae196d333a450ea129cf839ce51f7c48f9
Python
RideGreg/LintCode
/Python/825-bus-station.py
UTF-8
1,732
3.703125
4
[ "MIT" ]
permissive
# -*- encoding: utf-8 -*- # There are a city's N bus information, route[i] stores the bus stop through which the i-th bus passes, # find the minimum number of transfers from station A to station B. If you can't get to B from A, return -1. # 1 <= N <= 100, 2 <= |route[i]| <= 100, 0 <= route[i][j] <= 2^31 - 1 # Solutio...
true
93e287d72a97a5f87960ee052f140d1364cf8432
Python
DrRamm/ML_xyz
/test_model.py
UTF-8
1,156
2.609375
3
[]
no_license
# coding: "GBK from keras.engine.saving import load_model from numpy import concatenate from sklearn.metrics import confusion_matrix import pylab as plt from common import * np.random.seed(42) model = load_model(modelPath) model.load_weights(modelWeightsPath) def prepare_all_data(): print("\n---------------- Pr...
true
882094f1ff42a4f1c749c127fa0a565dc0033580
Python
Aasthaengg/IBMdataset
/Python_codes/p02848/s994893636.py
UTF-8
198
3.21875
3
[]
no_license
n = int(input()) s = input() a = "" for ss in s: if ord('A') <= ord(ss) + n <= ord('Z'): a += chr(ord(ss) + n) else: a += chr(ord(ss) + n - ord('Z') + ord('A') - 1) print(a)
true
94da486af2847e74a3452ad0252041edbec88354
Python
DavidLBrandt/UW_PYHTON330_Django-Blog
/blogging/tests.py
UTF-8
2,299
2.671875
3
[ "MIT" ]
permissive
from django.test import TestCase from django.contrib.auth.models import User from blogging.models import Post, Category import datetime from django.utils.timezone import utc class PostTestCase(TestCase): fixtures = [ "blogging_test_fixture.json", ] def setUp(self): self.user = User.object...
true
15034368d56f25bcef8e1faa3dfcf01fe09adf9b
Python
alelucio/python_exercises
/tests/test_lists.py
UTF-8
2,133
3.1875
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- import pytest from py_exercises.lists import * @pytest.mark.parametrize("last_func,error_type", [ (my_last, IndexError), (my_last_recursive, ValueError) ]) def test_my_last(last_func, error_type): assert last_func([1, 2, 3, 4]) == 4 with pytest.raises(err...
true
79dabc5a265dca4ab40d0c7595d691e414379da1
Python
jinnyhyunjikim/crouds
/WORKING_with_css/app/FindUsers.py
UTF-8
10,516
2.84375
3
[]
no_license
#!/usr/bin/python import string, psycopg2, requests, json, csv, time from datetime import datetime, date from geopy.distance import vincenty Foursquare_CLIENT_ID = '0015X0KQ1MLXKW0RTDOCOKUMACBCKE30ZY2IFYPCQDYTZ3EC' Foursquare_CLIENT_SECRET ='UKJRW30YZAXC5DUO5KOZFPM4XWD3O3YSK0ANCZKB3TYCMCA5' class FindUsers(): @...
true
49ba941dfad32a470d37db52717cefe9c70adef9
Python
ErenYeager0/Efficient-Trajectory-Optimization
/chebfun.py
UTF-8
2,380
2.734375
3
[]
no_license
from pychebfun import * from numpy import * def chebpts(n): dom = [-1,1] x = Chebfun.interpolation_points(n) * -1 x = scaleNodes(x, dom).reshape(-1, 1) w = quadwts(n) w = scaleWeights(w, dom) v = barywts(n) return x,w,v def chebpts_dom(n, dom): [x,w,v] = chebpts(n) t = scaleNo...
true
0945b7e115c1fa76fd09054887f53323bcff5fb9
Python
xiaomagh/assignment-4
/initialConditions1.py
UTF-8
682
3.328125
3
[]
no_license
import numpy as np # Initial conditions function for diffusion def squareWave(x,alpha,beta): "A square wave as a function of position, x, which is 1 between alpha" "and beta and zero elsewhere. The initialisation is conservative so" "that each phi contains the correct quantity integrated over a region" ...
true
eccdb0d3759829fa7772664b6c42bce0dec01087
Python
mjhcodes/pdxcodeguild
/python/practice2.py
UTF-8
2,365
4.40625
4
[]
no_license
# Practice 2 - Strings # Problem #1 def double_letters(user_string): """accepts a string from the user and returns another string with every letter doubled""" doubled_string = "" for letter in user_string: doubled_string += letter * 2 return doubled_string # user_string = input("Enter some text: ") # pri...
true
8cca58978888b7d041b54f0e4d6292c210c3612f
Python
langheran/NLP-for-political-polarity-classification-from-tweets
/load_dataframe.py
UTF-8
1,076
2.5625
3
[]
no_license
import pandas as pd import os import config as conf import numpy as np def getTokenizedDataFrame(): df = pd.read_pickle(os.path.join(conf.pickles_dir, "tokenized.pickle")) df = df[(df["proactivo"] > 0.0) | (df["provoto"] > 0.0) | (df["agresivo"] > 0.0) | (df["reactivo"] > 0.0)] return df def getPickle(na...
true
bcbb798b28b968c67cca699ed50b184ec5eb4f33
Python
milanmeu/AOC
/Day6Part2.py
UTF-8
518
2.984375
3
[ "MIT" ]
permissive
file = open("input6") yes = 0 line = file.readline() while line: yes_group = set() for letter in line: if letter != "\n": yes_group.add(letter) line = file.readline() while line and line != "\n": yes_person = set() for letter in line: if letter != "\n":...
true
edabb3a6ab14dce47bbcfdc4d1322dfab51d3b1b
Python
kim-jae-yun/testvscode
/602_이벤트송신자.py
UTF-8
1,061
2.828125
3
[]
no_license
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QPushButton, QLabel from PyQt5.QtCore import Qt import sys class 이벤트송신자(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.btn1 = QPushButton("버튼 1" ) self.btn2 ...
true
3617942fd4e8721049fca9bdc26a40a2e45c0999
Python
codemellow/codemellow_db
/modules/syntax_highlight/syntax.py
UTF-8
946
2.578125
3
[]
no_license
import ntpath import os.path import sys import magic from pygments import highlight from pygments.lexers import (guess_lexer_for_filename,get_lexer_by_name,guess_lexer) from pygments.formatters import HtmlFormatter if not os.path.isfile(sys.argv[1]): print "<p>(Sorry there's no file exist)</p>" sys.exit() size = os....
true
9c72ab9b911f3251fe96bcd2e4e30c688ba9148e
Python
twallengren/heatpump
/solar_simulation.py
UTF-8
5,732
3.453125
3
[]
no_license
# Author: Toren Wallengren from components.solar_panel import SolarPanel from components.cold_reservoir import ColdReservoir from components.pump import Pump from components.storage_tank import StorageTank class SolarSimulation: """ Simulation of heat pump from a cold reservoir at temperature Tc to a hot rese...
true
ae8f9a4fe1b9f8ee1ea811e8569b2d4211eeae7c
Python
werewolves-devs/Werewolf_Bot
/story_time/book.py
UTF-8
53,145
3.421875
3
[]
no_license
# From the rule book def find_role_rules(role): if role == "Innocent": msg = ''' The innocents are normal players. They only know their own role. The innocents can vote during the day on whomever they suspect to be an enemy, and hope during the night that they won't get killed. The Curse Caster can tu...
true
5a3cf3c03faee48047b05924f7a49e6ae644608b
Python
JaeSeung/briclo_intro
/accounts/forms.py
UTF-8
1,439
2.515625
3
[]
no_license
from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.forms import AuthenticationForm class SignupForm(UserCreationForm): class Meta(UserCreationForm.Meta): fields = ("username", "email") class SignupForm2(UserCreationForm): email = forms.EmailField...
true
2840218ceab515a4b6a5d84ed923f14e1fc6460e
Python
RanjeetVats/StringAndList
/Dictionary/DictProb6.py
UTF-8
95
3.21875
3
[]
no_license
value=input("enter string") l=value.split() d={} for i in l: d[i]=d.get(i, 0)+1 print(d)
true
5847152ef8acc94f6c1025fbeb71e94341fc0475
Python
ConorHK/assassin
/eliminate.py
UTF-8
7,051
3.203125
3
[]
no_license
import sys # Function that loads in the players in the current play order. def loadPlayers(): players = [] with open("TempGameFiles/playershuffle.txt") as file: players = file.read().splitlines() return players def loadTargets(): targets = [] with open("TempGameFiles/targetlist.txt")...
true
38f2c0977d79b351c5c6dc7e8787611a3623db0a
Python
drewhutchison/dvlp2015
/slidedeck/bin/assemble.py
UTF-8
2,406
2.8125
3
[]
no_license
#! /usr/bin/env python from os.path import dirname, realpath, abspath, join from os import chdir, getcwd from glob import glob from re import search from subprocess import check_output ROOT_PATH = abspath(join(dirname(realpath(__file__)), '../..')) SLIDES_PATH = join(ROOT_PATH, 'slidedeck') SRC_PATH = join(SLIDES_PAT...
true
cd3b5ed006b9858227d378551aff9d560a4073f3
Python
Amitsrma/code_practice
/HR/Fraudulent Activity Notifications.py
UTF-8
1,582
3.140625
3
[]
no_license
import time import bisect def median(arr, n): return (arr[n//2]+arr[n//2-1])/2 if n%2==0 else arr[(n+1)//2-1] def activityNotifications(expenditure, d): hashes_s = {} to_check = expenditure[d] n = len(expenditure) num_notification = 0 begin = expenditure[:d] begin.sort() ...
true
1bc4925b30d60c0ed13e83587e28dcdba99877e1
Python
BeeShall/OnceUponAPixel
/data/Model.py
UTF-8
572
2.59375
3
[]
no_license
from data.Clarifai import Clarifai from data.PassageFetcher import PassageFetcher class Model(object): def __init__(self, url): self.URL = url self.Tags = None def RunClarifai(self): tags = Clarifai.SubmitImageWithURL(self.URL) tags = sorted(list(Clarifai.GetProbabilities(ta...
true
c3802aa6fa13e7fb2dddbfeeb891013f76609b74
Python
hongjunChoi/H2R_Baxter_Classifier
/ref_code/generate_model.py
UTF-8
25,099
2.578125
3
[]
no_license
import yaml import sys from base64 import b64decode import zlib import struct import json import numpy as np import math from scipy.ndimage.filters import gaussian_filter class Observation: observationCount = 0 occupancyCount = 0 occupancyConfidence = 0.0 r = 0.0 g = 0.0 b = 0.0 def __ini...
true
3d66cc124b2158d3bd19cc468cfa8fab9247f3bc
Python
KatOkonska/Statki
/app/classes/board.py
UTF-8
1,333
2.8125
3
[]
no_license
from app.classes.settings import * class Board: def __init__(self, Size): print("Board constructor.") self.Size = Size self.Data = [[0 for x in range(self.Size)] for y in range(self.Size)] for item in self.Data: item = BoardDisplay.USELESS.value def GetData(self): ...
true
62a22c0a9ca4ff21b87b8efe16e69d7e1eb6c7d3
Python
iago-ribeiro28/jogos
/Jogos.py
UTF-8
598
3.71875
4
[]
no_license
import forca import Par_ou_impar import Adivinhacao jogando = 'S' while jogando == 'S': print('*'*22) print('***Escolha seu jogo***') print('*'*22) print(""" (1) Advinhação (2) Forca (3) Par ou impar""") jogo = 0 while 3 < jogo < 1: jogo = int(input('\nQual jogo? ')) if ...
true
4e26f0805603fbe4951937d116e11d6e9676bd4e
Python
jcdavis3795/newegg_scraper
/ne_scrape.py
UTF-8
899
2.984375
3
[]
no_license
from funcs import get_ne_components import sys # command line functionality. From the terminal in the project directory, run 'ne_scrape.py' the way you would normally # run a python file followed by two additional arguments: component type and the number of items you want returned if __name__ == '__main__': ...
true
59c13f7db2ab5ec5050d2df970b60e512818e913
Python
qrk1/lpthw
/ex14.py
UTF-8
1,688
4.4375
4
[]
no_license
#import the argv function from the sys module from sys import argv # assigns the variables that argv will use. The first one is # reserved for the name of the script (program), that variable # can be any names allowed in Python, does not have to be script. script, user_name = argv #creates a variable and assigns the ...
true
a76e6a928498dc280e0ef96b51863928a2702be1
Python
ryu022304/atcoder
/AtCoder_Beginner_Contest/041-050/048/a_atcoder_xxx_contest.py
UTF-8
49
2.78125
3
[]
no_license
x = list(input().split()[1]) print('A'+x[0]+'C')
true
1d3764222354077533ea2ff4bb9c21fca916c076
Python
WetzelVictor/cavity-modes
/reponse-forcee-animated/main.py
UTF-8
1,786
2.8125
3
[]
no_license
#!/usr/bin/python # -*- coding: utf-8 -*- """ Modelisation et visualisation de la réponse acoustique d'une cavité parallèlepipédique 2D parfaitement régléchissante """ """ === BIBLIOTHEQUES === """ import numpy as np from matplotlib import pyplot as plt import math import classReponseForcee as repl import colorGra...
true
ce4192b381a69ca68f5b3b14d1b2021e5042282a
Python
SupunSSW/nb-face-app
/aio/voice.py
UTF-8
1,121
2.734375
3
[]
no_license
import numpy as np import cv2 import speech_recognition as sr from PIL import Image import imagehash r = sr.Recognizer() with sr.Microphone(0) as source: r.adjust_for_ambient_noise(source) print("SAY Next or Previous") audio = r.listen(source) try: a = r.recognize_google(audio) print("a") except: pass ...
true
906d57c45d2b821bddd1ed6d143b3446b4d134dc
Python
Taoge123/OptimizedLeetcode
/LeetcodeNew/python2/LC_1526.py
UTF-8
4,299
3.90625
4
[]
no_license
""" 1526.Minimum-Number-of-Increments-on-Subarrays-to-Form-a-Target-Array 解法1: 线段树 直观上说比较容易想到贪心的解决方案。第一步,我们肯定会挑选全局最小的元素target[i],然后让整个数组都增加target[i]。此后任何操作都不可横跨整个数组。我们会选择递归处理[0:i-1]和[i+1:n-1]这两个区间。方法也类似,就是在[0:i-1]这个区间内找到最小的元素target[j],让这段区间都增加至target[j],既然我递归处理[0:j-1]和[j+1:i-1]这两个区间... 所以上述方法的难点在于快速挑选一段区间内的最小元素和它所在的位置...
true
56c714ebb67e192eaa56133858c238566b18d2b2
Python
Omeyco/omeybot
/t.py
UTF-8
3,647
2.78125
3
[]
no_license
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import time import random import datetime import telepot import db import urllib2 import json def handle(msg): chat_id = msg['chat']['id'] command = msg['text'].split(' ')[0] if command=='/start': message = """ <b>Bienvenido a Ome...
true
4e6343995bfc31c42a73afd1ea034f0d0f9e7349
Python
heitorchang/learn-code
/battles/fights/franciraldo_20170629.py
UTF-8
1,234
3.453125
3
[ "MIT" ]
permissive
def addDigits(a, b, n): rem = a % b result = [] result.append(str(a)) for i in range(n): best = -1 for digit in range(9, -1, -1): if (rem * 10 + digit) % b == 0: best = digit break if best == -1: break result.appen...
true
34e1725d501cc602b4fc87af04b681d703cfa9f6
Python
shaunagm/personal
/data_analysis/Mar2013/build/sunlight/examples/cross-api/death-metal
UTF-8
1,259
2.90625
3
[ "MIT", "BSD-3-Clause" ]
permissive
#!/usr/bin/env python # Copyright (c) 2012, BSD-3 clause, Sunlight Labs from sunlight import capitolwords from sunlight import congress phrase = "death metal" # Today, we'll be printing out the Twitter IDs of all legislators that use # this phrase most in the congressional record. for cw_record in capitolwords.phras...
true
7610f13aa7bac20ab16f92d3a446d20e0e61adb0
Python
archu2020/python-2
/DeepLearning/Verification_code_identification/create_captcha.py
UTF-8
3,025
3.1875
3
[ "Apache-2.0" ]
permissive
''' 学校验证码自动生成工具 create by Ian in 2018-3-5 10:31:47 ''' import random import sys from PIL import Image, ImageDraw, ImageFilter, ImageFont import os class MyGaussianBlur(ImageFilter.Filter): name = "GaussianBlur" def __init__(self, radius=2, bounds=None): self.radius = radius s...
true
3e9ca0a8d378d03c4ae3aa580c4f1e8b12d42953
Python
saimkhan92/Recursion
/list_sum_recursive.py
UTF-8
194
3.65625
4
[]
no_license
# Sum of a python list using recursion l=[2,5,2,6,88,4,6,8,7] def listsum(lst): if len(lst)==1: return lst[0] else: return lst[0]+listsum(lst[1:]) print(listsum(l))
true
1329500ffb0a58cd205bc2051578d910d0862c14
Python
wupsi/PP2_2021_Summer
/Practice/PP2 Midterm V1, 2021/C.py
UTF-8
168
3.40625
3
[]
no_license
arr = list(map(int, input().split())) cnt = 0 for i in range(len(arr)): for j in range(i + 1,len(arr)): if arr[i] == arr[j]: cnt += 1 print(cnt)
true
0d2fdeeef461fdda085191ce87e9d3943f6822cf
Python
mindspore-ai/models
/research/cv/frustum-pointnet/train/box_util.py
UTF-8
9,236
2.984375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license" ]
permissive
# Copyright 2022 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
true
1960013106ec8946008495c225f968843539bf6b
Python
Vittorio-Veneto-www/StudentManagement
/core.py
UTF-8
5,052
2.765625
3
[]
no_license
class core(): class student_data(): def __init__(self, properties): self.values = {} for i in properties: self.values[i] = None def dict(self): return self.values def changeValue(self, valuedict): for key in valuedict....
true
795e7963cf37f208562c7e7cd6a6921452126710
Python
qlh2561808384/Madison
/src/main/java/com/longshao/madison/Utils/python/test.py
UTF-8
945
2.9375
3
[]
no_license
#_*_coding:utf-8_*_ import sys import json if __name__ == '__main__': print('------------------------begin---------------------------') #Get the parameter list parameterList=sys.argv[1] # parameterList1 = sys.argv[2] # parameterList = {"test":1,"test1":"qlh"} # json解析并按key排序 print(parameter...
true
cee2bcf0fabc28d9bc268f65a3eaeca3ede62dee
Python
CTaylor5299/App_Project
/test/test_unit.py
UTF-8
2,868
2.515625
3
[]
no_license
import unittest from flask import url_for from flask_testing import TestCase from application import app, db from application.models import Teams, Players class TestBase(TestCase): def create_app(self): app.config.update(SQLALCHEMY_DATABASE_URI="mysql+pymysql://root:root@35.242.182.10/fpl", SEC...
true
69afbf8d9c63fd863343ee74845a7a74a16b6455
Python
Cinofix/secml
/src/secml/ml/scalers/tests/c_scaler_testcases.py
UTF-8
2,413
2.84375
3
[ "Apache-2.0" ]
permissive
from secml.testing import CUnitTest from secml.array import CArray from secml.ml.tests import CModuleTestCases class CScalerTestCases(CModuleTestCases): """Unittests interface for Normalizers.""" def _compare_scalers(self, scaler, scaler_sklearn, array, convert_to_dense=False): ...
true
84fbeb19825ed01a628ec192a5436e206bc8b521
Python
Aollarve/Wallbreakers
/Week_2/happy-numbers.py
UTF-8
333
3.0625
3
[]
no_license
class Solution: def isHappy(self, n: int) -> bool: l_nums = [] while(n != 1): str_n = str(n) l_nums.append(str_n) n = 0 for x in str_n: n += int(x)*int(x) if str(n) in l_nums: return False ...
true
e8042c4c726a185b074a12c191b98d71478dca30
Python
maodan-maodan/test
/selftype/选择性粘贴.py
UTF-8
1,422
3.6875
4
[]
no_license
#拷贝对应条件的文件,从需要拷贝的文件夹,至对应文件夹,文件夹需提前创建 #导入函数库 import os import shutil #创建复制函数 def copyfile(fromwhere,towhere,filetype): #fromwhere是需要拷贝文件的原地址 #towhere是需要拷贝至的目的地 #filetype是需要拷贝的文件类型,类似“.txt”,“.log”,“.ini”这种 for foldername, subfoldernames,filenames in os.walk(fromwhere): for filename i...
true