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
e3ac3e05db5148589805bdd985856c1b3d53511a
clickpn/final_proj
/sida_code/main.py
UTF-8
2,653
3.359375
3
[ "MIT" ]
permissive
from __future__ import division import pandas as pd import numpy as np import matplotlib.pyplot as plt from collections import Counter import operator import sys import visualizationTool as pievis from visualizationTool import * # DS-GA 1007 # Main program # Author: Sida Ye # need to modify """ This program was cre...
true
1af2c89a5d5f280a7e0ac20577b76206635107a1
Ajapai/advent_of_code_2020
/16_day/puzzle_2.py
UTF-8
1,431
2.96875
3
[]
no_license
#!/usr/bin/env python3 import math document = open('input').read().split("\n\n") rules = document[0].splitlines() my_ticket = document[1].splitlines()[1] rules_dict = { line.split(":")[0]:set( number for numbers in ( range(int(first), int(last) + 1) for first, last in ( ...
true
d852d6a5b6bbcdceaccee207f92e5dcd8d465f1f
lwd19861127/LeetCde-TopInterviewQuestions-Easy
/IntroToAlgorithms/Primes_gcd_lcm/sieve_of_eratosthenes.py
UTF-8
942
4.59375
5
[]
no_license
#!/usr/bin/python3 # The Sieve of Eratosthenes: To generate a list of prime numbers def sieve_of_eratosthenes(n): """ Create a boolean list prime[0...n] and initialize all entries as True. A value in prime[i] will finally be false if i is not a prime, else true. :param n: # of elements in List ...
true
3becfa7a97aa4751fc6835783cc3b4c975405e03
AllanCapistrano/debit-credit-mechanism
/services/file.py
UTF-8
3,073
3.265625
3
[]
no_license
import os from services.table import Table from services.calculateBalance import CalculateBalance DIRECTORY_NAME = "files" class File: def __writer__(self, fileName: str, text: str) -> None: """ Write text in the file Parameters ----------- fileName: :class:`str` Fil...
true
a9716144ea03801127882c8a33b0bc287f497d1d
aalokvsingh/email_python
/send_email_python.py
UTF-8
540
2.890625
3
[]
no_license
import smtplib reveiver = "YYYY@gmail.com" sender = "XXXXX@gmail.com" message = """From: XXXXXX <XXXXXXX@gmail.com> To: YYYY <YYYYY@gmail.com> Subject: SMTP e-mail test This is a test e-mail message. """ # creates SMTP session s = smtplib.SMTP('smtp.gmail.com',587) # start TLS for security s.starttls...
true
4a84f34b0954bab77bc842e5e02639aabb8a84bb
damianzradzica/Trening
/exercise_10.py
UTF-8
1,429
3.84375
4
[]
no_license
from random import randint listOfNumbers = [] class BankAccount(object): def __init__(self): self.__cash = 0 value = 100 for i in listOfNumbers: if i == value: value += 1 else: pass self.__number = value listOfNumbers...
true
9f9721e7fdc85c169de477e67733bdfab112ba80
saxenapranav9/AI-Trade-Bot
/stock-yahoo.py
UTF-8
2,503
2.578125
3
[]
no_license
def task(): from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait import time import os import shutil #to delete the exiting folder having old datasets dir_path = '/Users/pranavsaxena/Desktop/Python/Dissertation-Datasets' try: shutil.rmtree(dir_path) except OSError as ...
true
5e134f5fda684a84dc2a7032f22bc605c62e80d3
gsmnit/coding_for_interview
/python/binearysearch.py
UTF-8
511
3.5625
4
[ "MIT" ]
permissive
def bin_search(arr, num): x = len(arr) first = 0 last = x - 1 while(first +1 != last): #print(last) mid = (first + last) // 2 if arr[mid] == num: return True elif num > arr[mid]: first = mid else: last = mid if arr[0] == num...
true
810d419d9d7aba019321975bf56986d37455ca60
pijll/xxmaker
/xxmaker/gamepart/Map.py
UTF-8
4,897
2.90625
3
[ "MIT" ]
permissive
import Font from . import Hexag, Paper from Definitions import * import Colour from math import sqrt from graphics.cairo.Draw import LineStyle, TextStyle from graphics.cairo import Draw hexag_size = Hexag.hexag_size h = hexag_size / 2 s = hexag_size / sqrt(3) row_letters = [char for char in ".ABCDEFGHIJKLMNOPQRSTUVW...
true
1efa54e1820e8a2eba0d2a94648d5c32201e20fe
akshitha111/CSPP-1-assignments
/module 9/Functions and Objects Exercise-3/functions_and_objects_3.py
UTF-8
369
3.140625
3
[]
no_license
""" square """ def square(x_1): """ square """ return x_1*x_1 def apply_to_each(L, square): """ square """ return list(map(square, L)) def main(): """ square """ data = input() data = data.split(" ") list1 = [] for j in data: list1.append(int(j)) print(apply_to_each(list1...
true
5b854b741ecb7ad12dacb348494fc1a444363c2c
deliveree/psql-monitor-daemon
/test/modules/fake_client.py
UTF-8
1,051
2.703125
3
[]
no_license
import ssl import socket from json import dumps from time import sleep class FakeClient(): def __init__(self, conf, name=None): daemon_conf = conf["daemon"] self.deamon_port = daemon_conf["port"] self.deamon_host = daemon_conf["host"] self.name = name paths = conf["path"] ...
true
72c35321e4ae3f9e0e37e8d71cffe976da3a4435
xiaoluome/algorithm
/Week_01/id_3/bs/441/LeetCode_441_3_v1.py
UTF-8
140
2.890625
3
[]
no_license
def arrange_coins(n): if n <= 0: return 0 s = 0 k = 0 while s <= n: k += 1 s += k return k - 1
true
2b00da79abe2aae4c34a805aeedfffdbff8defb7
IvayloSavov/Fundamentals
/data_types_and_variables_exercises/triple_of_latin_letters_2.py
UTF-8
166
3.5
4
[]
no_license
n = int(input()) for fr in range(0, n): for scnd in range(0, n): for third in range(0, n): print(chr(97 + fr) + chr(97+scnd) + chr(97+third))
true
4aae60a28b48716f8a906901c6338c7695f6de7d
Saiber440/DIGI
/MAIN_FILES/main.py
UTF-8
4,991
2.5625
3
[]
no_license
import pyttsx3 from SEARCH_FUNCTIONS.YouTube import YouTubeSearch from CORE.TakeCommand import TakeCommand from BASIC_FUNCTIONALITIES.WishMe import WishMe from BASIC_FUNCTIONALITIES.SendEmail import tryout, exception from BASIC_FUNCTIONALITIES.DateAndTime import datetime, date, time from BASIC_FUNCTIONALITIES.cpu impor...
true
2805f63d2ad9f4ab5c38f3ae1948c6c9c65ee053
MHagan3/wordcount-project
/wordcount/views.py
UTF-8
1,342
2.921875
3
[]
no_license
from django.http import HttpResponse from django.shortcuts import render import operator def hello(request): return render(request, 'hello.html') # The HttpResponse function will send a page with the desired string def home(request): return render(request, 'home.html') # The render function will send the user...
true
24abdb66d35ef1a9c786ef090aba1424b83c5361
abeldavid/spaceggs
/spaceggs/filters/kf.py
UTF-8
3,448
3.046875
3
[ "MIT" ]
permissive
import numpy as np class KF: def __init__(self, n, m, k): ''' Inputs: - _n: number of observed and hidden state variables - _m: number of control inputs - _k: number sensors ''' self._n = n self._m = m self._k = k ''' ...
true
35597605f2cefe6665b177a1b8450eebdf3c92a4
minerva-ml/open-solution-data-science-bowl-2018
/src/postprocessing.py
UTF-8
7,387
2.6875
3
[ "MIT" ]
permissive
import numpy as np import skimage.morphology as morph from scipy import ndimage as ndi from scipy.stats import itemfreq from skimage.transform import resize from skimage.filters import threshold_otsu from .utils import relabel, get_crop_pad_sequence def resize_image(image, target_size): """Resize image to target...
true
4d20e9fd3c9513092566f874296bc24eb976066f
dkaisers/Project-Euler
/008/8.py
UTF-8
246
3.015625
3
[ "Unlicense" ]
permissive
import operator import functools number = str(open("number.txt", "r").read()) numbers = [] for i in range(0, len(number)-13): n = [int(i) for i in number[i:i+13]] numbers.append(functools.reduce(operator.mul, n, 1)) print(max(numbers))
true
577f144b3d3af04a0bdbbce013b3f8aaf2429107
ssviridov/kdd-didi
/simulator/driver.py
UTF-8
11,477
3.03125
3
[]
no_license
import itertools import random import numpy as np from datetime import datetime as dt import hashlib import logging logger = logging.getLogger(__name__) class DriverException(Exception): pass class DriversCollectionException(Exception): pass class DriversCollection(list): randomizer = random.Random()...
true
628177020c4c0c347af24f045d7fb83c5ca564c1
d4rkn3bula/Python
/Decode64/decode64.py
UTF-8
987
3.46875
3
[]
no_license
#!/usr/bin/python3 # simple script to pass a text file with a list of base64 strings to decode # imported modules import sys, os, base64 # function for command line argument to specify a file # example: python decode64.py test_data.txt def inputfile(): filepath = sys.argv[1] if not os.path.isfile(filepath): print("...
true
ff5cc56f9bd62a25ce07403a18abad3449a205e5
ishaansharma/blind-75-python
/tests/test_problem30.py
UTF-8
207
2.78125
3
[ "MIT" ]
permissive
import unittest from problems.problem30 import solution class Test(unittest.TestCase): def test(self): self.assertEqual(solution([7, 1, 5, 3, 6, 4]), 5) self.assertEqual(solution([7, 6, 4, 3, 1]), 0)
true
cb4e846720a67edffa7e2b817e0e3f7a34d42e5f
dborzov/practicin
/41-house-robber/sol.py
UTF-8
1,035
3.234375
3
[ "MIT" ]
permissive
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def rob(self, root): """ :type root: TreeNode :rtype: int """ memoize = {} ...
true
2f191048a653160e12765d39b2c953b361f9df44
stjordanis/adventofcode2020-1
/day10.py
UTF-8
1,614
3.5625
4
[]
no_license
# https://adventofcode.com/2020/day/10 import pytest def numbers(fname): with open(fname) as f: return list(map(int, f)) def part1(fname): nums = sorted(numbers(fname)) jolts = 0 diff1 = diff3 = 0 for num in nums: if num - jolts == 1: diff1 += 1 elif num - jolt...
true
7919ac9851b4b76eb746d90d5c9c62d6403afd21
niyasimonc/Exercism
/leap.py
UTF-8
352
3.421875
3
[]
no_license
def main(): year=raw_input("Enter the year ") if int(year)%4 ==0: if int(year)%100==0: if int(year)%400==0: print 'leap year' else: print 'not leap year' else: print 'leap year' else: print 'not leap year' if _...
true
aa98d8d7944733c8f2b6e3aee09ac336eb9a4128
weller0987/datascience-python
/04-fn1/test_newmath.py
UTF-8
120
2.828125
3
[]
no_license
from newmath import * def test_add_pos(): assert add(3, 4) == 7 def test_add_neg(): assert add(3, -4) == -1
true
f70b95acf6ea9256a32a6e417fb709fe2e251b4e
yykaii/digital-image-processing
/rotation1.py
UTF-8
3,163
3.09375
3
[]
no_license
# import the necessary packages import numpy as np import cv2 import math #先做正常旋转判断,再通过判断长宽比判断是否需要旋转90度 isShowImage = True def showCV2Image(title, img): cv2.namedWindow(title, cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # 调整窗口大小并保持比例 cv2.imshow(title, img) cv2.waitKey(0) image = cv2.imread('0.png') if isS...
true
0da83892dfe5ea92ec9fd9ec2f132cfb0631ffe0
Himanshusajwan001/codezen
/Balanced_Brackets.py
UTF-8
1,086
4.28125
4
[]
no_license
""" Given a string expression, check if brackets present in the expression are balanced or not. Brackets are balanced if the bracket which opens last, closes first. You need to return true if it is balanced, false otherwise. Note: This problem was asked in initial rounds in Facebook Sample Input 1 : { a + [ b+ (c + d)]...
true
269ae16d577f8ea6dc3f9b5091a213ed7a654747
sunnyyy/algorithms_contest
/unsorted/solutions/reverser/reverser.py
UTF-8
2,126
3.328125
3
[]
no_license
# Solution to the Word Order Reverser Problem # # File: reverser.py # Authors: Bob Walton (walton@seas.harvard.edu) # Date: Wed Sep 28 06:32:44 EDT 2016 # # The authors have placed this program in the public # domain; they make no warranty and accept no liability # for this program. # reverser [-pattern] [debug] # #...
true
8091d4bc2c67f3f1fda3d0f938e332062c6f8a5f
AlimbekovE/hackerrank.com
/String/string_validators.py
UTF-8
221
3.234375
3
[]
no_license
line = str(input()) print (any(i.isalnum() for i in line)) print (any(i.isalpha() for i in line)) print (any(i.isdigit() for i in line)) print (any(i.islower() for i in line)) print (any(i.isupper() for i in line))
true
944ea96e549544cd06a8da9fee7913288204ac9a
LeetCodeSolution/DuplicateNumber
/solution1.py
UTF-8
330
3.40625
3
[]
no_license
class Solution(): def duplications(self, array): array = sorted(array) print(array) last = array[0] for n in array[1:]: if n == last: yield n last = n s = Solution() array = [2, 3, 1, 0, 2, 5, 3] result = list(s.duplications(array)) prin...
true
c42571bade2a3081c429c86d07263a5b8231493f
patallen/Udacity_Tournament-Results
/tournament.py
UTF-8
2,455
3.390625
3
[]
no_license
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2, bleach def connect(): """Connect to the PostgreSQL database. Returns a database connection.""" db = psycopg2.connect("dbname=tournament") cursor = db.cursor(); return db, cursor def deleteMatc...
true
fe231a369f25583259a85f89ca2471d9da766b82
Ghali-Benbernou/facturation-py
/cp.py
UTF-8
246
2.609375
3
[]
no_license
class Client(object): def __init__(self, nom, ville): self.nom = nom self.ville = ville class Prod(object): def __init__(self, nom, prix, quant): self.nom = nom self.prix = prix self.quant = quant
true
fd4b11792df660b50391c9d467c0205846506b51
AliMakiGmail/SimpleFWI
/optimization.py
UTF-8
2,529
2.671875
3
[ "MIT" ]
permissive
import numpy as np def BBiter(misfitfunc, m0, tol=1.e-6, maxit=5, bounds=None): mk = m0.copy() fk, gk, _ = misfitfunc.evaluate(mk) tk = np.linalg.norm(gk) history = [] print(f"Optimization starts!") for k in range(1, maxit + 1): # update sk = -gk / tk mk += sk ...
true
c4fcea40eb766af22c3888d1a200c49f7fba93b1
tabatsky/imctools
/imctools/io/txtparserbase.py
UTF-8
4,933
2.609375
3
[ "MIT" ]
permissive
from __future__ import with_statement, division import csv from imctools.io.imcacquisitionbase import ImcAcquisitionBase from imctools.io.abstractparserbase import AbstractParserBase import array TXT_FILENDING='.txt' class TxtParserBase(AbstractParserBase): """ Loads and strores an IMC .txt file """ ...
true
2c9b6f8f86f5b9b9faab9575cc2ef2ea9b7e60b7
LaGipeR/lab5
/classes.py
UTF-8
5,532
3.6875
4
[]
no_license
import re class Subject: def __init__(self, subject_name: str, exam_mark: int, mark: int, semester_mark: int, sum_mark: int): if not re.fullmatch(r'[-\w" ]{3,62}', subject_name): raise ValueError("Subject name is not str or contains characters not from set {letters, -, space, \"}") sel...
true
4640e3e63afc3e56db92477035cff82211113ec6
ElectroJuan/Par-o-impar
/par o impar.py
UTF-8
728
4.40625
4
[]
no_license
#Par o impar #Lo primero que vamos a realizar es dar la bienvenida preguntando un número entre 1 y 1000 #Cuando el usuario proporciona el número, comprobaremos si es par o impar y después imprimimos el mensaje con el resultado. #Ejemplo: #Mensaje que se muestra: ¿En qué número estás pensando? #Entrada: 25 #...
true
1f16127bbb634cab48fb3a9e8b097b3b2b8d73c0
LanaSina/prednet_gol
/prednet/convert_checkpoints.py
UTF-8
1,017
2.53125
3
[ "MIT" ]
permissive
''' Extract single GPU model weights from a checkpoint of a multi-gpu model. ''' import os from keras import backend as K from keras.models import model_from_json from keras.utils import multi_gpu_model from prednet import PredNet from datasets_settings.kitti_settings import * num_gpus = 4 # Number of GPUs the mode...
true
94e189ff589510eae2da3a6954dd80ab58bf258d
apurvTri123/calculadora-tk
/app/calculadora.py
UTF-8
11,761
3.34375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- # @autor: Matheus Felipe # @github: github.com/matheusfelipeog # Builtins import tkinter as tk import platform from functools import partial # Módulos próprios from app.calculador import Calculador import app.style as style class Calculadora(object): """Classe para criação do layout da ...
true
68c7520faf8e78ba4445b06473cc3b9c5678423c
trifectafantasy/preliminary_project
/python/basketball_acquisitions.py
UTF-8
5,038
2.640625
3
[]
no_license
##### IMPORT LIBRARIES ###### from pymongo import MongoClient import subprocess import time import sys from collections import OrderedDict ##### DEFINE FUNCTIONS ##### # function that combines data from all matchup collections for total season trifecta owner matchup standings def acquisitionValue(db, sport, year, own...
true
81004ea82b0b3be12e19a659461d6d3f697b60fd
deepVector/slyr
/slyr/parser/stream.py
UTF-8
7,134
2.953125
3
[]
no_license
#!/usr/bin/env python """ Binary stream representing persistent objects """ from struct import unpack, error import binascii from typing import Optional from slyr.parser.object_registry import ObjectRegistry, REGISTRY from slyr.parser.object import Object from slyr.parser.exceptions import UnsupportedVersionException,...
true
26032aca8360ef2bd9e7d70d1cd47acf6f0667db
Threesome2/ML
/knn/knn3.py
UTF-8
1,755
3.015625
3
[]
no_license
# knn3.py filename=(u"D:\gitcode\Machine-learning-in-action\k-Nearest Neighbor\datingTestSet2.txt") #load data setfrom file import numpy as np def data_read(filename): fr = open(filename,'r') data_features = [] data_labels = [] while True: # print(fr.readline()) a=fr.readl...
true
eb28f474ac03b32b5c565ff342922d0c976a3fc1
yeshantharaka/machine-learning-and-data-mining
/Lab1/Dataset/minima.py
UTF-8
413
3.28125
3
[]
no_license
import numpy as np import csv with open('bonusExercise.csv','rb') as f: # read csv file reader=csv.reader(f) list1=list(reader) matrix = np.array(list1).astype("float") num_rows, num_cols = matrix.shape print('LOCAL MINIMAS : \n') for i in range(1,num_rows-2): if (matrix[i][0] < matrix[i-1][0]) &...
true
d09914b37c45476e613c6442ec46d65d2638264a
alaishan/Unsupervised-
/2.EvaluatingClusters.py
UTF-8
2,472
3.59375
4
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 13 20:06:26 2021 @author: Alaisha Naidu Name: Evaluating Clusterings Creds: DataCamp """ import pandas as pd import numpy as np from sklearn.datasets import load_iris from sklearn.cluster import KMeans import matplotlib.pyplot as plt #K-Means Cl...
true
7f346f9d5244f17a0536bb70922220ceafe223cf
roger6blog/LeetCode
/SourceCode/Python/Problem/00343.Integer Break.py
UTF-8
764
3.796875
4
[]
no_license
''' Level: Medium Tag:[Math] Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: n = 2 Output: 1 Explanation: 2 = 1 + 1, 1 x 1 = 1. Example 2: Input: n = 10 Output: 36 Explanation:...
true
36767cc3be40b055f4598eb15037b06226e3ea66
luozhhub/MitEdit
/fileIO.py
UTF-8
5,000
2.65625
3
[]
no_license
import os import sys import pandas as pd import pysam class bamIO(): def __init__(self, bam_file=None): self.bam = bam_file #read bam file self.samfile = pysam.AlignmentFile(self.bam, "rb") #check index file if not self.samfile.check_index(): print("bam index fil...
true
07d47604649c9755338e092ee3e8bd0da0aa569a
d0iasm/CtCI
/Chapter01/06_string_compression.py
UTF-8
1,038
3.578125
4
[]
no_license
import unittest def string_compression(string): compressed = [] counter = 1 for i in range(1, len(string)): if string[i] != string[i - 1]: compressed.append(string[i - 1]) compressed.append(str(counter)) counter = 0 counter += 1 compressed.append(s...
true
008b276b1329f061a1d49548f54a5eb0a5a8a6aa
jamesnovakowski/python_examples_rsg
/Process_Transit-Path_Cleaned_Data UTA - Post Direction Assignment-UPDATED.py
UTF-8
13,462
2.921875
3
[]
no_license
#James, review this and update to make it clean. There are some large chunks of commented code down below. #This file originally developed by Eric Talbot for the Seattle Sound Transit OD 2011-2012 #Filepath: "Q:\Projects\WA\Sound Transit\11166 Sound Transit 2011-2012 OD\9. Analysis\Weighting\python\weight_data.py" ...
true
617cf394dc293ac7f54fc378bcf809fab3633fe8
zetongqi/Mathematical-Machine-Learning
/hw1/rand.py
UTF-8
849
3.125
3
[]
no_license
import numpy as np import random def rand (n): return random.randint(0, n-1) def rand_k (k, n): l = list(range(0, n)) selection = [] for i in range(k): index = random.randint(0, len(l) - i -1 ) selection.append(l[index]) del l[index] return selection def bivariate_random_generator (dist): x_axis = [] y_...
true
6288698cfb3156f431a7ea1fe593ea9fe24e7d21
alperenozil/algorithm-exercise
/cities.py
UTF-8
128
3.515625
4
[]
no_license
list_of_cities = ['Adana', 'Mersin', 'Ankara'] cities = '-'.join(list_of_cities) print() print("All cities: "+cities) print()
true
c0a938703912bdff25780e96ade9a72ae5fe22a3
SorokinStanislav/captcha_recognition
/main/extract_symbols.py
UTF-8
3,449
2.59375
3
[]
no_license
import cv2 import imutils as imutils import numpy as np from imutils import contours from main.detect_letter_with_turning import resolve_symbol # load the reference MICR image from disk, convert it to grayscale, # and threshold it, such that the digits appear as *white* on a # *black* background SYMBOL_TEMP_FILE = 's...
true
d879eed04469c7d33078f70d2167164cadc7c8de
IndiFox/rvs
/myproject.py
UTF-8
4,581
2.734375
3
[]
no_license
from flask import Flask, jsonify, request , render_template from datetime import datetime import logging import redis import os from dotenv import load_dotenv app = Flask(__name__) def get_connection(): try: REDIS_SERVICE_SERVICE_HOST = str(os.environ.get('REDIS_SERVICE_SERVICE_HOST')) if os.environ.get("HOST_FRO...
true
d3105f2cf8101cf765c704ac7327313cce77e0af
Doaa-Ismael/DesignPatternsImplementation
/FactoryMethod.py
UTF-8
588
3.609375
4
[]
no_license
from abc import abstractmethod class Furniture: def __init__(self, home_type): self._home_type = home_type def show(self): if self._home_type == 'new': print('show colorful furniture') else: print('show gold furniture') class NewHome: def show_furniture(...
true
5f209b2b6a60d63de2a78acd2961949879ae81ac
laky/advent_of_code_2020
/advent_of_code_2020_01.py
UTF-8
776
3.703125
4
[]
no_license
def find_numbers_summing_to(sorted_input_array, number): start = 0 end = len(sorted_input_array)-1 while start < end: sum = sorted_input_array[start] + sorted_input_array[end] if sum == number: return (start, end) elif sum < number: start += 1 else: end -= 1 return None if __name__ == "__main...
true
036823c79f1224f405eb89f728f57e3a142ddcc9
galid1/Algorithm
/python/programmers/level2/타겟_넘버.py
UTF-8
480
3.484375
3
[]
no_license
from queue import Queue def solution(numbers, target): answer = 0 q = Queue() q.put(-numbers[0]) q.put(numbers[0]) for i in range(1, len(numbers)): for j in range(q.qsize()): cur_num = q.get() # 더하고 뺀것 넣기 q.put(cur_num - numbers[i]) q.put(c...
true
f7fb7fbc2e9dc7837a35b75d81e165bc98bec322
AryanSahu/ResumeParsing__MAILID_PHONE
/Parser.py
UTF-8
226
2.75
3
[]
no_license
import docx2txt import re my_text = docx2txt.process("resume.docx") pattern = re.compile(r'[a-zA-Z0-9-\.]+@[a-zA-Z-\.]*\.(com|edu|net)') matches = pattern.finditer(my_text) for match in matches: print(match.group(0))
true
ea6ff577f44500d529c1258ce906f1c5b18d86ba
florianeinfalt/nuketemplate
/nuketemplate/convert.py
UTF-8
5,766
2.984375
3
[ "Apache-2.0" ]
permissive
import copy import attr import subprocess import networkx as nx from .graph import AbstractGraph from .graph import NukeNode from .exceptions import AbstractTemplateError from nuketemplate import logger @attr.s(repr=False) class AbstractTemplateConverter(object): """ Template to Graph Converter :param ...
true
6974dbd355246cb08081312a358f8694e3dac3f3
gtangg12/Pathtracing
/scenes/cbox/box.py
UTF-8
338
2.8125
3
[]
no_license
fin = open('cbox.txt', 'r') fout = open('cbox2.txt', 'w') for line in fin.readlines(): temp = line[:-1].split(' ') if temp[0] == 'v': for i in range(3): temp[i+1] = round(float(temp[i+1])*100, 3) temp[i+1] = str(temp[i+1]) fout.write(' '.join(temp)+'\n') else: ...
true
7469d6c087771a20a4792634060b7574b45e29f2
allie/aoc2016
/6/part2.py
UTF-8
447
3.203125
3
[]
no_license
def least_common(lst): return min(set(lst), key=lst.count) def parse(file_name): instr = [] with open(file_name) as f: instr = f.readlines() columns = [[],[],[],[],[],[],[],[]] for line in instr: s = line.split("\n")[0] if s != "": for i in range(len(s)): columns[i].append(s[i]) result = "" fo...
true
89a770dc721bf0614ed5aee2d2037f254fa76295
ftczohaib/python_Assignments
/Assignment_1/Assignment1_5.py
UTF-8
159
2.90625
3
[]
no_license
def displayData(): i=10; while(i>0): print(" ",i,end=""); i = i-1; def main(): displayData(); if(__name__=="__main__"): main();
true
2923961be3439552a254810a299becd85d63b16c
Azmah-Bad/ServerX
/trainer.py
UTF-8
2,735
2.875
3
[]
no_license
""" this script tests the server's performance with multiple parameter to determine the best and optimal configuration :param that are going to be tested - TIMEOUT - WINDOW SIZE """ import logging import csv from multiRunner import multiRunner import progressbar from src import WindowServer import subprocess from fu...
true
6e8509167f0b70e5107170094b24ee5b0836056f
varunn807/Coding-Exercise
/minimumSteps.py
UTF-8
538
3.203125
3
[]
no_license
class Solution(object): def minCostClimbingStairs(self, cost): import math minCosts=[None]*(len(cost)+1) print(len(minCosts)) minCosts[0] = 0 minCosts[1]=0 for i in range(2,(len(cost)+1)): minCosts[i]=min([minCosts[i-1]+cost[i-1] ,minCosts[i-2]...
true
fd28de4038218332520bd5022fe7c27182dc467c
KunalSinghP/Python-Beginner
/Student Records In Dictionary.py
UTF-8
375
3.390625
3
[]
no_license
d={} n=int(input("Number of student records to be entered:")) for i in range(n): x=int(input('Enter Roll No.:')) y=input("Name:") z=input("Stream:") a=input("Class:") fj=(y,z,a) d[x]=fj m=int(input("Enter Roll Number to see details of a student:")) z=d[m] print("Name\t""Stream\t""Clas...
true
b46c551dab73d7d308cc5507d63a6a6ba17cecbe
tpillars/Codility
/codility_intern_test_fixed3.py
UTF-8
2,695
3.109375
3
[]
no_license
####################################################################################################### ################################### ORIGINAL ######################################################### ####################################################################################################### A=[1, 12...
true
2869e851fdcd4830f0a0f0f33b92016bcdca0cc5
westlakemaomao/python-da
/da/stat/normalStat.py
UTF-8
3,179
3.078125
3
[]
no_license
import numpy as np import da.odbc.MysqlConnect as mysqlDB def vwapStat(klineItem): """"volume-weighted average price""" vwap = np.average(klineItem["close"], weights=klineItem["vol"]) return vwap def rateOfReturn(klineItem): returns = np.diff(klineItem["close"]) / klineItem["close"][:-1] return ...
true
03e9ef73c075dff4136d74886b8b020269058f2b
cristian0159/HPC
/FibonacciPython.py
UTF-8
680
3.453125
3
[]
no_license
import multiprocessing def fib(n): if n <= 2: return 1 else: return fib(n-1)+fib(n-2) def fact(num): array = [] i = 2 j = 0 print(num,": ",end="") while num > 1: if (num % i == 0): num = num / i array.append(...
true
368371c8a86356e8e8c1c23dad886d21da4e1d68
Yamp/wows
/testing/portfolio.py
UTF-8
1,289
3.328125
3
[]
no_license
from collections import Collection class Portfolio: """Мой портфель""" @staticmethod def from_tickers_and_money( money: float, tickers: list[str], ): """Создаем портфель из денег и тикеров.""" def __init__( self, amounts: dict[str, float], ...
true
e2aac39b93369ddb98a3b5f4dc9fd14331736618
Gabrielganchev/week2final
/whilelloops/sum_of_evens2.py
UTF-8
105
3.484375
3
[]
no_license
a=int(input()) c=0 b=0 while b<=a: c+=b b+=1 if c%2==0: print(c,"is even ")
true
d4694f323b97cca28c04912e3b6700f63b7ebb2a
getsentry/examples
/aws-lambda/python/out_of_memory/out_of_memory.py
UTF-8
1,505
3.015625
3
[ "MIT" ]
permissive
# /** # ****************************************************************************** # * File name : out_of_memory.py # * Description : This file contains code that consumes memory limit for lambda # * Assumption : Max memory limit for lambda function has been set to 128MB # ***************************************...
true
51565cb8845d94594df85be61e3194fc0b25b23d
thirdcaptain/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
UTF-8
1,380
3.921875
4
[]
no_license
#!/usr/bin/python3 """ Defines a function that parses and prints text with two new lines after: period, question mark, and colon """ def text_indentation(text): if not isinstance(text, str): raise TypeError("text must be a string") character = ['.', ':', '?'] new_text = "" for n in text: ...
true
a2758aef1833e7d49945ad7353fbb2d2963ef904
heyhello89/openbigdata
/02_Coding Dojang/180313/Multiples_of_X_and_Y.py
UHC
356
3.25
3
[]
no_license
#coding: cp949 sum=0 while True: X=int(input("X Էϼ :")) Y=int(input("Y Էϼ :")) Z=int(input("Z Էϼ :")) if X==0 or Y==0 or Z==0: print("α׷ մϴ.") break for i in range(1,Z): if i%X==0 or i%Y==0: sum+=i print(":",sum)
true
2687b63b8a99796bc7a515c72c86f168b4285fbf
siboles/lsmgridtrack
/lsmgridtrack/test/test_image.py
UTF-8
4,940
2.640625
3
[ "BSD-3-Clause" ]
permissive
import unittest import numpy as np import pytest import SimpleITK as sitk import vtkmodules.all as vtk from hypothesis import event, given from hypothesis import strategies as st from .. import image from ..config import ImageOptions, SurfaceAxis2D, SurfaceAxis3D from . import data @pytest.fixture(scope="module") d...
true
065fd5425a5781be7f01c93f7c139d51e20a0e31
PreetiSajjan/YellowTaxiTripData
/publisher.py
UTF-8
908
2.71875
3
[]
no_license
#!/usr/bin/env python from datetime import time import stomp import csv def publish(conn, msg, destination): conn.send(body=msg, destination=destination) def main(): conn = stomp.Connection(host_and_ports=[('localhost', '61613')]) conn.connect(login='system', passcode='manager', wait=True) with op...
true
b940bf74781595acf2ff5e08db059637e767fd74
Duha357/my_chat
/databases/sqlite_database.py
UTF-8
5,738
2.703125
3
[]
no_license
import datetime from sqlalchemy import create_engine, Column, Integer, String, DateTime, ForeignKey from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker class ServerDatabase: Base = declarative_base() class Users(Base): __tablename__ = 'users' id = ...
true
552ee4c350ae4568f32e6758f61d92697af11fe0
muhammss/CFD
/Assignment 1/tdma.py
UTF-8
435
2.71875
3
[]
no_license
from pylab import * #Function implementing the TDMA algorithm def tdma_solve((A, Ad, Au), b): #Get size of linear equations to be solved n = size(b) - 1 #Initialise the solution T = zeros((n+1,1)) #Forward Elimination for i in range(1, n+1): f = Ad[i]/A[i-1] A[i] -= f*Au[i-1] b[i] -= f*b[i-1] ...
true
335cfaa25cec4d7cf9f6a4f9079901a1924ae0b2
ojus1/Date2Vec
/Data.py
UTF-8
1,058
3.0625
3
[ "MIT" ]
permissive
from torch.utils.data import Dataset import numpy as np class NextDateDataset(Dataset): def __init__(self, dates): dates = [date.split(",") for date in dates] convert_int = lambda dt: list(map(int, dt)) self.dates = [convert_int(date) for date in dates] #print(dates) def __le...
true
6b051b446662fee347394e42569fed797b57b5c4
4ingers/Crypto-McNuggets
/api/labs/lab3.py
UTF-8
619
2.71875
3
[]
no_license
from .tools import binaries, conversions def Task3(data): try: i = int(data['i']) j = int(data['j']) except KeyError: return { 'Error': "No 'i' or 'j' property"} except ValueError: return { 'Error': "'i' or 'j' is not a number"} try: binary, size = conversions.str_to_bin(data['binary']) ...
true
0bd1165aa550d7ae44b66c525ae695a6ed010247
abhigyan709/dsalgo
/Python_basics/deep_dive_to_conditional_statements.py
UTF-8
3,405
4.3125
4
[ "MIT" ]
permissive
# conditional tests car = 'bmw' # assignment operator car == 'bmw' # relational operator # ingnoring a case when making a comparision car = 'Audi' car.lower() == 'audi' # True # checking for inequality topping = 'mushrooms' topping != 'anchovies' # True # numerical comparison age = 18 age == 18 # true age != 18...
true
ec59394bfb3d7a2ccfd3185fd37f9fa8a5c2b892
lulu20006/python_exercises
/exercises/exer_23.py
UTF-8
135
3.609375
4
[]
no_license
#Define a function which can compute the sum of two numbers. l=input().split(',') n = int (l[0]) m = int (l[1]) sum = m+n print (sum)
true
41129d6239a9e103787d9db5034b50110e2b823c
claoidek/Project_Euler
/119_digit_power_sum.py
UTF-8
1,098
3.90625
4
[]
no_license
# Finds the 30th entry in the sequence of numbers that are equal to the sum of # their digits raised to some power from time import clock def sum_of_digits(num): return sum([int(x) for x in str(num)]) def add_to_list(num): if len(valid_nums) < num_to_find: valid_nums.add(num) elif num < max(valid...
true
9ee209f043f605ed8c361fe57c642b3b168c8d36
KDD-anonymous-code/individual_treatment_prescription
/synthetic_data_generator.py
UTF-8
6,499
3.109375
3
[]
no_license
from enum import Enum from typing import List, Tuple import numpy as np import pandas as pd from sklearn.model_selection import train_test_split class ComplianceType(Enum): # constant compliance value for all items Single = 1 # multiple compliance values, using the same features as treatment uplift values...
true
1eba591d41208f25ea0dbe7cd1ae092501048e9e
ivh/obs-rapport
/db.py
UTF-8
4,709
2.546875
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- from os.path import join,exists from pysqlite2 import dbapi2 as sqlite from mod_python import apache,util BASE=join('/','p1','astronomi2009','rapport') DBNAME=join(BASE,'rapport.db') def opendb(name=DBNAME): if not exists(name): return 'Give me a database to ...
true
5eaffe61a198a00da4d13a1d7f0138169098c7c0
only-cr/uploading
/uploading/uploading/backup/lg.py
UTF-8
2,731
2.796875
3
[]
no_license
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.feature_selection import RFECV from sklearn.metrics import accuracy_score,roc_curve,classification_report,auc,confusion_matrix from sklearn.decomposition import PCA from hyperopt import hp, tpe, fmi...
true
f778b4f6349c514ab71c49177fbc2669d214e680
793375175/spidertest
/爬虫练习/day_01/01_str_bytes.py
UTF-8
206
3.4375
3
[]
no_license
str = '你好' print(type(str)) print(str.encode()) print(type(str.encode())) byte = str.encode('GBK') print(byte) print(type(byte)) print(byte.decode('GBK')) print(type(byte.decode('gbk')))
true
04192d4b05597273a77215c0526ef140fc5bd878
kaitlynning/Py-practice
/Py-practice/0404-2.py
UTF-8
461
3.59375
4
[]
no_license
# We’ll have accidentally ended the string before we wanted to by including the " character. # By adding a backslash in front of the special character we want to escape, \", we can include it in a string. #theycallme"crazy"91 password = "theycallme\"Kitty\"93" #His password was causing some errors in the system becaus...
true
4b9462b73ee1dee3ee34486bd3a103139a66537a
nickjingyuli/CS598-deep-learning
/cs411/sent_analysis.py
UTF-8
828
2.671875
3
[]
no_license
import numpy as np import os import nltk import itertools import io import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable word2id = np.load('imdb_dictionary_w2id.npy') comment = "Overall this is a decent movie. The sound effect is great, t...
true
9455d99f9c0e9479f08a9113ef06ed27058f11d3
cmdellinger/udacity-data-engineering-nanodegree
/05 - data pipelines with airflow/04 - project/project/home/airflow/plugins/operators/load_dimension.py
UTF-8
1,275
2.53125
3
[]
no_license
from airflow.hooks.postgres_hook import PostgresHook from airflow.models import BaseOperator from airflow.utils.decorators import apply_defaults class LoadDimensionOperator(BaseOperator): ui_color = '#80BD9E' @apply_defaults def __init__(self, redshift_conn_id="", table=...
true
a1178f79883b582ccf07320dbaea1af0c29965f3
abingham/project_euler
/python/src/euler/exercises/ex0056.py
UTF-8
369
3.578125
4
[]
no_license
# Considering natural numbers of the form, a^b, where a, b < 100, what is the maximum digital sum? import euler_util as eu def digital_sum(x): return sum(eu.digits(x)) def run(): max = 0 for a in range(100): for b in range(100): s = digital_sum(pow(a,b)) if s > max: ...
true
9dfd27643837403e9345c50736e3766ddfafa62c
xu1718191411/AT_CODE_BEGINNER_SELECTION
/CONTEXT_45/C.py
UTF-8
505
3.375
3
[]
no_license
import itertools S = input() def calculate(s): arr = list(s) totalLength = len(s) spliteIndexes = [i for i in range(1,totalLength)] result = 0 for i in range(1, totalLength): for item in itertools.combinations(spliteIndexes, i): ttr = [0] ttr.extend(list(item)) ...
true
1614ea820871bc9fb6409e8c399269ce7c80ac13
euccastro/Python_Pygame-Xogo-Estratexia
/modulos/subs_espacios-tabs.py
UTF-8
838
3.609375
4
[]
no_license
# -*- coding: utf-8 -*- import sys if len(sys.argv) > 1: nome_arquivo = sys.argv[1] else: nome_arquivo = raw_input(">>> Introduce o nome do arquivo: ") texto_arquivo = open(nome_arquivo,"r").read() print(u"Substituir:") opcion = raw_input(u"[1] - Espacios por Tabs\n[2] - Tabs por Espacios\n>>> ") if opcion == ...
true
4cd57306b48ea716fe9dd318bd8a92574464d7d5
harveylabis/GTx_CS1301
/codes/CHAPTER_3/Chapter_3.3_Loops/Lesson_5/3.5.5_sample_answer_1.py
UTF-8
1,413
4
4
[]
no_license
beats_per_measure = 4 measures = 5 #----------------------------------------------------------- #There are two tricky parts of this problem. We should #generally know that we want two for loops, one inside the #other. One will count from 1 to beats_per_measure, one will #count from 1 to measures. # #Which one goes fir...
true
46efe89dcf8623026ac4b062595022ae784b785f
ziippy/python_work
/get_maximum_difference_between_two_elements.py
UTF-8
1,941
3.984375
4
[]
no_license
''' Given an array arr[] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number. Examples Input : arr = {2, 3, 10, 6, 4, 8, 1} Output : 8 Explanation : The maximum difference is between 10 and 2. Input : arr = {7, 9, 5, 6, 3, 2} Output : 2 Expl...
true
378888ab1257344fffbc1bdb2d899050eabb00b5
bh0085/compbio
/utils/path_mgr.py
UTF-8
1,268
3.765625
4
[]
no_license
#!/usr/bin/env python ''' A few utilities to manage the path stack and to get the filepath of the currently running script pushd: Push a directory onto the stack. popd: Pop a directory from the stack. getd: Get the directory of the currently running script. ''' globals()['dstack'] = [] import inspect, os def pushd(...
true
15326412501eac6d8b21954a197ebd962cb2a85b
YuriyGoryachkin/prototype
/UDP_reader/gui/start_window.py
UTF-8
1,319
2.578125
3
[]
no_license
from PyQt5.QtWidgets import * import sys class StartWindow(QDialog): def __init__(self, parent=None): super(StartWindow,self).__init__(parent) self.loginLabel = QLabel('Login') self.loginPass = QLabel('Password') self.login = QLineEdit(self) self.password = QLineEdit(self) ...
true
5751fb6f5e2dc9e7c2f99d49efaed25b47368fbf
faizan2sheikh/PythonPracticeSets
/PracticeSet4/Q10+11+12.py
UTF-8
4,104
4.5625
5
[]
no_license
def PrintMat(matrix,x): ''' takes matrix as list and print it in matrix format''' print(x,'matrix is:') for lst in matrix: print('|',end='\t') for element in lst: print(element,end="\t") print('|') return('~'*98)#Just customization def InputMat(x,r): ...
true
4cd2ec4e91202ca63f87801ae539eb95e782a471
sanazshahbazian/charity-project
/app.py
UTF-8
2,552
2.71875
3
[]
no_license
from flask import Flask, render_template import datetime import json # Import our pymongo library, which lets us connect to our mongo DB import pymongo # Create an instance of our Flask app app = Flask(__name__) # Create connection variable conn = 'mongodb+srv://falcon2020:Falcon20@charity-cluster-homax.azure.mongo...
true
c8ed4fff9b7cce0fd4323fad618b6fed25831479
fpl/geotutorial_basic
/11/02_boundingBoxesToShapefile.py
UTF-8
1,874
2.796875
3
[]
no_license
''' Save countries bb in a new shapefile ''' import os, os.path, shutil from osgeo import ogr from osgeo import osr # Open the source shapefile. srcFile = ogr.Open("files/TM_WORLD_BORDERS-0.3.shp") srcLayer = srcFile.GetLayer(0) # Open the output shapefile. if os.path.exists("bounding-boxes"): shutil.rmtree("b...
true
f8d392b67245b50a5a33739e1ebba5345d3b6d07
AsaiTomohiro/Python
/jidouseisei_tokutei/re_1.py
UTF-8
549
3.359375
3
[]
no_license
import re path = './青木.txt' #ファイルをオープンする text_data = open(path,"r") #全ての内容を読み込む text = text_data.read() text1=re.sub(r'https?://[\w/:%#\$&\?\(\)~\.=\+\-…]+', "", text) text=re.sub('RT', "", text) text=re.sub('お気に入り', "", text) text=re.sub('まとめ', "", text) text=re.sub(r'[!-~]', "", text)#半角記号,数字,英字 text=re.sub(r'[︰...
true
fa5d80992ba9ce2fbac7d5ccc7bf0044b80c1c51
daryadm/python
/DataCamp/file_pandas.py
UTF-8
4,736
3.390625
3
[]
no_license
# Import the pandas package import pandas as pd # Initialize reader object: df_reader df_reader = pd.read_csv('ind_pop.csv', chunksize=10) # Print two chunks print(next(df_reader)) print(next(df_reader)) # Assign the filename: file file = 'titanic.csv' # Read the file into a DataFrame: df df = pd.read_csv(file) # ...
true
aa5d266438c5901156554fe674c4d84abea78f39
Ivan-Daniel/Algortimo-y-Programacion-Talleres
/Taller Estructuras de control/ejercicio_5.py
UTF-8
743
3.6875
4
[ "MIT" ]
permissive
""" Entradas Sueldo-->float-->sueldo departamento 1-->float-->dep1 departamento 2-->float-->dep2 departamento 3-->float-->dep3 """ sueldo=float(input("Digite el sueldo: ")) dep1=float(input("Ventas echas por departamento 1: ")) dep2=float(input("Ventas echas por departamento 2: ")) dep3=float(input("Ventas echas por d...
true
51909ce3aee7c3acd59c5dd15d13dc48863d4ad8
untalinfo/holberton-system_engineering-devops
/0x15-api/2-export_to_JSON.py
UTF-8
913
2.984375
3
[]
no_license
#!/usr/bin/python3 """ Using what you did in the task #0, extend your Python script to export data in the JSON format. """ import json import requests from sys import argv if __name__ == "__main__": USER_ID = argv[1] file_name = USER_ID + '.json' user_id = 'https://jsonplaceholder.typicode.com/users/{}'...
true