blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
133
path
stringlengths
2
333
src_encoding
stringclasses
30 values
length_bytes
int64
18
5.47M
score
float64
2.52
5.81
int_score
int64
3
5
detected_licenses
listlengths
0
67
license_type
stringclasses
2 values
text
stringlengths
12
5.47M
download_success
bool
1 class
a9b4c9bd4e37b6f8a03a70af469dddd34368f4b0
Python
pascalmi/chalearn_first_impression
/pre-processing/extract_faces_from_frames.py
UTF-8
3,145
3.015625
3
[ "MIT" ]
permissive
"""This script iterates through a given directory containing only JPG images, runs a facial detection model on every image, and if successful, crops and stores 224px x 224px image chips around those faces in the target directory.""" import sys import os import random import time import shutil from multiprocessing impor...
true
01b2deecba5a476d26e641b87cee4fb4a4809d08
Python
mansi135/CTCI
/CHAPTER2/3_delete_middle_node.py
UTF-8
775
4.03125
4
[]
no_license
#Implement an algorithm to delete a node in the middle of a singly linked list, # given only access to that node. # We can copy the data from the next node to the node to be deleted and # delete the next node. from CHAPTER2.MyLinkedList import * def delete_middle(node): if node.next is not None: node....
true
bcf21e99c772ba26bebd60a8fa8034bfdab5d122
Python
SlicerIGT/aigt
/UltrasoundSegmentation/Archive_TensorFlow/Spine/evaluation_metrics.py
UTF-8
7,052
2.78125
3
[ "BSD-3-Clause" ]
permissive
import numpy as np import scipy.ndimage import warnings import tensorflow as tf from tensorflow.keras import backend as K # String constants to avoid spelling errors TRUE_POSITIVE_RATE = "true_positive_rate" RECALL = "true_positive_rate" SENSITIVITY = "true_positive_rate" FALSE_POSITIVE_RATE = "...
true
40e16e667b437e41b81aae8f562cada377a10646
Python
AkshayKumarTripathi/Algorithms-And-Data-Structures
/Day 24 (Dynamic Programming)/rod cutting.py
UTF-8
494
2.9375
3
[]
no_license
rod=8 price = [5,5,7,3,11,16,16,20] length=len(price) table=[[-1 for _ in range(rod+1)] for _ in range(length+1) ] def cut(i=length, rem=rod,p=0): if table[i][rem]!=-1: return table[i][rem] if i==0: return p if rem==0: return p new_cut=price[i-1] if rem-i>=0: t...
true
64781d5869a51b4bcb6dfb103f0b27ac8286c0de
Python
silphire/atcoder
/abc130/b.py
UTF-8
202
2.609375
3
[]
no_license
n, x = map(int, input().split()) l = list(map(int, input().split())) d = 0 for i in range(n): if d > x: print(i) exit(0) d += l[i] if d > x: print(n) else: print(n + 1)
true
3a8280c42abf1af23999752a076a9e5da21c808f
Python
smallfat17/FluentPython
/day04/hashable_test.py
UTF-8
501
3.390625
3
[]
no_license
class Student: def __init__(self, name, gender, lessons=None): self.name = name self.gender = gender self.lessons = lessons def __hash__(self): return super().__hash__() def __eq__(self, other): return self.lessons == other.lessons if __name__ == '__main__': s...
true
2f03429f28a6645bd10827083a8c77365240abee
Python
xubaochuan/mm_intern
/raw/word_trigram.py
UTF-8
1,334
3.015625
3
[]
no_license
#coding=utf-8 from pypinyin import lazy_pinyin, load_single_dict, load_phrases_dict def get_pinyin(sentence): special_mapping = { 'b': u'bi', } res = lazy_pinyin(sentence, errors=lambda x:special_mapping.get(x, '')) return res def sentence_to_letter_trigram_hierarchic(sentence): pinyin_lis...
true
7a4f6d8dec5088a0aff20baf955ef6c469bd47c0
Python
dvida/UWO-PA-Python-Course
/Lecture 2/L2_lecture.py
UTF-8
4,537
4.46875
4
[ "MIT" ]
permissive
from __future__ import print_function # While loop # Fibonacci series a, b = 0, 1 while b < 50: print(b, end=',') a, b = b, a+b print() # Many new concepts in the code above! # INDENTATION - Python's way of grouping statements # - NO BRACKETS # - NICELY FORMATTED CODE # - 4 SPACES # # INFIN...
true
5e70cb35c63f29df10f824edfec87a661c9c4cc4
Python
filyph/blazegraph-python
/pymantic/util.py
UTF-8
2,070
3.171875
3
[]
no_license
"""Utility functions used throughout pymantic.""" __all__ = ['en', 'de', 'one_or_none', 'normalize_iri', 'quote_normalized_iri',] import re from urllib import quote def en(value): """Returns an RDF literal from the en language for the given value.""" from pymantic.primitives import Literal return Literal...
true
65902f886cfbb8c7ddf70cb814d0bea9c8029371
Python
gwlilabmit/Ram_Y_complex
/varna/remove_varna.py
UTF-8
1,028
2.59375
3
[]
no_license
''' Gets rid of all files in the varna directories that shouldn't be of use for the paper. I only want to keep the following: centroid, mfe, mea, locarna if present, paired constrained, consensus without dms and rnaalifold--all with paired coloring only ''' import os directory = "dlta_varna" name = directory.split(...
true
08810c668fe109aa3b3bef44a35cdd11509a6fb6
Python
Jenny-Jo/AI
/study/keras73_boston_dnn.py
UTF-8
3,238
3.078125
3
[]
no_license
#회귀모델 import numpy as np from sklearn.datasets import load_boston import matplotlib.pyplot as plt # 1. Data # data : x 값 # target : y값 dataset = load_boston() x = dataset.data y = dataset.target # DNN으로 구현 print(x.shape) # (506,13) print(y.shape) # (506, ) from sklearn.preprocessing import Stan...
true
1283956ffab7ba14c0a65fed2d982598a8ef0377
Python
Gitrocha/BR-MarineTraffic
/Main/database/connectors.py
UTF-8
7,186
2.765625
3
[ "MIT" ]
permissive
''' Module functions to properly interact with Database ''' import sqlite3 def add_data(atr, connection): with connection: c = connection.cursor() c.execute("INSERT INTO tempos_atr_2019 (IDAtracacao," "TEsperaAtracacao," "TEsperaInicioOp," "TO...
true
6575f507bb7327cce408c2be0a26d4326c8e614d
Python
caramelomartins/adventofcode
/2019/2/main.py
UTF-8
1,029
3.8125
4
[ "MIT" ]
permissive
def calculate_output(codes): i = 0 while i < len(codes): opcode = codes[i] if opcode == 1: bucket = codes[i+3] codes[bucket] = codes[codes[i+1]] + codes[codes[i+2]] i += 4 elif opcode == 2: bucket = codes[i+3] codes[bucket] = ...
true
ce7d2bd2afcd2168af9dfc165c3ba600b98a6be1
Python
mbronckers/cmsc23360
/p2/model.py
UTF-8
1,630
2.6875
3
[]
no_license
#!/usr/bin/env/python import numpy as np import matplotlib.pyplot as plt import pandas as pd from joblib import dump, load from sklearn.ensemble import RandomForestClassifier from sklearn import svm from sklearn.linear_model import LogisticRegression # Community data import (make sure to have path with access to pars...
true
62cbd7f222b2486dbbe27dcc63019f9f825f41df
Python
francocurotto/YDDM-re-old
/source/game_logic/game_states/dimension_state.py
UTF-8
4,560
2.9375
3
[]
no_license
import settings from duel_substate import DuelSubstate from dice_nets.dice_net import create_net from dice_nets.pos import Pos from dungeon_tile import DungeonTile class DimensionState(DuelSubstate): """ State when player choose where to dimension the dice after a roll. """ def __init__(self, duel,...
true
5bf14343e3c0ceb3652d84871ae9fb8fff460955
Python
aKryuchkova/programming_practice
/week03/exercise12.py
UTF-8
302
3.34375
3
[]
no_license
''' Нарисуйте пружину. Используйте функцию, рисующую дугу. ''' import turtle as tu tu.shape('turtle') n = 10 tu.penup() tu.goto(-200,0) tu.pendown() while n >= 0: tu.right(90) tu.circle(10, -180) tu.circle(3, -180) tu.right(-90) n -= 1
true
b8d709295a07da95998b73645b7efcf5ec3c33d0
Python
samkorn/python-ev3dev
/ev3_demo.py
UTF-8
1,057
3.46875
3
[]
no_license
#!/usr/bin/env python3 import sys from ev3dev2.motor import LargeMotor, MediumMotor, MoveTank, MoveSteering from ev3dev2.motor import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D from ev3dev2.sound import Sound # initialize objects sound = Sound() right_motor = LargeMotor(OUTPUT_B) left_motor = LargeMotor(OUTPUT_C) # pri...
true
6e682cf211af48b84777a9566f39a5dcefa04e00
Python
wangheng1409/local_test
/baiguan1/spider_commen/cut_by_price.py
UTF-8
1,058
2.65625
3
[]
no_license
# !/usr/bin/env python # -*- coding:utf-8 -*- class CutByPrice: async def handle(self,response,split_str,cf,deal_core,next_url,*args,**kwargs): ''' :param response: a html or a json :param split_str: cutting mark :param cf: the result of the cutting :param deal_cor...
true
ac3146187b02fbfeb053d187e824783fbf367cef
Python
rafael2ll/Topicos-em-IA
/Atividade6/rafael/domain/dist_calc.py
UTF-8
490
3.0625
3
[]
no_license
from domain.distance import Distance, EuclideanDistance, ManhattanDistance from domain.models import VanillaDataset def calc_dist(dataset: VanillaDataset, distance: Distance): dists = [] for row in dataset.data: dists.append([distance.calc_dist(row, other_row) for other_row in dataset.data]) ...
true
7e37ee47912f846a8625fd50015f3483406a15d9
Python
yannistannier/twitter-sentiment-analysis
/spark-aws-emr/twitter_nohashtag.py
UTF-8
4,854
2.640625
3
[]
no_license
import os import sys import re import datetime import json import requests from emoji.unicode_codes import UNICODE_EMOJI from pyspark import SparkContext from pyspark.sql import SparkSession from textblob import TextBlob from sklearn.externals import joblib class Tweet: def __init__(self): url = "https://...
true
486c1db7ab0a56b1f59a8e032075395aefb50b73
Python
aysegulkrms/SummerPythonCourse
/Week4/04_OOP_4.py
UTF-8
662
4.4375
4
[]
no_license
class Dog: # Class Attribute species = "mammal" # Initializer / Instance Attributes def __init__(self, name, age): self.name = name self.age = age # Method def speak(self, sound): print("{} says {}".format(self.name, sound)) # Create an information function that pr...
true
db8e7469bb6121eec8cc25a4630a3089d10a60a3
Python
CunningLogic/android-work
/bf_password/bf_password.py
UTF-8
6,289
2.890625
3
[]
no_license
import hashlib, struct, sqlite3, binascii, sys, os import itertools from string import ascii_letters # Interesting files in AOSP: # mydroid/libcore/luni/src/main/java/java/lang/Long.java # mydroid/frameworks/base/core/java/com/android/internal/widget/LockPatternUtils.java # # Interesting files on-device: # /data/data...
true
8df0b00ccf6afa80391acbb2e1541b63a87dff74
Python
DrewOrtego/Miscellaneous-Python
/Text-Based-Game-Engine/saveLoad/loadGame.py
UTF-8
1,773
3.546875
4
[]
no_license
''' loadGame.py Provides functionality to load a game from a save file. This takes a serialized file and copies its contents into the setup.objects dict. This dict is utilzied by the game loop in main.py when calling various functions in the program. ''' import pickle, glob, os from gameObjects impor...
true
c6654e81f56b04daff70caff7e79fc296bdd8167
Python
TimChild/AdventOfCode
/Day22.py
UTF-8
6,162
3.484375
3
[ "Unlicense" ]
permissive
import numpy as np import time import copy from typing import List, Tuple import pandas as pd class Player: def __init__(self, starting_cards): self.hand = starting_cards def get_hands(fp): with open(fp) as f: raw = f.readlines() h1start = 1 h1end = np.where(np.array(raw) == '\n')[0...
true
5b1c7b072cd7fb18c2ed3d982ab1c90d6302f377
Python
AndradeLaryssa/Python_Funcoes
/Prova_main.py
UTF-8
978
2.78125
3
[]
no_license
import Prova_funcoes tupla = ('A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e') listaGabarito = [] listaRespostas_alunos = [] listaNotas = [] listaNomes = [] listaMatriculas = [] contador = 0 cont = 0 contad = 0 maiores_notas = 0 #cadastrar gabarito do professor funcoes.cadastrarGabaritoprofessor(contador, tupla, lis...
true
fbc104969f749d244f625bddf938515b905f55ff
Python
punkdit/bruhat
/bruhat/extern/homology.py
UTF-8
4,073
2.8125
3
[ "MIT" ]
permissive
#!/usr/bin/env python """ from: https://github.com/j2kun/computing-homology/blob/master/homology.py https://jeremykun.com/2013/04/10/computing-homology/ """ import numpy import numpy.linalg def rowSwap(A, i, j): temp = numpy.copy(A[i, :]) A[i, :] = A[j, :] A[j, :] = temp def colSwap(A, i, j): temp = num...
true
617fc06b763769963587c76caa764b5bd71ee04a
Python
MatthewTsan/Leetcode
/python/q138/q138.py
UTF-8
761
3.28125
3
[ "Apache-2.0" ]
permissive
# Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random class Solution: def copyRandomList(self, head: 'Node') -> 'Node': dictP = {} newHead = Node(0) p_o...
true
939fbcd29c28eef55fef4be03560c9f8f7a9134b
Python
zopefoundation/zope.container
/src/zope/container/btree.py
UTF-8
3,364
2.609375
3
[ "ZPL-2.1" ]
permissive
############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # TH...
true
5984840c2a9b390907d862cdd5e985fea2d36d84
Python
naka-tomo/HSMM-word-segmentation
/HSMMWordSegm.py
UTF-8
9,285
2.6875
3
[]
no_license
# encoding: utf8 from __future__ import unicode_literals, print_function import numpy import random import math import time import codecs import os class HSMMWordSegm(): MAX_LEN = 8 AVE_LEN = 2 def __init__(self, nclass): self.num_class = nclass self.word_class = {} self.segm_sent...
true
c47193606b32715470581ea839a77755de9e05a9
Python
jolatechno/cli-utils
/cmds/3dPrinting/scale
UTF-8
2,242
2.515625
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 License = '''MIT License Copyright (c) 2020 joseph touzet 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...
true
c48b43acc15cdc15aa1f8ff181d7275c42d718ee
Python
NSCO/NSCO
/Python/datos/test.py
UTF-8
863
3.21875
3
[]
no_license
import pandas as pd; import matplotlib.pyplot as plt import numpy as np file_path = 'C:/Users/geraq/Documents/Python/NSCO/datos/avgpm25.csv'; datos = pd.read_csv(file_path); datos["pm25"][0:3]; datos["pm25"].describe(); datos.boxplot("pm25"); (fig, axes) = plt.subplots(nrows=2, ncols=2, figsize=(6,6)); axes[0, 0].box...
true
9862e77dddcc6b215bfb4eec537ccdf2e1bc2655
Python
woodenCaliper/msLib
/msQuat.py
UTF-8
1,505
3.109375
3
[]
no_license
#!/usr/bin/env python #coding: utf-8 #[x,y,z,w] from tf import transformations def makeQuat2(axis, theta): qN = transformations.quaternion_about_axis(theta, axis) #return type=numpy.array return qN.tolist() def product2(leftQuat, rightQuat): qN = transformations.quaternion_multiply(leftQuat, rightQuat) return qN...
true
765dc790281eed7dd7f0c8347e7d06dcf7d2a4de
Python
mrshaikh4u/Problem-solving
/LeetCodeGeneral/left_most_val.py
UTF-8
822
3.203125
3
[]
no_license
from collections import deque class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def findBottomLeftValue(self, root: TreeNode) -> []: queue = deque() queue.append(root) output = [] ...
true
d06c75c118fd24a696041fe537ca04d2100843f1
Python
FranciscoFerreiraff/maratona_python_SJ
/aritmetica.py
UTF-8
669
3.078125
3
[]
no_license
x = int(input()) simb = input() y = int(input()) simb2 = input() z = int(input()) ops = {"+": (lambda x,y: x+y), "-": (lambda x,y: x-y), "*": (lambda x,y: x*y), "/": (lambda x,y: (x//y))} try: if (simb == "+" or simb== "-") and (not simb2=="*" and not simb2=="/"): a = ops[simb](x,y) b = ops[simb2](a...
true
fcd9ff740ad4938633ad4015259860f3831993a9
Python
WhiteDevilBan/CommentCrawler
/site/mybzz/util/DbUtil.py
UTF-8
827
2.953125
3
[]
no_license
import pymysql """ 数据库工具包 """ def getConn(): """ 获取数据库连接和游标 :return: """ conn = pymysql.connect(host="localhost", user="root", passwd="banban123", db="comment", port=3306, charset="utf8") cur = conn.cursor() return (conn,cur) def getAllResult(statement): """ 获取所有结果 :param state...
true
e190198f7987e0449fa098f6a65eb76458777362
Python
knmcdaniel/Programming-Projects-Completed
/Coding Dojo/Python/exam_project/quotable_quotes_app/models.py
UTF-8
2,635
2.65625
3
[]
no_license
from django.db import models import bcrypt, re # Create your models here. class UserManager(models.Manager): def registration_validator(self, postData): errors = {} password = postData['password'] confirm_password = postData['confirm_password'] if password != confirm_password: ...
true
748ae8063516467a34fea5813b16c88d56bb2cfa
Python
choidslab/IntroducingPython
/ch8/binaryfile_read.py
UTF-8
112
2.828125
3
[]
no_license
readfile = open('bfile', 'rb') # rb 모드로 열기 bdata = readfile.read() print(len(bdata)) readfile.close()
true
fc2c5cd85dfe4f18fb851f42897ae3b44803185b
Python
loranne/hb-js-trials-1
/trials.py
UTF-8
2,261
4.09375
4
[]
no_license
"""Python functions for JavaScript Trials 1.""" def output_all_items(items): for item in items: print(item) list_of_items = [1, 'hello', True] output_all_items(list_of_items) def get_all_evens(nums): even_nums = [] for num in nums: if num % 2 == 0: even_nums.append(num) ...
true
41cddd4aff08ed297132442a72f081d0ce593678
Python
Raarbiarsan1899/LeetCode
/MaximumErasureValue.py
UTF-8
573
3.03125
3
[]
no_license
class Solution: def maximumUniqueSubarray(self, nums: List[int]) -> int: max_score = 0 seen_dict = {} start = 0 subtotal = 0 for i, k in enumerate(nums): if k in seen_dict and seen_dict[k] >= start: for j in range(start, seen_dict[k] + 1):...
true
0d3962f068ccb8c81d21661684949e0a6b7d0392
Python
pharalambiev/SoftUni_Python_Basics_week1_lab
/03_Deposit_Calculator.py
UTF-8
185
3.359375
3
[]
no_license
amount = float(input()) term = int(input()) annual_interest = float(input()) deposit = (amount*annual_interest)/100 deposit = deposit/12 deposit = (term*deposit)+amount print (deposit)
true
96d924dd5c85f4370be1ca924720a74a8ea3eb0d
Python
KimPopsong/Algorithm_Class
/String/BruteForce.py
UTF-8
530
3.515625
4
[]
no_license
def BruteForce(p, t, k): M = len(p) N = len(t) i = k j = 0 while j < M and i < N: if t[i] != p[j]: i -= j j = -1 i += 1 j += 1 if j == M: return i - M else: return i text = 'asdbafsdfqweefsdfasdfadfasdfas' pattern = 'qweef...
true
09cce8287a4009266ae2ffdc373c725cffea5bed
Python
animesh/generic-expression-patterns
/pseudomonas_analysis/nbconverted/viz_expression_data.py
UTF-8
2,965
2.53125
3
[ "BSD-3-Clause" ]
permissive
#!/usr/bin/env python # coding: utf-8 # # Visualize gene expression # # This notebook visualizes the trends in gene expression data for the template and simulated experiments # In[1]: get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('load_ext', 'rpy2.ipython') get_ipython().run_l...
true
a602843c88870b6d1d22184f4732c29404f101cc
Python
WSU-CASAS/AL
/ji.py
UTF-8
10,759
2.59375
3
[]
no_license
#!/usr/bin/python # python oc.py <data_file>+ # # Performs activity learning on the given data files and outputs either the # learned model, or the confusion matrices and accuracy for a 3-fold # cross-validation test. Each activity is learned by a separate # one-class classifier. # Written by Diane J. Cook, Washingto...
true
50e37e976f15552597a5669e7cacf06988bfd8c3
Python
abacccc/NetworkingTopDownAnswer
/SMTPMailClient/SMTPMailClient.py
UTF-8
1,590
2.9375
3
[]
no_license
from socket import * msg = '\r\n I love computer networks!' endmsg = '\r\n.\r\n' # Choose a mail server (e.g. Google mail server) and call it mailserver mailServer = '*****************' port = 25 # Create socket called clientSocket and establish a TCP connection with mailserver #Fill in start clientSocket = socket(AF_I...
true
b9124ad7aa20a2a72a523d5c4b1085f9d1db52a4
Python
keachico/CS303E_and_CS313E
/CS 313E/Practice Programs/Turtle Programs/Simple_Circle.py
UTF-8
550
3.953125
4
[]
no_license
import math class Circle: """Define a class of circles. Circles have an associated radius.""" _circlesCount = 0 def printCount(): print("Created " + str( Circle._circlesCount ) + " circles.") def __init__(self, radius): self._radius = radius Circle._circlesCount += 1 ...
true
87506716dae7761c1526c6a5ccbe8875f4a3f34d
Python
dagorham/reddit_recommender
/src/userinfo.py
UTF-8
6,808
2.890625
3
[]
no_license
from collections import Counter import praw import numpy as np from sklearn.decomposition import LatentDirichletAllocation from sklearn.feature_extraction.text import TfidfVectorizer from build_reddit import Reddit, Subreddit from wordcloud import WordCloud __name__ = 'userinfo' class Redditor: def __init__(se...
true
db4e54a6512389fb33169f3254d1541cc7b72570
Python
pragatirahul123/java_questions
/function_question/More_Exercise/more_exercise1.py
UTF-8
163
3.1875
3
[]
no_license
i=1 while i<=1000: if i%21==0: print"navgurukul",i print "nav",i elif i%7==0: print"gurukul",i elif i%3==0: print "nav",i i=i+1
true
6b888a869da6b393de956b9db0aa29ef68d4e1fa
Python
404duan/BlockChain
/main_Coin.py
UTF-8
5,505
3.25
3
[]
no_license
from hashlib import sha256 from pprint import pprint import time class Block(object): """ data -> array of object 之前区块的哈希值 自己的哈希值:由存储在区块里的信息算出来的(data + 之前区块的哈希值) """ def __init__(self, transactions, previousHash): """ 初始化 """ self.transactions = transactions ...
true
0b60ef46aa355fe01d591ab1685af75c0fdf3d89
Python
jrd261/globe
/globe.py
UTF-8
1,629
3.28125
3
[ "MIT" ]
permissive
""" Globe """ import math import random _RADIUS = 6371000 def distance(lat1, lon1, lat2, lon2): lat1, lon1 = latlon2sc(lat1, lon1) lat2, lon2 = latlon2sc(lat2, lon2) dlon = lon2 - lon1 c_lat1 = math.cos(lat1) c_lat2 = math.cos(lat2) s_lat1 = math.sin(lat1) s_lat2 = math.sin(lat2) s_...
true
c0891245498516177c7370656d954192bcf5e9e3
Python
RaphaelJ/Navistree
/scripts/template.py
UTF-8
1,217
2.640625
3
[]
no_license
#!/usr/bin/python #-*- coding: Utf-8 -*- import navistree TEMPLATES_DIR = navistree.SCRIPTS_HOME + "/templates/{template}.tpl" _templates_cache = {} # Cache le contenu des templates ouverts class Template: def __init__(self, tpl): self.path = TEMPLATES_DIR.format(template=tpl) self._dic = {} ...
true
81f4be4deb48225e8558e342670a94c89b87502a
Python
soumodeeptocode/DSA-playground
/src/python/hackerrank/easy/diagonal_diffrence.py
UTF-8
659
3.390625
3
[]
no_license
w, h = 3, 3 Matrix = [[0 for x in range(w)] for y in range(h)] Matrix[0][0] = 1 Matrix[0][1] = 8 Matrix[0][2] = 6 Matrix[1][0] = 2 Matrix[1][1] = 9 Matrix[1][2] = 3 Matrix[2][0] = 5 Matrix[2][1] = 12 Matrix[2][2] = 45 def diagonalDifference(demoArr): lToR1 = lToR2 = lToRCounter = rToLCounter = 0 rToL1 = 0 ...
true
99b29da58a54216ca6fab66c053a8bf6290a1753
Python
Shovon588/Programming
/Codeforces with Python/1058A - In Search of an Easy Problem.py
UTF-8
91
2.96875
3
[]
no_license
n=int(input()) a=list(map(int,input().split())) if 1 in a:print('HARD') else:print('EASY')
true
49df848e4a202dc591b03f204426a0e8021a2bae
Python
DongZhaoXiong/Text-to-Cloth-GAN
/data_loader.py
UTF-8
1,914
2.703125
3
[]
no_license
import os from os.path import join import argparse import skipthoughts import h5py # use Fashion-166 dataset def save_caption_vectors_cloth(data_dir): import time img_dir = join(data_dir, 'cloth/jpg') image_files = [f for f in os.listdir(img_dir) if 'jpg' in f] image_captions = {img_file: [] for img...
true
f60d4488397aca03fc5fdefe8706ca2f3e33cee3
Python
dayitachaudhuri/Basic_Python_Problems
/27_tuplesubset.py
UTF-8
121
2.859375
3
[]
no_license
a=eval(input("Enter tuple 1:")) b=eval(input("Enter tuple 2:")) if set(b).issubset(a): print("TRUE")
true
1391697590249e5e4a6fe56f4a57baa064f825a1
Python
bakunobu/exercise
/1400_basic_tasks/chap_7/7_172.py
UTF-8
603
3.484375
3
[]
no_license
from main_funcs import get_input def first_second_place(n:int=22) -> tuple: first_place = False second_place = False for i in range(n): t = get_input('Введите время спортсмена: ') if not first_place: first_place = t elif not second_place: second_pla...
true
73415f90802f1d619d2f7734178c0489b5aae6bc
Python
jinci94/Kattis
/code/driversdilemma.py
UTF-8
815
3.375
3
[]
no_license
# Capacity [gallons], fuel loss [gallons per hour], distance [miles]: C, X, M = [float(x) for x in input().split()] # {speed [miles per hour]: fuel efficiency [miles per gallon]} = {A: B, ...} speed_fuel = {int(speed):float(fuel) for speed, fuel in [input().split() for i in range(6)]} # hours to get there: M/A #...
true
131f3a4bbef6b049a6df19087b1a7d4a1196fd08
Python
Eunah-Kim/keras
/01삼성전자DNN.py
UTF-8
2,192
3.0625
3
[]
no_license
import pandas as pd # from pandas import to_numeric import numpy as np from numpy import array samsung = pd.read_csv('samsung.csv', encoding='euc-kr') for column in samsung.columns[1:]: samsung[column] = samsung[column].map(lambda x: int(x.replace(',', ''))) samsung = samsung.sort_index(ascending=False) samsung ...
true
860da65bc51e9ae33c6e19c2cb96ba290d637404
Python
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_116/542.py
UTF-8
2,447
3.53125
4
[]
no_license
from copy import deepcopy def isWon(board): #board is 0s and 1s #check rows for row in board: if sum(row)==4: return True #check cols for colindex in range(len(board[0])): num = 0 for rowindex in range(len(board)): num+=board[rowindex][colindex...
true
9f400919311af91b39d69422d5d39872568f746c
Python
klmsathish/DataStructures
/Finding(Search)SLL.py
UTF-8
1,110
3.953125
4
[]
no_license
class node: def __init__(self,data): self.data=data self.next=None class Linkedlist: def __init__(self): self.head=None self.last_node=None def append(self,data): if self.head is None: self.head=node(data) self.last_node=self.head ...
true
977c5a96d1000a8a2ea5e7017dea5a2e80ef3549
Python
rwleander/cpxGames
/ch07/skeet/code.py
UTF-8
2,309
3.0625
3
[ "MIT" ]
permissive
# Python code for Ten Games for the Circuit Playground Express # by Rick Leander # Copyright (c) 2020 Rick Leander All rights reserved # Buy the book at https://www.amazon.com/author/rleander # # Skeet Playground from adafruit_circuitplayground import cp import random import time #constants pixels...
true
c7a3a0e84729dfb9890da37cff3831960b25ff6d
Python
willwillhi1/python_practice
/data_type_practice.py
UTF-8
1,050
3.625
4
[]
no_license
#list ls1 = [] ls2 = [] ls1.append(element) ls1.extend(ls2) ls1.insert(index, element) del ls1[index] ls1.remove(element_name) ls1.index(element_name) #return element's index element in ls1 #return true if in list ls1.count(element) #return num of element ls1.join(sep) #combine the element by sep ls2 = sorted(ls1) len(...
true
2a3ddc336a8791492b8db5f6d268ad0e92335bbb
Python
zhr619151879/PunchCardSystem
/签到打卡/dataLayer.py
UTF-8
4,231
2.609375
3
[]
no_license
# -*- coding:utf-8 -*- # @Time : 2019/12/25 2:16 下午 # @Author: zhr619151879 # @Keymap: 「command+1:surround command+p:parameter ctr+o overide」 # @File : dataLayer.py # import sqlite3 import io import numpy as np import zlib import pymysql as mysql host_ip = "47.96.157.49" # host_ip = "localhost" host_usr = "root" host...
true
d0b55f316a25a167a18ff9317438f590a0ed56df
Python
conceptfab/PM_NX_PUB
/cfab_mod_view.py
UTF-8
3,184
2.96875
3
[]
no_license
''' Moduł zawierający widoki list ''' import logging import os logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s') # logging.disable(logging.CRITICAL) # TODO dodać kolory def view_projects_list(projects_dict): ''' Krótka lista projektów :param projects_dict:...
true
63fe1064523ef5afea82fd5478e7d64669bf047a
Python
davidp-ro/ai-ml
/StudentRep/main.py
UTF-8
2,180
3.40625
3
[ "MIT" ]
permissive
# Imports: import pandas as pd import numpy as np import pickle # sklearn: import sklearn from sklearn import linear_model from sklearn.utils import shuffle # Matplotlib: import matplotlib.pyplot as pyplot from matplotlib import style # File paths: DATA_PATH = '../Dataset/student-mat.csv' SAVE_PATH = '../SavedModels/s...
true
f4bbc7f40025369b06ebbed268d162ee50e9dfda
Python
queceo/Pentesting
/task.py
UTF-8
1,175
2.703125
3
[]
no_license
import importlib from threading import Thread import subprocess import sys class Task: status = ['idle','']; name = []; thread = 0; #start the thread def startScript(self): self.thread.start(); def __init__(self, scriptname): self.name = scriptname; ...
true
34f3bd25aa860d4f18ce8ad00d9f26dc1990d8a1
Python
gerald-liu/python
/simple_scripts/norm_calc.py
UTF-8
127
2.65625
3
[]
no_license
#%% from scipy.stats import norm #%% print('{:.4f}'.format(1-norm.cdf(1.5))) #%% print('{:.4f}'.format((2*norm.ppf(0.9))+12))
true
26912817c10a9a368b7d7edc5a0cc691ee529e7b
Python
AndyReiblein/pythonrefresh.py
/pythonrefresher.py
UTF-8
1,047
4.75
5
[]
no_license
#Variables,strings, ints, and print name = "Andrew" age = '23' sentence = ("Hi my name is {} and I am {} years old".format(name,age)) #If statements and comments if int(age) > 18: print(sentence) else: ('You are younger than 18') #to add comments punch the hash button """with multyline comments you c...
true
edf17e63a760fc1d73caacc1630e99b1e574e6bf
Python
AlexYangLong/Foundations-of-Python
/day008/4-callback-function.py
UTF-8
353
3.546875
4
[]
no_license
''' title: 回调函数 time: 2018.04.04 17:07 author: 杨龙(Alex) ''' ''' 回调函数: 在定义函数时,将函数名作为参数传递过来,然后再函数里边再次调用函数. ''' def my_callback_sum(num1, num2): print(num1 + num2) def my_sum(num1, num2, fn): return fn(num1, num2) my_sum(12, 45, my_callback_sum)
true
4f9eb5e00d5513511fb9e1b06c4e996119a267fb
Python
Arjunnemani/kivy-camera
/main.py
UTF-8
1,223
2.75
3
[]
no_license
from kivy.app import App from kivy.uix.camera import Camera from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button class CameraExample(App): def build(self): layout = BoxLayout(orientation='vertical') # create a camera object ...
true
afeee686eb8a4920300eee7e31a1ba9a8ca4fa0b
Python
avinabadey6/python
/string1.py
UTF-8
99
3.546875
4
[]
no_license
lol=input("write a name") # print(".".join(lol.upper())) for a in lol: print(a.upper(),end=".")
true
87a5cc9a447efc16ab69945df6c51ac5c9b9da09
Python
physics91si/gatctg-lab10
/sets.py
UTF-8
1,879
3.96875
4
[]
no_license
import math class Set: def __init__(self): '''initializes the set as the empty set''' self.list = [] def contains(self, element): '''Checks to see if an element is within the set; returns Boolean''' for item in self.list: if item == element: return Tr...
true
7b08279725429242b4a14cc6dd73417cb5d1bc8b
Python
hu357/python
/20201003 tk13 五角星.py
UTF-8
724
3.203125
3
[]
no_license
from tkinter import * import math as m root = Tk() w = Canvas(root,width=200,height=100) w.pack() center_x=100 center_y=50 r=50 point = [ # 左上点 center_x - int(r*m.sin(2*m.pi/5)), center_y - int(r*m.cos(2*m.pi/5)), # 右上点 center_x + int(r*m.sin(2*m.pi/5)), center_y - int(r*m.cos(2*m.pi/5)), ...
true
ada6b89dd56f87de7bafbcce59bea6bef8aebda3
Python
orez-/Hex-Tic-Tac-Toe
/ai.py
UTF-8
1,568
3.140625
3
[]
no_license
# -*- coding: utf-8 -*- def _alphabeta(node, depth, player, a=-float('inf'), b=float('inf')): if depth == 0 or node.gameover: # The multiplier here is technically unnecessary, but adding it # makes it favor moves that let it win faster or lose slower. return node.heuristic() * (depth + 1), ...
true
20c83e06fb58ed1340dc06922673dc711b8e9cec
Python
aadilmeymon/100-days-of-python
/100 days of python day 4/day4_2.py
UTF-8
222
3.890625
4
[]
no_license
import random names_string = input("Give me everybody's names, separated by a comma. ") names = names_string.split(",") rand_pick=random.randint(0,len(names)-1) print(f"{names[rand_pick]} is going to buy the meal today! ")
true
0b3310ae26bdd30d876a4828ad9834357e5e4f15
Python
Transi-ent/LeetcodeSolver
/iv04.py
UTF-8
2,049
3.609375
4
[]
no_license
class Solution: """ 将二分搜索法进行拓展,拓展到二维空间 """ def findNumberIn2DArray(self, matrix: list, target: int) -> bool: if not matrix: return False m, n = len(matrix), len(matrix[0]) if m==1: return target in matrix[0] else: return self.bs2D(matri...
true
fad2bde0a0ad5eb84f4cbfe4c5ec75a7ff45dcc9
Python
tungrg/AI-1
/main.py
UTF-8
505
2.65625
3
[]
no_license
import sys import csv def caua(listRow): res=[] for key in listRow[0].keys(): count = 0 for row in listRow: if row[key] == '': res.append((key,count)) count += 1 res=dict(res) return res if __name__ == '__main__': input_file_name = str(sys...
true
d96a5a1ef0cd0767d8a320ab03b13608fc3dc26a
Python
haijunsu/GroupStudy
/haijun/python/testNum.py
UTF-8
891
3.625
4
[]
no_license
#!/usr/bin/env python3 import itertools def mydiff(): """ Show different between isdigit, isnumeric, isdecimal Source: https://stackoverflow.com/questions/22789392/str-isdecimal-and-str-isdigit-difference-example """ line = "-" * 50 print(line) print("| No. | isdigit | isdecimal | isnum...
true
9de29f0034b67e214cf0ee5f3dba6a224f0f240b
Python
junpei-oyama/gnavi_search
/gsearch.py
UTF-8
749
2.921875
3
[]
no_license
import requests def main(): # 目標: フリーワード検索の結果上位5件における必要情報を出力する # フォーマット 店名,URL,路線名駅名 API_KEY = '' payload = {'keyid': API_KEY, 'freeword': 'ワイン', 'hit_per_page': 5} # ワイン -> 店名 URL url = 'https://api.gnavi.co.jp/RestSearchAPI/v3/' response = requests.get(url, params=payload) rest_li...
true
690cfd6531d3487107752dff409aa4e7832aaa1a
Python
924070845/TanzhouPythonVipSecondClass
/网络编程/socket_server02.py
UTF-8
2,106
3.40625
3
[]
no_license
''' 我们要实现的功能是,客户端向服务端发送一个消息, 服务端可以收到,并且原封不动的返回给客户端 ''' import socket import time ''' 1:建立连接 ''' server = socket.socket() # 创建socket server.setblocking(False) # 设为非阻塞 server.bind(('0.0.0.0', 8001)) # 绑定IP地址 server.listen() # 创建监听 # 这里的监听还可以有参数,那是解释器版本的差异,有餐数是指最多有几个用户可以连接我。 # 不加人最大,任意数连接 # 不...
true
0210260deab8097451d1b1d62cd8d8e415d940fa
Python
Superbelko/ocr-test
/blur.py
UTF-8
611
2.984375
3
[]
no_license
import argparse import json import cv2 as cv def laplacian_variance(image): return cv.Laplacian(image, cv.CV_64F).var() def main(): parser = argparse.ArgumentParser(description='Blur detection utility, calculates pixel variance for an image. (less variance = more blur)') parser.add_argument('--input', ...
true
8fca732df4a923723594a58c8b532052b9c23b5d
Python
AIPHES/vldb2018-sherlock
/ukpsummarizer-be/summarizer/utils/phrase_extractor.py
UTF-8
2,663
3.34375
3
[ "Apache-2.0" ]
permissive
import nltk def leaves(tree): """Finds NP (nounphrase) leaf nodes of a chunk tree.""" for subtree in tree.subtrees(filter = lambda t: t.label()=='NP'): yield subtree.leaves() def normalise(word, stemmer): """Normalises words to lowercase and stems and lemmatizes it.""" word = word.lower() ...
true
1d02c2659d181d75b981ce728a5260995c0c035c
Python
mochammadfariz/Analisis-data-siswa
/del.py
UTF-8
469
2.625
3
[]
no_license
import pandas as pd import numpy as np import sklearn from sklearn import linear_model from sklearn.utils import shuffle data = pd.read_csv("student-mat.csv",sep=";") print(data.head()) data = data[["G1","G2","G3","studytime","failures","absences"]] predict = "G3" x = np.array(data.drop([predict],1)) y = np.array(d...
true
999c4e7215aa543c6cd3f9fa19ba1ab1822664ea
Python
AboudyKreidieh/traffic-autocalibration
/fcpnn/train.py
UTF-8
6,144
3.015625
3
[ "MIT" ]
permissive
""" """ from model import NN # , PNN, FCPNN import numpy as np import tensorflow as tf from collections import defaultdict import random import os import errno import pandas as pd # number of layers in the neural network model LAYERS = [1, 2, 3, 4] # number of nodes in each hidden layer NODES = [64, 256] # learning ...
true
309aeb9e5357b2ccbdfb8dadab74ecee41ef7b65
Python
kingbob2015/python_playground
/practice_problems/staircase.py
UTF-8
548
3.453125
3
[]
no_license
def numWaysDP(n, X): if n==0: return 1 nums = [0] * (n+1) nums[0] = 1 for i in range(1, n+1): total = 0 for j in X: if i-j >= 0: total += nums[i-j] nums[i] = total return nums[n] def numWaysRec(n, X): if n==0: return 1 tota...
true
dc82561fe6a5bf515b6f12c94e8c965993819dc8
Python
krishankansal/PythonPrograms
/oops/#021.py
UTF-8
511
3.265625
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 19 08:34:53 2020 @author: krishan """ class Silly: @property def silly(self): "This is a silly property" print("You are getting silly") return self._silly @silly.setter def silly(self, value): ...
true
8b6804fa38e4464e4156c893443b5d4796b8bf2b
Python
hitesh2940/Python_practice
/Assignment_2/Q15_filehandling_read_and_write.py
UTF-8
327
3.96875
4
[]
no_license
#Write a python code to create a text file Delta_file.txt and to write the input string from the user. Read the stored string from the file and print it in the reverse order f=open("Delta_file.txt",'w+') s=input("enter string") f.write(s) f.close() f=open("Delta_file.txt",'r') a=f.read() print(a[::-1]) f.clos...
true
c089fa34a8e1ec69578304b8d11bb770bb74159b
Python
santoshmore85/estudiando_el_kay
/figuras/PycharmKayStatisticalReport/problem_3_14.py
UTF-8
1,839
3.53125
4
[ "MIT" ]
permissive
import string letters = string.ascii_lowercase N_max = len(letters) N = 10 N = min(N, N_max) # generate list of all possible words with the N first letters of the alphabet words = [] for i in range(N): a = letters[i] for j in range(N): b = letters[j] for k in range(N): c = letter...
true
08a66fde710f2896ec9d4b3c462b877489b992c5
Python
KirillIvano/pickles
/server/db_interface/item.py
UTF-8
825
2.796875
3
[]
no_license
from app.models import Item, Product, ProductWeight, Order from typing import Dict, List def add_product_objects( items: List[Dict[str, object]] ) -> List[Dict[str, object]]: """ items in item structure add product object """ for i, item in enumerate(items): items[i]['product_weigh...
true
94261188f3cbce1323600fda5be972cf063a9b7b
Python
scottjab/supybot-cah
/cah.py
UTF-8
5,808
3.015625
3
[]
no_license
from random import choice import os import json import test # Settings you change card_folder = 'cards' answer_cards_file_names = ['answer_cards', 'custom_anwser_cards'] question_cards_file_name = ['question_cards', 'question_cards1', 'question_cards2', 'custom_question_cards'] # Settings that are used #this is one l...
true
6f0e731d8b1c7c07199aaf64730cb72766329d0b
Python
yonilev/error-detection
/src/LanguageModel.py
WINDOWS-1255
3,842
2.703125
3
[]
no_license
#encoding=cp1255 ''' Created on 14/02/2011 @author: levyeh ''' from BguCorpusReader import BguCorpusReader from Lexicon import Lexicon from nltk.probability import FreqDist from DetectErrors import hasEngChars, hasExtraChar, hasDigit,ligitWord def countNChars(words,N): if N<1: return None count = {} ...
true
071001508f204595c8678d3bb06e06c5de8289ea
Python
reidliujun/Network_Application_Frameworks-
/assignement1/files/json_generate.py
UTF-8
236
2.609375
3
[]
no_license
''' use xmltodict library to export json file from xml file ''' import io, xmltodict, json infile = io.open("books.xml", 'r') outfile = io.open("books.json", 'wb') o = xmltodict.parse( infile.read() ) json.dump( o , outfile, indent=2)
true
bf62f015e916bcd292c58c0e4ec22e37cc2b5ebe
Python
ManicEuphoria/fm
/models/backgroundM.py
UTF-8
707
2.6875
3
[]
no_license
import random from sqlalchemy import Column, Integer, String from sqlalchemy.ext.declarative import declarative_base from utils import fredis from fbase import get_session Base = declarative_base() class Background(Base): __tablename__ = "background" background_id = Column(Integer, primary_key=True, autoin...
true
7a0a7d4b4ad5e201f9957cd3a8e27ceb59906d2d
Python
WrongAman/RSA
/Edit.py
UTF-8
1,174
2.671875
3
[]
no_license
from PyQt5.QtWidgets import QTextEdit, QFileDialog def sub(): Editor.NextId -= 1 class Editor(QTextEdit): NextId = 1 def __init__(self, fileName=""): super().__init__() self.fileName = fileName if not self.fileName: self.fileName = "Unnamed-{0}.txt".format( ...
true
c7ad7798b6cd7bddd2216cf67dedf04b63d74264
Python
zhenya-paitash/diplom_project
/BOT/main.py
UTF-8
22,797
2.515625
3
[]
no_license
import requests from bs4 import BeautifulSoup import telebot from telebot import types import random as R import threading token = 'thisismytoken' bot = telebot.TeleBot(token) # ====================================================================================================================== @bot.message_handler...
true
fd6430c521eb0197ddbb04221dc003d629ef0798
Python
KachanS/pt_backtest_py
/models/Ema.py
UTF-8
516
3.4375
3
[]
no_license
class Ema: def __init__(self, window: int, source: float, value: float): self.window = window self.source = source self.value = value self.__a = 2/(window + 1) def calculate(self, source: float): #print(f'{self.__a}*{source} + (1 - {self.__a})*{self.value} = ...
true
a413129f003f0bf637b2883dd2090fcaf8a13add
Python
zhengzishang/MingText
/Model_Selection/regression_metrics.py
UTF-8
1,048
3.046875
3
[]
no_license
# -*- coding: utf-8 -*- """ 模型选择 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 回归问题性能度量 :copyright: (c) 2016 by the huaxz1986. :license: lgpl-3.0, see LICENSE for more details. """ from sklearn.metrics import mean_absolute_error, mean_squared_error def test_mean_absolute_error(): ''' 测试 mean_absolute_error...
true
777e350205ad4f8dfbc48202b14a9681a3d7d4d2
Python
TheTinyBit/snacs_crawling
/stats.py
UTF-8
6,191
2.90625
3
[]
no_license
from save import * import numpy as np import matplotlib.pyplot as plt import networkx as nx def calculate_statistics(G, save=False, output=True, plot=False, log=True, savePlot=False, filename=None): # Calculate links and nodes max_node = int(max(G.nodes())) amt_links = G.number_of_edges() amt_nodes = ...
true
0e5bc3ad77d817d8a61da9b1160514afc8c87e27
Python
jeroenstalenburg/judgment-aggregation
/judgment_aggregation/data/Data.py
UTF-8
3,122
3.109375
3
[ "Apache-2.0" ]
permissive
import os import shlex from ..JAError import JAError def get_file_in_path(file, path, get_all=False): """Get a file which can be found in one of the folders in the given path. """ found_files = [] for root, dirs, files in os.walk(path): if file in files: found_files.append(os.path....
true
151ecbc363a125c7379ae2c4b28003cc717834fa
Python
Bossy1996/Sentiment-analysis-project
/SentimentAnalysisPipeLine/example.py
UTF-8
2,229
3.609375
4
[]
no_license
# NLTK examples of usage import nltk from nltk.classify.decisiontree import f from nltk.corpus.reader import lin nltk.download([ "names", "stopwords", "state_union", "twitter_samples", "movie_reviews", "averaged_perceptron_tagger", "vader_lexicon", "punkt", ]) w = nltk.corpus.shakespe...
true
c627e00fecf7c538cf19bbe00032a3c2987a387c
Python
eronekogin/leetcode
/2019/longest_valid_parentheses.py
UTF-8
1,492
4.25
4
[]
no_license
""" https://leetcode.com/problems/longest-valid-parentheses/ """ class Solution: def longestValidParentheses(self, s: str) -> int: workStack = [-1] # Push -1 first to the stack to avoid boundary issue. maxLen = 0 for i, c in enumerate(s): if c == '(': workStac...
true