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
09a3ff3d62dc2baf7cf1c9b3f6ed4a8305b8cc9e
Python
HenriqueBaetaLeite/Cadastro_Alunos
/CadastroAlunos.py
UTF-8
1,495
3.875
4
[]
no_license
from datetime import date from time import sleep lista_Aluno = [] while True: print('''Menu de escolha: 1 - Cadastro de novo aluno 2 - Registar pagamento 3 - Histórico do aluno 4 - Sair do programa''') opção = int(input('Escolha sua opção: ')) sleep(.5) if opção...
true
5f2f03c7f936eaa40be666599fadb0eaa95cf3b5
Python
prhuft/rubidium
/csv_analysis/rigolcsv.py
UTF-8
3,649
3.109375
3
[]
no_license
from pandas import DataFrame, Series from numpy import * import csv class RigolCSV: """ Class for clean handling Rigol spectrum analyzer data """ def __init__(self, filename, exclude=2, trace2=False, no_offset=True, zero=True): """ 'exclude': the number of column to start at; i.e. exclude=2 mea...
true
65ac87726f2d7121740d14c01814afe6bf3e91b3
Python
kanbujiandefengjing/python
/python实例/列表元素绝对值排序.py
UTF-8
739
4.5
4
[]
no_license
''' 列表元素绝对值排序 题目内容: 输入一个列表,要求列表中的每个元素都为整数; 将列表中的所有元素按照它们的绝对值大小进行排序,绝对值相同的还保持原来的相对位置,打印排序后的列表(绝对值大小仅作为排序依据,打印出的列表中元素仍为原列表中的元素)。 可以使用以下实现列表alist的输入: alist=list(map(int,input().split())) 输入格式: 共一行,列表中的元素值,以空格隔开。 输出格式: 共一行,为一个列表。 ''' alist=list(map(int,input("请输入列表的元素,以空格隔开:").split())) alist.s...
true
6b57e7e6a73d576ce1a7d6c38efe8a2f4a902baf
Python
stonelasley/django-animals
/animals/tests.py
UTF-8
6,504
2.53125
3
[ "MIT" ]
permissive
from django.test import TestCase, RequestFactory from django.core.urlresolvers import reverse from animals.models import Animal, Breed, Food, Brand def create_animal(): """ Creates an animal to test against. """ return class AnimalsViewTests(TestCase): """ View Tests """ def setUp(...
true
75017db80acd8b9a32a8955ac1e2282d50684596
Python
hbina/leetcode-solutions
/leetcode_python/src/problem_416_test.py
UTF-8
1,982
3.359375
3
[]
no_license
import unittest from typing import List class Solution: def canPartition(self, nums: List[int]) -> bool: total_sum = sum(nums, 0) if total_sum % 2 != 0: return False else: nums.sort(key=lambda x: x, reverse=True) return canPartition_recursion(nums, 0, t...
true
99d4cfb66150aca60bea10134e30ceefd8cf7d33
Python
DamonDay/Issuu-PDF-Downloader
/core/resizer.py
UTF-8
204
2.84375
3
[]
no_license
from PIL import Image def resizer(image): image1 = Image.open(image) # Change to resize images width = 1060 height = 750 image1 = image1.resize((width, height)) image1.save(image)
true
618ea641c3060bebd48ff536b333f31403b44552
Python
himanshuks/python-training
/advanced/perfectGuess.py
UTF-8
1,132
4.15625
4
[]
no_license
# Random library is used to generate random numbers between provided range import random # Both X and Y are included in the range for random number randNum = random.randint(1, 100) userGuess = None numberOfGuesss = 0 # Below game takes username and number of guess # If number is greater, we ask them to enter smaller...
true
371bde5a2ae922273cab69a3dba9a3d6d777fe38
Python
yuki-baker-baimatan/org.geppetto.frontend
/src/main/webapp/js/components/publish_components.py
UTF-8
1,227
2.734375
3
[ "MIT" ]
permissive
#!/usr/bin/python # Zips up folders in the ./dev directory and places them in org.geppetto.bower # directory located at source root. Accepts a parameter -v that specifies the version # Usage: ./publish_components.py -v <version> import os, sys, json, distutils.core, shutil, glob, zipfile, getopt from subprocess impo...
true
824e9c2cab2781ed06b20231bfef9619c91006af
Python
julianVAgolzwarden/Python_scripts
/hamiltonian.py
UTF-8
2,753
2.734375
3
[]
no_license
import matplotlib.pyplot as plt import numpy as np import time t0 = time.time() with open('hamiltonianData.txt') as h: content = h.readlines() n_hamiltonian = len(content) - 1 #construct hamiltonian matrix hij = np.zeros((n_hamiltonian+1, 3)) for x in range(1, n_hamiltonian + 1): for y in range(3): ...
true
20213586cd88bc10077bc3e48831229bf8fb0122
Python
kcetskcaz/RandomForest
/main.py
UTF-8
1,150
2.828125
3
[]
no_license
import sys from forest import Forest from utils import * def main(): debug = False threshold = 1 for i in range(0, len(sys.argv)): if sys.argv[i] == '-d': debug = True elif sys.argv[i] == '-t': threshold = sys.argv[i+1] elif sys.argv[i] == '-h': ...
true
be71f6efd0093ce0c293e501b96997fc4ea2d14a
Python
chandrasendr/Udemy_python_postgresql
/movie-system/user.py
UTF-8
1,741
3.75
4
[]
no_license
from movie import Movie # 1 class User: def __init__(self, name): self.name = name self.movies = [] # 2 def __repr__(self): return "<User {}>".format(self.name) # 4 def add_movie(self, name, genre): movie = Movie(name, genre, False) self.movies.append(movie)...
true
fa76492a9a1d94d4aa794cb8c2563c25917dcae9
Python
leandrotune/Python
/pacote_download/PythonExercicios/ex029.py
UTF-8
352
3.921875
4
[ "MIT" ]
permissive
# Radar de multa: carro = float(input('Em que velocidade seu carro estava rodado ? ')) multa = (carro - 80) * 7 if carro <= 80: print('Bom dia! Dirija com segurança!') else: print('MULTADO! você excedeu o mimite de 80km/h') print('Você deve pagar uma multa de: R${}'.format(multa)) print('Tenha um bom d...
true
6b9e18db6457037b1fa547c86d098efa9235f02d
Python
swigder/language_modelling
/language_modelling/basic_ngram_calculator.py
UTF-8
2,113
3.90625
4
[]
no_license
class BasicNgramCalculator: """ Calculates the ngrams in a corpus and provides data about uniqueness among ngrams """ def __init__(self, corpus): self.corpus = corpus def calculate_ngrams(self, n, pad_left=False, pad_right=False): """ Calculate the ngrams in a corpus ...
true
134b95be78addf0dad800096d93a0b21a91ef6ea
Python
cuulee/trace
/carbonplan_trace/v1/model.py
UTF-8
12,220
2.609375
3
[ "CC-BY-4.0", "MIT" ]
permissive
import os import numpy as np import pandas as pd import xgboost as xgb from joblib import dump, load from s3fs import S3FileSystem from sklearn.cluster import KMeans from sklearn.ensemble import GradientBoostingRegressor, RandomForestRegressor from sklearn.metrics import mean_absolute_error, r2_score from sklearn.mode...
true
acf7583d057c67fbf1c4e470384062399dc37c06
Python
evheny0/face-yidi
/test_single.py
UTF-8
2,027
2.515625
3
[]
no_license
import sys import keras from keras import models from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img from PIL import Image, ImageDraw import face_recognition import cv2 import numpy as np model = models.load_model('model.h5') def inverse_dict(d): return {v: k for k, v i...
true
ed5c3aefb8097cce95454e51a29f4e251da5dd99
Python
melios/edx---Introduction-to-Computer-Science-and-Programming-Using-Python-2017
/scrips/genFib.py
UTF-8
727
3.609375
4
[]
no_license
def genFib(): fibn_1 = 1 # fib(n-1) fibn_2 = 0 # fib(n-2) while True: # fib(n) = fib(n-1) + fib(n-2) next = fibn_1 + fibn_2 yield next fibn_2 = fibn_1 fibn_1 = next if __name__ == "__main__": fib = genFib() print(fib.__next__()) print(fib.__next__()) ...
true
68db9c76904f4c895302c336e158696c5536ca91
Python
Joyce428/FlaskProjects
/project4/budget.py
UTF-8
3,362
2.71875
3
[]
no_license
from flask import Flask, request, render_template from werkzeug.exceptions import abort import json app = Flask(__name__) uncat_pur=[0,] #CATS = { # "cat1": {"name": "house", "limit": 100, "remaining": 100}, # "cat2": {"name": "food", "limit": 100, "remaining": -10} #} CATS={} #dictionary for purchases #PURS ={ # "...
true
27a19a7591524f02ea777acfce48643690ddfc03
Python
changquanyou/visual_to_caption
/text_generation/data/utils.py
UTF-8
2,882
2.78125
3
[]
no_license
import codecs import numpy as np import os from gensim.models import Word2Vec class TextLoader(): def __init__(self,word2vec_model, data_dir, batch_size, seq_length, encoding='utf-8'): self.word2vec_model=word2vec_model self.data_dir = data_dir self.batch_size = batch_size self.se...
true
b47e0fc5c56d419920a82daa66bf308cfe1babe3
Python
aroio/web-api
/getConfigEntry
UTF-8
1,088
3.140625
3
[]
no_license
#!/usr/bin/env python3 import argparse import json import sys """ Function to get any value from database Example usage: `setConfigEntry configuration.network.hostname` would return the hostname of the network in BASH use: NAME=$(getConfigEntry configuration.network.hostname 2>&1) echo $NAME """ parser = argparse....
true
012feaca775484b2628fc6bf393643d4d41ab7fe
Python
bksim/chinese-translation
/OlderVersionofCode.py
UTF-8
16,441
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
#!/usr/bin/python # -*- coding: utf-8 -*- import nltk import sys reload(sys) sys.setdefaultencoding('utf8') def match_rule(pos): e2c_rules = {} # negative sentences # how can we put I can't eat or I cannot eat. #SVO e2c_rules['PRP','VBP','NN'] = ['PRP','VBP','NN'] #i eat rice: wo chi fan e2c_rules['PRP','VBZ'...
true
d131299414817e35a770930cee2c99b86c30aebd
Python
ajonaed/Python-DS
/Chapter 2/OOP/oopSuperCls.py/main.py
UTF-8
571
3.109375
3
[]
no_license
from creditcard import CreditCard from visacard import Visa def main(): #Creating an object of CreditCard first_customer = CreditCard('Abdullah Jonaed','Chase Bank','47896512345',5000) print(first_customer.get_limit()) # Creating an object of Visa visaCustomer = Visa('AJ', 'Capital One', '587964123'...
true
2dfc40f612ef9fdc8efffd4fdfb6c422cb9df9fc
Python
jdbennet2001/OverStreet
/tests/test_hash.py
UTF-8
1,423
3.015625
3
[]
no_license
from PIL import Image from os import path, listdir import imagehash import json ''' Can generate a hash signature for a comic cover ''' def test_hash(): test_path = path.dirname(path.realpath(__file__)) data_path = path.join(test_path, 'data/flash-91-cover.jpg') # Generate a hash for Flash 91 cover ...
true
e3053e248958962b7d7c238d2cda9ccb99aa4e16
Python
takumiw/AtCoder
/ABC025/B.py
UTF-8
293
3.125
3
[]
no_license
N, A, B = map(int, input().split()) ans = 0 for _ in range(N): s, d = input().split() if s == 'East': ans -= min(max(int(d), A), B) else: ans += min(max(int(d), A), B) if ans == 0: print(0) elif ans < 0: print('East', abs(ans)) else: print('West', ans)
true
3a6a3f3199df2c4cee971ad2f87e75b14848cb96
Python
dickwillingale/qsoft
/examples/Athena/plot_ladapt_modules.py
UTF-8
691
2.96875
3
[]
no_license
#!/usr/bin/env python # Plot the Athena large adaptor SPO module layout from __future__ import print_function import numpy as np import matplotlib.pylab as plt # Set up SPO modules from athena_ladapt_modules import * # Function to return the aperture of each module def rectangle(x,y,w,h,t): cth=np.cos(t) sth=np...
true
f3fd0684bc4685674386e6e143998601495f0c94
Python
NCRivera/COP1990-Introduction-to-Python-Programming
/Book_Exercises/Chapter_2/2_7_minutes.py
UTF-8
149
3.921875
4
[]
no_license
# Minutes in a year Calc. hour = 60 day = 24 year = 365 yearInMinutes = hour * day * year print("The number of minutes in a year is", yearInMinutes)
true
c1a70177d4c34b045175eccd10045e69bc239b18
Python
HongyuanWu/ukbb-1
/anna_code/gwas/collapse_highly_correlated_features.py
UTF-8
1,705
3
3
[]
no_license
import pandas as pd import argparse import pdb def parse_args(): parser=argparse.ArgumentParser(description="collapses pairs of highly correlated features by selecting one feature from the pair to remove") parser.add_argument("--corr_mat") parser.add_argument("--thresh",type=float) parser.add_argument(...
true
924a9a5c69b51c7ae2bfe14334f03a948350be65
Python
tdhris/HackBulgaria
/Week0/cat/solution.py
UTF-8
177
2.921875
3
[]
no_license
import sys def cat(file_name): file = open(file_name, "r") print(file.read()) file.close() def main(): cat(sys.argv[1]) if __name__ == '__main__': main()
true
d4717f16d7e2041a48e202afc7b15335e035942a
Python
kiyoxi2020/leetcode
/huawei/HJ6.py
UTF-8
645
3.984375
4
[]
no_license
''' HJ6 质数因子 输入描述: 输入一个long型整数 输出描述: 按照从小到大的顺序输出它的所有质数的因子,以空格隔开。最后一个数后面也要有空格。 示例1 输入: 180 输出: 2 2 3 3 5 ''' def compute(n, out): i = 2 while(i<n): if i*i>n: break if n%i == 0: out.append(i) return compute(n//i, out) i+=1 out.a...
true
ca629525d80ec177ff4409ea3e719fc4a10b1389
Python
Ilario96/italian-pharmacy-dw
/farmacistiXregione/main.py
UTF-8
952
2.859375
3
[]
no_license
import pandas as pd import numpy as np import sys from datetime import datetime import calendar def giveYear(obj): return obj.year def dateconverter(value): return datetime.strptime(value, '%d/%m/%Y') def toF(value): return float(value) def toInt(value): return int(value) def dayofyear(date) : ...
true
04fe36f2bb61aa72f745e53ebcc81956724c4071
Python
NikolaYolov/open-decentralised-voting
/voter-cli.py
UTF-8
1,703
2.984375
3
[]
no_license
import sys help = '''usage: <command> [<args>] <command> must be one of the following: sync vote status server dav sync [hostname=localhost] Fetches an election description from a URL. dav vote election vote Casts a vote in a specified election. dav status [election=all] Prin...
true
41ca5dc88035ea9095c06091e217346f76354663
Python
meelement/ESL
/SupervisedBasic/zipcode.py
UTF-8
2,162
3.21875
3
[ "MIT" ]
permissive
''' Created on 2014-5-4 @author: xiajie ''' import numpy as np import regression_classify import knn def loaddata(): train_data = np.genfromtxt('zip.train') test_data = np.genfromtxt('zip.test') return train_data, test_data def cookdata(data): dlist = data.tolist() cooked = [] for i in r...
true
a651905a19dae36ba2d5c93b09a2cae658552989
Python
2m/pyhocon
/pyhocon/config_tree.py
UTF-8
9,049
3.375
3
[ "Apache-2.0" ]
permissive
from collections import OrderedDict import re from pyhocon.exceptions import ConfigException, ConfigWrongTypeException, ConfigMissingException class ConfigTree(object): KEY_SEP = '.' def __init__(self): self._dictionary = OrderedDict() def _merge_config_tree(self, a, b): """Merge config ...
true
9d0e0dbfd5c3cee177dc64efd902a0322d7cc25d
Python
preetisaraswat17/hackerrank_python_challenges
/Collection_DefaultDict.py
UTF-8
1,860
4.03125
4
[]
no_license
#In this challenge, you will be given integers,n and m . There are n words, which might repeat, in word group A. There are m words #belonging to word group B. For each m words, check whether the word has appeared in group A or not. Print the indices of each occurrence #of m in group A. If it does not appear, print ...
true
5371c9b965ba200c9d4db7ca22c09de1d6b861a0
Python
zaldeg/book
/10/10-11.py
UTF-8
188
3.015625
3
[]
no_license
import json favorite_number = int(input('Enter your favorite number\n')) filename = 'files/favorite_number.json' with open(filename, 'w') as f_obj: json.dump(favorite_number, f_obj)
true
c4b132f08e50f9117cd4159bc5ec7cbdf25f9e03
Python
JaeGyu/PythonEx_1
/20171227_4.py
UTF-8
310
3
3
[ "MIT" ]
permissive
import os if not(os.path.exists("sampleForFile.txt")): print("존재안함") else: print("존재함") f = open("sampleForFile.txt") for data in f: try: (role, line_spoken) = data.split(":") print(role,line_spoken,end="") except ValueError: print("오류군!") print()
true
7c5f41102c50ae2ca7032d43c4612c5341e8b160
Python
dsparrow27/slither
/slither/plugins/datatypes/generic.py
UTF-8
3,202
2.921875
3
[]
no_license
from slither.core import types def isIteratable(obj): try: for i in iter(obj): return True except TypeError: return False class FloatType(types.DataType): Type = float def __add__(self, other): return self.__class__(self._value + other.value()) def __float__...
true
6e533089bda7d9f4e7d57c327f50a68d891261b0
Python
JustForkin/Programming
/Python/PythonSimple/src/SpellChecker.py
UTF-8
989
4.375
4
[]
no_license
''' Created on May 11, 2011 @author: Michael ''' class SpellChecker: #Reads in a list of words from Dictionary.txt and "spell-checks" user-inputted words def spellCheck(self): myFile = open("Dictionary", 'r') wordList = myFile.readlines() for i in range(0, len(wordList), 1): ...
true
de372df1e0f3ed3ae6692b2d51dcb3106edd7303
Python
oatley/space
/doom.py
UTF-8
2,136
2.703125
3
[]
no_license
#!/usr/bin/env python import pyglet from game import resources, load, player import random from pyglet import clock # Main window game_window = pyglet.window.Window(800, 600, vsync=True) # Batches main_batch = pyglet.graphics.Batch() # Labels #score_label = pyglet.text.Label(text='Score: 0', x=10, y=575, batch=main_...
true
62f1daf37273a39dae2bee14ab976d1912f32dc9
Python
Theodor7/theosMastermind
/mastermind.py
UTF-8
13,365
3.25
3
[]
no_license
import pygame from random import randint, choice from os import path, chdir from itertools import product pygame.init() background = (158,98,61) brown0 = (132,73,39) brown1 = (114,63,33) brown2 = (165,108,74) red = (255,0,0) green = (0,255,0) blue = (0,0,255) yellow = (255,255,0) magenta = (255,0,255) cyan = (0,255,...
true
d3d51399b204ad899a5bdcb0af2eae4f7bfff53b
Python
byssup/algorithm-old
/kmp/kmp.py
UTF-8
701
2.890625
3
[]
no_license
def get_slow_pi(n): m = len(n) pi = [0 for _ in range(m)] for begin in range(1, m): for i in range(m - begin): if n[begin + i] != n[i]: break pi[begin + i] = max(pi[begin + i], i + 1) return pi def get_fast_pi(n): m = len(n) pi = [0 for _ in ra...
true
feb275692852895dda38989803ede0c8e6ff9aa4
Python
Charlie-Robot/file-mover
/file_parser_tests.py
UTF-8
29,175
2.90625
3
[]
no_license
import unittest, os, tempfile, shutil from time import gmtime, strftime from file_parser import * class Test(unittest.TestCase): def setUp(self): #Testfiles self.IMG = 'testImage.JPG' self.TXT = 'testText.txt' self.BMP = 'testBMP.bmp' #Define Directorie...
true
cbccd49dcc188c58b5e72da9f008e758c3ffb8a4
Python
mbreyes/spikelearn
/spikelearn/measures/univariate.py
UTF-8
5,437
2.96875
3
[ "MIT" ]
permissive
import numpy as np import pandas as pd from scipy.stats import pearsonr from scipy.stats import norm def bracketing(arr, border_size=1, range=None): """ A simplified measure of 'U-shapeness'. Negative values imply inverted U. Mean values at center subtracted from mean border values. Parameters ---...
true
a10ea2f546b1c56f0e96cc16b850ce6cda524ec1
Python
JTaeger/graphio
/graphio/objects/relationshipset.py
UTF-8
9,677
2.515625
3
[ "Apache-2.0" ]
permissive
from uuid import uuid4 import logging import json from graphio.objects.relationship import Relationship from graphio import defaults from graphio.queries import query_create_rels_unwind, query_merge_rels_unwind from graphio.queries.query_parameters import params_create_rels_unwind_from_objects from graphio.objects.hel...
true
804a2b42602cee349d0724ecc0b57aa86fb21101
Python
nijatmursali/sign-language
/main.py
UTF-8
4,626
3.203125
3
[ "Apache-2.0" ]
permissive
import tkinter as tk import speech_recognition as sr from PIL import Image import webbrowser import os import pathlib import nltk import bs4 import requests from nltk.tokenize import word_tokenize from nltk.stem import PorterStemmer, WordNetLemmatizer from nltk.corpus import stopwords #from re import search window = t...
true
9b8d2a01589cc03af0375eac85987f34e19232a6
Python
adipixel/conding-questions
/DataStructures/Tree/binary_tree_from_inorder_preorder.py
UTF-8
1,372
3.375
3
[]
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: def reconstructTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] :rty...
true
94097a9ccf0aa6e9d773559ea1907a87ec8cf621
Python
shivashuklabbk123/sum-of-array-in-python
/sum_of_array.py
UTF-8
331
4.1875
4
[]
no_license
# Python 3 code to find sum # of elements in given array # driver function arr = [] # input values to list arr = [12, 3, 4, 15] # sum() is an inbuilt function in python that adds # all the elements in list,set and tuples and returns # the value ans = large(arr) # display sum print ('Sum of the array is...
true
55c63adfe258cfe52c8329602783d71000986e7f
Python
anantkaushik/Competitive_Programming
/Python/GeeksforGeeks/minimum-element-in-bst.py
UTF-8
2,116
4.46875
4
[]
no_license
""" Problem Link: https://practice.geeksforgeeks.org/problems/minimum-element-in-bst/1 Given an array of size N which represents the elements to be inserted into BST (considering first element as root). The task is to find the minimum element in this given BST. If the tree is empty, there is no minimum elemnt, so pr...
true
f5e9e10249e0065c429f87ac9b20d97161bd7075
Python
DRC-AI/code-wars
/first_non_repeating.py
UTF-8
849
4.5625
5
[]
no_license
#Write a function named first_non_repeating_letter that takes a string input, and returns the first character that is not repeated anywhere in the string. #For example, if given the input 'stress', the function should return 't', since the letter t only occurs once in the string, and occurs first in the string. #As a...
true
7490485da847ffa75f45a43e8c3d91582d86b819
Python
FelixKleineBoesing/pyFeatSel
/pyFeatSel/misc/Helpers.py
UTF-8
2,174
3.171875
3
[ "MIT" ]
permissive
import pandas as pd import numpy as np from itertools import chain, combinations def create_k_fold_indices(len_data: int, k: int): ''' custom function to create k fold subsets :param len_data: number of observations in data :param k: number of folds :return: return list of dictionaries which conta...
true
4c8aca439a4bb33666a26348e92f7a055f944fe6
Python
MuffinAmor/timmy
/lib/func.py
UTF-8
583
3.65625
4
[]
no_license
from time import time def time_calc(start, now): sekunden = now - round(time() - start) if sekunden < 60: return str(sekunden) + " seconds" elif sekunden < 3600: minutes = sekunden // 60 seconds = sekunden - 60 * minutes return str(minutes) + " minutes and " + str(seconds) ...
true
54b2fc82ce0131fbb2f054f03872c1fd4ef0800d
Python
t3rmin4t0r/igbin.py
/igbin.py
UTF-8
4,912
2.6875
3
[]
no_license
import struct class BinaryReader(object): __slots__ = ["stream"] def __init__(self, stream): self.stream = stream # TODO build a bufferred stream def read(self, count): buf = self.stream.read(count) return buf def read8(self): return self.unpack(1,"B") def read16(self): return self.unpack(2, "!H") d...
true
f4131ca2330898cde426414ddf252d2c7a4a159c
Python
maxdavid/Graphs
/projects/ancestor/ancestor.py
UTF-8
520
3.375
3
[]
no_license
from graph import Graph def earliest_ancestor(ancestors, starting_node): graph = Graph() for member in ancestors: graph.add_vertex(member[0]) graph.add_vertex(member[1]) for vertex in ancestors: graph.add_edge(*vertex) max_path = [] for vertex in ancestors: path =...
true
6f7db1ac27a8ea159ae01a0efe325d4c086c0c02
Python
QuantumFractal/hackisu-2017-nucleus
/point-cloud-stuff/depth_to_point.py
UTF-8
1,595
2.546875
3
[ "MIT" ]
permissive
""" Converts a depth image to a point cloud """ from PIL import Image import numpy as np import pcl #from pcl import registration def main(): img = Image.open("out.png") #img = Image.open("images/capture745d.jpg") depth = np.array(img) print(depth[2][2]) np_pc = depth_to_cl...
true
b2bb5a9ffa260554c82b9a65bcdd8cfd09ab3a17
Python
grahamaloo/cse415
/a4/AStar.py
UTF-8
3,261
3.1875
3
[]
no_license
'''William Menten-Weil wtmenten CSE 415, Spring 2017, University of Washington Instructor: S. Tanimoto. Assignment 3 Part II. 3. A* ''' # Astar.py, April 2017 # Based on ItrDFS.py, Ver 0.3, April 11, 2017. # A* Search of a problem space. # The Problem should be given in a separate Python # file using the "QUIET" fil...
true
e628c5df230c4487595549cd5ace1cc9c10341dd
Python
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_135/2231.py
UTF-8
758
3.09375
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): n = int(raw_input()) for i in range(n): a1 = int(raw_input()) m1 = [set([int(x) for x in raw_input().split()]) for j in range(4)] a2 = int(raw_input()) m2 = [set([int(x) for x in raw_input().split()]) for j in range(4)] ...
true
45f7f6af0ea418662ff48dbc1cfae69e40bffee2
Python
osalpekar/Blackjack
/game.py
UTF-8
2,533
3.984375
4
[]
no_license
import sys from player import * def play(): game_over = False p1_turn = True #creating 2 player objects player1 = Player('Player 1') player2 = Player('Player 2') #print out rules print('\n\n') print('Welcome to BlackJack!') print('Both players will be dealt 2 cards each to start off') print('After tha...
true
15a53b410c3033ad59e000e257aa6f7e9be3f43f
Python
sebprince/production-tools
/python/config/ConfigException.py
UTF-8
190
3.0625
3
[ "MIT" ]
permissive
class ConfigException(Exception): """Specialized exception for configuration classes""" def __init__(self, message): super(ConfigException, self).__init__(message)
true
eef7ace5ac6c5640045813763418dfbe84c3d08b
Python
ikejs/playlistr
/app.py
UTF-8
5,182
2.546875
3
[]
no_license
import os from flask import Flask, render_template, request, redirect, url_for from pymongo import MongoClient from bson.objectid import ObjectId import urllib.parse as urlparse from datetime import datetime app = Flask(__name__) host = os.environ.get('MONGODB_URI', 'mongodb://localhost:27017/Playlister') client = Mo...
true
79170cc29964e90fe7f79832e61f7f509d0776ad
Python
Ciroye/multilingual_kws
/label_directory.py
UTF-8
2,277
2.578125
3
[]
no_license
import glob import sys import tty import termios from pathlib import Path import csv import os import pydub import pydub.playback import pydub.effects class _GetchUnix: """https://stackoverflow.com/a/510364""" def __call__(self): fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) ...
true
944609c6fb269be13ae19b73df004a7b67e4636f
Python
MrYuan123/Web-Crawler-Repository
/pmmp/data_judge.py
UTF-8
3,331
2.953125
3
[]
no_license
#!/usr/bin/env python # -*-coding:utf8 -*- import csv, pymysql,traceback def get_urls(): # get urls from csv file mylist = list() with open("disease_data.csv","r") as f: reader = csv.reader(f) for item in reader: temp = list() temp.append(item[1]) # name ...
true
f7972e65c75b11004011d8384347bcd9c4124a2f
Python
prithvi-kam/startercode-fall2021
/hw3/faircount.py
UTF-8
757
3.375
3
[]
no_license
class WordCount: def mapper_init(self): self.cache = {} def mapper(self, key, line): for word in line: self.cache[word] += 1 if( self.cache > len(self.cache)): for w in self.cache: yield w, self.cache[w] self.cache.cl...
true
62c0bb68914a974889c86ff4e5f04ddd612a346c
Python
mikeselezniov/python-21v
/unit_04/18.py
UTF-8
462
3.546875
4
[]
no_license
a_set = {1,2,3,11,44,4,7,9} b_set = {21,1,4,11,2,23,111,744,48,79,9} print(a_set) print(b_set) c_set = a_set.symmetric_difference(b_set) print(len(c_set)) print(c_set) d_set = b_set.symmetric_difference(a_set) print(len(d_set)) print(d_set) if c_set == d_set: print('symmetric') if b_set.union(a_set) == a_set.u...
true
b739b0307f1804fa7c02fc5ec351be80e9e847c8
Python
daniel-reich/ubiquitous-fiesta
/ojBNREQrg7EW9ZzYx_19.py
UTF-8
535
3.1875
3
[]
no_license
import math def count_eatable_chocolates(total_money, cost_of_one_chocolate): m=total_money a,b='','' c=cost_of_one_chocolate for i in m: if i.isnumeric(): a+=str(i) for i in c: if i.isnumeric(): b+=str(i) if '-' in i: b+='-' if in...
true
ad3021d3732469705de2a5715ba2709246a7c3df
Python
vanderson-henrique/trybe-exercises
/COMPUTER-SCIENCE/BLOCO_37/37_3/exercicios/exercicio2_merge_sort.py
UTF-8
1,860
4.15625
4
[]
no_license
def merge_sort(array): # caso base: se já atingiu a menor porção (1) if len(array) <= 1: # retorne o array return array # calculo do pivot: índice que indica onde o array será particionado # no caso, metade mid = len(array) // 2 # para cada metade do array # chama a função me...
true
9ba97dd6d23ac4007173e10a9672f1448c7429f7
Python
shilpiBose29/CIS519-Project
/All_reviews/city_reviews/merge_all_reviews.py
UTF-8
1,339
3.171875
3
[]
no_license
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Nov 23 09:05:01 2017 @author: arranzignacio """ import pandas as pd def concatenate_all_reviews(cities): reviews = [] for i in range(len(cities)): review = cities[i]+"-reviews.csv" reviews.append(review) he...
true
a4e8b86ba90900c39e60a447abd33168102fe473
Python
Ansalemon/proyecto_big_data
/punto_6/mapper2.py
UTF-8
122
2.953125
3
[]
no_license
import sys a=[] for line in sys.stdin: words = line.split('\t') print(words[0].replace("\n","")+"\t"+words[1])
true
3ac961d528f8721b43f4b56dc7a210bbd8fa74d7
Python
prashant9316/Web-Scraping----Selenium
/Web Scraping with selenium.py
UTF-8
1,483
2.96875
3
[]
no_license
# Web Scraping with selenium # Import libraries from selenium import webdriver import pandas as pd # Accessing the website driver = webdriver.Chrome('C:/Users/bandi/Desktop/Text Analytics/TA Session/chromedriver_win32/chromedriver') driver.get('https://forums.edmunds.com/discussion/2864/general/x/entry-level-...
true
0ecac2c0bbb100f36ec06d46e3759cb6a9bc3daa
Python
davidgardner11/p3_demo
/launch.py
UTF-8
2,880
2.9375
3
[ "MIT" ]
permissive
import PySimpleGUIWeb as sg from random import randint import numpy as np from time import sleep from utils import Board while True: h = 10 w = 10 board = Board(w, h) game_lost = False previous_display = board.display.copy() exited = False mines = board.num_mines mode_on = ('black','gre...
true
358cd227b0ee54787cae3f934b9bbb3ff5a3ee75
Python
okiljon85/python_lessons
/6.list_bilan_ishlash.py
UTF-8
2,418
2.703125
3
[]
no_license
# cars = ['bmw', 'mercedes-benz', 'volvo', 'genetal motors', 'tesla', 'audi'] # # cars.sort() # # print(cars) # # cars.sort(reverse=True) # # print(sorted(cars, reverse=True)) # sonlar = [12, 45, 23, 56, 998, 1, -5, -7.2] # print(sorted(sonlar)) # print(sonlar) # sonlar.sort() # print(sonlar) # sonlar.sort(reverse=Tru...
true
9069f3c1514d0db9f1a41c0507a695116710b75d
Python
bzerath/Miscellaneous
/Gwenaelle/exam_28_02/exercices_strings.py
UTF-8
4,708
4.1875
4
[]
no_license
def get(mot: str, i: int): """ Return element n°`i` in string `mot` """ if i > len(mot) or i <= 0: print("Erreur !") else: return mot[i-1] def sub(s: str, position: int, length: int): """ Return substring from element `position` of length `length` """ # Verify that substring will ...
true
d8c5c04b13c46dd6a47ea4e8858fa22775a2f358
Python
tcflanagan/transport
/src/core/graph.py
UTF-8
11,422
3.28125
3
[]
no_license
"""A container for graphical data. A `Graph` is an object to facilitate interactions between an `Experiment` and an actual GUI implementation of graphing. This module provides the following classes: Graph: An interface for passing data from an experiment to a visual graph. AbstractGraphManager: A...
true
20158697c704f483bcd7c32157134fb4485e5a19
Python
patrickoreilly20/patrickoreilly-python
/Unit3Lab /Unit3Lab.py
UTF-8
1,369
4.40625
4
[]
no_license
def schoolSub() : print('I go to Bellarmine') print('My favorite Subject is Python') schoolSub() def schoolLen() : years = input('What year are you in school? - ') yearsSchool = (int(years) - 1) print('you have been in school ' +str(yearsSchool) + ' years') #schoolLen() #def homeBase() : #h...
true
56be3c91e8b1d18fbfbffe744c3448b51708ea0c
Python
nbush257/VG3D
/plotting/plot_pillow_canonical_angles.py
UTF-8
3,707
2.53125
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt import pandas as pd import os import seaborn as sns import plotVG3D figsize = plotVG3D.set_fig_style()[1] p_load = os.path.join(os.environ['BOX_PATH'],r'__VG3D\_deflection_trials\_NEO\pillowX') p_results = os.path.join(os.environ['BOX_PATH'],r'__VG3D\_deflect...
true
7533c621fbac50a6448300a210d6a5d0e3471951
Python
gsengupta2810/Data-Analysis-with-Python
/Regression/polynomial_reg.py
UTF-8
3,825
2.90625
3
[]
no_license
import numpy as np import pandas as pd import matplotlib.pyplot as plt import scipy.stats import seaborn import statsmodels.formula.api as smf import statsmodels.stats.multicomp as multi import statsmodels.api as sm import matplotlib.figure from pylab import * df=pd.read_csv("~/datasets/gapminder.csv") df["urbanrat...
true
7e4a4593734de14e97ce860e421edc891d6f64a0
Python
AKumar-2/hacker-cup-2020-Qualification-Round-Solutions-Python
/alchemy_source_code.py
UTF-8
455
3.75
4
[]
no_license
#input for no of cases T = int(input()) for i in range (1, T+1): #input for shards and their arrangements no_of_shards = int(input()) shards_arrangement = input() #Putting a counter count = 0 for j in shards_arrangement: if j == "A": count += 1 else: ...
true
091ea6a25ceb4735a65b0cc6b7a0e7adc787bf4e
Python
humbertoperdomo/practices
/python/AutomateTheBoringStuffWithPython/PartI/Chapter06/bullet_point_adder.py
UTF-8
439
3.34375
3
[]
no_license
#!/usr/bin/python3 # bullet_point_adder.py """Adds Wikipedia bullet points to the start of each line of text on the clipboard. """ import pyperclip TEXT = pyperclip.paste() # Separate lines and add stars. LINES = TEXT.split('\n') for i, line in enumerate(LINES): # loop through all indexes in the "lines" list ...
true
401f2eb1471e6c728584c79314d09b306dbf68f3
Python
chrisroman/CloudComputing
/EdgeServer/src/test_scripts/test_reservations.py
UTF-8
741
2.59375
3
[]
no_license
import datetime import time import requests import json SERVER_URL = 'webalb-157542678.us-east-1.elb.amazonaws.com' RESERVATION_URL = "http://{}/api/v1/reservations/".format(SERVER_URL) def make_request(user_id): body = {"lot_id" : 1, "start_time": int(time.time()), "end_time": int(time.time()) ...
true
401f1694ec368298e66334823e80313a2bd6cc7f
Python
YutoUchimi/dotfiles_public
/.local/bin/video_resize
UTF-8
2,076
3.046875
3
[]
no_license
#!/usr/bin/env python import argparse import os import os.path as osp import shlex import shutil import subprocess def resize_video_with_scale(video_file, scale): base, ext = osp.splitext(video_file) out_file = base + '_x{scale}'.format(scale=scale) + ext cmd = 'ffmpeg -i {video_file} -vf ' \ '...
true
d5f88bca2beee19f5b1145eeffb3501c78aca977
Python
lifera/projecteuler
/19 Counting Sundays.py
UTF-8
1,071
4.0625
4
[]
no_license
''' You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twe...
true
4289e513669c1587e7a071a7b344968f8c9c17c0
Python
shun998/crawler2
/chap4/04.py
UTF-8
1,320
2.71875
3
[]
no_license
# -*- coding: utf-8 -*- # TODO 北京新发地爬虫 # @Date : 2021/7/11 12:57 # @Author : layman import requests from lxml import etree from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/9...
true
b37a09741858440e2038f46d786c96566e1a72dc
Python
robertvoinescu/PosDef
/PosDefRunIt.py
UTF-8
5,169
2.703125
3
[]
no_license
import numpy as np import pandas as pd import sys import logging def isit_corr(C,eigval): psd = True if np.linalg.norm(np.diag(C)-1)>1e-6: #print('STATUS: DIAGONALS ARE NOT 1!') psd = False if np.linalg.norm(.5*(C+C.T)-C)>1e-6: #print('STATUS: NOT SYMMETRIC!') psd = False ...
true
e8d0de2bd3a385baac1dcc4154f113de2cdf0a95
Python
songliwen940523/Deep-Learning-For-Image-Process
/TensorFlow_Classification/test_tensorflow_official_demo/model.py
UTF-8
907
2.671875
3
[ "Apache-2.0" ]
permissive
# -*- coding: UTF-8 -*- """ Author: LGD FileName: model DateTime: 2021/1/13 21:52 SoftWare: PyCharm """ from tensorflow.keras.layers import Dense, Flatten, Conv2D from tensorflow.keras import Model import tensorflow as tf tf.keras.backend.set_floatx('float64') class MyModel(Model): def __init__(sel...
true
1731a4a74412c8b614b7d4b1058563f8b09d65d2
Python
rohanmhetar/FakeMLv2
/interactive.py
UTF-8
2,235
3.28125
3
[]
no_license
#Imports necessary modules for the program to run import pandas from pandas import DataFrame from sklearn.feature_extraction.text import HashingVectorizer from sklearn.svm import LinearSVC import tkinter.simpledialog from graphics import graphics from sklearn.calibration import CalibratedClassifierCV import tkinter fro...
true
80c4cf8ca3164d29b31c9a5990c046431c121402
Python
matveyvarg/bankparser
/csvunifier/writer.py
UTF-8
1,823
3.109375
3
[]
no_license
import csv from typing import Iterable, Union from pathlib import Path from .utils import map_data class AbstarctWriter: """ Abstact Base Class for Unified output """ def __init__(self, pathfile: Union[str, Path], data: Iterable, ouput_format: dict = None, ): self.data = data self....
true
14ff64bbe6ad8c4c8438e84dca03b776305bd44a
Python
zhouwei713/data_analysis
/analyse_of_King_glory/all_hero_deal.py
UTF-8
2,994
2.765625
3
[]
no_license
# coding = utf-8 """ @author: zhou @time:2019/3/12 19:47 """ import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from sklearn.mixture import GaussianMixture from sklearn.preprocessing import StandardScaler from pyecharts.charts import Pie from collections import Counter plt.rcParams['font.sans-...
true
e3a8adec7ac8b7b01f4509744e09f7fc5a8b4816
Python
mixeract/my_scripts
/python/phone.py
UTF-8
669
3.828125
4
[]
no_license
digitLetters = {"2": 'abc', "3": 'def', "4": 'ghi', "5": 'jkl', "6": 'mno', "7": 'prs', "8": 'tuv', "9": 'wxy'} def getLetters(number): result = [] for digit in number: if digit in digitLetters: result.append(digitLetters[digit]) else: result.append(digit) return re...
true
2d19e24271d3c46099f97a244746a95491a76051
Python
lorenzomoulin/Programacao-Competitiva
/UVA/problem solving paradigms/completesearch/624-CD.py
UTF-8
525
2.8125
3
[]
no_license
import math def solve(cd, s): if cd == len(duration): return 0 npega = solve(cd + 1, s) #print(duration[cd]) if s - duration[cd] >= 0: pega = duration[cd] + solve(cd + 1, s - duration[cd]) return max(pega, npega) return npega while True: try: duration,...
true
02d157d817fe8f3a3d2ee3b3353abd640abdd62a
Python
PrinceB7/ADBNF-for-classification-and-regression
/abalone_age_prediction.py
UTF-8
2,437
2.828125
3
[]
no_license
import numpy as np np.random.seed(1337) # for reproducibility from sklearn.model_selection import train_test_split from sklearn.metrics.regression import r2_score, mean_squared_error from sklearn.preprocessing import StandardScaler, MinMaxScaler import pandas as pd import seaborn as sns import matplotlib.pyplot as pl...
true
dd2f99de3b3468432d5fab7db1e75aa290a171e8
Python
ArretVice/algorithms-and-data-structures
/selection_sort.py
UTF-8
1,127
3.8125
4
[]
no_license
import numpy as np from time import time def find_smallest(array): smallest_index = 0 smallest_item = array[0] for index, item in enumerate(array): if smallest_item > item: smallest_item = item smallest_index = index return smallest_index def selection_so...
true
3fa7e26eed3ae15f8cbe1eb38cb9294775e4549b
Python
willnight/PythonHomeWork
/task7_2.py
UTF-8
759
3.953125
4
[]
no_license
from abc import ABC, abstractmethod class Clothes(ABC): def __init__(self, size): self.size = size @property @abstractmethod def tissue_consumption(self): pass def __add__(self, other): return self.tissue_consumption + other.tissue_consumption class Coat(Clothes): ...
true
6c899f4bf5e3db99070f866c7d1a2888667dfc3d
Python
mhetrerajat/ds-challenge
/daily_coding_problem/problem_40.py
UTF-8
711
4.15625
4
[ "MIT" ]
permissive
""" This problem was asked by Google. Given an array of integers where every integer occurs three times except for one integer, which only occurs once, find and return the non-duplicated integer. For example, given [6, 1, 3, 3, 3, 6, 6], return 1. Given [13, 19, 13, 13], return 19. Do this in O(N) time and O(1) spac...
true
8d294eb71c94f36208149fcbea560887332fa3b4
Python
talonvoice/wav2train
/src/wpiece.py
UTF-8
4,560
2.609375
3
[ "MIT" ]
permissive
import argparse import os import sentencepiece as spm import sys def build_corpus(name, lists=(), corpora=()): words = set() if not lists and len(corpora) == 1: # fast path for using an existing text corpus with open(corpora[0], 'r') as f: for line in f: for word in ...
true
96bcf41e120cac4cc5ef1ddb75b5aeb48f471493
Python
Aanandi03/15Days-Python-Django-Summer-Internship
/Day_3/python_basic_program/ex6_factorial.py
UTF-8
204
4.15625
4
[]
no_license
# factorial of input number n = int(input('enter number: ')) def fact(n): if n == 1: return 1 f = n * fact(n - 1) return f ans = fact(n) print('Factorial of ',n,' is ',ans)
true
df082154356e376ff989d194ae2c0b7de1875153
Python
briancecile/tensorflow
/Part 2/basic-tensorflow-example.py
UTF-8
331
3.65625
4
[]
no_license
import tensorflow as tf first_string = tf.constant('Hello') second_string = tf.constant(' World') print('\nType of first_string') print (type(first_string)) combined_string = (first_string + second_string) print('\nType of combined_string') print (type(combined_string)) print('\nCombined String is:') print (combin...
true
e920882f25b9aec975f78431cdbd649f08a0a40b
Python
Sheikh2Imran/Data-structure-and-alogorithm
/9.bracket_balance.py
UTF-8
743
4
4
[]
no_license
''' Name : Parentheses, curly braces, square brackets balanced check using python's list Author, Md Imran Sheikh Dept. of CSE, JUST ''' def is_balanced(str): s = list() for ch in str: if ch == "(": s.append(ch) if ch == ")": if not s: ret...
true
5a01d679a221c2e0b60dab2fc1a4dfcbdfc759e9
Python
aidanohora/Python-Practicals
/p15p3b.py
UTF-8
624
4.5625
5
[]
no_license
def funct(n): """define a recursive function to take as its single argument an integer that is greater than or equal to one and print out that number of terms from the series displayed in practical 15 """ if n == 0: return 13 elif n == 1: return 8 else: ret...
true
0e19f0c6df3916802fb63d4aa721a3b3f64ef992
Python
PZawieja/public_samples
/sample_2/recipes.py
UTF-8
2,975
3.03125
3
[]
no_license
import pandas as pd import numpy as np import json import os import re from urllib.request import urlretrieve from pandas.io.json import json_normalize #package for flattening json in pandas df # pd.set_option('display.height', 1000) # pd.set_option('display.max_rows', 500) # pd.set_option('display.max_columns', 500) ...
true
d4057023ae27ae2ff0f7e760aacf57e92ef4b337
Python
molnarjani/appdaemon-apps
/apps/alarm.py
UTF-8
3,651
2.71875
3
[]
no_license
import appdaemon.plugins.hass.hassapi as hass # Alarm App # # Args: # - wakeup_time: time you want to wake up at from math import ceil from dateutil.parser import parse from dateutil.relativedelta import relativedelta from music_client import MusicClient class AlarmService(hass.Hass): """ Starts playing music ...
true
42be643e244e04ce91a2fd73eae628ca9d79fb00
Python
Eagerod/backup-toolkit
/tests/ext/games/test_games_manager.py
UTF-8
3,414
2.65625
3
[ "MIT" ]
permissive
from unittest import TestCase from backup.ext.games.game import Game from backup.ext.games.games_manager import GamesManager, GameNotFoundError THIS_MACHINE_SIMULATED_PLATFORM = 'some_platform' OTHER_MACHINE_SIMULATED_PLATFORM = 'some_other_platform' class GamesManagerTestCase(TestCase): @classmethod def s...
true
c59acc643ab81ed43d6dacc470b64c8fa03aa09f
Python
Proccyon/Irdis_Simulations
/IrdisPython/IrdapFunctions.py
UTF-8
7,259
2.984375
3
[]
no_license
#-----Header-----# #This file contains some relevant functions for bad pixel correction from Irdap. #The code will be used in Irdis and SCExAO calibration. #--/--Header--/--# #-----Imports-----# import numpy as np import scipy.stats as stats from scipy import ndimage #--/--Imports--/--# #-----Functions...
true