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
872eba536ae1ceb69a3fdac6e32b5319f03e64b6
dmtomas/TalkingAI
/IATalk/speaker.py
UTF-8
1,754
3.140625
3
[]
no_license
import numpy as np import csv import tensorflow as tf def encontrar(lista, a): mindif = np.inf ans = 0 for i in range(0, len(a)): dif = 0 for j in range(1, len(a[i])): dif += (lista[j-1] - a[i][j]) ** 2 if dif < mindif: mindif = dif ans = i ...
true
2371611680d3a5d8510162414644d128694f9100
x1jiang/biocaddie
/datarank/search/source/expProcess.py
UTF-8
1,934
2.75
3
[]
no_license
def get_kappa(A=None,B=None): import pandas as pd import numpy as np A = np.array(A) print np.histogram(A, range(6)) B = np.array(B) if A is None or B is None: k=5 n=30 A=np.array([np.random.randint(k)+1 for _ in range(n)]) B=np.array([np.random.randint(k)+1 for _...
true
260d485c9e4e0132a5ff4eb4744a1c512d808bd9
Vanevo00/Python_exercises
/5kyu/valid_parentheses.py
UTF-8
1,289
4.9375
5
[]
no_license
# Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if it's invalid. # "()" => true # ")(()))" => false # "(" => false # "(())((()())())" => true...
true
4a428b2a745b856b25b65d5accb073430a468609
zozulia-developer/battle-simulator-light-it-academy
/factory/strategy_factory.py
UTF-8
998
3.109375
3
[]
no_license
# -*- coding: utf-8 -*- """ Module for strategy factory This module demonstrates strategy builder. """ from strategy.random_strategy import RandomStrategy from strategy.strongest_strategy import StrongestStrategy from strategy.weakest_strategy import WeakestStrategy class StrategyFactory: """ Strategy builder ...
true
003902ac1dd09b61a1aa08e9faff7333252ced43
doublenote1/PythonLearning
/12. 算数・数学/SymPyの使い方(因数分解、方程式、微分積分など).py
UTF-8
3,901
4.375
4
[]
no_license
# === 変数、式を定義: === # sympy.symbol() """変数は以下のように sympy.symbol() で定義する""" import sympy x = sympy.Symbol('x') y = sympy.Symbol('y') print(type(x)) """ ・その変数を使って自由に数式を定義できる ・四則演算(+, -, *, /)、べき乗(**)などの演算子はPython標準のものを使う。 """ expr = x**2 + y + 1 print(expr) """ 変数の名称と sympy.symbol() の引数に渡す文字列は違っていてもいいが、 分かりにくくなるだけなので、...
true
820bb3687730835ccc28771318617710a3254013
danlapko/SlidesVideoSynch
/run.py
UTF-8
3,543
2.59375
3
[]
no_license
import argparse import json from collections import OrderedDict import cv2 from matcher import best_slide_ml, get_pdf_pages from ocr import get_slide_texts, best_slide_ocr, get_image_text, filter_text from video_processing import video_to_slide_imgs def get_args(): parser = argparse.ArgumentParser() parser....
true
df13fde00db03bd440f922010e5ede5921914e27
freedomDR/coding
/leetcode/929.py
UTF-8
378
2.796875
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- class Solution: def numUniqueEmails(self, emails: List[str]) -> int: t = set() for s in emails: s2 = s.split('@')[1] s1 = s.split('@')[0] s1 = s1.split('+')[0] string = s1.replace('.', '') +'@'+ s2 ...
true
a33d2892500b8984b70a1f6c1e3b5558069f42c0
nalinmshah/pandas_project
/q02_get_unique_values/build.py
UTF-8
368
3.046875
3
[]
no_license
import pandas as pd import numpy as np str_path='data/ipl_dataset.csv' def read_csv_data_to_df(path): pd_df= pd.read_csv(path, delimiter=',' ) return pd_df def get_unique_venues(): npArray = np.array (df['venue'].unique()) return npArray df=read_csv_data_to_df(str_path) print (df.shape) npArray_Venues = get...
true
2c4b07304da4697774877715c38b9f51bbe0f534
Linda-Kirk/cp1404practicals
/prac_04/quick_picks.py
UTF-8
1,074
3.984375
4
[]
no_license
""" This program will generate "quick picks". The number of quick picks required will be obtained from user. The program will then generate that many lines of output. Each line will consist of 6 random numbers between 1 and 45. These values should be stored as CONSTANTS. """ import random QUANTITY_NUMBERS_PER_LINE = ...
true
19a862821d3bf7490437e5e900f283e7e2e35077
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/13_15.py
UTF-8
2,267
4.21875
4
[]
no_license
Python – Selective consecutive Suffix Join Given a list of elements, the task is to write a Python program to perform a join of consecutive strings according to the suffix of each string. > **Input** : test_list = [“Geeks-“, “for-“, “Geeks”, “is”, “best-“, “for”, > “geeks”, suff = ‘-‘ > **Output** : [‘G...
true
3603af20217f72ca3db7155439cb9210b987cdcc
GeorgiTodorovDev/Python-Fundamental
/06.Exercise: Basic Syntax, Conditional Statements and Loops/MoreExercise/02.find_the_capitals.py
UTF-8
160
3.328125
3
[]
no_license
string = input() store_list = [] counter = 0 result = [] for char in string: if char.isupper(): result.append(counter) counter +=1 print(result)
true
589cad6220109980931eb5ab347ce86b2d818558
OJRR-91/Random_programs
/server_connection.py
UTF-8
1,804
3.796875
4
[]
no_license
# -*- coding: utf-8 -*- """ Created on Tue Mar 3 17:14:29 2020 we'll create a few classes to simulate a server that's taking connections from the outside and then a load balancer that ensures that there are enough servers to serve those connections. To represent the servers that are taking care of the connectio...
true
6c8459b2002d2316dcdcaa7dbe141ebed84f3806
Tyzeppelin/Project-Euler
/problem44/problem44.py
UTF-8
723
3.34375
3
[]
no_license
import math import time class Found(Exception): pass def isPentagonal(n): return (1/6.0 * (1 + math.sqrt(24*n + 1)))%1 == 0.0 def Pentagonal(n): i = 1 arr = [] while i <= n: arr.append(i*(3*i-1)/2) i+=1 return arr if __name__ == "__main__": t1 = time.clock() base = P...
true
3f81d3447218ed835eef849479641bfa71fb852a
Jayaprakash1998/Python-practice-problems-set-2
/Johnny Sins on Reality Kings.py
UTF-8
1,479
4.09375
4
[]
no_license
''' QUESTION: Johnny Sins on Reality Kings: Johnny Sins is going to participate in a game TV show called Reality Kings. The game is popularly known as Me vs N. The game goes in rounds, where in each round the host asks Johnny and his opponents a common question. All participants failing to answer are elimin...
true
1114f394d9b6d7899f77216b859e94e5c13bed56
Python3pkg/BrickPython
/BrickPython/Sensor.py
UTF-8
6,042
2.953125
3
[ "MIT" ]
permissive
# Sensor - represents a single value sensor supported by the BrickPython library # # Copyright (c) 2014 Charles Weir. Shared under the MIT Licence. from . import BrickPi class Sensor(): '''Sensor, representing a sensor attached to one of the BrickPi ports. Parameter *port* may be either a value (BrickPi.PORT...
true
1cd342e0e7028b13461152f37b21a5c02a00f80b
alteryx/featuretools
/featuretools/tests/primitive_tests/transform_primitive_tests/test_is_federal_holiday.py
UTF-8
2,971
2.78125
3
[ "BSD-3-Clause" ]
permissive
from datetime import datetime import numpy as np import pandas as pd from pytest import raises from featuretools.primitives import IsFederalHoliday def test_regular(): primitive_instance = IsFederalHoliday() primitive_func = primitive_instance.get_function() case = pd.Series( [ "2016...
true
d7fa7c7c6eac391aec32767c19c022e0250ebead
Manas167/Work
/Speed and Parallel/sample_for_cmdline.py
UTF-8
120
3.03125
3
[]
no_license
import sys print("Hello") print "Enter a file name:", filename = raw_input() print(filename) print(sys.argv[1])
true
b0b327b52bd7a87b58b995d91a81ac6fb10484a6
ancillaryfactory/web-rename
/webname.pyw
UTF-8
1,041
3.296875
3
[]
no_license
import sys import os import re from Tkinter import Tk def copy_to_clipboard(fixed_name): # add new filename to clipboard # http://stackoverflow.com/questions/579687/how-do-i-copy-a-string-to-the-clipboard-on-windows-using-python r = Tk() r.withdraw() r.clipboard_clear() r.clipboard_append(fixed_name) r.destro...
true
3c9f42f8a52e14675cc29b181484b9568ed0e411
aiaiaiaiaiya/Plantopia-App
/Pot Sourcecode/code Control/ctrl_littlePump_offline.py
UTF-8
483
3
3
[]
no_license
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(15, GPIO.OUT) GPIO.output(15, GPIO.HIGH) """ try: while 1: #GPIO.output(22, GPIO.HIGH) except KeyboardInterrupt: GPIO.output(22, GPIO.LOW) """ try: while 1: #GPIO.output(22, GPIO.HIGH) dc = raw_input("Enter [s] to stop: ") ...
true
c788d3ab7b7b42566c6e9e5810a749a7472a9fdd
msivakumarm/PycharmProjects
/Python/m.py
UTF-8
169
2.96875
3
[]
no_license
class A: pass class B: def m1(self): print("This is m1 method") def m2(self): print("This is m2 method") def m3(): print("this is m3")
true
485a136babf06338a2c4048e3090e4886c5931e9
terschure/Dataprocessing
/Homework/Week3/data/datatransform.py
UTF-8
756
3.078125
3
[]
no_license
# # By: Anneke ter Schure, 6084087 # # imports import csv # open and read datafile datafile = open('KNMI_20150101.csv', 'r') reader = csv.reader(datafile) # open and make headers in new datafile newfile = open('transformeddata.csv', 'w') writer = csv.writer(newfile) headers = ['YYYY/MM/DD', 'Max Temperature'] writer...
true
90f19d61a8ae9253dc9fba948efaafc92cac2757
nikvdp/agora-server
/app/db.py
UTF-8
8,747
2.84375
3
[ "Apache-2.0" ]
permissive
# Copyright 2020 Google LLC # # 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 agreed to in writing, ...
true
4bae488f108de6f5863d6e6d5dde9237f1c03ede
sanndra95/SC-Project
/SCProject/neural_network.py
UTF-8
7,071
2.5625
3
[]
no_license
__author__ = 'Sandra' import csv import re from keras.models import Sequential, load_model from keras.utils.np_utils import to_categorical from keras.layers import Dense, Dropout import numpy DATA = [] EMOTIONS = [] DATA_TEST = [] EMOTIONS_TEST = [] DATA2 = [] EMOTIONS2 = [] DATA_TEST2 = [] EMOTIONS_TEST2 = [] ...
true
5724ab63788fe4d8ef2bd40b2491a68aaee3bc61
yhoazk/cloaked-octo-computing-machine
/distLockr/distLockr.py
UTF-8
1,248
3.34375
3
[]
no_license
#!/usr/bin/python #import sys #import os """ For this the first strategy that comes to mind is to calculate the distance on each point to all the locker points, then select the shortest and print it. """ # dist |(x0 - xp)|+|(y0 - yp)| def getMinDist(row, col, xl, yl): dMin = (abs(row-(xl[0]-1))+ abs(col-(yl[0]...
true
e8d2889e5791036e8a7364be6b92c9844e3a8ce5
freshkimdh/Machine_Learning
/Level_3_ML/2.Linear_Regression/Linear_Regression_1.py
UTF-8
1,024
3.15625
3
[]
no_license
#1.0 버전으로 변경 import tensorflow.compat.v1 as tf tf.disable_v2_behavior() # 2.0 버전 # import tensorflow as tf # X, Y 값 정의 : x가 1 일때, y는 1 x_train = [1, 2, 3] y_train = [1, 2, 3] # W, b 값 정의 # tf.random_normal([shape]) 몇 차원? W = tf.Variable(tf.random_normal([1]), name='weight') # 텐서플로우가 사용하는 변수 선언 "Variable" b = tf.Vari...
true
6af78cbfb34260116a0ea3b8ec301be6c020674f
SchulerHunter/CMPSC-465
/insertionSort/sort.py
UTF-8
495
3.53125
4
[]
no_license
def sort(sortArray): swaps = 0 for i in range(1, len(sortArray)): k = i while k > 0 and sortArray[k] < sortArray[k-1]: sortArray[k], sortArray[k-1] = sortArray[k-1], sortArray[k] swaps += 1 k -= 1 return (swaps, sortArray) with open(input("Provide file pa...
true
bdb6778c411683ffb030026af5f3947b27246a3e
TimofeyNick/Zachet
/Exam/38 heap sort.py
UTF-8
177
3.359375
3
[]
no_license
from heapq import * def heap_sort(A): H = [] for x in A: heappush(A, x) for i in H: A[i] = heappop(H) A = [6,8,9,6,5,4,1,2,3] heap_sort(A) print(A)
true
1b9ba06574d1c7a907015dd1971fa065bb129d55
deanconnell1999/kattis
/Tarifa.py
UTF-8
170
3.15625
3
[]
no_license
allowance = int(input()) months = int(input()) left = 0 for i in range(months): used = int(input()) left = allowance - used + left print(left+allowance)
true
5ab623f6172ff652b518e47ebd8231dbe7dfc764
3346zsai98/resouce
/02.py
UTF-8
2,130
3.109375
3
[]
no_license
# create database heima charset="utf8"; # use heima; # create table user ( # -> id int unsigned primary key auto_increment, # -> name varchar(32) unique not null, # -> password varchar(32) # -> ); import pymysql class User(object): def __init__(self): self.conn = pymysql.connect(host="local...
true
cf2af12bdcd1680379156fe5da021ad7dc45fc24
Wangyf46/deeplabv3-pytorch
/utils.py
UTF-8
2,684
2.5625
3
[ "BSD-3-Clause" ]
permissive
import math import random import ipdb import numpy as np import torch import torchvision.transforms as transforms from PIL import Image class AverageMeter(object): def __init__(self): self.val = None self.sum = None self.cnt = None self.avg = None self.ema = None self.initialized = False ...
true
59ee4b8cf545546c987e596e69c6e0c4e78cc9c5
DongxuZhang-ZhangJiaKou/im-python
/server.py
UTF-8
2,974
2.84375
3
[]
no_license
# server.py # 导入系统模块 import os, sys # 导入网络编程(传输层)模块 from socket import * # IO多路复用模块 from select import select # 设置模块 from settings import * # 语言模块 from language import * def main(): 'main 主函数' server = socket(AF_INET, SOCK_STREAM) # 建立TCP套接字 server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) # 设置端口可立即重用 ...
true
d8d2cca0e22c43ca5649f295e9e6af515890ab03
johncadigan/Coursework
/NLP/rulefinder.py
UTF-8
1,974
3.03125
3
[]
no_license
from nltk.corpus import treebank import re symbols = "\.\,\'\"\*\$\-\?\%\&" rule = "[A-Z0-9{0}]".format(symbols) + "{1,10}" word = "[\w*{0}]".format(symbols) + "{1,20}" def balanced_parens(sent): rgt = sent.count("(") lft = sent.count(")") if lft==rgt and lft > 0: return True else: ret...
true
811328e5955b95569655ed65515821425d47ddf3
HussainAther/physics
/quantum/kernel.py
UTF-8
4,497
2.78125
3
[]
no_license
import matplotlib.pyplot as plt import numpy as np from pyquil import Program, get_qc from pyquil gates import CCNOT, CNOT, H, MEASURE, RZ, X from foresttools import init_qvm_and_quilc """ Kernel method for spatial mapping. """ qvm_server, quilc_server, fc = init_qvm_and_quilc("") qc == get_qc("4q-qvm", connection=f...
true
2eb368b0bbb6c3008023d7dbc559952e27d3354f
gabywang/Leeeeetcode
/771. Jewels and Stones.py
UTF-8
273
2.890625
3
[]
no_license
class Solution: def numJewelsInStones(self, J, S): """ :type J: str :type S: str :rtype: int """ # count() method returns the number of occurrences of the substring in the given string. return sum(map(J.count, S))
true
6cb3c00375bfbb4512d9888f26fc49a9267b7cf6
openvinotoolkit/openvino
/tools/mo/openvino/tools/mo/middle/pattern_match.py
UTF-8
6,194
2.6875
3
[ "Apache-2.0" ]
permissive
# Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import logging as log import numpy as np from networkx.algorithms import isomorphism as ism from openvino.tools.mo.graph.graph import Node, dict_includes, Graph def inverse_dict(d: dict): return {v: k for k, v in d.items()} def...
true
efb2c8470d989fea533f135982ce676779d202bd
marcosptf/fedora
/python/sistema-de-contatos-sqlalchemy/sqlalchemy_schema.py
UTF-8
1,047
2.671875
3
[]
no_license
# -*- coding: utf-8 -*- #criando um mapper da tabela from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String from sqlalchemy_base import engine Base = declarative_base() Base.metadata.create_all(engine) class Contatos(Base): __tablename__ = 'contatos' id = Colu...
true
569ba94ea6bb849df1a5b6e206202526b341596c
wangjie58/apiTestIHRE
/script/test_login.py
UTF-8
4,609
2.53125
3
[]
no_license
import unittest import logging from api.login_api import LoginApi import app # class LoginConfig: # # 在登录的配置类中增加HEADERS变量 # HEADERS = {"Content-Type": "application/json"} from utils import assert_common_utils class TestLogin(unittest.TestCase): def setUp(self): self.login_api=LoginApi() def te...
true
818368c3f906d53be3ce63c3c1f2c51ecf5f4bb9
guanguiwensy/cov2sg
/workflow/pairing/rnatk/src/rnatk/hts/barcode.py
UTF-8
3,436
2.84375
3
[]
no_license
""" Extract barcode/index from read and rename its name as num|barcode """ import os import sys import argparse from rnatk.ios.fastq import reader_fastq, Fastq import logging _logger = logging.getLogger(__name__) from rnatk import __version__ def iter_parsed_read(fqfile, bc_start=0, bc_end=4, bc_drop=True): """G...
true
ff132ea9f5621d800d5326f32b738e652e5a0cf6
LouisVIlegros/ContentS_Server
/Controllers/factory/autocomplete.py
UTF-8
1,221
2.625
3
[]
no_license
from Model.DAL import FireBase as DAL from Controllers.factory.Trie_Patern import TrieNode class SearchEngine : __slots__ = ("searchedString", "data", "Controller") def __init__(self, word, dataType): self.searchedString = word.capitalize() self.data = DAL.FireBase(dataType).getAll() ...
true
7d5364566506abfa8303a98346f4536d62ab5ff2
MlHsieh/Pathfinding
/path_pgzero.py
UTF-8
6,066
3.5625
4
[ "MIT" ]
permissive
""" A* path finding with pygamezero Find the shortest path from top-left corner to bottom-right corner. Obstacles are generated randomly each time. Numbers shown are the fcost (the total path length) Basically the same as pygame version. Only add the numbers. Author: ML Hsieh 2020-2-23 """ # pylint: dis...
true
6e682bd5f349e828a9fbd95ca8a64dad9790f5e8
SunivAlgo/Algorithm
/byeonghun/13week/등굣길/등굣길.py
UTF-8
537
2.953125
3
[]
no_license
def solution(m, n, puddles): answer = 0 arr = [[0 for _ in range(m)] for _ in range(n)] for i in puddles: arr[i[1] - 1][i[0] - 1] = -1 arr[0][0] = 1 for i in range(n): for j in range(m): if arr[i][j] == -1: continue if i + 1 != n and arr[i+1][j...
true
ea4ffeb85aaf5375901cc6326e0678373e561589
Vicas/practice-counter
/ini_defaults.py
UTF-8
992
2.828125
3
[]
no_license
import configparser import os from pathlib import Path DIR_PATH = Path(os.path.dirname(os.path.realpath(__file__))) CONFIG_PATH = DIR_PATH / 'config.ini' def create_default_counter_config(): config = configparser.ConfigParser() config['SETTINGS'] = { 'counter_name': 'Practice Counter', 'butto...
true
b6cc0cceb82a2466e250431d89ee2328128cfb76
Alberdi/ancientest
/test/test_country.py
UTF-8
4,081
3.78125
4
[ "MIT" ]
permissive
import unittest import country, creature class TestCountry(unittest.TestCase): def setUp(self): self.c = country.Country() # Countries have an area defined by a list of points def test_add_area(self): # Two points don't make a valid area self.c.add_area([(0,0), (100,100)]) self.assertIsNone(self.c.area) ...
true
50b7874bbb8cd484f835c1d12c00042619a24f11
RymaBmzz/ExplainMultilabelClassifiers
/python/3_precompute_paiwise_distances.py
UTF-8
5,846
2.921875
3
[]
no_license
import pandas as pd import numpy as np import pickle import gzip from scipy.spatial.distance import pdist,squareform from scipy.spatial import distance from multilabelexplanations import distance_functions def mixed_distance(x, y, n_var_cont, cdist, ddist): # type: (pandas.Series, pandas.Series, list, list, list,...
true
27c5596790598373136b7d642378cbe4cdbb3f86
diksha16017/MLForBeginners
/KMeans_and_RL/KMeans/KMeansClustering.py
UTF-8
2,986
2.890625
3
[]
no_license
import numpy as np import math import random import operator import matplotlib.pyplot as plt # make sure this class id compatable with sklearn's LogisticRegression class KMeansClustering(object): def __init__(self, K = 2, max_iters =10, dataset="Plot"): # define all the model hyper params here s...
true
020a06c96e66ce7af71cd0ebd7e7f48e45c83166
Techrobo/visual-search-actr
/utils.py
UTF-8
4,256
2.6875
3
[]
no_license
import numpy as np from numpy import expand_dims from tensorflow.keras.preprocessing.image import load_img from tensorflow.keras.preprocessing.image import img_to_array from matplotlib import pyplot from matplotlib.patches import Rectangle class BoundBox: def __init__(self, xmin, ymin, xmax, ymax, objness = None, cl...
true
724599654b754d81f90caeba2d6a71dfe204e245
ystromm/videostore
/python/price.py
UTF-8
1,231
3.03125
3
[]
no_license
from code import MovieCode class Price: def __init__(self): self._price_code = -1 @property def price_code(self): return self._price_code def cost(self, days_rented): result = 0 return result def points(self, days_rented): result = 0 return result...
true
708e9841220067aebf95dc94d9976370ca73f947
lbbgit/PythonDemo
/s2.py
UTF-8
606
2.8125
3
[]
no_license
import urllib #import urllib2 import urllib.request page = 1 url = 'http://www.qiushibaike.com/hot/page/' + str(page) #try: # urllib.request 不能直接called,参数多 # request = urllib.request(url) # response = urllib.request.urlopen(request) # print( response.read()) # except urllib2.URLError, e ...
true
af3a0ae745a8863ce2e16d26bf59dc5a67a669e5
ramazanbozkir/python_projects_basic
/Sockets/PortCheck.py
UTF-8
286
2.71875
3
[]
no_license
# Hacktrickconf 2017 - EmreOvunc # Python For Hackers import socket targetIP = input("Target IP: ") portSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: conn = portSocket.connect((targetIP, 80)) print("Port 80 is OPEN!") except: print("Port 80 is CLOSED!")
true
139fa9f3f492dc43da8c40130c6d06166a946952
joestalker1/leetcode
/src/main/scala/algorithms/TwoSum.py
UTF-8
382
3.40625
3
[]
no_license
def twoSum(arr, x): if not arr: return None sarr = sorted(arr) left = 0 right = len(arr) - 1 while left <= right: s1 = sarr[left] + sarr[right] if s1 == x: return [sarr[left], sarr[right]] if s1 < x: left += 1 else: right -...
true
a21cb17094bce9daf0786507579fb8b44fd248c5
SaewonY/algorithm_study
/programmers/problem_44.py
UTF-8
1,101
3.3125
3
[]
no_license
''' 멀쩡한 사각형 https://programmers.co.kr/learn/courses/30/lessons/62048 문제 설명 가로 길이가 Wcm, 세로 길이가 Hcm인 직사각형 종이가 있습니다. 종이에는 가로, 세로 방향과 평행하게 격자 형태로 선이 그어져 있으며, 모든 격자칸은 1cm x 1cm 크기입니다. 이 종이를 격자 선을 따라 1cm × 1cm의 정사각형으로 잘라 사용할 예정이었는데, 누군가가 이 종이를 대각선 꼭지점 2개를 잇는 방향으로 잘라 놓았습니다. 그러므로 현재 직사각형 종이는 크기가 같은 직각삼각형 2개로 나누어진 상태입니다. 새로...
true
0b9a35765c62d5b93f5bd05979e22d3587ab0e2d
sphinxteam/mlcourse_2019
/lec2/rks4.py
UTF-8
802
3.109375
3
[]
no_license
def train_kernel_ridge(X, y, lamb=0.05): n_samples, n_features = X.shape # Obtain kernelized Gram matrix and perform least-squares estimation corr = np.exp(-.5 * cdist(X, X) ** 2) coef = np.linalg.lstsq(corr + lamb * np.eye(n_samples), y)[0] # Compute training error error = np.mean((y ...
true
ede30e654f628182838b9ae4178953f35d02c20c
kcelebiler/bilge_turkish_ai_assistant
/get_news.py
UTF-8
9,371
3.140625
3
[]
no_license
import bs4 import requests import random sports_url = "https://www.haberler.com/spor/" latest_news_url = "https://www.haberler.com/son-dakika/" paparazzi_news_url = "https://www.haberler.com/magazin/" economy_news_url = "https://www.haberler.com/ekonomi/" health_news_url = "https://www.haberler.com/saglik/" general_ea...
true
a340400434e326825d4d50906fe26298e8c0c0a4
qnomon/Python-Studies
/ex044.py
UTF-8
625
4
4
[ "MIT" ]
permissive
v = float(input('Digite o valor do produto ')) cond = int(input('Digite [1] para pagamento a vista com dinheiro ou cheque;\nDigite [2] para pagamento a vista no cartão\nDigite [3] para pagamento de 2x no cartão\nDigite [4] para pagamento 3x ou mais no cartão: ')) if cond == 1 : print(f'O valor a ser pago é de R${v-...
true
3f31d50e3d2136a64530ab22902b80cf13cc0b77
yongdono/potato
/components/database/mongo.py
UTF-8
2,294
2.65625
3
[ "Apache-2.0" ]
permissive
#encoding:utf-8 #name:mod_db.py from pymongo import MongoClient from components.database.configure import getConfigInfo from engine.logger import getLogger class mongo_db(object): def __init__(self, collection): serv = getConfigInfo('Mongo') self.__host = serv['host'] self.__port = serv['po...
true
9046b4f1e7a9d1657b8e2f17cc872d31bff06f34
stephx8x/travis_ese1
/fizzbuzz/fizzbuzz.py
UTF-8
398
3.890625
4
[]
no_license
# -*- coding: utf-8 -*- class FizzBuzz: def convert(self, number): if(number < 1 or number > 100): raise Exception("1<=number<=100") elif(number % 3 == 0 and number % 5 == 0): return "FizzBuzz" elif(number % 3 == 0): return "Fizz" elif(number % 5 ...
true
8b6878970a4237e98adcf0307a943e55f4a74c66
ranjithkumar121/Python
/ASSIGNMENT 2/1.Area_of_rectangle.py
UTF-8
120
3.265625
3
[]
no_license
lenght=float(input()) breadth=float(input()) area=lenght*breadth print("{:.4f}".format(area)) #12.789902 #14.938287
true
25a41608d5bbe6bb16140c08eb02ba0d0923a291
iwbailey/shakemap_oasisloss
/shakemap_oasisloss/areaperilgrid.py
UTF-8
3,061
3.609375
4
[ "MIT" ]
permissive
import numpy as np import numpy.ma as ma # ----------------------------------------------------------------------------- class AreaPerilGrid: """Defines a grid with which to assign geographic coordinates. Points assigned to grid cells with left and bottom edges closed, i.e. x_i <= x < x_i+1 Indexing is ...
true
b2bc08e596bc5102dc30a84009b03d6248237762
gabrielsule/cursopython
/07_modules/01_path.py
UTF-8
156
2.796875
3
[]
no_license
from pathlib import Path path = Path("c:\\code\\data.json") print(path.name) print(path.stem) print(path.suffix) print(path.parent) print(path.absolute())
true
7e5c18aa58075c7b6ad8c8c32d9074587756d44d
pilkaton/pilkaton
/ultrasonic.py
UTF-8
772
2.703125
3
[]
no_license
import grovepi from threadPrinter import DigitalPrinter class Ultrasonic: def __init__(self, port, subscribers): self.port = port self.subscribers = subscribers self.limit = grovepi.ultrasonicRead(self.port) print self.limit def handle(self): while True: try: value = grovepi.u...
true
94a785a7f51923d032fa7c7dbcc03e0d4924bf4b
muthuguna/python
/MergeFiles.py
UTF-8
1,142
3
3
[]
no_license
""" File1.txt Little Rock:72201 Sacramento:94203 Denver:80201 Hartford:06101 Dover:19901 Washington:20001 Miami:33124 Atlanta:30301 Honolulu:96801 Montpelier:83254 #File2.txt Hartford:Conneticut Dover:Deleware Washington:District of Columbia Miami:Florida Atlanta:Georgia Honolulu:Hawaii Montpelier:Idaho Huntsville:Ala...
true
3e4692a0a63cac7e8285a6b1859ac6cf5998fa8c
yz48/basic-algs
/sort_alg.py
UTF-8
4,371
3.546875
4
[]
no_license
__author__ = 'yz48' # bubble sort def bubble_sort(array): for i in range(len(array)): f = 0 for j in range(1,len(array)-i): if array[j-1] > array[j]: f = 1 array[j-1], array[j] = array[j], array[j-1] if f == 0: break return array ...
true
f693e7fd09756eaf817ec06cd5b482575e51c35d
throughput-ec/ec_workshops_py
/exercises/solution_05_04.py
UTF-8
937
2.984375
3
[ "MIT" ]
permissive
import pandas as pd import matplotlib.pyplot as plt # this block loads the data. You will need to reuse it in all exercises going forward. url = 'https://raw.githubusercontent.com/LinkedEarth/Pyleoclim_util/master/example_data/wtc_test_data_nino.csv' df = pd.read_csv(url,skiprows=0) t = df['t'] # time in fractional ...
true
874ec5d696c773d0c926e7a31f337f9a000a89f4
adityakuriti/Hands-On-Python
/parsing.py
UTF-8
1,159
4.46875
4
[]
no_license
# Index starts from 0 list1 = [1 ,5 ,10.0 , "python","ok"] str = "python" tuple1 = (10,50,"String1",100.0,"Hello") # parsing and changing list print("\nParsing and changing value of list") for i in list1: print ("The value in list1 is : ",i) print("The value of the 3rd index in the list is : ",list1[3]) print("The ...
true
d29d97a6a0c2e8ccd4f18a1355279a00fe4c7639
shaniavina/Leetcode_Python
/repeated_dna_sequences.py
UTF-8
363
2.859375
3
[]
no_license
import collections class Solution(object): def findRepeatedDnaSequences(self, s): """ :type s: str :rtype: List[str] """ l = [] if len(s) < 10: return [] for i in range(len(s) - 9): l.extend([s[i : i + 10]]) return [k for k, v i...
true
2c0490ff578da7077df237977446d756c4a76b8a
lecklis/python-crash-course-exercises
/chapter-2/2_5_famous_quote.py
UTF-8
443
3.78125
4
[]
no_license
''' 2-5. Famous Quote: Find a quote from a famous person you admire. Print the quote and the name of its author. Your output should look something like the following, including the quotation marks: Albert Einstein once said, “A person who never made a mistake never tried anything new.” ''' famous_quote = '...
true
7d1c7e5ab30047f23f2fd7b3e30993377fe80598
marcelosalles/idf-creator
/pre-analise/conta_erro.py
UTF-8
182
3.15625
3
[ "MIT" ]
permissive
import glob files = glob.glob('*.csv') for file in files: print(file) with open(file, 'r') as file_read: x = file_read.readlines() print(len(x))
true
090e25da7b03e0b3c51da5e374dfdc483ba8ff94
17688832018/blogproject
/blog/templatetags/blog_tags.py
UTF-8
1,839
2.75
3
[]
no_license
#!-*-coding:utf-8 -*- from django import template from ..models import Post, Category, Tag # 引入Count,在 Django ORM 中是保存到 Category 的实例的属性中,每个实例对应一条记录 from django.db.models.aggregates import Count """ 页面侧边栏逻辑 将函数 get_recent_posts 装饰为 register.simple_tag模板标签(django固定格式) * django1.9后支持simple_tag 模板标签 这样就可以在模板中使用语法 {% get_r...
true
c69c5939397df09e8b84856b4cd067f9d4f7773d
aeciovc/sda_python_ee4
/SDAPythonIntermediateDecorators/sample2.py
UTF-8
143
2.546875
3
[]
no_license
def mute(func): def wrapper(): pass return wrapper @mute def emit_sound(): print("Emitting sound....") emit_sound()
true
2886709c4159dc76b0f87c658065059ec448d780
astoned/How-to-Think-Like-a-Computer-Scientist
/clock_alarm.py
UTF-8
911
4
4
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 9 17:37:29 2019 @author: astoned """ # ============================================================================= # You look at the clock and it is exactly 2pm. You set an alarm to go off in 51 hours. At what time does the alarm go off? (Hint...
true
68cf1c9a2ac487e6bc254cdc9fd27da354407741
shashankbaveja/SWD_Billing
/SWD_Billing_Tshirts.py
UTF-8
3,368
2.921875
3
[]
no_license
## The following program automates the procedure of billing students for t-shirts by different assocs ## the program is tested on win 8.1 with python 2.7 ## download splinter to navigate through web, xlrd to read your excel, xlwt to write in excel files ## works perfectly fine on Google Chrome given you have downloade...
true
2b6e5ff0a9cbc90dfa965e2c4b596c73cc319834
thecomputerguy/full-speed-python
/modules/find_maximum.py
UTF-8
207
3.671875
4
[ "MIT" ]
permissive
import math def find_maximum(x,y): return max(x,y) print(find_maximum(10,20)) def find_maximum_using_if_else(x,y): if x > y: return x else: return y print(find_maximum(20,30))
true
bd6f4eab5d082a28ff8ac75638e84ae64aa7cc87
franpe1/starting_with_python_ver2
/chap8_8.py
UTF-8
1,345
4.125
4
[]
no_license
def main(): # Initiate the uspopulation list uspl = [] # Open the File , Remove the \n and store in uspl list file = open('data/USPopulation.txt','r') uspf = file.readline() while uspf != '': uspl.append(int(uspf.rstrip('\n'))) uspf = file.readline() file.close # Create a list wit...
true
bdc7eb3645687bb3f7b59c6e21a7b46bd18ea883
andm90/GeometricalFigures
/FiguryGeometryczne/test_Squere.py
UTF-8
294
2.8125
3
[]
no_license
import unittest from Squere import Squere class test_Squere(unittest.TestCase): def test_area(self): self.assertEqual(Squere(3).area(), 9) def test_perimeter(self): self.assertEqual(Squere(3).perimeter(), 12) if __name__ == '__main__': unittest.main()
true
4497db2e505a8681f16a34a55885bc3068fdd58d
ashawkey/CGT_Othello
/solver.py
UTF-8
5,472
3.03125
3
[ "MIT" ]
permissive
from sqlitedict import SqliteDict import queue class solution(): def __init__(self, state="undecided", remoteness=-1, pos=None, move=None): self.state = state self.remoteness = remoteness self.pos = pos self.move = move self.parents = [] self.children = [] ...
true
2399a256c8e9db564189fbd1c556e8eaa356bbd8
pjok1122/baekjoon-online-judge-practice
/greedy/coin0(11047).py
UTF-8
758
3.75
4
[]
no_license
''' 1. price[] 에 맞춰, 동전의 개수를 최소로 주는 문제. 2. pirce는 오름차순으로 정렬되어있기 때문에 가장 비싼 동전부터 할당. 3. 비싼 동전을 하나씩 주지 말고, 몇 개까지 한 번에 줄 수 있는지 결정한다. ex) 5200원을 500원 짜리와 100원을 최소로 주고 싶을 때, 500*10을 바로 할당하는 것이 보편적. 따라서 q = 5200/500 을 계산한다. 4. 시간 복잡도 : O(n) ''' n, k = map(int, input().split()) price =[] for i in range(n)...
true
791cc6c51b81c15ad5e51783bb6c30cdc6753c11
wallamejorge/MscThesis
/Source & Sim/BeagleBone Black/Libraries/PyBBIO-master/bbio/platform/beaglebone/i2c.py
UTF-8
2,038
2.53125
3
[ "MIT" ]
permissive
# i2c.py # Part of PyBBIO # github.com/graycatlabs/PyBBIO # MIT License # # Beaglebone i2c driver import bbio, cape_manager, os, glob, serbus from config import I2C_BASE_ADDRESSES class I2CBus(serbus.I2CDev): def __init__(self, bus): assert 1<= bus <= 2, 'Only I2C buses 1 and 2 are available' # Run serbus...
true
f60e0248f94f1b3d19e78e09bebae17aa071a293
kmehuly/python
/data-structures/PostOrderTraversal.py
UTF-8
1,120
3.828125
4
[ "MIT" ]
permissive
class newNode: # Constructor to create a newNode def __init__(self, data): self.data = data self.left = None self.right = None def postorder(head): temp = head visited = set() while (temp and temp not in visited): # Visited left ...
true
c2c14de594d1902a4a155366ee183707ecf3a3db
Parizval/CodeWars
/Numericals of a String/Sol.py
UTF-8
394
3.75
4
[]
no_license
# Coded by Parizval def numericals(s): if len(s) == 0 : return "" else : val = {}; ans = "" for i in range(len(s)): if s[i] not in val.keys(): val[s[i]] = 1 ans += "1" else : val[s[i]] += 1 ans...
true
3dbc6a940439078e83ab3de235348d484b7f457c
boynux/daastani
/lib/aws.py
UTF-8
1,132
2.71875
3
[ "MIT" ]
permissive
import boto3 import datetime import requests class CredentialsProvider(object): def __init__(self, url, certs): self.url = url self.certs = certs self._creds = None self._session = None self._expiration = datetime.datetime.now() def renewCredentials(self): res ...
true
10144b2b1e02787e4c8ddff00313bb167a67e2c4
LuisFelipeUrena/Sprint-Challenge--Algorithms
/recursive_count_th/count_th.py
UTF-8
915
4.125
4
[]
no_license
''' Your function should take in a single parameter (a string `word`) Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters. Your function must utilize recursion. It cannot contain any loops. ''' # i am not sure if this is allowed but i could not figure out the recu...
true
b2b48e260498ac8aacf42939851339a255ed3125
bjg/bridgingmodule2013
/ie/dit/soc/bridgingmodule2013/first.py
UTF-8
96
2.828125
3
[]
no_license
''' Created on 31 Aug 2013 @author: brian ''' def add(a, b): return a + b print add(1, 2)
true
32523554f211578b23199dc6ca9563840cb457e9
anvshrnikhil/Internship
/adv_testing.py
UTF-8
1,722
2.75
3
[]
no_license
import numpy as np import dataret as dr import pandas as pd frame = dr.get_data('clean_data.xls') def divide(item): item_frame = frame[frame['Item_Id'] == item] return item_frame def get_reference_items(frame_list): ref_list = [] for fr in frame_list: src = list(fr['source']) ...
true
c56b27917352647421e4e92e3ba0dbc518ed9d11
sushantchandanwar/Assignment_01
/16_ClearListWays.py
UTF-8
443
4.5625
5
[]
no_license
# 16. Different ways to clear a list in Python # method-1 # GEEK = [6, 0, 4, 1] # print('GEEK before clear:', GEEK) # # GEEK.clear() # print('list clear:', GEEK) # method-2 # list = [{1, 2}, ('a'), ['1.1', '2.2']] # # # clearing the list # del list[:] # # print('List:', list) # method-3 list = ['Mon', 'Tue', 'Wed'...
true
fe7882bd49e80d223b60958303f9ea8f4e32c8ef
rheaajep/Computer-Vision-Project
/Feature Descriptors, Homographies and RANSAC/planarH.py
UTF-8
3,737
2.875
3
[]
no_license
import numpy as np import cv2 from BRIEF import briefLite, briefMatch from numpy import linalg as la import random def computeH(p1, p2): ''' INPUTS: p1 and p2 - Each are size (2 x N) matrices of corresponding (x, y)' coordinates between two images OUTPUTS: H2to1 - a 3 x 3 ma...
true
0340af48f9ba7a60b14bf4fbe7b304e2febb5bbe
Jworboys/Learning_Python
/learning Python/28_type_hinting/code.py
UTF-8
126
2.953125
3
[]
no_license
from typing import List def list_avg(sequence: list) -> float: return sum(sequence)/len(sequence) list_avg(123)
true
84064b96f327193e0556fc4a1a8d89fbb2a9b7d2
raft-tech/cfgov-refresh
/cfgov/alerts/tests/test_newrelic_alerts.py
UTF-8
3,766
2.578125
3
[ "CC0-1.0" ]
permissive
import datetime import time import unittest import mock import requests from alerts.newrelic_alerts import NewRelicAlertViolations class TestNewRelicAlertViolations(unittest.TestCase): def setUp(self): # Set up patcher for all requests.get calls to New Relic patcher = mock.patch('requests.get')...
true
f9a979a5bf91402bfec61cdc5bec9c96abc7c73d
glamod/glamod_landQC
/qc_tests/odd_cluster.py
UTF-8
5,504
2.859375
3
[]
no_license
""" Odd Cluster Checks ^^^^^^^^^^^^^^^^^^ Find isolated data (single points and small runs) """ #************************************************************************ import numpy as np import qc_utils as utils #************************************************************************ MAX_LENGTH_OBS = 6 # up to X ...
true
c8d2fb6dbfde548e72368b5d971406a9abf371a8
tkleinen/acaciadata
/acacia/acacia/data/knmi/util.py
UTF-8
843
3.125
3
[]
no_license
''' Created on Sep 17, 2015 @author: theo ''' import math def distance(obj, pnt): dx = obj.location.x - pnt.x dy = obj.location.y - pnt.y return math.sqrt(dx*dx+dy*dy) def closest_object(query,target): closest = None dist = 1e99 for obj in query: d = distance(obj, target) if ...
true
61d0049d679d5a6e5bc159e007853d43d4471112
Pravuswain/P342A6
/a6q3.py
UTF-8
743
3.578125
4
[]
no_license
import math f = lambda x:math.exp(-x**(2)) print(f'Method Integral N ') from integrator import error from integrator import simpsons N1 = error(0,1,0.001,12,'simpsons') out1= simpsons(f,0,1,N1) print(f'simpsons: {out1}',N1) from integrator import error from integrator import midpoint N2 ...
true
98d53a16855188df2c23097824195018ff08d622
vhai19/100_knock
/80-89/q83.py
UTF-8
1,404
2.921875
3
[]
no_license
# -*- coding: utf-8 -*- """ 83. 単語/文脈の頻度の計測 82の出力を利用し,以下の出現分布,および定数を求めよ. usage bzcat ./data/enwiki.txt.bz2 | python q80.py | python q81.py| python q82.py | python q83.py """ import sys from collections import defaultdict def main(fi): # with構文でも良いが,横に長くなりすぎる… fo1 = open("/work/kiyono/f_tc.txt","w") fo2 = ope...
true
8aa6fe7a5172d3421024dd2eb44ebf33cf1da0ce
solairedev/Examples
/Python/graph.py
UTF-8
1,930
3.640625
4
[]
no_license
graph = {} def sozdanie(): global graph kol = int(input('Введите кол-во вершин - ')) for i in range(1,kol+1) : temp_contiguity = [] temp_graph = {} while True : temp = input('Введите вершину смежную для %s вершины(n - stop)\n' % str(i)) if temp != 'n': ...
true
503d3ac1ac2f4288bd52587c461fa8bb92428676
Factumpro/HackerRank
/Python/Tutorials/30 Days of Code/Day_06.py
UTF-8
141
3.03125
3
[]
no_license
#!/usr/bin/env python3 for i in range(int(input())): s = input() step = 2 print(*[''.join(s[:: step]), ''.join((s[1:: step]))])
true
0512b376ec594ed81bc498f34ef53be5c016d449
ShabbirHasan1/PyTDS
/data/account_data.py
UTF-8
4,135
2.671875
3
[]
no_license
import requests import uuid import json from config.config import get_app_config import logging import threading class Account(object): def __init__(self, username: str = None, password: str = None, client: str = None) -> None: self.accounts = {} self.lock = threading.Lock() self.app_confi...
true
69898a5a738c4f914c55cbbd8d1a11724c982da1
ravishankarveerabadharan/pranesh-code
/pranesh/fruit.py
UTF-8
658
3.734375
4
[]
no_license
#!usr/bin/env python print "\n" print " The Available Fruits is\n" fruits = ["apple","orange","grapes","pineapple"] print fruits apple = 30 orange = 25 grapes = 32 pineapple = 50 i = raw_input("\nType the above fruits to know the details of price,\nType the above fruit is case sensitive \nEnter ur fruit : ") if i == ...
true
6ac0241132b1cc73cf257a090daf1fb8236d5b9f
madiej6/EarthquakeDamageModel
/WorkingScripts/o1_Earthquake_ShakeMap_Download.py
UTF-8
13,433
2.765625
3
[ "MIT" ]
permissive
# Imports import arcpy try: from urllib2 import urlopen except: from urllib.request import urlopen import json import shutil import os import zipfile import io import datetime from within_conus import check_coords from get_file_paths import get_shakemap_dir def check_for_shakemaps(mmi_threshold = 3): Fil...
true
e3f020f440ebeadd2d492ecc536aaf45437c248b
khand420/Learn-Python
/if_else.py
UTF-8
331
4.25
4
[]
no_license
# var1 = 6 # var2 = 56 # var3 = int(input("Enter a Number for Greater and Smaller: ")) # if var3>var2: # print("Greater") # else: # print("Lesser") print("What is you Age? ") age = int(input()) if age<18: print("You are a child") elif age<=60: print("You are Adult") elif age>60: print("You ...
true
0ceb2574b1a63fb2f7cbfb6c6d32fbd3fcc649f5
AcedenD/pc-fan
/web/app.py
UTF-8
594
2.65625
3
[]
no_license
from flask import Flask,jsonify,render_template,request, redirect app = Flask(__name__) @app.route("/") def index(): return render_template("index.html") speed = 0 @app.route("/get_speed") def get_speed(): data = {"speed":speed} return jsonify(data) # @Dayton @app.route("/set_speed", methods=['GET', 'P...
true
ced4e5ad00b2cdc756905371e79994448f6642db
chyylq/leetcode
/621_task_scheduler/sol.py
UTF-8
1,563
3.015625
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Thu Oct 4 20:12:22 2018 @author: yilin """ class Solution: def leastInterval(self, tasks, n): """ :type tasks: List[str] :type n: int :rtype: int """ next_n_excl = [None for i in range(n)] #jobs = [] n_jobs = 0...
true
52d957c74a3391b3a35592bd497a2a23e25a3054
SamuelTrostle/RoundBallAnalytics
/project/RoundBallmain.py
UTF-8
5,710
2.546875
3
[]
no_license
# Imports from flask import Flask, render_template, redirect, url_for, request, g import csv, sqlite3 import pandas as pd app = Flask(__name__) # Login @app.route('/login', methods=['GET', 'POST']) def login(): error = None if request.method == 'POST': # Check for Admin Priv if request.form['u...
true