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
a246ae7352c54edc10f0447d15f2eb61f54ec3a4
trueleo/censored-telegram
/database.py
UTF-8
1,691
2.671875
3
[ "MIT" ]
permissive
# Table "public.filedict" # Column | Type | Collation | Nullable | Default # -------------+-----------------------+-----------+----------+--------- # key | character varying(64) | | not null | # fileid | character varying | | not null | # filetype | cha...
true
3e5c19ada4f8003a645b5841520d25621edbf6a0
bnookala/ampy
/src/am.py
UTF-8
2,759
2.9375
3
[]
no_license
#!/usr/bin/env python #AMPY V3 #Standard libraries import signal #3rd party import urwid import ampylib class SongWalker(urwid.ListWalker): """ Listwalker compatible class for songs """ focus = None def __init__(self): self.focus = 0 def get_focus(self): return def ...
true
edefd80c273b0beaae8f3375c4c9411b1f8a651f
live-abhishek/ds-algo
/uva/00616.py
UTF-8
982
3.21875
3
[]
no_license
import sys sys.stdin = open("input.txt") sys.stdout = open("output.txt", "w") # TODO: NOT SOLVED def find(coco): peo = -1 monkey_share = 1 for tot_peo in range(int(coco**0.5), 1, -1): curr_coco = coco people_woke = 0 for p_num in range(1, tot_peo + 1): people_woke += 1...
true
d61e2738571a9e0a17e0e938d7618c194eebd23c
onism7/spider
/GUI/Tkinter2.py
UTF-8
352
3.15625
3
[]
no_license
import tkinter as tk class APP(object): def __init__(self, master): frame = tk.Frame(master) frame.pack() self.hi_there = tk.Button(frame, text='测试', fg='blue', command=self.say_ceshi()) self.hi_there.pack() def say_ceshi(self): print("GUI编程测试") st = tk.Tk() app = AP...
true
e86289085b6fdb76f7c91aa6ff531d30f6619ab2
poojanikita/build-a-blog
/Blog/post.py
UTF-8
1,595
3.234375
3
[]
no_license
class Post: def __init__(self, title, author, body): self.title = title self.author = author self.body = body self.likes = 0 def like(self): self.likes += 1 def __str__(self): return self.title + " by " + self.author class VideoPost(Post): def __init__...
true
ec4c260c174267b9c330f4bd7e46840ffb431649
AlexBastosMorais/Exercicios-Python
/Udemy/Udemy3.py
UTF-8
356
4.1875
4
[]
no_license
#Escreva um programa que resolva uma equação de segundo grau. from math import sqrt a = float(input('Digite o valor de a: ')) b = float(input('Digite o valor de b: ')) c = float(input('Digite o valor de c: ')) delta = b**2 - 4*a*c raizdelta = sqrt(delta) x1 = (-b + raizdelta)/(2*a) x2 = (-b - raizdelta)/(2*a) pri...
true
5be1dc9499ca14e870a5192a7dd3c60453246a05
stefan2134/COMP1531
/lib/user.py
UTF-8
9,725
2.609375
3
[]
no_license
from abc import ABC, abstractmethod from flask_login import UserMixin #for login thing from enum import Enum from datetime import time from lib.rating import Rating import copy, random, csv from lib.manager.rating_manager import RatingManager class ProviderService(Enum): GP = "General Practitioner" PHARMACIST ...
true
8a5e03c184109d60a0f9c81eeb0a1c2e0a4befcc
amruthavp/8th_sem_project
/faceRecognition.py
UTF-8
1,737
2.6875
3
[]
no_license
import cv2 import os import numpy as np def faceDetection(test_img): gray_img = cv2.cvtColor(test_img, cv2.COLOR_BGR2GRAY) face_haar_cascade = cv2.CascadeClassifier('C:/Users/ANAGHA/FaceRecognition-master1/HaarCascade/haarcascade_frontalface_default.xml') faces = face_haar_cascade.detectMultiScale(g...
true
b3b0b07d5d1cb2b344396d8e1fd3fb8e1799fddb
cc97nitu/Playground
/GroundTorchOcelot/src/PetraIV/OrbitPrediction.py
UTF-8
2,659
2.546875
3
[]
no_license
import sys sys.path.append("../") import torch import torch.nn as nn import torch.optim as optim import matplotlib.pyplot as plt from OcelotMinimal.cpbd import elements import PlotTrajectory from LatticePetraIV import PetraIVLattice from Simulation.Models import SecondOrderModel # general properties dtype = torch....
true
d65e3672055e45a3e445cb07ba095c4547416968
AkshdeepSharma/Classroom
/Firecode.io/Level 4/longest_common_prefix.py
UTF-8
196
2.703125
3
[]
no_license
def long_common_prefix(input_list): same = [] for a in zip(*input_list): if len(set(a)) == 1: same.append(a[0]) else: break return "".join(same)
true
df4087fc3e55dc72df491eb60a1b8588124e5470
DLocarno/math_race
/game/Parser.py
UTF-8
1,288
3.203125
3
[]
no_license
import pygame import os class Parser(): def __init__(self): self.index = 0 def load_transcript(self, transcript): self.transcript_file = transcript try: with open(self.transcript_file) as file: self.transcript = file.readlines() except: ...
true
ce5719851d046b7b016c6f6df40122e0fe78bdac
angelacpd/Introduction_to_Algorithms
/E2-1-4.py
UTF-8
849
3.859375
4
[]
no_license
# Code for exercise 2.1-4 # Input: Two sequences of n elements A = <a1, a2, ..., an> and B <b1, b2, ..., bn> representing two # n-bit binary integers. # Output: The sum of the two input sequences as a (n+1)-element array C representing (n+1)-bit # binary integer. import numpy as np # Inputs n = 4 A = np.random.rand...
true
483769a953342708e3d7d835c2e77f6610e785fe
duongnt52/ngotungduong-fundamentals-c4e25
/Fundamentals/Session4/intro.py
UTF-8
575
3.0625
3
[]
no_license
#name age location exes status friends person = ["Quan", 25, "Hanoi", 3, False, 125] # Kho hieu # person = {} # print(person) # print(type(person)) # person = { # "name": "Quan" # } # print(person) person = { "name": "Quan", "age": 25, "location": "Hanoi", "exes": 3, "status": Fa...
true
f34ab788e6432fa43d71b97643893dc9a500d8fc
Nokorot/MyConfigs
/home/.bin/pdfcropG
UTF-8
4,350
3
3
[]
no_license
#!/usr/bin/python3 from tkinter import * import tempfile import PyPDF2 from pdf2image import convert_from_path import os, sys def pdfcrop(pdffile, rect, page_nr=1, output=None): with tempfile.TemporaryDirectory() as path: os.system(f'pdftk "{pdffile}" cat {page_nr} output {path}/page.pdf') os.s...
true
e9de6e036aae35a0bb8aff5558ac209437273016
Confuzerpy/checkio_solve
/home/count_words.py
UTF-8
158
3.4375
3
[]
no_license
def count_words(text, words): count = 0 text = text.lower() for word in words: if word in text: count += 1 return count
true
05e6b8a692ed714dccaf6b6d2af704c34a4aad4e
haoccheng/pegasus
/coding_interview/binary_num1.py
UTF-8
342
3.890625
4
[]
no_license
# Implement a function to get the number of 1s in the binary representation of an integer. # 9 : 1001 in binary. -> 2. # integer 32-bit. def count1(input): count = 0 for i in range(32): bit = (1 << i) v = input & bit if v != 0: count += 1 return count print count1(0) print count1(1) print coun...
true
ee4069ef514fcec5561aa799e9bd379fb7ec2389
zkulphong/capitalone
/analysisScripts_sfpd/callTypes.py
UTF-8
583
2.859375
3
[]
no_license
import pandas as pd import csv #import dataset into dataframe csv_name = "sfpd-dispatch/sfpd_dispatch_data_subset.csv" data = pd.read_csv(csv_name) #get dictionary with keys of types from "call_type_group" and values counting the frequency of each type in dataset dTypes = {} for dispatch in data["call_type_group"].va...
true
896305ea95dfba2aafdac921fb7b0eb04ffcb446
thiagossp/stb-automated-tester
/poc/regularExpressions.py
UTF-8
177
3.03125
3
[]
no_license
import re teste = 'asd11:12:13asd' pattern = re.compile("[0-9]{2}:{1}[0-9]{2}") print(pattern.search(teste).group(0)) if pattern.search(teste) is not None else print("None")
true
adf8581ebc22a58fe7ab461049059e3ef3748ef1
CFloy66-v12o/Facebook-
/facebook.py
UTF-8
783
3.0625
3
[]
no_license
#! python from selenium import webdriver from time import sleep from webdriver_manager.chrome import ChromeDriverManager from getpass import getpass from selenium.webdriver.chrome.options import Options usr = input('Enter Email Id: ') pwd = getpass('Enter Password: ') driver = webdriver.Chrome(ChromeDriverManager()....
true
93dd1e78b554f967d9c754ac614ee44357ac14a2
Adharshmahesh/Natural-Language-Processing-IMDB-dataset
/lr_different_parameters.py
UTF-8
9,841
2.796875
3
[]
no_license
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import numpy as np import pandas as pd import os import re from sklearn.feature_extraction.text import CountVectorizer from sklearn.linear_model import LogisticRegression from sklearn.svm import LinearSVC from sklearn.metri...
true
5075c55a28f0de59f76836f1a6b528d65474363f
lfcten/Leetcode
/Dp/Freedom Trail/Solution.py
UTF-8
1,935
3.234375
3
[]
no_license
import collections class Solution: def findRotateSteps(self, ring, key): """ :type ring: str :type key: str :rtype: int """ m, n = len(ring), len(key) def dist(i, j): return min(abs(i - j), m - abs(i - j)) dic = collections.defaultdict(...
true
b29c7417991fa8867ffbce08319b0943d40ea19e
ChaucerG/Vehicle-Distance-Detection
/test_draw_on_image.py
UTF-8
1,745
2.921875
3
[ "MIT" ]
permissive
import numpy as np from PIL import Image, ImageDraw, ImageFont def draw_boxes(image, out_scores, out_boxes, out_classes, class_names, colors, out_distance): print(image.size) # print(image.shape[0]) font = ImageFont.truetype(font='font/FiraMono-Medium.otf',size=np.floor(3e-2 * image.size[1] + 0.5).astyp...
true
1a26ed804da0d1969c878a86a33e63d55cb82273
sandermn/CVDL-assignment-3
/task3d.py
UTF-8
8,255
2.5625
3
[]
no_license
import pathlib import matplotlib.pyplot as plt import utils import torch from torch import nn from torchvision import transforms from dataloaders import load_cifar10 from trainer import Trainer, compute_loss_and_accuracy class Model1_with_dropout(nn.Module): def __init__(self, image_channels, ...
true
24c48239e79d07c8ac1e4ba22623dce8b5e1459b
99banroimattroi/trinhdinhhung-labs-c4e26
/Session 2/Homework_S2_TrinhDinhHung_C4E26/Turtle_exercise_2.py
UTF-8
49
3.1875
3
[]
no_license
def sum(x,y): s = x + y print(s) sum(1,5)
true
ed27b4c2129a9b3227657873850799d10eed7cf1
faisal3397/blog-api
/test_app.py
UTF-8
7,479
2.703125
3
[]
no_license
import os import unittest import json from flask_sqlalchemy import SQLAlchemy from src.app import app from src.database.models import setup_db, Post, Comment class BlogTestCase(unittest.TestCase): def setUp(self): """Define test variables and initialize app.""" self.app = app self.clien...
true
49f8435600b5ad7bff696bfdb5191e8a035649ac
kingkang00/Superhero-Index
/Index.py
UTF-8
3,959
3.03125
3
[ "MIT" ]
permissive
import sys import time from modules import colors class Hero: def __init__(self, name, age, status, creator, team, powers, power_ranking): self.name = name self.age = age self.status = status self.creator = creator self.team = team self.powers = powers self....
true
a16d0e343c60fc30f0eb99d014b39ba7e79c9db4
ejaz-vel/AppDynamics
/experiments.py
UTF-8
2,468
3.015625
3
[]
no_license
import KMeans # Runs experiments for KMeans # You have the option of choosing to use TF-IDF scores or not. def runExperimentsForKMeans(numClusters, numExperiments, useTFIDF=True): maxSim = 0 experiment = 0 for i in range(numExperiments): print "\nExperiment " + str(i) + " for " + str(numClusters) + " clusters" ...
true
812de43b20502c5bec45052a8a9369ab48eb5ae8
edmundcheng221/CSCI-003
/Homework 11/test_recursive.py
UTF-8
639
3.484375
3
[]
no_license
""" Homework #11 CSCI-UA. 0003-001 Fall 2020 Edmund Cheng ec3219 2020-12-06 """ import unittest from recursive import count_nested_tuple # write your test class here! # I made two test cases; 1 for tuple, 1 for nested tuple class TestRecursive(unittest.TestCase): def test_tuple(self): count = 7 ...
true
9d662e22a602f911770f9a7d7dbfb077409df11f
johanzebin/scicopy_group1
/hw1/grepy_jkeyser.py
UTF-8
7,021
2.90625
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- """ grepy implements some core functionality of the *nix grep command. SCICOPY SS11, homework 1 Authors: group01, i.e. mrausch, jkeyser, shennig, sfleck """ from optparse import OptionParser import os import sys import re def colorize_string(text="", color_str="yellow"): ...
true
4a564df408a4d32664d11c0ffcbb2bdb63387065
Richard5127/Python
/list/list-add1.py
UTF-8
259
3.328125
3
[]
no_license
#!/usr/bin/python # coding: utf-8 list7 = [ '1', '9', 'N', 'h', 'e' ] list8 = [ '5', 'V', 'l', '2', 'N', 'I', 'i', 'E' ] list9 = [ 'b', 'd', 'u', '3' ] nu = int(input("請輸入一數字")) if nu > 3: list7 += list8 print (list7) else: print (list9 * nu)
true
aa67bfa8667c6f54a35ff986741dbf41793ed3ba
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/arc020/B/3918051.py
UTF-8
333
2.671875
3
[]
no_license
#!/usr/bin/env python3 n, c = map(int, input().split()) a = [int(input()) for _ in range(n)] ans = 1e7 for i in range(1, 11): for j in range(1, 11): if i == j: continue b = [[i, j][k % 2] for k in range(n)] cnt = sum([a[k] != b[k] for k in range(n)]) ans = min(ans, cnt) p...
true
9bce54d153df952ab8b76abf18ed449c17d556c2
gyjoo/efp57
/24_Anagram_Checker/24_Anagram_Checker.py
UTF-8
680
4.59375
5
[]
no_license
def isAnagram(string1, string2): 'This function checks that whether strings are anagram or not' str1_size = len(string1) str2_size = len(string2) if str1_size != str2_size : print('Both input strings must be the same length.') return false for i in range(0,str1_size): for string1[i] in string2: return ...
true
2758256acf3347019965834632fe1fb4ef90367e
Anuise/Pythonpractice-
/example_code/test.py
UTF-8
369
2.75
3
[]
no_license
import os import sys fileList = [] fileSize = 0 folderCount = 0 rootdir = '/home/au/example_code/image' for root, subFolders, files in os.walk(rootdir): folderCount += len(subFolders) for file in files: f = os.path.join(root,file) fileSize = fileSize + os.path.getsize(f) fileList.appen...
true
d979b6eac9e0f3116d7ed5b9db754bd93f46fd9a
gjwei/cikm2018
/code/utils/data_utils.py
UTF-8
1,402
3
3
[]
no_license
# coding: utf-8 # Author: gjwei import numpy as np def load_vocab(path): vocabs = [] with open(path, 'rt', encoding='utf-8') as f: for line in f.readlines(): vocabs.append(line.strip()) return vocabs def load_char_vocab(path): vocabs = ['@'] with open(path, 'rt', encoding='utf...
true
01c4688bdc65a3d4b27a00642accc9c08302ea87
AlexAalbertsberg/practice-python
/ex33-birthday-dictionaries/ex33.py
UTF-8
545
3.90625
4
[]
no_license
birthdays = { "Alex Aalbertsberg" : "08/05/1991", "Albert Einstein" : "03/14/1879", "Henk" : "01/01/2001" } def show_known_birthdays(): print("Welcome to the birthday dictionary. We know the birthdays of: ") for i in birthdays.keys(): print(i) def main(): show_known_birthdays() na...
true
e8f0640cd78a242e6b992f73b00aaf30316c32f7
jadudm/feather-isa
/infra/libs-400rc2-20190512/examples/motorkit_stepper_simpletest.py
UTF-8
180
2.625
3
[ "MIT" ]
permissive
"""Simple test for using adafruit_motorkit with a stepper motor""" from adafruit_motorkit import MotorKit kit = MotorKit() for i in range(100): kit.stepper1.onestep()
true
4cafbccf9bd2a6d01b196a7279a60168772be19e
insaf-ismath/DHL_Hackathon
/test.py
UTF-8
43
3
3
[]
no_license
x= range(1,10) print(x[2]) print(type(x))
true
f18a8a38fd38bb2706484492445a3a97a7f62a2d
Apprentice76/PracticeCode
/Assignment/4.py
UTF-8
169
3.75
4
[]
no_license
if '__main__' == __name__: c = input('Enter temp. in celsius') f = (9/5) * c + 32 f = round(f, 2) print('Fahrenheit equivalent of ' + c + ' is ' + f)
true
5d5eaba9f2d79c34e9181b26481c0bb683a18343
ss892714028/Maze-PathFinder-Visualization-Python
/src/a_star.py
UTF-8
2,631
3.078125
3
[]
no_license
import sys import numpy as np from config import config from collections import deque import time import pygame from queue import PriorityQueue import copy def is_valid(mat, row, col): M, N = mat.shape return (row >= 0) and (row < M) and (col >= 0) and (col < N) \ and mat[row][col] == 0 def manhatta...
true
96fa60f95f1dc37682782de4c28d117573512ed5
pgraciae/DataEngineering
/PerformanceEngineering/BS.py
UTF-8
1,781
3.328125
3
[]
no_license
import numpy as np def BinSearch(Val, Idx, Pos, N, M): for i in range(M): V = Val[i] Left =-1 Right= N Size = (Right - Left) >> 1 # integer division by 2 implemented by bit shifting while (Size > 0): Middle = Left + Size value = Idx[Middle] if (value < V): Left = Mid...
true
4e36789c59732e55091b7ced2f732a93f4b09623
dmurillo976s/Coding_Challenge_FastAPI
/api/modules/data_classes.py
UTF-8
3,056
2.8125
3
[]
no_license
from pydantic import BaseModel, Field from typing import Optional, Tuple # Pydantic data classes definition------------------------------------ # Data class for User response verification class BaseUser(BaseModel): id: str = Field(..., description="Unique value for identifying a user") name: str = Field(...,...
true
3a21d9d1165265d8d1ea84c1ae357cc638f341ab
OOAmusat/pyomo
/pyomo/contrib/surrogates/kriging.py
UTF-8
31,211
2.90625
3
[ "BSD-3-Clause" ]
permissive
import numpy as np from scipy.optimize import basinhopping import scipy.optimize as opt import pandas as pd from pyomo.core import Param, exp from sampling import FeatureScaling as fs class ResultReport: """ ======================================================================================================...
true
75965525cd9a54b44f47221084f5c01bafecf666
tijugeorge/Python-code-practice
/DB-API.py
UTF-8
387
3.75
4
[]
no_license
import sqlite3 # Fetch some student records from the database. db = sqlite3.connect("students") c = db.cursor() query = "select name, id from students order by name;" c.execute(query) rows = c.fetchall() # First, what data structure did we get? print "Row data:" print rows # And let's loop over it too: print print "...
true
9733e4fdd233841bd2206c3448c85b3c34cde77d
mchong6/Draw-Anime-GAN
/crop_resize.py
UTF-8
3,283
2.703125
3
[]
no_license
from __future__ import print_function from multiprocessing import Pool from PIL import Image import numpy as np import sys import os import cv2 # im from PIL.Image.open, face_pos position object, margin def faceCrop(im,face_pos,m): """ m is the relative margin added to the face image """ if not im: ...
true
c20f3b3aa5c971e203a3090f0ef290f6a2a2292d
Gabriel1521/leetcode
/270_Closest Binary Search Tree Value.py
UTF-8
1,400
3.671875
4
[]
no_license
# 270. Closest Binary Search Tree Value # 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 closestValue(self, root, target): """ :type root: TreeNode ...
true
a33c46327ccb87865df2529a21bfe005afda5dc4
mduppes/webhooks
/server/webhooks/DB.py
UTF-8
6,638
2.703125
3
[]
no_license
import mysql.connector import config import json import logging import time def save_webhooks_update(update): """Given a string update, decodes it to json and stores it if valid""" topic = update['object'] entries = update['entry'] if not topic or not entries: return connection = mysql.c...
true
e4063e03f6ee40857792cdf43cdd16e372069eb3
valliammai-tech/python-training-sessions
/DictComprehension-Ex5.py
UTF-8
766
4.09375
4
[]
no_license
# Question 3 - # # using Dict Comprehension find the occurrences of Numbers. Your function will take an Integer X followed by any # number of Arrays. You need to parse each array and find out elements in the Array that is divisible by X and # return the count of numbers that's divisible by X with its position. # # Exam...
true
cba060df72a99734a2adff7a8245cd990f201b7a
bhavyatamil55/PYTHON
/24.py
UTF-8
105
3.234375
3
[]
no_license
vsb=int(input()) ssb=list(map(int,input().split()[:vsb])) ssb.sort() for skp in ssb: print(skp,end=" ")
true
91154e2b1d0ea942dcfa70f139199982e221b2b5
Gayatri-soni/python-training
/assignment15/qu1.py
UTF-8
814
2.671875
3
[]
no_license
#q1 Extract the user id, domain name and suffix from the following email addresses. #emails = "zuck26@facebook.com" "page33@google.com" #"jeff42@amazon.com" #desired_output = [('zuck26', 'facebook', 'com'), ('page33', 'google', 'com'), ('jeff42', 'amazon', 'com')] import re s= " zuck26@facebook.com page33@google.com ...
true
e4a75bc030be78c5726591185291a61f456361a5
li275071519/Weishen2017
/判断闰年.py
UTF-8
137
3.578125
4
[]
no_license
year = int(input('请输入年份:')) is_leap = (year % 4 == 0 and year % 100 != 0 ) or \ (year % 400 == 0) print(is_leap)
true
f94816ccfaf869123677cae9b71a5baed1fa5d6c
Doonsles/Algorithms
/cardgame.py
UTF-8
3,003
3.984375
4
[]
no_license
import random def cardgame (placeholder): num_cards = 0 while int(num_cards) < 4 or int(num_cards) > 24 or int(num_cards) % 2 != 0: num_cards = raw_input("How many cards would you like? Enter an even number between 4 and 24.\n") num_cards = int(num_cards) cards = [] user_score =...
true
d86df404c1c68548ade44b78faeef4a50dea1542
tmilang/TLang
/triangle.py
UTF-8
153
3.375
3
[]
no_license
import turtle turtle.home() turtle.forward(100) turtle.left(120) turtle.forward(100) turtle.left(120) turtle.forward(100) input("press enter to exit")
true
862faaad458f74ea00ccdcfb228f3043bf2bf033
jmshnds/PySnake
/button.py
UTF-8
999
3.46875
3
[ "MIT" ]
permissive
import pygame from utils import Color from gameObject import GameObject class Button(GameObject): def __init__(self, x, y, width, height, text): super().__init__(x, y) self.width = width self.height = height self.text = text def draw(self, draw, screen, color): # Create font if not pygame.font.get_in...
true
e928d7ce64917fceb664ff84a947fe1ec4baa68f
derHeinz/service_monitor
/info/compoundinfo.py
UTF-8
1,114
2.625
3
[]
no_license
import logging from pydoc import locate logger = logging.getLogger(__file__) SERVICE_INFO_ERROR_PREFIX = "error getting information: " class CompoundInfo(object): def create_info(self, info_config): info_type = locate(info_config['info_type']) return info_type(**info_config['info_args']) de...
true
cd9aa09d362a3a075c7adc32c4d0f51f86022cd3
ChangxingJiang/LeetCode
/未完成题目/LCP/LCP34/LCP34_Python_1.py
UTF-8
350
2.890625
3
[]
no_license
from LeetTool import TreeNode from LeetTool import build_TreeNode class Solution: def maxValue(self, root: TreeNode, k: int) -> int: pass if __name__ == "__main__": print(Solution().maxValue(root=build_TreeNode([5, 2, 3, 4]), k=2)) # 12 print(Solution().maxValue(root=build_TreeNode([4, 1, 3, 9,...
true
84911d1b7e6b4669a61f321cb2473931de3e87ba
FutureSeller/TIL
/ps/leetcode/0784_letter_case_permutation.py
UTF-8
388
3.109375
3
[]
no_license
class Solution: def letterCasePermutation(self, s): result = [] def dfs(index, substring, result): if len(substring) == len(s): result.append(substring) return if s[index].isalpha(): dfs(index + 1, substring + s[index].swapcase(), result) dfs(index + 1, substr...
true
f71d9c3f5f1f164f8f8c8b3470033f1da909fb56
kimhyeongju/coding_practice
/programmers/Level 1/이상한 문자 만들기.py
UTF-8
910
4.03125
4
[]
no_license
""" 문자열 s는 한 개 이상의 단어로 구성되어 있습니다. 각 단어는 하나 이상의 공백문자로 구분되어 있습니다. 각 단어의 짝수번째 알파벳은 대문자로, 홀수번째 알파벳은 소문자로 바꾼 문자열을 리턴하는 함수, solution을 완성하세요. 문자열 전체의 짝/홀수 인덱스가 아니라, 단어(공백을 기준)별로 짝/홀수 인덱스를 판단해야합니다. 첫 번째 글자는 0번째 인덱스로 보아 짝수번째 알파벳으로 처리해야 합니다. """ def solution(s): answer = '' i = 0 for n in s: if n == " ": ...
true
e092b3ba1a9a8210ff1f0b47b311842f8002ca96
SeanKingG/prative
/pyCharm_project/1/frequentlyFunction.py
UTF-8
1,263
3.453125
3
[]
no_license
# a = 21414 # b = 'eghgeojgenafljeijfjaejfalgfnjh' # print(type(str(a))) # list = [',7','efe','34']#sequence:序列类型 # print(3 in list) # print(len(list))#统计列表元素个数 # print(list.count(3))#统计列表中特定元素个数 # # print(max(list))#统计列表最大值 # # print(min(list))#统计列表最小值 # print("a在字符串中的个数:"+str('fahefhaenkjafhea'.count('a')))#统计字符串中某个元...
true
7d11818fadbdbb83e6169507279be81fb202e05d
piotrmaslanka/satella
/satella/coding/concurrent/functions.py
UTF-8
2,061
3.40625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
import typing as tp from concurrent.futures import Future from threading import Thread from satella.coding.decorators.decorators import wraps from satella.coding.sequences.sequences import infinite_iterator from satella.coding.typing import T def run_as_future(fun): """ A decorator that accepts a function th...
true
6d0252d02d889860f4314c43d5539ac8ef38cc1a
andreybukhtoyarov/hhhomework-1
/core/decorators.py
UTF-8
934
3.328125
3
[]
no_license
def cache_decorator(funk): # Реализовать декоратор который кэширует результаты вызова функции (есть в лекции) # Применить для функции calculator (в calculator.py уже есть import функции cache_decorator) # Настоятельно прошу написать декоратор руками, а не копировать, т.к. важно запомнить как это работает ...
true
77f3763e4a892d433c3e500c44b5bd137ea43cc1
drongo-platform/drongo-core-modules
/drongo_modules/tests/utils.py
UTF-8
2,773
2.5625
3
[]
no_license
import json import time import urllib3 from threading import Thread from nest import Nest class APIClient(object): def __init__(self, api_url): self.http = urllib3.PoolManager() self.api_url = api_url self.headers = {'connection': 'keep-alive'} def set_auth_token(self, token): ...
true
7f8fee7a3879e9a522d42696dce779b8a492b776
Tundus/Python
/Zed_Shaw/R2D/r2d/parser.py
UTF-8
1,987
3.171875
3
[]
no_license
#import sys #sys.path.insert(0, "/home/andras/pythonHW/ex48") #from ex48 import lexicon class ParserError(Exception): pass class Sentence(object): def __init__(self, subject, verb, object, number): self.subject = subject[1] self.verb = verb[1] self.object = object[1] try: self.number = number[1] exc...
true
93171cc5ed85adb32a0a04cebf1b9d1c25ba58f1
Razin1996/Stock-Prediction-Using-fb-Prophet
/Test Files/Stock_Prediction.py
UTF-8
2,593
3.25
3
[]
no_license
import os import sys import tweepy import requests import numpy as np from keras.models import Sequential from keras.layers import Dense from textblob import TextBlob # Login into twitter using twitter API consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' auth = tweepy.OAuthHandler(co...
true
03101fa4314122f5fb4747fa7c05d4a73f742d48
1siddhi7/Learning-From-Data
/Logistic Regression/log_reg.py
UTF-8
2,121
3.140625
3
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 2 17:55:38 2019 @author: siddhi """ import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split features=[] labels=[] with open("marks.txt",'r') as f: for line in f: if no...
true
daeeef9a26e5ac535e86c994e728211ae574bfaf
tcanfield/giveaway
/giveaway/models.py
UTF-8
2,775
2.765625
3
[]
no_license
from django.db import models import random, math, datetime # Create your models here. class Category(models.Model): parent_category = models.ForeignKey('Category', on_delete=models.CASCADE, null=True, blank=True) name = models.TextField() description = models.TextField() def get_all_sub_categories(self...
true
d5cd97137763a8f205018af1d063108898739f90
ksy141/us
/final_pmf.py
UTF-8
1,492
2.75
3
[]
no_license
import numpy as np import glob import pandas as pd kj_to_kcal = 0.239006 files_tmp = glob.glob('pmf[1-4].dat') files = [x.split('.')[0] for x in files_tmp] pmf = {} for file in files: a = pd.read_csv(file + '.dat', delim_whitespace=True, header=None, usecols=[0,1], comment='#') pmf[file] = {} pmf[file...
true
b361107089051be80b1ac8ccd2fb285cfb6e7754
TeamAleph/hostman
/hostman/__init__.py
UTF-8
9,467
2.8125
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- """Hostman. Usage: hostman add [-fqbvq] [--force] [--path=PATH] ( [ENTRY ...] | [--input-file=FILE] | [--input-url=URL] ) hostman remove [-qbvq] ([--address=<address>] [--names=<names>]) [--path=PATH] [--input-file=FILE] [--input-url=URL]...
true
e6b2c585f512ff64ea1b989c97a90c9722d2fe51
jamalsenouci/causalimpact
/tests/test_inferences.py
UTF-8
10,560
2.640625
3
[ "Apache-2.0" ]
permissive
"""Unit Tests for inferences module""" import pytest import numpy as np import pandas as pd from pandas.testing import assert_series_equal from statsmodels.tsa.arima_process import ArmaProcess import causalimpact from unittest.mock import Mock from causalimpact.model import ModelResults compile_inferences = causal...
true
e4371a8d49d7f84c31196e3a710e3173341c6c37
wwtang/code02
/recursivePractise/test0fTest.py
UTF-8
313
2.859375
3
[]
no_license
def func(x): if x > 100: return x-10 else: return func(func(x+11)) def main(): print func(99) print func(98) print func(97) print func(91) print func(80) print func(10) print print func(102) print func(104) print func(108) print func(200) print func(200000) if __name__=="__main__": main()
true
72a72b2afcb98c1e0524eb2e3d77c2d5ee4795fa
jacopodisi/mru_securitygame
/analysis/plot_util_ratio.py
UTF-8
2,402
2.640625
3
[]
no_license
import matplotlib.pylab as plt import pandas as pd import numpy as np from itertools import cycle def plot_utils_ratios_enum(den, dead, markerstyles, linestyles, save=False): plt.figure() mark = cycle(markerstyles) line = cycle(linestyles) data = pd.read_pickle('data/exp_utils_ratios_enum.pickle') ...
true
8b80f22a44cb08eb3340642c887e5c520f1b841e
surucuonur/Machine_Learning
/ML_models(from Scratch)/MLP_Scratch/nn_class_v2.py
UTF-8
1,954
3.8125
4
[]
no_license
""" - The creation of dataset is taken from: https://cs231n.github.io/neural-networks-case-study/ """ import numpy as np import matplotlib.pyplot as plt np.random.seed(0) # This function generates a spiral dataset def create_data(): N = 100 # number of points per class D = 2 # dimensionality K = 3 #...
true
5780f43031c5d6a5d1e8c1582552339e233e6251
nkmk/python-snippets
/notebook/numpy_method_chain.py
UTF-8
369
3.546875
4
[ "MIT" ]
permissive
import numpy as np a = np.arange(12) a = a.reshape(3, 4) a = a.clip(2, 9) print(a) # [[2 2 2 3] # [4 5 6 7] # [8 9 9 9]] a_mc = np.arange(12).reshape(3, 4).clip(2, 9) print(a_mc) # [[2 2 2 3] # [4 5 6 7] # [8 9 9 9]] a_mc_break_parens = ( np.arange(12) .reshape(3, 4) .clip(2, 9) ) print(a_mc_break...
true
31046760c4c754395fdd04f10fbe96e081c7169c
mwagrodzki/codecool_dojos
/most_frequent.py
UTF-8
407
3.859375
4
[]
no_license
def most_frequent(table): ''' Check what is the most frequent number in an array. If there are multiple such numbers, return the largest one. python3 -m doctest most_frequent.py >>> most_frequent([3, 3, 3, 2, 2, 2, 4, 4]) 3 >>> most_frequent([3, 3, 2, 2, 2, 4, 4]) 2 >>> most_f...
true
e634725a72f869b8850316490f23891ff21fc8fc
kovacsbalazspeter21/f0003
/f0003b.py
UTF-8
1,096
3.640625
4
[]
no_license
##F0003b: Bővítsd az előző programot úgy, hogy a kiírás előtt kérdezze meg a születési évedet és a csillagjegyedet, és az előző feladatban megadott mondat után ezt is közölje veled. Megoldás itt. vezetéknév = input('Mi a vezetékneved?') keresztnév = input('Mi a keresztneved?') születésiév = input('Melyik évben sz...
true
0c99a87a1ca988f0dca8ff26428b5263d2db4b6d
ZekeMiller/euler-solutions
/solutions/087_prime_power_triples/prime_power_triples.py
UTF-8
913
2.9375
3
[]
no_license
import math from os.path import dirname import os, sys sys.path.append(dirname(dirname(dirname(os.path.abspath(__file__))))) from util import * def numExpressibleUnder(n): primes = genPrimes(math.ceil(math.sqrt(n))) found = set() amount = 0 for primeSq in primes: square = primeSq ** 2 ...
true
e27d3d0dbae21c9f36a4a4d6217540ed278f3841
wangwei6688/RISC-Verdi
/resources/view.py
UTF-8
9,181
2.71875
3
[ "MIT" ]
permissive
""" Copyright 2018-2019 Dover Microsystems, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, ...
true
8c462ec7267553db635d4b2d62f7ffcf3fe5a4ca
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3_neat/16_0_3_level1rosh_2016 Quals C - Coin Jam.py
UTF-8
3,867
3.453125
3
[]
no_license
from math import sqrt, ceil inputName = 'C-coinjam-practice' # Take input infile = open(inputName + '.in', 'r') lines = infile.readlines() infile.close() outfile = open(inputName + '-out.txt', 'w') outfile.write('Case #1:') # Prime-checking function # For small numbers, could have a precompiled list ...
true
b4bd2cfb6256087ca02eee0796f41197db3daa65
romanannaev/python
/STEPIK/date_.py
UTF-8
666
3.328125
3
[]
no_license
# import datetime # # y, m, d = [int(i) for i in input().split()] # (y, m, d) = map(int, input().split()) # x = datetime.date(y, m, d) # y = datetime.timedelta(days = int(input())) # c = x + y # print(c.year, c.month, c.day) # put your python code here # import datetime # inp = datetime.datetime.strptime(input(), "%Y...
true
28502a7a9387546fc2f77ac91136eb93e8447943
virajs/codeeval
/1-moderate/sum-to-zero/main.py
UTF-8
452
2.859375
3
[ "Unlicense" ]
permissive
import sys import itertools test_cases = open(sys.argv[1], 'r') for test in test_cases: test = test.strip() if len(test) == 0: continue values = map(int, test.split(',')) combinations = [list(x) for x in itertools.combinations(values, 4)] result = 0 for c in combinations: total ...
true
5514bedacc82494a2b2b5405281687f100978f4e
wonkoderverstaendige/PyFL593FL
/PyFL593FL/core/fl593fl.py
UTF-8
3,234
2.734375
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created on 05 Apr 2014 3:27 AM @author: <'Ronny Eichler'> ronny.eichler@gmail.com FL593FL evaluation board USB interface class """ import sys import logging from collections import namedtuple import Devices from Channels import StatusChannel, LaserChannel if sys.hexv...
true
a4e472cf2272af717ed23c31e030c58c3d420389
DTRminecraft/PP1
/PP!.py
UTF-8
2,467
2.84375
3
[]
no_license
import pygame pygame.init() WIDTH = 500 HEIGHT = 500 BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) clock = pygame.time.Clock() screen = pygame.display.set_mode((500, 500)) reload = pygame.mixer.Sound("reload.wav") gun = pygame.mixer.Sound("gunshot.wav") pygame.display.set_caption(...
true
03e18c8c1c307e708c62a2d80fe7bb60d199b7fa
frozenbanana/rest-api-python-flask
/init_db.py
UTF-8
873
3.171875
3
[]
no_license
# Creates a dummy datebase -> crud.splite # This should be run first if there is no crud.sqlite file from app import db, Job import random db.create_all() nr_of_items = 200 for i in range(0, nr_of_items): title = 'title' + str(i) description = 'description' + str(i) company = 'company' + str(random.randi...
true
419406d0aea7d9ee4bf66f62326297ac1edcaa29
alok-sin/shadow-nemesis
/make_tags.py
UTF-8
1,468
2.796875
3
[]
no_license
import os import sys import string import binascii from random import shuffle from Crypto.Hash import HMAC, SHA key = b'enron_secret_key' def hmac_sha256(key, msg): hash_obj = HMAC.new(key=key, msg=msg, digestmod=SHA) return hash_obj.hexdigest() walk_dir = sys.argv[1] output_dir = sys.argv[2] print('walk_d...
true
2d58669dfdb94e88a5deb9e2f32a59c1c9685d06
gistable/gistable
/all-gists/1a3a338781f28cde488efbd05d5f1b7a/snippet.py
UTF-8
2,609
2.765625
3
[ "MIT" ]
permissive
from flask import Flask, request, Response, abort from flask.ext.restful import Api, Resource, from hashlib import sha256 import hmac, redis CHARGIFY_SHARED_KEY= "XYZ789" REDIS_HOST="ip_address" REDIS_PORT="1234" FLASK_HOST="ip_address" FLASK_PORT="1234" app = Flask(__name__) api = Api(app) r = redis.StrictRedis(host...
true
d1b5f2cf090fc69d9c241b8e918f8fa2fede184d
Younghusband/python_LiaoXuefeng
/com/yangfan/homework/_maxAndminFromList.py
UTF-8
596
3.703125
4
[]
no_license
from collections import Iterable def find_min_max(L): # 判断是否为None [] 以及不可迭代对象 if L is None or L == [] or not isinstance(L, Iterable): return None, None _min = L[0] _max = L[0] for i, v in enumerate(L): if v > _max: _max = v if v < _min: _min = v ...
true
fd52e42d37b6a9ddc1aad18de84d590e738f7f16
afkmaster/drump-galactic
/simulator.py
UTF-8
3,877
2.9375
3
[]
no_license
import sys import math from guest import * from elevator import * DOOR_OPEN_TIME = 10 FLOORS_PER_SECOND = 1 INITIAL_FLOOR = 1 WAIT_TIME = 1 INFINITY = 9999 BUSY_FLOORS = {0:0, 1:1, 10:0, 100:0} #key is each floor, value specifies whether an elevator has been assigned to that floor or not class Simulator(object): def...
true
beae77ca218f7180db8fb1410a916f8d8e04bdb5
divya-gopinath/hebb-nat
/Models/fast_model.py
UTF-8
4,888
2.984375
3
[]
no_license
import numpy as np import networkx as nx import matplotlib.pyplot as plt N_NEURONS = 102 # Number of nodes in the graph EPSILON = 0.01 # Epsilon value used for update DISP_THRESH = 0.0 # Does nothing SIM_ITERS = 120 # Number of iterations to run Hebb for SIM_DISPLAY = 4 # Number of times we stop the simulation an...
true
9455a393ac0530b41b4d0010c3e50744da3708ae
memoglr/shopyo
/shopyo/modules/box__ecommerce/shop/tests/test_shop.py
UTF-8
571
2.84375
3
[ "MIT" ]
permissive
""" This file (test_shopy.py) contains the functional tests for the `shopy` blueprint. These tests use GETs and POSTs to different endpoints to check for the proper behavior of the `shop` blueprint. """ import pytest @pytest.mark.order("first") def test_shop_home_page(test_client): """ GIVEN a Flask applicat...
true
b20d9d2f1bf2c6b89fc51923d719d0cd294195b6
etclabscore/evm_llvm
/test/CodeGen/NVPTX/ld-st-addrrspace.py
UTF-8
2,815
2.515625
3
[ "NCSA", "LLVM-exception", "Apache-2.0" ]
permissive
# This test generates all variants of load/store instructions and verifies that # LLVM generates correct PTX for them. # RUN: python %s > %t.ll # RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_30 | FileCheck -check-prefixes=CHECK,CHECK_P64 %t.ll # RUN: llc < %t.ll -march=nvptx -mcpu=sm_30 | FileCheck -check-prefixes=CHECK,C...
true
12bfc7c2df35a4ea856c4bbc1afa22604611ea3f
vbyelo/python_lessons
/oop/class_example2.py
UTF-8
411
3.375
3
[]
no_license
class Dog: def __init__(self, weight=15, height=67): self.weight=weight self.height=height def voice(self): print('Gaaf') class Cat: def __init__(self, weight=10, height=37): self.weight=weight self.height=height def voice(self): print('Mew') ...
true
10185e0dccfee23026ed8dd8f11e64a09f3ab85f
20113261/p_m
/similar/attraction_similar.py
UTF-8
3,907
2.734375
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/6/12 上午9:42 # @Author : Hou Rong # @Site : # @File : attraction_similar.py # @Software: PyCharm import pymysql import uuid from collections import defaultdict __sql_dict = { 'host': '10.10.180.145', 'user': 'hourong', 'password': 'hou...
true
d1b0146561dc32b2f3d95fc328c8af6f19cb9765
TewariSagar/Python
/listSlices.py
UTF-8
213
3.609375
4
[]
no_license
#all the rules of string slice apply to list slice list = [1,2,3,4,5,"a","bc"] #slice from 0 upto 3 but ont including 3 print list[0:3] #we always put indexes in the order of traversing the list left to right
true
eeb316decc7478538c8d9f110cf0cbe78c37df3e
YeveYa/PythonBasics
/Lesson3/HomeWork_03_01.py
UTF-8
2,023
4.6875
5
[]
no_license
# Задание: # Задайте в программе переменную string1 = 'Съешь ещё этих мягких французских булок ДА выпей же чаю'. # Разбейте строку на отдельные слова. Выведите на экран 4-е слово в строке в верхнем регистре (большими # буквами). Выведите на экран 7-е слово в строке в нижнем регистре (маленькими буквами). Выведите на...
true
261aab37d840513ac00044e79cdab8728f0aa34e
Zoryana06/SeleniumCourseStepik
/lesson2.1_step5.py
UTF-8
733
3.0625
3
[]
no_license
from selenium import webdriver import time import math def calc(x): return str(math.log(abs(12*math.sin(int(x))))) try: link = "http://suninjuly.github.io/math.html" browser = webdriver.Chrome() browser.get(link) x_element = browser.find_element_by_xpath("//span[@id='input_value']") x = x_element.text y = cal...
true
d334c9134e7d605795ca0e53fc91e711d822aead
huawei-noah/vega
/vega/common/file_ops.py
UTF-8
8,278
2.625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "BSD-3-Clause", "MIT" ]
permissive
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # 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...
true
aa7d41be29555c18bb05fdd5d1e106a9bcf6c3cc
blankspeedster/Advance-Python-Code-Files
/Module 12/illustration_123.py
UTF-8
379
3.171875
3
[]
no_license
class Complex: def _init_(self, real=None, ima=None): if ((real == None)&(ima==None)): self.real=0 self.ima=0 else: self.real=real self.ima=ima def putData(self): print(str(self.real)," +i ",str(self.ima)) c1=Complex() c1._init_(5, 3) c1....
true
8460aaf1960e3db0e6f6b8d487b0d79a61c10b08
nikitachunikhin/Python_train_project
/my_codewars_functions/lists/99_roblems_1_last_in_list.py
UTF-8
426
4.4375
4
[]
no_license
def last(lst): """ Write a function last that accepts a list and returns the last element in the list. If the list is empty: In languages that have a built-in option or result type (like OCaml or Haskell), return an empty option In languages that do not have an empty option, just return None ...
true
6249fa9bfa145976532def5d6d9a5caa23d58cf6
Nyota254/QUIZ_APP
/app/models.py
UTF-8
2,850
2.5625
3
[ "MIT" ]
permissive
from . import db,login_manager from werkzeug.security import generate_password_hash,check_password_hash from flask_login import UserMixin @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id)) class User(UserMixin,db.Model): ''' This is a class that contains the database sc...
true
18bc027482a17da9dc8dcfe0ae583b81211b7872
codrinleonte/python_labs
/LabIV/Ex2.py
UTF-8
727
3.46875
3
[]
no_license
#2. Scrieti un script care primeste ca parametru de la linia de comanda un path si # afiseaza primii 4096 bytes daca path-ul duce la un fisier, intrarile din acesta daca # path-ul reprezinta un director si un mesaj de eroare daca path-ul nu este unul valid. import os import sys def readPath(path): try: i...
true
3e477e7b1038fb0689c920c41e44244395e768b0
KentoSugiyama7974/PythonVideoPlayer
/MainWindows/MainWindow.py
UTF-8
2,094
2.8125
3
[]
no_license
import tkinter as tk from tkinter import messagebox from MainWindows.SelectFile import SelectFile from MainWindows.VideoPlayer import VideoPlayer class MainWindow(tk.Frame): def __init__(self,master=None): super().__init__(master,width=1000,height=500) self.root = master self.confi...
true