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 |
|---|---|---|---|---|---|---|---|---|---|---|
5a6a82fc874a42019832d2639c0d9fc5a7cc0118 | flyhawksz/study-algorithms | /question_shortest_path_graph_adj_list.py | UTF-8 | 16,398 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/11/16 0:26
# @Author : flyhawk
# @Site :
# @File : question_shortest_path_graph_adj_list.py
# @Software: PyCharm Community Edition
from class_graph_adjacency_list import GraphAdjacencyList
from Class_Queue import Queue
import networkx as nx
impor... | true |
8fd742eec37f4f414dcedf3461f7fe6b60d2a65d | k123321141/SelectNet | /src/SelectNet.py | UTF-8 | 5,525 | 2.6875 | 3 | [] | no_license | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
eps = np.finfo(float).eps
class SelectLayer(nn.Module):
def __init__(self, in_dim, ver=1, p=1.):
super(SelectLayer, self).__init__()
self.ver = ver
self.p = p
self.in_dim = in_dim
self.th... | true |
e1e82bbc5da9531fe009233314b54397cb735c9d | di-yuan/toc-chatbot | /fsm.py | UTF-8 | 4,516 | 2.703125 | 3 | [] | no_license | from transitions.extensions import GraphMachine
from utils import send_text_message
from utils import send_image_url
import search
import search2
year = ["2016", "2017", "2018"]
mylist = []
addname = []
class TocMachine(GraphMachine):
def __init__(self, **machine_configs):
self.machine = GraphMachine(
... | true |
d01bc4814035be6ea30f82906b8b40d7dc420fe2 | ninepillars/trunk | /example/pythonexample/bookexample/lession_1/lession_1_9.py | UTF-8 | 1,039 | 3.828125 | 4 | [] | no_license | # coding: utf-8
'''
Created on 2011-11-29
@author: Lv9
'''
#初始化字典 用大括号包起来是MAP
stock = {
"name" : "GOOG",
"shares" : 100,
"price" : 490.10
}
# stock = {} 一个空字典
# stock = dict() 一个空字典
name = stock["name"];#访问字典成员 用中括号("[]") 包关键字
value = stock["shares"] * stock["price"];
p... | true |
aa82cd8b14ac750d2e51a46add5665e8f8f4ab0c | fzubowicz/Python_bootcamp | /struktury_danych/min i max while true.py | UTF-8 | 440 | 3.765625 | 4 | [] | no_license |
komunikat = 'Podaj kolejną liczbę lub wpisz [koniec]'
res = input(komunikat)
# najpierw obsłużwyjątkowe sytuacje
if res == 'koniec':
exit('Nie wyrałeś żadnej liczby')
liczba = int(res)
min = liczba
max = liczba
while True:
res = input(komunikat)
if res == 'koniec':
break
liczba = int(res)
... | true |
ea7154c7efae17c8d448aba613032dcd2425a75b | tonycorejz/algorithms | /1.1.15/1.1.15.py | UTF-8 | 355 | 3.171875 | 3 | [] | no_license | def gcd(a,b):
p = 1
q = 0
r = 0
s = 1
m = a
n = b
while not(m==0 or n==0):
if m>=n:
m = m - n
p = p - r
q = q - s
else:
n = n - m
r = r - p
s = s - q
if m == 0:
k = n
x = r
y = s
else:
k = m
x = p
y = q
print(k,x,y)
x = int... | true |
9dcc6aac854a1071a05e136de3cb19a1b04beaca | demc/unix-scavenger-hunt | /gifs.py | UTF-8 | 572 | 2.84375 | 3 | [] | no_license | #!/usr/bin/python
import os
import random
import subprocess
import sys
tags = [
'angry'
, 'bored'
, 'shocked'
, 'embarassed'
, 'excited'
, 'happy'
, 'hungry'
, 'inspired'
, 'scared'
, 'sad'
]
gifs_dir_exists = os.path.exists('./gifs')
count = 10 if len(sys.argv) == 1 else int(sys.argv[1])
if co... | true |
ac96980cd356dbee49c301a1b201c6edb7263e91 | Sabinu/6.00x | /pset 02/pset_02 p_02 - paying debt off in a year.py | UTF-8 | 745 | 3.203125 | 3 | [] | no_license | __author__ = 'Sabin Purice'
balance = 3329
annualInterestRate = 0.2
#balance = 320000
#annualInterestRate = 0.2
b = balance
r = annualInterestRate
#b = int(raw_input('Ballance = '))
#r = float(raw_input('Anual Interest Rate = '))
total = 0
p = 180
def min_pay(b, p):
"""Returns Unpaid Bal... | true |
64411f22e54242f6f0c8f20377d499f3e090e75d | bu11durm/myProjects | /hockey_ranks/make_player_dict.py | UTF-8 | 748 | 2.671875 | 3 | [] | no_license | from selenium import webdriver
driver = webdriver.Chrome('../venv/chromedriver.exe')
driver.get('https://www.espn.com/fantasy/hockey/story/_/id/29458089/end-season-rankings-keep-draft-next-season')
ranks = driver.find_elements_by_class_name('last')
print('{')
for rank in ranks:
first_split = rank.get_attribute('in... | true |
0310fc30ab5a29a3ba77c82f836315c26aeb9a8e | bgroveben/DataScienceFromScratch | /2_chapter/functional_tools.py | UTF-8 | 2,415 | 4.625 | 5 | [] | no_license | # https://docs.python.org/2/tutorial/datastructures.html#functional-programming-tools
# https://docs.python.org/2/library/functions.html#filter
# https://docs.python.org/2/library/functions.html#map
# https://docs.python.org/2/library/functions.html#reduce
# When passing functions around, sometimes we want to partial... | true |
e999602d12b243376fcd75bab5cdac16565d5a85 | Ukonhattu/THS-BOT | /thsbot.py | UTF-8 | 4,206 | 2.921875 | 3 | [] | no_license | import discord
from discord.ext import commands
import random
import os
import giphy_client
from giphy_client.rest import ApiException
import json
import wolframalpha
from googletrans import Translator
translator = Translator()
description = '''The Hopeless Situation - Discord bot for everything'''
bot = commands.B... | true |
0a371a751a82efc24985d43004853d3f494e930f | Andrew04071989/Python3_course-Practice_NIIT | /task13.py | UTF-8 | 1,483 | 4.375 | 4 | [] | no_license | # Задание 13:
# Подобрать те функции библиотеки itertools,
# которые дадут правильные ответы на следующие вопросы:
from itertools import chain, filterfalse
from itertools import permutations
# 1) Функция должна принимать три массива ([1,2,3], [4,5], [6,7]),
# а вернуть лишь один массив ([1,2,3,4,5,6,7])
def three_t... | true |
1e56f93e13532915860a554212edf44f5410473c | jeffgonadoolay/rockpaperdildogame | /jeff.py | UTF-8 | 874 | 3.765625 | 4 | [] | no_license | import random
options = ["rock", "paper", "dildo"]
print("lets play rock, paper, dildo!")
print("what do you choose?")
playermove = input()
if playermove in options:
print("okay great!")
print("computers turn...")
computermove = random.choice(options)
print("computer chooses " + computermove)
if ... | true |
7b50cf319bc6bdc5a3fd9185199102b82f6a067e | abhib95/Python_Selenium_Framework_practice_proj | /Page_objects/Shoppingpage.py | UTF-8 | 805 | 2.6875 | 3 | [] | no_license | from selenium.webdriver.common.by import By
class ShoppingPage:
def __init__(self, driver):
self.driver = driver
mobiles = (By.CSS_SELECTOR, ".card-title a")
card_footer = (By.CSS_SELECTOR, ".card-footer button")
Checkout_btn = (By.CSS_SELECTOR, "a[class='nav-link btn btn-primary']")
de... | true |
f854b9acda5fb38df94e4876d63c5f1c8bffaf8b | mirage007/rtconsole | /test_console.py | UTF-8 | 876 | 2.828125 | 3 | [] | no_license | import time
from IPython.kernel import get_connection_file
from rtconsole import start_console
if __name__ == '__main__':
import logging
logging.basicConfig(filename='test.log', level=0)
app = start_console(locals())
#print statements won't work as they are now routed to the console
time.sleep(5)
... | true |
2baa6d525f3631f5b6fbbedd4bcef107cd7fc07f | lssxfy123/PythonStudy | /udacity_test/AIPND-cn-master/Image Classifier/data_process.py | UTF-8 | 3,002 | 2.609375 | 3 | [
"MIT"
] | permissive | import os
import json
import torch
from torchvision import datasets, transforms, models
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
train_key = 'train'
valid_key = 'valid'
test_key = 'test'
## 加载数据
## 返回class_to_idx, dataloaders
def load_data(data_directory):
if not os.path.isabs(dat... | true |
11b70b169ec9737401c960741288fa69f33994a3 | zwickers/EPI-Python | /PrimitiveTypes/02_swap_bits.py | UTF-8 | 708 | 4.15625 | 4 | [] | no_license | #
# Question: A 64-bit integer could be viewed as an array of bits, where the 0th
# index is the LSB, and the 63rd index is the MSB. Given an integer and two
# indices, i and j, swap the two bits at i and j.
#
def swap_bits(num,i,j):
# check if the i-th and j-th bits differ
if (num >> i) & 1 != (num >> ... | true |
1464d824f1d4d3b57c67e05e8228b44a86b24d3c | ytpessoa/python-codes | /00-fundamentos/string.py | UTF-8 | 2,015 | 3.59375 | 4 | [] | no_license |
#String é imutável
s = "1,2,3"
print( s[0] )
#1
print (dir(str))
# ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
# '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len... | true |
a9fff3262018119f6ee3c3a94493e3ecb535ad19 | PedroAntonioFS/Apredizado-de-maquina-aplicada-a-patologias-renais | /Extração de características da imagem/model_selection.py | UTF-8 | 496 | 2.796875 | 3 | [] | no_license | import numpy as np
import pandas as pd
from math import ceil
def train_test_split_per_class(x, y, test_size):
test_indexes = []
for _class in y.unique():
indexes = y[y == _class].index.values
test_indexes.extend(np.random.choice(indexes, ceil(test_size*indexes.size)))
x_train... | true |
a50390348d3e7221a016a140a57cc4b3a8ee7fb4 | flunardelli/reportloader | /reportloader/platforms/rubicon/reader.py | UTF-8 | 2,173 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | """ Module for retrieving appnexus reporting data """
import csv
import re
class OutputReaderInterface():
"""The 'OutputReaderInterface' class declares the interface that must be
implemented by all output_readers.
"""
def readOutput(self):
raise NotImplementedError
class OutputCsvReader(Outpu... | true |
b3f4d70ad671e046fc8d3e1a47d7814bde97a2c0 | benhmali/Jeux-de-batons | /Projet Final/SQRIPT3.py | UTF-8 | 1,891 | 2.6875 | 3 | [] | no_license | from Game import Game
from Player import CPUPlayer
from Player import HumanPlayer
import pickle
STICKS_NB = 15
player1 = CPUPlayer("CPU1_hard", "hard", STICKS_NB)
player2 = CPUPlayer("CPU2_hard", "hard", STICKS_NB)
player3 = CPUPlayer("CPU3_medium", "medium", STICKS_NB)
player4 = CPUPlayer("CPU4_medium", "medium", STI... | true |
dcc781c275331923aa0edf1cff383c5a9c7cc454 | AlbertoSierraLopez/DisenoAnalisisAlgoritmos | /RepasoDiseño/Divide y Venceras/Digitos Compartidos.py | UTF-8 | 452 | 3.859375 | 4 | [] | no_license | # Ejercicio 6.2
def Digitos_Compartidos(a):
k = len(a)
if k == 0:
return {}
elif k == 1:
return Digitos(a[0])
else:
a1 = Digitos_Compartidos(a[:k // 2])
a2 = Digitos_Compartidos(a[k // 2:])
return a1 & a2
def Digitos(n):
if n < 10:
return {n}
els... | true |
c7058f5229b36358b82c96d95aa08dae2a5b8fb5 | anandi-bharwani/Digit-Recognition-using-CNNs-on-the-Street-View-House-Numbers-dataset | /cnn_tf.py | UTF-8 | 3,203 | 2.609375 | 3 | [] | no_license | #0.28
import tensorflow as tf
import numpy as np
from util import error_rate, y2indicator, get_train_data, get_test_data
def reshape(X):
#Input : (32, 32, 3, N)
#Output: (N, 32, 32, 3)
return X.transpose(3, 0, 1, 2)/255
def init_filter(shape, poolsz):
W = np.random.randn(*shape)/np.sqrt(np.prod(shape[:2]) + np.... | true |
0964b726826570d5f3b50f6f09784eb5a53ec62a | dangokyo/leetcode_python | /013-RomanToInteger.py | UTF-8 | 630 | 3.6875 | 4 | [] | no_license | class Solution:
# @param {string} s
# @return {integer}
def romanToInt(self, s):
length = len(s);
i = 0;
ans = 0;
mydict = dict();
mydict['I'] = 1;
mydict['V'] = 5;
mydict['X'] = 10;
mydict['L'] = 50;
mydict['C'] = 100;
mydict['D'] = 500;
mydict['M'] = ... | true |
b543968b8915307d486ad586d00113a3d6192ff9 | Mausy5043/domog | /graph29.py | UTF-8 | 3,067 | 2.796875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import matplotlib
matplotlib.use("Agg")
from cmath import rect, phase # noqa
from matplotlib.dates import strpdate2num # noqa
import numpy as np # noqa
import pylab as pl # noqa
def bytespdate2num(fmt, encoding='utf-8'):
# co... | true |
7e8a33a73e4c7a3dad946e6033caa6b9217b3c33 | stefanocovino/SRPAstro | /Scripts/SRPLineProfile | UTF-8 | 2,894 | 3.03125 | 3 | [
"MIT"
] | permissive | #! python
""" Code to compute the line profile due to various transitions.
Context : SRP
Module : SRPLineProfile.py
Author : Stefano Covino
Date : 28/07/2014
E-mail : stefano.covino@brera.inaf.it
URL: : http://www.merate.mi.astro.it/~covino
Purpose : Compute the line profile.
Usage : SRPLineProfile -b [arg... | true |
21c7e24bb955b19ee529df06e404b50588143b81 | Raymond-P/Github-Dojo | /Python_200_Problems/basic/input_age.py | UTF-8 | 900 | 4.15625 | 4 | [] | no_license | # ---------------------------------------------------------------
# python best courses https://courses.tanpham.org/
# ---------------------------------------------------------------
# Create a program that asks the user to enter their name and their age.
# Print out a message addressed to them that tells them the year... | true |
51722fd4c4568d8cecf615ffc8fade9f40f4eea5 | Liam782/C-100-project | /atm.py | UTF-8 | 347 | 2.828125 | 3 | [] | no_license | class Atm(object):
def __init__(self, card_number, pin_number):
self.card_number = card_number
self.pin_number = pin_number
def check_balance(self):
print("Checking balance")
def deposit_cash(self):
print("Depositing cash")
def withraw_cash(self):
... | true |
abf5ea135d2941d907aa2a749c0010c7ca050dc5 | AwesomeTickets/database-server | /init.py | UTF-8 | 4,345 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pymysql
import os
import random
DB_HOST = 'localhost'
DB_NAME = 'awesome_tickets'
DB_USER = 'root'
DB_PSWD = '123456'
DB_CHARSET = 'utf8'
DB_CONN_SOCKET = '/var/run/mysqld/mysqld.sock'
GEN_RAND_SOLD_SEATS = False
TEST_SHOW_DATE = ['2017-05-01', '2017-05-02', '2017... | true |
e9200a59a73d113225042611fce604eba0f2024c | quanduyan/Learning-Programming | /day01-1/test_2.py | UTF-8 | 1,020 | 4.09375 | 4 | [] | no_license | #####################
#int
num1 = 0x23 #16진수 ==> 35
print(num1)
print(type(num1))
no1 = 1.0 #==> Float
print(type(no1))
import sys
print(sys.maxsize) #==> 정수형 변수가 갖을 수 있는 최대값
a = 1.0
b = 3.5e3 #==> 3.5*(10^3)
print(b)
#####################
#long ==> 3버전부터는 정수는 전부 in... | true |
03793d9be50b28e70c12736d8ca2e01c84709be6 | Aasthaengg/IBMdataset | /Python_codes/p03211/s670892104.py | UTF-8 | 164 | 2.9375 | 3 | [] | no_license | s = input()
ans = abs(753 - int(s[0] + s[1] + s[2]))
for i in range(1,len(s) - 2):
n = s[i]+ s[i + 1] + s[i + 2]
ans = min(ans,abs(int(n) - 753))
print(ans) | true |
afc4161fefd7898117fa8d7942e85360ea3af50b | Kitware/VTK | /Utilities/Maintenance/WhatModulesVTK.py | UTF-8 | 7,849 | 3.015625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python3
import re
from collections import defaultdict
from pathlib import Path
def get_program_parameters():
import argparse
description = 'Generate a find_package(VTK COMPONENTS ...) that lists all modules referenced by a set of files.'
epilogue = '''
This uses the VTK source folder to de... | true |
3f145028eefccdfa8417ae6632ef4ca1e9a51ffb | BekaValentine/RetroUI | /src/retroui/terminal/tixel.py | UTF-8 | 2,129 | 3.671875 | 4 | [] | no_license | from typing import List, Optional, Tuple
from retroui.terminal.color import Color
class Tixel(object):
"""
A `Tixel` is a textual picture element, corresponding to a single character
with a foreground and background color.
When used for rendering images, it would correspond to two pixels vertically
... | true |
bf24f1c19b57dbdd2c1a0ea49c01408ac207655c | Demons-wx/python_tec | /wx_file/read_file.py | UTF-8 | 595 | 3.71875 | 4 | [] | no_license | # coding=utf-8
# 某文本文件编码格式已知(如utf-8,gbk,big5)在pyhton2.x和python3.x中分别如何读取该文件?
#
# python2 写入文件前对unicode编码,读入文件后对二进制字符串解码
# python3 opne函数指定t的文本模式,endcoding指定编码格式
# python2
f = open('py2.txt', 'w')
s = u'你好'
f.write(s.encode('gbk'))
f.close()
f = open('py2.txt', 'r')
t = f.read()
print t.decode('gbk')
# python3
f = o... | true |
b40473822080e73f2991dd1758ee845e15dfdcff | mraaz/Python_practice | /Merge_sort/John's_example.py | UTF-8 | 2,089 | 3.9375 | 4 | [] | no_license | class MergeSort(object):
def __init__(self, numbers):
self.values = numbers
self.count = len(numbers)
def sort(self):
self.merge_sort(0, self.count - 1)
return self.values
def merge_sort(self, low, high):
if low < high:
mid = (low + high) // 2
... | true |
9b25f1a8aefe541aa73a334e933c30a81bc7cfb8 | Gendo90/topCoder | /0-300 pts/topcoderReppity.py | UTF-8 | 1,260 | 4.03125 | 4 | [] | no_license | # Problem Statement
#
# Given a string, input, with up to 50 characters, find the length of the longest substring that appears at least twice (non-overlapping) in input. If no substring appears twice, non-overlapping, return 0.
# Strings are case sensitive, and only upper case letters and lower case letters are allowed... | true |
02a27c5deec36717781ef88c3ead6bf980fbd5f3 | Hadhat/flow-inspector | /lib/backend/flowbackend.py | UTF-8 | 12,880 | 2.8125 | 3 | [
"MIT"
] | permissive | """
Backend wrappers. Select and create the appropriate objects for
backend communication.
Currently supported backends:
- mongodb
- mysql
- oracle
Author: Lothar Braun
"""
import sys
import config
import common
import time
import operator
class Collection:
"""
This class is a wrapper for the mongo db colle... | true |
8b51f189127f135a394fa795dd71711615a6758d | SeanKG/mfp_analyzer | /src/go.py | UTF-8 | 1,703 | 2.75 | 3 | [] | no_license | import myfitnesspal
import sqlite3
import datetime
db = sqlite3.connect("mydb.db")
cursor = db.cursor()
# cursor.execute('''
# DROP TABLE diary;
# ''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS diary(
date DATE PRIMARY KEY,
calories INTEGER,
carbohydrates INTEGER,
fat INTEGE... | true |
ab44f35cd56353b740ed6f8e636e6f4bdc9fa989 | YuanYunjing/shequkaifa0.0 | /tool/featureVec.py | UTF-8 | 9,404 | 2.546875 | 3 | [] | no_license | # -*- coding:utf-8 -*-
"""
@author:Yuan
@file:featureVec.py
@time:2018/1/26 10:43
"""
import time
import numpy as np
import pymysql
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, TfidfTransformer
import math
import readwrite as rw
from sklearn.datasets.base import Bunch
'''... | true |
3d25ca2af34fdab7390c2676e78f2764f5cf43ad | acompagno/ProjectEuler | /27/quadprime.py | UTF-8 | 615 | 3.546875 | 4 | [] | no_license | def isprime(x):
x = abs(int(x))
if x < 2:
return "Less 2", False
elif x == 2:
return True
elif x % 2 == 0:
return False
else:
for n in range(3, int(x**0.5)+2, 2):
if x % n == 0:
return False
return True
def test(a,b):
y=2
x=0
best_a = 0
best_b = 0
best_count = 0
while i... | true |
689109e3261d09733911db75751e8e6dec949641 | GrinninReaper/ET5-Projet-TAL | /tp/TP3/tp3_ex2.py | UTF-8 | 1,181 | 2.796875 | 3 | [] | no_license | import nltk
from nltk import pos_tag
from nltk.tokenize import word_tokenize
from nltk import RegexpParser
inputPath = "wsj_0010_sample.txt"
outputPath = "wsj_0010_sample.txt.chk.nltk";
inputFile = open(inputPath, "r+");
content = inputFile.read();
inputFile.close();
nltk.download('averaged_perceptron_ta... | true |
d1627e0845d5a99f99d3b97a3df5c14373555c96 | kansi/Trail_Python | /System_prog/p20x_key_logger.py | UTF-8 | 1,143 | 2.734375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 20:44:39 2013
@author: kansi
"""
import pyHook, pythoncom
# create a keyboard hook
def OnKeyboardEvent(event):
print 'MessageName:',event.MessageName
print 'Message:',event.Message
print 'Time:',event.Time
print 'Window:',event.Window
... | true |
2463eba3fcad0e9646b758151535e7bb3c7e4b9a | edenmelman/learning_python | /Lesson_10/queue_out_of_stacks_improved_shifts.py | UTF-8 | 839 | 3.75 | 4 | [] | no_license | class Stack:
def __init__(self):
self._l = []
def push(self, item):
self._l.append(item)
def pop(self):
return self._l.pop()
def peek(self):
return self._l[-1]
def is_empty(self):
return not self._l
class Queue:
def __init__(self):
self.stack_a = Stack()
self.stack_b = Stack()
def enqueue(sel... | true |
7d5690d553a32c773d320b42cfdff73475983604 | pigeonism/pass-old | /pass.py | UTF-8 | 1,215 | 3.5 | 4 | [
"BSD-2-Clause"
] | permissive | from random import shuffle, randint, SystemRandom
# basic use
import string
def get_pass(leng=0, symbols=False):
if (leng > 0 and leng <= 62):
chars = [chr(i) for i in range(32,127) if (chr(i).isalpha() or chr(i).isdigit())]
if symbols:
symbs = [chr(i) for i in range(32,127) if... | true |
5d371823e7ac3747943cc8f04443264eba676199 | vegetable68/sbb | /mpc_local/plaintext_test.py | UTF-8 | 1,271 | 2.84375 | 3 | [
"CC0-1.0"
] | permissive | # A plaintext comparison for sanity check
import argparse
from aws_batch_classify import PHASH_LEN
def hex_string_to_bin_string(hex_string):
'''
Converts a hex encoded string (without a leading 0x) to a binary encoded
string
'''
return format(int(hex_string, 16), f'0{PHASH_LEN}b')
def hamming_di... | true |
1cb65aaea715be8dc148f6e654c42e398648b94f | BruderOrun/PY111-april | /Tasks/a3_check_brackets.py | UTF-8 | 419 | 4 | 4 | [] | no_license | def check_brackets(brackets_row: str) -> bool:
"""
Check whether input string is a valid bracket sequence
:param brackets_row: input string to be checked
:return: True if valid, False otherwise
"""
s = 0
for i in brackets_row:
if i == '(':
s += 1
else:
... | true |
781f263d09400fbd5d50046e740995c4526f1ec0 | fagan2888/CostAware_ECTS | /utils/classifiers.py | UTF-8 | 1,432 | 2.59375 | 3 | [] | no_license | import numpy
from sklearn import svm
from sklearn.base import clone
from sklearn.cross_validation import StratifiedKFold
__author__ = 'Romain Tavenard romain.tavenard[at]univ-rennes2.fr'
def linear_svm(probability=False):
try:
return svm.SVC(kernel="linear", random_state=0, probability=probability)
... | true |
ae31dd9ac664fe4acdcb3c61445ab455e9cb5712 | mxl123/tumblr_spider | /tumblr.py | UTF-8 | 2,506 | 2.828125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import time, re, os, urllib.request,sys
from threading import Lock, current_thread, Thread
def main():
username = []
for i in range(1,len(sys.argv)):
username.append(sys.argv[i])
print(' '.join(username))
tumblr_id(username)
def download(args):
print('A... | true |
6fd538effc29f4f40629bb36ceedb163b63f3208 | andrewyager/python-asterisk-dialplan | /asterisk_dialplan/dialplan.py | UTF-8 | 3,611 | 3.609375 | 4 | [] | no_license | """ Dialplan Functions """
from .patterns import pattern_to_ranges
import re
def parse_diaplan_context(dialplan_string):
""" Build a dictionary that represents the given set of dialplan elements
contained in this input string. The key in the dictionary corresponds to
the extension, and the arguments are pri... | true |
6da5e42f9e995ec5882cfa65f9a69c2505b92aa9 | bimri/programming_python | /chapter_8/demo-check-auto.py | UTF-8 | 766 | 4 | 4 | [
"MIT"
] | permissive | # check buttons, the easy way
from tkinter import *
root = Tk()
states = []
for i in range(10):
var = IntVar()
chk = Checkbutton(root, text=str(i), variable=var)
chk.pack(side=LEFT)
states.append(var)
root.mainloop() # let tkinter keep track
print([var.get() for var in stat... | true |
60c24a25e259d79a11dc4a7835944a4c7813e776 | mcfunley/euler | /p0094.py | UTF-8 | 1,276 | 3.578125 | 4 | [] | no_license | #!/usr/bin/env python
from itertools import count
from euler import is_perfect_square
def has_integral_area(side, base):
# side^2 = (0.5 * base)^2 + h^2
# h^2 = side^2 - 0.25 * base^2
# area = base * h / 2
# area^2 = base^2 * h^2 / 4
# area^2 = base^2 * (side^2 - base^2 / 4) / 4
# area^2 = (b... | true |
8655b09121bca4696cdbeb3569890349abe65eb6 | AlEmerich/capstone-project | /src/main_walk.py | UTF-8 | 3,874 | 2.640625 | 3 | [] | no_license | import argparse
import json
# import threading
from walk.agents.ac_policy import environmentFactory
from walk.agents.abstract_humanoid import AbstractHumanoidEnv
from walk.agents.abstract_bipedal import AbstractBipedalEnv
from walk.agents.abstract_inverted_pendulum import AbstractInvertedPendulumEnv
from walk.agents.ra... | true |
997601020acf9f8d2967a22e6b29d5a1a3c0e4e1 | BoboTiG/thermalprinter | /tests/test_barcode_position.py | UTF-8 | 768 | 2.796875 | 3 | [
"MIT"
] | permissive | import pytest
from thermalprinter.constants import BarCodePosition
from thermalprinter.exceptions import ThermalPrinterConstantError
def test_default_value(printer):
assert printer._barcode_position is BarCodePosition.HIDDEN
def test_changing_no_value(printer):
printer.barcode_position()
assert printer... | true |
1e4897787c8150f8500fbe15d6155eb536d08ac3 | ArronHZG/algorithm-with-python | /leetcode/dynamicProgramming/213_rob.py | UTF-8 | 635 | 3.40625 | 3 | [] | no_license | import unittest
from typing import List
def robOnce(nums: List[int]) -> int:
dp_1 = dp_2 = 0
for i in range(len(nums)):
dp = max(nums[i] + dp_2, dp_1)
dp_2 = dp_1
dp_1 = dp
return dp_1
class Solution:
def rob(self, nums: List[int]) -> int:
if len(nums) == 0:
... | true |
c1d730cf506af5de6e296d16c807be71f71ccae1 | barendt/biopython | /Tests/test_HMMGeneral.py | UTF-8 | 6,593 | 3.265625 | 3 | [
"LicenseRef-scancode-biopython"
] | permissive | #!/usr/bin/env python
"""Test the HMM.MarkovModel and HMM.DynamicProgramming modules.
Also tests Training methods.
"""
# standard modules
import unittest
# biopython
from Bio import Alphabet
from Bio.Seq import Seq
# stuff we are testing
from Bio.HMM import MarkovModel
from Bio.HMM import DynamicProgramming
from Bi... | true |
2018bbe5ff82f96157a3b966ce3844a472fbc03d | alidaho/HanaSocialMedia | /server/src/incFiles/fire.py | UTF-8 | 1,496 | 2.5625 | 3 | [] | no_license | import firebase_admin
from firebase_admin import credentials, firestore, db, auth
import google.cloud
from google.cloud.firestore_v1 import Increment
cred = credentials.Certificate("path/zumish-a7a8c-firebase-adminsdk-djj1b-d969258375.json")
app = firebase_admin.initialize_app(cred)
store = firestore.client()
doc = st... | true |
47f9ef10137f9f36db0fd037ac68fc4e842a0cdb | chan-hoo/regional_workflow | /ush/python_utils/interpol_to_arbit_CRES.py | UTF-8 | 1,688 | 3.515625 | 4 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env python3
def interpol_to_arbit_CRES(RES, RES_array, prop_array):
"""Function to interpolate (or extrapolate) a grid cell size-dependent property
to an arbitrary cubed-sphere resolution using arrays that specify a set of property
values for a corresponding set of resolutions
Args:
... | true |
3a636c69c6fea698e86f2fa75c7abf191fd51b30 | zb5003/simulacra | /dev/primes.py | UTF-8 | 1,177 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | import datetime as dt
from simulacra.math import *
if __name__ == '__main__':
low_limit = 100
t_start = dt.datetime.now()
print('Primes below {} via sieve:'.format(low_limit))
for p in prime_sieve(low_limit):
print(p, end = ', ')
print('\nElapsed time: {}'.format(dt.datetime.now() - t_st... | true |
c3993cca238572740e35da27910ea036d50ee3b0 | smsn/pyweb | /www/orm.py | UTF-8 | 9,292 | 2.703125 | 3 | [] | no_license | import asyncio
import aiomysql
import logging
async def create_pool(loop, **kwargs):
# 创建连接池
# **kwargs 关键字参数 eg:city='Beijing' kwargs={'city': 'Beijing'}
logging.info("Create database connection pool ...")
global __pool
__pool = await aiomysql.create_pool(
host=kwargs.get("host", "localh... | true |
c407fabaff6d66fafd5553bf4a82553f33822c65 | myliu/python-algorithm | /leetcode/factor_combinations_mle.py | UTF-8 | 477 | 2.59375 | 3 | [] | no_license | class Solution(object):
def getFactors(self, n):
"""
:type n: int
:rtype: List[List[int]]
"""
def dfs(n, start, tmp, result):
if n <= 1:
if len(tmp) > 1:
result += tmp,
return
for i in range(start, n... | true |
6d7487860990d8dfab7c673c32f065f266897f6b | HotView/PycharmProjects | /youtobe教程实例/tutorial23.py | UTF-8 | 638 | 2.59375 | 3 | [] | no_license | import cv2
def contours_demo(image):
dst = cv2.GaussianBlur(image,(3,3),0)
gray = cv2.cvtColor(dst,cv2.COLOR_BGR2GRAY)
ret,binary = cv2.threshold(gray,0,255,cv2.THRESH_BINARY|cv2.THRESH_OTSU)
cv2.imshow("binary image",binary)
cloneimage,contours,heriachy = cv2.findContours(binary,cv2.RETR_EXTERNAL,... | true |
2ab32848075e80f528cbbb723780597ad4786e98 | riffschelder/train.usaco.org | /chapter2/section2.4/fracdec.py | UTF-8 | 1,085 | 3.65625 | 4 | [] | no_license | """
ID: riff.sc1
LANG: PYTHON3
TASK: fracdec
"""
def main():
with open('fracdec.in') as fin:
# n for numerator, d for denominator
(n, d) = [int(x) for x in fin.read().split()]
# simulate long division.
answer = str(n // d)
answer += '.'
if n % d == 0:
answer += '0'
else:
answer += get_decim... | true |
ac6b824b34c7b303d1ae80d870a747c674cff62a | dpezzin/dpezzin.github.io | /test/Python/dataquest/dataframe_basics/column_by_name_to_var.py | UTF-8 | 450 | 3.421875 | 3 | [] | no_license | #!/usr/bin/env python
# First we can get the names of all the columns (in order)
print(list(food_info.columns.values))
# The we can get a column by name.
print(food_info["Protein_(g)"][0:10])
# And again.
sodium_column = food_info["Sodium_(mg)"]
# Assign the FA_Sat_(g) column to the variable saturated_fat.
# Assign... | true |
4a2ac3fe9cd9702b4f053c396ba1c8ca5dc242d6 | fishfishin/procrustrean | /cgan on sof/loaddata_conv.py | UTF-8 | 3,107 | 2.546875 | 3 | [] | no_license | import cv2
import os
import glob
import numpy as np
from PIL import Image
import random
import scipy.io
import tensorflow as tf
import matplotlib.pyplot as plt
'''
images size is 480 x 640 x 3,and I downsize the images for accelerate the learning to h x w x 3.
there are two kinds of partition: illumination... | true |
11d3cb7a6a4c4a96b34a213b5e6e527c65ba43ea | TonGarcia/NLPSpacy | /nlp_app.py | UTF-8 | 340 | 2.5625 | 3 | [] | no_license | import spacy
# nlp = spacy.load("pt_core_news_sm")
# nlp = spacy.load("en_core_web_sm") # load model package "en_core_web_sm"
# nlp = spacy.load("/path/to/en_core_web_sm") # load package from a directory
nlp = spacy.load("en") # load model with shortcut link "en"
doc = nlp("Thi... | true |
4999de4ee66b142d84d5f70fb51ca379814c646f | anantja-in/recommend-classes | /code.py | UTF-8 | 7,704 | 2.921875 | 3 | [
"MIT"
] | permissive | from scipy import *
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy
import pickle
class ProbabilisticMatrixFactorization():
def __init__(self, rating_tuples, latent_d=1):
self.latent_d = latent_d
self.learning_rate = .0001
self.regularization_strength = 0.1
... | true |
ff9760f64dc90254060bc4ccf3ca7edd5f8f17cf | vishcocity/Team-lovelace-p3 | /lovelace-p3/zip_extractor.py | UTF-8 | 568 | 3.28125 | 3 | [
"MIT"
] | permissive | import os
import zipfile
def extract_zips():
"""creates new folder data within data and extracts all tar files into it
"""
#loops over all directories within data folder
for filename in os.listdir('../data'):
if filename[-3:]!="zip":
continue
#prints filename for testing
#print(filename)
#opens tarfil... | true |
7ba2b47a36db7e097a7e2765a099b3b5d03e0401 | guigui2993/Euler | /p139/p139optim.py | UTF-8 | 1,008 | 3.703125 | 4 | [] | no_license | """
Problem 139
a,b,c the length of the triangle
a+b+c is less than 10**8
b > a
c is the hypotenuse => a and b < c
a**2 + b**2 = c**2
we want n*(b-a) = c (b-a multiple of c)
For lim = 5000 => 16s
For lim = 7080 every unit pythagorian triples are enumerated
Not 15086639 !!!!
10057761 ?
"""
import time
import sys
... | true |
338704a9ecc1ad18e0d39b8532e5878f087a840d | Masa-74/stock_preb | /msvc/py/services/utils/exception_manager_util.py | UTF-8 | 275 | 3.21875 | 3 | [] | no_license |
########################################################
# Exception when data in db is empty.
########################################################
class EmptyData(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value) | true |
f709b9b1cd7a0b69f374b1223bf0421ddc879b19 | Freddy875/Python | /Variables/AsignarVariosValores.py | UTF-8 | 529 | 4.25 | 4 | [] | no_license | '''
Python permite asignar multiples
variables en un linea
'''
x,y,z = "Naranja", "Manzana" , "Cereza"
print(x)
print(y)
print(z)
'''
Puede asignar el mismo valor a multiples variables
en una linea
'''
x = y = z = "Naranja"
print(x)
print(y)
print(z)
print("Desempaquetar una coleccion")
'''
Si tiene una coleccion d... | true |
2f7bae1ff3f8c8b3414124b31d348b3fb30fb90c | minzdeflaz/BigOCodingBlue | /midterm/printerQueue.py | UTF-8 | 555 | 2.78125 | 3 | [] | no_license | import heapq
num = int(input())
for _ in range(num):
n, m = map(int,input().split())
queue = list(map(int,input().split()))
heap = [i * -1 for i in queue]
heapq.heapify(heap)
time = 1
i = 0
count = 0
while True:
cur = heapq.heappop(heap) * -1
if i == m:
print(time)
break
if cur ... | true |
eafb7c6a34ddd805da61279b2bb99b392d043d53 | Growail/Python-codes | /cuenta_de_banco_POO.py | UTF-8 | 5,995 | 3.890625 | 4 | [] | no_license | #definicion de las clases
class Cuenta:
numeroCuenta= 0
nombreCliente=""
ID=0
saldo= 0
totalDepositos=0
cantidadDepositos=0
totalRetiros=0
cantidadRetiros=0
estado= "Activa"
def Depositar(self,p):
self.saldo = self.saldo + p
self.totalDepositos+... | true |
99c06a0ce23e5b947e67bc3f453e101021d44bda | OZ-T/leetcode | /0/11_container_with_most_water/main.py | UTF-8 | 1,307 | 3.5625 | 4 | [
"Apache-2.0"
] | permissive | class Solution:
def maxArea(self, height: list[int]) -> int:
n = len(height)
# starting from two ends, because longer width container might hold more water
i = 0
j = n - 1
res = 0
while i < j:
# calculate the water volume
res = max(res, (j-i... | true |
c9659eb3b79e8d464f2710aa894ddc064ac3eadb | kyhau/small-coding-exercises | /codility/tape_equilibrium.py | UTF-8 | 903 | 3.765625 | 4 | [] | no_license | """
Minimize the value |(A[0] + ... + A[P-1]) - (A[P] + ... + A[N-1])|.
See https://app.codility.com/programmers/lessons/3-time_complexity/tape_equilibrium/.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [2..100000]
- each element of array A is an integer within the ran... | true |
eae76f786b1fb9f2abb9729a5b3cb61018937933 | mateuszklinowski/Python_Semestr_2_WSB | /histograms.py | UTF-8 | 1,412 | 3.46875 | 3 | [] | no_license | import random
import string
#Zad1
def create_histogram_from_string(string):
dictionary = {}
string = sorted(string);
for char in string:
if char not in dictionary:
dictionary[char] = 1
else:
dictionary[char] += 1
return dictionary
random_hist = create_histogram_... | true |
f974a1dc0407cffbbc5c35126e43230b2352f234 | Ellianto/Skripsi-OTA | /Python/Target_Code/TC_04.py | UTF-8 | 1,231 | 3.25 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
DEBUG = False
GREEN_LED_PIN = 11
RED_LED_PIN = 12
# Used for pin setups
# Array of tuples (pin_number, GPIO.OUT or IN)
# There is a third parameter, but the meaning depends on the pinmode (Input or Output)
output_pins = [
(RED_LED_PIN, GPIO.OUT),
(GREEN_LED_PIN, GPIO.OUT)
... | true |
96deebd58521db688f1d58393b33b1fe20a53d93 | AzaubaevViktor/brainfuck_ng | /executor/exc.py | UTF-8 | 2,822 | 2.96875 | 3 | [] | no_license | from traceback import format_exc
from typing import Union, List
from lexer import LexerResultT, Lemma
class ErrorStackFrame:
def __init__(self, lemma: LexerResultT):
self.lemma = lemma
def __str__(self, wrong_lemma: LexerResultT = None):
if not self.lemma:
return "()"
if... | true |
b6c9d6c754445e8d0b557d112547987c312bc4af | emmanuelgendy/sbe459-introduction-to-bioinformatics | /cg_content.py | UTF-8 | 423 | 3.234375 | 3 | [] | no_license | def cg_content(strand):
length = len(strand)
countC = 0
countG = 0
for i in range(length):
if strand[i] == "C":
countC += 1
if strand[i] == "G":
countG += 1
return countC+countG
def cg_content_BuiltIn(strand):
return strand.count("C")+strand.count("G")
... | true |
0593e19d3be6d8a5dbcec53c982fb36e52905553 | IJSComplexMatter/cddm | /cddm/test/test_window.py | UTF-8 | 2,902 | 2.84375 | 3 | [
"MIT"
] | permissive | """tests for window functions"""
import unittest
import numpy as np
from cddm.conf import FDTYPE
from cddm.window import blackman, gaussian, tukey, hann, plot_windows
def _r(shape, scale = 1.):
"""Returns radius array of a given shape."""
ny,nx = [l/2 for l in shape]
ay, ax = [np.arange(-l / 2. + .5, l / ... | true |
d7ebd4e8d251541589d007b55266bcdb62c81e55 | mohitsh/python_work | /recursion/tower_of_hanoi.py | UTF-8 | 717 | 3.890625 | 4 | [] | no_license |
# we have three towers From, Via and To
# From: initial tower
# Via: intermediate tower
# To: final tower
# this function attempts to move a tower of height h
# from From tower to To tower
def moveTower(h,From,Via,To):
if h >= 1:
# move tower of height (n-1) i.e. tower
# leaving the bottom disk to Via tower ... | true |
c9951c896d106771297b6c43e9be7753d923bac7 | johnash1990/stat527_final_project | /lasso_utils.py | UTF-8 | 5,733 | 3.390625 | 3 | [
"BSD-2-Clause"
] | permissive | import matplotlib.pyplot as plt
import numpy as np
def center_data(X, cols_to_center):
"""
Parameters:
@X {2D numpy array} dataset with variables to be centered
@cols_to_center {list} list of columns (i.e., variables to center)
Return:
@centered_data {2D numpy array} the dataset, but... | true |
0e9ac395bd68875bd9082239386b2b9149489b78 | Aasthaengg/IBMdataset | /Python_codes/p02748/s323003222.py | UTF-8 | 306 | 3.046875 | 3 | [] | no_license | A, B, M = map(int, input().split())
lis_a = list(map(int, input().split()))
lis_b = list(map(int, input().split()))
lis_price = []
lis_price.append(min(lis_a) + min(lis_b))
for i in range(M):
x, y, c = map(int,input().split())
lis_price.append(lis_a[x-1] + lis_b[y-1] - c)
print(min(lis_price))
| true |
94bc2175cdfc4d8b774fb2ba134e9694c796f9a6 | hsiao78611/data-for-paper | /packages/utils/scrollpage.py | UTF-8 | 4,139 | 2.625 | 3 | [] | no_license | import time
from datetime import datetime
from random import randint
import re
def _scroll_down(driver, load_more_button_Xpath):
# find the button
load_more_button = driver.find_element_by_xpath(load_more_button_Xpath)
# scroll to the position
load_more_button.location_once_scrolled_into_view
# c... | true |
ddf6248ec8035b1910dc915f3d4fafac6f1ffc29 | rafailiadimaki/online-school-management-system-part-b | /6b. Add the course 'CB13PTJS'.py | UTF-8 | 800 | 3.15625 | 3 | [
"MIT"
] | permissive | import mysql.connector
conn = mysql.connector.connect(host='localhost', user='root', passwd='MyNewPass', database='private_school')
myCursor = conn.cursor()
# 1 : query
add_course= ('INSERT INTO courses'\
'(course_id, title, language, description, Type)'\
' VALUES (%s, %s, %s, %s... | true |
6d4af64f35b4fa6c9488dad617d27ab5b25b4a56 | duramato/Maker | /StatMaker.py | UTF-8 | 3,993 | 3.203125 | 3 | [] | no_license | import csv
from random import choices
from collections import Counter
def check_if_present(number, list):
if number in list:
#print("O numero {} ja esta presente, a gerar outro.".format(number))
return True
else:
return False
def gerar_sorteio():
with open('sorteios.csv', newline=... | true |
74d452c8213734fa987258eb13e25c76ec575c7f | OliverSekiro/python_log | /oneClassSvm/NoveltyDetection/normalDistribution.py | UTF-8 | 2,187 | 2.96875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from sklearn.svm import OneClassSVM
from matplotlib import font_manager
# generate a coordinate matrices
xx,yy = np.meshgrid(np.linspace(-5,5,500),np.linspace(-5,5,500),sparse=False)
#generate 200 training set ,2 dimensions
X = 0.3*np.random.randn(100,2)
X_train = np.... | true |
da5a617af99e921b227f441b2046fe536622e7a2 | wangke-tech/DataStructure | /steps.py | UTF-8 | 364 | 3.875 | 4 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
"""
动态规划问题 1:
有n级台阶,一个人每次上1级或2级,问有多少种走完n级台阶的方法?
"""
def f(n):
if n <=0:
return 0
if 0 < n <=2:
return n
else:
return f(n -1) + f(n -2)
print __doc__
n =int(raw_input('input a num:\n'))
print '\nresult:\n', f(n)
| true |
5ad1a2b603738f6a062db39a164b71bc5e6ba39d | liwang0904/Deep-Learning | /Linear Algebra for Machine Learning/Chapter 11/11.6_vector_rank.py | UTF-8 | 227 | 3.046875 | 3 | [] | no_license | from numpy import array
from numpy.linalg import matrix_rank
v1 = array([1,2,3])
# [1 2 3]
print(v1)
vr1 = matrix_rank(v1)
# 1
print(vr1)
v2 = array([0,0,0,0,0])
# [0 0 0 0 0]
print(v2)
vr2 = matrix_rank(v2)
# 0
print(vr2)
| true |
356f4dea88b8a32d537911d4e21f0484d07fd5c2 | 972424611/machine-learning | /practice/糖尿病预测sklearn.py | UTF-8 | 4,961 | 3.78125 | 4 | [] | no_license | # coding: utf-8
# 利用 diabetes数据集来学习线性回归
# diabetes 是一个关于糖尿病的数据集, 该数据集包括442个病人的生理数据及一年以后的病情发展情况。
# 数据集中的特征值总共10项, 如下:
# 年龄
# 性别
# 体质指数
# 血压
# s1,s2,s3,s4,s4,s6 (六种血清的化验数据)
# 但请注意,以上的数据是经过特殊处理, 10个数据中的每个都做了均值中心化处理,然后又用标准差乘以个体数量调整了数值范围。验证就会发现任何一列的所有数值平方和为1.
# 关于数据集更多的信息: http://scikit-learn.org/stable/modules/generated/... | true |
6a9f5da76d2e9b47ce9bc2a3cdda148e0d10aa2d | cjdxsxd/python3.6Project | /testCase/test_getDemo.py | UTF-8 | 1,047 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @time 2018/3/15 23:47
# @autor:shangxudong
# @name: test_getDemo.py
# @software: PyCharm
import requests
import unittest
import json
class test_getDemo(unittest.TestCase):
url = "https://httpbin.org/"
def test_getNoParams(self):
resp = requests.get(self.u... | true |
c12289467f68d09c445dc454e31892e52ee92db5 | tarekosama126/leet-code-problems | /lastStoneWeight.py | UTF-8 | 306 | 3.1875 | 3 | [] | no_license | import heapq
def lastStoneWeight(stones) -> int:
myneglist = [-x for x in stones]
heapq.heapify(myneglist)
while len(myneglist) >= 2:
x = heapq.heappop(myneglist) * -1
y = heapq.heappop(myneglist) * -1
heapq.heappush(myneglist, (x - y) * -1)
return myneglist(0) * -1 | true |
a27d86ceff9adadcdb9fea136d4d72e14c495047 | noiclas/15C-PID-HUMIDIFIER | /PID-SYSTEM/sensorArray.py | UTF-8 | 3,003 | 2.796875 | 3 | [] | no_license | import board
import busio
from adafruit_htu21d import HTU21D
from adafruit_tca9548a import TCA9548A
import time
import numpy as np
import pickle
class sensorArray:
def __init__(self):
self.i2c = busio.I2C(board.SCL, board.SDA)
self.tca = TCA9548A(self.i2c)
self.sensor1 = HTU21D(self.tca[2]... | true |
f0d6591b3a9e84c31248f6ed02770327a03f681e | BC9466/RockPaperScissors | /RockPaperScissors_Final_11282019-9252020.py | UTF-8 | 39,930 | 3.546875 | 4 | [] | no_license |
#we import these two class because we need them in our code
from tkinter import *
import random, time
# All images were drawn by Dennis Phan
# Collaboration course project by Dennis Phan and Cheng-Hsi Li
# This is our code for the game, rock,paper,scissors
# our code is run & divided into different chunk ... | true |
9818282cb4989e70e7fea8e08f4ded8067a1e8b4 | helenakristina/appsheet | /app/models.py | UTF-8 | 1,613 | 3.296875 | 3 | [] | no_license | """
models.py is stores our SQLAlchemy model for sanitizing/validation
of inputs prior to inserting into database.
If the phone number is not valid US number, the User object will not
be created.
"""
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_utils import PhoneNumber... | true |
1bb702ceb8e4a2265c3f1f11ef4f381efac7b9c2 | wooyeon1212/wooyeon1212 | /hanoi(수정).py | UTF-8 | 586 | 3.328125 | 3 | [] | no_license | #-*- coding: utf-8 -*-
count=0
#count를 변수로 지정해서 시행 횟수를 나타내고자 하였으나 따로 구할수가 없네요...어떻게 짜야할지를 모르겠습니다.
def T(N, Beg, Aux, End):
count+=1
if N == 1:
print(Beg, '->', End)
else:
T(N-1, Beg, End, Aux)
T(1, Beg, Aux, End)
T(N-1, Aux, Beg, End)
#N=원판의수, BEG,AUX,END 기둥
#재귀 알고리즘을 활용
... | true |
a0d9bb7d9d810257e806a65eb4db39fb2d6af1ad | huangbow/INF553 | /Assignment2/Huang_Bowen_unique_trims.py | UTF-8 | 404 | 2.734375 | 3 | [] | no_license | import MapReduce
import sys
mr=MapReduce.MapReduce()
def mapper(record):
key=record[0]
value=record[1]
h=hash(value)
#remove last 10 letters
value=value[:-10]
mr.emit_intermediate(h,value)
def reducer(key,list_of_value):
#guarantee that if it duplicates, only output one
mr.emit(list_of_value[0])
if __name... | true |
69738c8ad7eef00349c3e4734a54892dbffea4e7 | wumingpu/Leetcode | /algorithm/restore_ip_address.py | UTF-8 | 723 | 3.828125 | 4 | [] | no_license | """
给定一个只包含数字的字符串,复原它并返回所有可能的 IP 地址格式。
示例:
输入: "25525511135"
输出: ["255.255.11.135", "255.255.111.35"]
"""
class Solution(object):
def restoreIpAddresses(self, s):
"""
:type s: str
:rtype: List[str]
"""
self.generateIpAddress("", s)
def generateIpAddress(self, ip, s):... | true |
5d27c2b8f91db7fc7ec14f49999b064bdbcc2da7 | sgwon96/codingTestPython | /codeUp100/61~80/64.py | UTF-8 | 151 | 2.984375 | 3 | [] | no_license | numbers = list(map(int,input().split()))
print(min(numbers))
# [기초-3항연산] 정수 3개 입력받아 가장 작은 값 출력하기(설명)(py) | true |
f6d15464b5bd58fed17429b0ff76209b4cf7b7a4 | spacetelescope/jupyterhub-deploy | /deployments/common/image/common-scripts/test-notebooks | UTF-8 | 4,420 | 2.8125 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | #! /usr/bin/env python
# -*-python-*-
"""Using the Python env/kernel specified by the first parameter, execute all
notebooks specified by subsequent positional parameters.
If --jobs <N> is specified run <N> notebooks in parallel.
Skip notebooks preceded by "#", as in #<notebookpath> with no spaces.
Run notebooks pr... | true |
731a14fbf67f816076eff163f201a77fc8535f8c | anarquias/Python-for-Pentesters-1 | /code/Lesson-12/file_stats.py | UTF-8 | 550 | 3.375 | 3 | [] | no_license | #!/usr/bin/python
import os
import argparse
import sys
import time
# Takes command line arguments as the filepath
fn = sys.argv[1]
# Extract the size of the file and print it out
size = os.path.getsize(fn)
print 'Size of the file is -> %d' %size
# Extract the creation time of the file and print it out... | true |