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 |
|---|---|---|---|---|---|---|---|---|---|---|
56831f4433417b4c2b0a47df5cbdeafa4194747d | sonic182/carrera | /carrera/communications/remote_actor.py | UTF-8 | 1,162 | 2.546875 | 3 | [] | no_license | """Remote actor representation."""
class RemoteActor(object):
"""Remote actor representation."""
def __init__(self, dispatcher, actor_name, _id, node):
self.id = _id
self.node = node
self.name = actor_name
self._dispatcher = dispatcher
def __del__(self):
"""Remove... | true |
dd23316fc830d810fecc001def51d8721b9742fb | itsolutionscorp/AutoStyle-Clustering | /assignments/python/series/src/67.py | UTF-8 | 366 | 3.640625 | 4 | [] | no_license | def slices(sequence, length):
seqlength = len(sequence)
if seqlength < length:
raise ValueError("Sequence length is less than slice length.")
if length < 1:
raise ValueError("Slice length is less than 1.")
return [[int(sequence[i + j]) for j in range(length)]
for i in ... | true |
5e9cbea370638102e650b2a862df381bf68ee0e1 | jchawthorne/StrainProc | /StrainProc/genproc.py | UTF-8 | 3,051 | 2.71875 | 3 | [] | no_license | #---------some simple codes to facilitate calculations, filtering---------
import numpy as np
from math import log10,floor
import obspy
import scipy
def roundsigfigs(x,n):
"""
:param x: value to round
:param n: number of significant figures to keep
"""
if isinstance(x,int) or isin... | true |
c984258791045475c803aa758fbf8a5ad3eb70f2 | lytcool369/python-basic | /02/19. comprehenstion.py | UTF-8 | 1,062 | 4.03125 | 4 | [] | no_license | results = []
for num in [1, 2, 3, 4, 5, 6, 7, 8]:
result = num * num
results.append(result)
print(results)
results = [num * num for num in [1, 2, 3, 4, 5, 6, 7, 8]]
print(results)
print('')
# 문자열 리스트에서 길이가 2 이하인 문자열만 새로운 리스트로 출력
strings = ['a', 'as', 'bat', 'car', 'dove', 'python']
results = [s for s in stri... | true |
f74f719c83cade85d7b9bb9973a118be0ecfd84b | 1505069266/python-study | /day1/arr.py | UTF-8 | 860 | 4.0625 | 4 | [] | no_license | motorcycles = ['朱晓乐', '郑璇', '张晓媛']
print(motorcycles)
motorcycles[0] = "朱晓飞"
print(motorcycles[-2])
# 添加一个到尾部
motorcycles.append("章小欢")
print(motorcycles)
# 插入一个到指定位置
motorcycles.insert(1, "郑楚凡")
print(motorcycles)
# 删除一个或多个元素 直接del 加那个元素
del motorcycles[-1]
print(motorcycles)
# pop()也是删除一个,不过是默认删除最后一个元素,如果... | true |
10dfbff27ac934c5b3f02c13f0dd4149f39238b5 | anlaganlag/Funcs | /罐子倒水ai算法.py | UTF-8 | 2,295 | 3.65625 | 4 | [] | no_license | from collections import defaultdict
#defaultdict真的牛逼
j1,j2,aim = 4,3,2
#j1,j2相當於罐子的最大容量,aim是目標容量
visited = defaultdict(lambda:False)
#初始化的defaultdict,且默認值爲false
def w(a1,a2):
#該遞歸函數會打印中間步驟
且會通過的True或者False表明是否可解
#且a1和a2是當前的水含量
if (a1==aim and a2==0) or (a1==0 and a2 == aim):
#用if語句檢查是否已經達到的目標,也就是base情況
pr... | true |
e2ef89453f8e06810b74f2db7340d81290878186 | yucefsourani/pygobject-demos | /welcome.py | UTF-8 | 1,445 | 2.5625 | 3 | [] | no_license | import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Pango
from common import Window
class Welcome(Gtk.EventBox):
def __init__(self, title_text, subtitle_text):
super().__init__()
self.title_label = Gtk.Label(title_text)
self.title_label.set_justify(Gtk.Justification... | true |
cec3ac18644d5678aa376fefa57d880ca7a3ff49 | nowaylv/py_traning | /构造函数.py | UTF-8 | 252 | 3 | 3 | [] | no_license | class Person:
def __init__(self):
print("我出生了,啦啦啦!")
p = Person()
#self training
print("\n--------------self training-----------------")
class build_demo:
def __init__(self):
print("i am building function") | true |
999bede23c47ede436d837198cfdf137f1549c39 | Bhavya2201/KisanSathi-Crop-Production-Predictor | /app.py | UTF-8 | 833 | 2.703125 | 3 | [] | no_license | import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
import gzip, pickletools
app = Flask(__name__)
#model = pickle.load(open('pickle_dump1.pkl', 'rb'))
with gzip.open('pickle_dump1.pkl', 'rb') as f:
p = pickle.Unpickler(f)
clf = p.load()
@app.route('/')
def home():... | true |
623075857db4b1f897e6442dc9ac212857d699cb | wide725/lihang_book_algorithm | /decision_tree/data_analysis.py | UTF-8 | 1,098 | 3.078125 | 3 | [] | no_license | # @Time : 2018/11/18 下午12:15
# @Author : Kaishun Zhang
# @File : data_analysis.py
# @Function:
import numpy as np
import matplotlib.pyplot as plt
from collections import Counter
import pandas as pd
# 数据格式已改,需要修改代码
frame = pd.read_csv('watermelon3.csv')
data = frame.values
data = data[data[:,7].argsort()]
data_less =... | true |
5ac96648f745904522af0d1e0e91428ba1196d7b | jomine1994/RootBuild | /code/size_classify_cell.py | UTF-8 | 882 | 2.5625 | 3 | [] | no_license | import sys
import os
import numpy as np
import math
def size_classify_cells(x,y,A,big,small):
# Categorised as big, small, tiny based on area
np_A=np.asarray(A)
sorted_index=np.argsort(np_A)
sorted_A=np.sort(np_A)
num_big=len(sorted_A[np.where(A>big)])
num_tiny=len(sorted_A[np.where(A<=small)])
... | true |
bf5be7393de5d8c8861eb9692bcd8bae4d9095af | Lisafiluz/calendar | /app/internal/statistics.py | UTF-8 | 17,399 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | import datetime
from typing import Dict, List, NamedTuple, Tuple, Union
from sqlalchemy import and_, func, or_
from sqlalchemy.orm import Session
from sqlalchemy.util import symbol
from app.database.models import Event, UserEvent
from app.routers.user import does_user_exist, get_users
SUCCESS_STATUS = True
ERROR_STA... | true |
7937758978de78e05db36caf9e88469c431f3bac | rgupta45/Tenserflow | /mnist dataset.py | UTF-8 | 4,307 | 2.734375 | 3 | [] | no_license | # coding: utf-8
from sklearn.neural_network import MLPClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report,confusion_matrix,precision_score,accuracy_score
impor... | true |
6d673f0ef283f44ec540c1aa98c65ff3f47453c6 | nujgnayuf/force-riscv | /tests/riscv/APIs/api_genFreePagesRange_01_force.py | UTF-8 | 6,113 | 2.609375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# Copyright (C) [2020] Futurewei Technologies, Inc.
#
# FORCE-RISCV is licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# THIS SOFTWARE IS PRO... | true |
1cd31a9d2dde863d0d2a7ee8aa507a6cf36db361 | LeandbSpace/leanDB | /leandbTable.py | UTF-8 | 3,870 | 2.875 | 3 | [] | no_license | """
Handle a table inside a database
Both table and database fundamentally a directory.
-> Create Table
-> Delete Table
-> Rename Table
"""
from leandbHelper import *
import os
import shutil
pathEndsWith = pathEndWith()
# fetch and assign leandb configuration data
# configData = starterConf()
de... | true |
bfe07ed8e9034d1eb2385986990dc0ee70faf8d6 | srandolph32195/Python | /randolph.py | UTF-8 | 17,311 | 3.671875 | 4 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
def dynamics_solve(f, D = 1, t_0 = 0.0, s_0 = 1, h = 0.1, N = 100, method = "Euler"):
""" Solves for dynamics of a given dynamical system
- User must specify dimension D of phase space.
- Includes Euler, RK2, RK4, that user can choose from usin... | true |
70967cc11e40fbf12de07e1116a269d730815f3a | svinge/CPALS-2 | /test4.py | UTF-8 | 649 | 3.21875 | 3 | [] | no_license | from matplotlib import pyplot as plt
class LineBuilder:
def __init__(self, line):
self.line = line
self.xs = list(line.get_xdata())
self.ys = list(line.get_ydata())
self.cid = line.figure.canvas.mpl_connect('button_press_event', self)
def __call__(self, event):
print('c... | true |
896ced2498ecddb0940439df1d3f0ea2167e677f | RoniKish/dokka_task_geo_api | /python_request_example.py | UTF-8 | 607 | 2.640625 | 3 | [] | no_license | import json
import requests
url = 'http://127.0.0.1:5000/api/'
files = {'upload_file': open('myCsvFile.csv', 'rb')}
def post_request_example():
with open("myCsvFile.csv", "rb") as csv_file:
file_dict = {"csv_file": csv_file}
response = requests.post(url + "getAddresses", files=file_dict)
... | true |
5429ec32446042bbab0695b004c0731eb71872e4 | mdreveton/Spectral-clustering-with-persistent-edges | /MarkovBlockModel_edge_view.py | UTF-8 | 3,770 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 24 10:26:09 2021
@author: mdreveto
"""
import numpy as np
import random as random
from tqdm import tqdm
def makeMSBM_temporal_edges( N, T, initialDistributionRateMatrix, TransitionRateMatrix, nodesLabels, tqdm_ = False ):
temporal_edges = dict... | true |
b66178e935d5922bced8d07b5b8803d1798dddb0 | rioyokotalab/polaris | /polaris/params.py | UTF-8 | 1,580 | 2.71875 | 3 | [
"MIT"
] | permissive | import numpy as np
from polaris.optimizers import bayesian_opt, rand, tpe
OPTIMIZERS = {
'bayesian_opt': bayesian_opt.calc_next_params,
'random': rand.calc_next_params,
'tpe': tpe.calc_next_params
}
class Bounds:
"""
A class to declare range of each hyperparameters.
For now, Polaris do not ... | true |
b4f9c5b90c08ebfeee5fe2fab7501f3a6220a166 | chenygdlut/Algorithm_practice | /重复子字符串.py | UTF-8 | 819 | 3.859375 | 4 | [] | no_license | '''
找两个字符串的所有公共子字符串。
eg:1234567890 0123634556
ans:0 123 345 56 6
'''
def find_substring(s1,s2):
ans=[]
m=len(s1)
n=len(s2)
temp=[[0 for _ in range(n)]for _ in range(m)]
visited=[[0 for _ in range(n)]for _ in range(m)]
for i in range(m):
for j in range(n):
if s1[i]==s2[j]:
... | true |
2e2621934d0bc31ecb4ef00ed2fc67289d48c26c | ChoLong02/PJ_Python_CNUWordCloud | /webcrawler/UniversityNews.py | UTF-8 | 5,265 | 2.765625 | 3 | [] | no_license | #############################################################
## [Developer] → cholong02 ##
## [DATE] → 2020-07-24 ##
#############################################################
## [Description] → ##
## keyword... | true |
7064a009a1a23c64153450c0e6e86134e8a8330a | DetegiCE/TFStudy | /tensors/tensors9.py | UTF-8 | 150 | 3.015625 | 3 | [] | no_license | import numpy as np
a = np.arange(6)
print("first \n",a)
a = np.reshape(a, [2,3])
print("second \n",a)
a = np.reshape(a, [3,2])
print("thrid \n",a)
| true |
3414b6086fbe77a53d25b96cec45638274ca8a0b | eadains/VolatilityAnalysis | /vol_calcs.py | UTF-8 | 14,053 | 3.359375 | 3 | [] | no_license | import pandas as pd
import sqlalchemy as sql
import numpy as np
import pyflux as pf
from scipy.optimize import least_squares
from collections import namedtuple
class HorizontalSkew:
def __init__(self, symbol):
"""
:param symbol: string containing OPTION ticker not index ticker. ie SPXW not SPX
... | true |
90d26c578cbd79c995884e5ed0793033a5e669d2 | MulengaKangwa/Hello-world | /71LocalandGlobalVariables.py | UTF-8 | 118 | 3.359375 | 3 | [] | no_license | x=123 # This is a global variable.
def display():
y=678 #This is a local method
print(y)
print (x)
display()
| true |
914e6f7c89aa39a56fd10010b11450b11fe0aa41 | skaurl/baekjoon-online-judge | /1769.py | UTF-8 | 240 | 3.3125 | 3 | [] | no_license | def asdf(n):
result = 0
for i in n:
result+=int(i)
return str(result)
n = input()
cnt = 0
if int(asdf(n))%3==0:
check="YES"
else:
check="NO"
while len(n)!=1:
n = asdf(n)
cnt+=1
print(cnt)
print(check) | true |
bde4effb973432711a9e06c1f0754565243e2624 | bestpower/Web_Data_Crawling_Test | /main.py | UTF-8 | 3,933 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | import pymysql
import datetime
import time
from bs4 import BeautifulSoup
import urllib.request
import urllib.request
import urllib.parse
import urllib.request, urllib.parse, http.cookiejar
# 初始化爬取数据存储数据库信息
host = '127.0.0.1' # 主机地址(本地)
user = 'root' # 用户名
password = 'asd' # 密码
port = 3306 # 接口
db = 'lottery' # 数据... | true |
174494deb2d748e4c02e9be5febb0876f6ddd068 | Aasthaengg/IBMdataset | /Python_codes/p02718/s688955827.py | UTF-8 | 276 | 2.953125 | 3 | [] | no_license | import numpy as np
p,q= input().split()
a,b =(int(p), int(q))
ans_list = input().split()
ans_list =np.array(ans_list).astype(float)
#print(ans_list)
ans_list=np.sort(ans_list)[::-1]
#print(ans_list)
if ans_list[b-1] >= sum(ans_list)/4/b:
print('Yes')
else:
print('No') | true |
109043941a816db3e0baf57063d6d9dd96b122f6 | nickest14/Leetcode-python | /python/medium/Solution_15.py | UTF-8 | 2,442 | 3.3125 | 3 | [] | no_license | # 15. 3Sum
from typing import List
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
ans = []
nums.sort()
for i, val in enumerate(nums):
if val > 0:
break
if i > 0 and val == nums[i - 1]:
continue
l,... | true |
a3ef63f193e7f3df9a2bfb7ead3ac5218bd1b98a | moogacs/monitor | /utils/file.py | UTF-8 | 1,244 | 2.875 | 3 | [
"MIT"
] | permissive |
import yaml
from utils.config import Config
class File:
@classmethod
def read_yaml_monitor_file(cls, filepath=None):
if not filepath:
filepath = Config.MONITERFILE
with open(filepath, 'r') as stream:
try:
return yaml.safe_load(stream)
excep... | true |
7e7c27d8d587230cd1e2e89e3c29294d71a9379b | neaccristina/python | /finalasig.py | UTF-8 | 785 | 3.59375 | 4 | [] | no_license | import re,os
def countword(filename):
try:
file=open(filename,'r')
list_words=[]
lines=file.readlines()
for l in lines:
list_words.extend(l.split(" "))
mylist=[re.sub(r'[^A-Za-z0-9]+', '', x) for x in list_words]#[^A-Za-z0-9]+ matches a string of characters that are not leters or numbers
#'\... | true |
a07240a17497dbf2b891da0bef022fd221bbefe3 | xjhuang1993/PythonExercise | /leetcode/053.Maximum Subarray/common.py | UTF-8 | 260 | 3.484375 | 3 | [] | no_license | """
Time Limit Exceeded
"""
def func(nums):
sums = []
for i in range(len(nums)):
for j in range(i, len(nums)):
sums.append(sum(nums[i:j + 1]))
return max(sums)
if __name__ == "__main__":
nums = [1]
print(func(nums))
| true |
45982c69801b379af3d48cbaefc3e1dacb2c6d96 | bwhite/hadoop_clustering | /hadoop_clustering/nn_l1.py | UTF-8 | 759 | 3.1875 | 3 | [] | no_license | import numpy as np
def nn(feature, clusters):
"""Find L1 nearest neighbor
>>> nn(np.array([1]), np.array([[1], [2]]))
(0, 0.0)
>>> nn(np.array([1.]), np.array([[2.], [1.]]))
(1, 0.0)
>>> nn(np.array([2]), np.array([[1], [2]]))
(1, 0.0)
>>> nn(np.array([[1]]), np.array([[1], [2]]))
... | true |
bb01a3704eb710c8c4ddc44f66b6b0983bd97a8b | Pedro0901/python3-curso-em-video | /Python 3 - Mundo 2/Desafio das Aulas - Mundo 2/Desafio42-AnalisandoTriangulosV2.py | UTF-8 | 872 | 4.59375 | 5 | [
"MIT"
] | permissive | '''
Exercício Python 42: Refaça o DESAFIO 35 dos triângulos, acrescentando o recurso de mostrar que tipo de triângulo será formado:
– EQUILÁTERO: todos os lados iguais
– ISÓSCELES: dois lados iguais, um diferente
– ESCALENO: todos os lados diferentes
'''
A = int(input('Informe o comprimento da primeira reta: '))
B =... | true |
bdc1b8a8a4ae29a1fb2f8a11e2f179f78479cf20 | japankid-code/projects | /Python/Udacity/lesson3/slicing.py | UTF-8 | 381 | 3.734375 | 4 | [] | no_license | # slicing never returns IndexError, a slice that tries to extract chars off the end
# of a string will instead just return what it can, even if that ends up being nothing.
word = "definitely"
length = len(word)
# print(word[:length])
# print(word[:length - 2])
# print(word[length - 8:])
# print(word[length -8:length ... | true |
abc488d59b32391e4bd95372588420c8be5d62ff | lcfyi/advent-of-code | /day3/part1/sol.py | UTF-8 | 3,282 | 3.734375 | 4 | [] | no_license | from math import inf
# Manhatten distance doesn't matter if x,y or y,x
def get_distance(crossing):
return abs(crossing[0]) + abs(crossing[1])
# Path is a tuple from the starting to end
def get_least_distance(place, path, orthogo_paths):
least_distance = inf
for num in range(path[0], path[1] + 1):
... | true |
c386b861e7dba35321dec78caafbf6cf7fe37f58 | andrenasturas/hausse | /tests/plugins/test_relations.py | UTF-8 | 612 | 2.546875 | 3 | [
"MIT"
] | permissive | from pathlib import PurePath
from hausse.lib import Element, Project
from hausse.plugins import Collection, Relations
def test_relations_default():
e1 = Element("e1", c2=["e3", "e4"])
e2 = Element("e2", c2="e3")
e3 = Element("e3")
e4 = Element("e4")
c1 = Collection("c1", [e1, e2])
c2 = Coll... | true |
4dd6edd0bbc6164608b9ab68298d5fe68893cacb | jk16/Udacity-Design-of-Computer-Programs | /Lesson 2: Zebra Problem/cryptarithmetic.py | UTF-8 | 860 | 4 | 4 | [] | no_license | import string, re
import itertools
def solve(formula):
"""
Given formula of the form: 'ODD + ODD == EVEN', fill in digits
to solve it.
output: digit-filled string or None
"""
for f in fill_in(formula):
if valid(f):
print (f)
def fill_in(formula):
"Generate all possible... | true |
615cad41defbc74c38d050a8633e3f5847739116 | AceCentre/RelayKeys | /resources/viewComPorts.py | UTF-8 | 717 | 2.609375 | 3 | [
"MIT"
] | permissive | import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
for p in serial.tools.list_ports.comports():
print("name:", p.name, "desc:", p.description, "hwid:", p.hwid, "vid:", p.vid, "pid:", p.pid, "ser:", p.serial_number,"\r")
nrfVID = '239A'
nrfPIDs = ['8029', '8051']
for p in serial.tool... | true |
79abf9771d572774969ca4bd5f72974a4cab1c39 | yagoAribeiro/CorruptedSoulsProject | /text_builder.py | UTF-8 | 1,108 | 3.09375 | 3 | [] | no_license | class Text():
def __init__(self) -> None:
pass
def animation(self) -> None:
pass
class item_text(Text):
def __init__(self, font, text, posx, posy, size, color):
self.font = font
self.size = size
self.text_object = text
self.pos_x = p... | true |
5e7443da2651bcc721fa7371a1abdac498cdff65 | logan-ankenbrandt/LeetCode | /LongestSubstringNoRepeats.py | UTF-8 | 5,488 | 4.25 | 4 | [] | no_license | def lengthOfLongestSubstring(self, s: str) -> int:
"""
1. Goal
- Find the longest substring without repeating characters
and return its length
2. Examples
- Example #1
a. Input
i. s = "abcabcbb"
b. Output
... | true |
2e5d79eb7588539d37f6a9aa4d9dbaa31b9ba043 | DavidLazarescu/Python | /Challanges/ReverseInteger/main.py | UTF-8 | 525 | 4.0625 | 4 | [] | no_license | """
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go
outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
"""
def reverse_int(n):
result = 0
ne... | true |
8344f5858c25fb9100b58ca7e467a9ea2e676878 | morganjwilliams/exploratory-geochemistry | /src/compositions.py | UTF-8 | 6,684 | 2.828125 | 3 | [
"MIT"
] | permissive | import pandas as pd
import numpy as np
from sklearn.base import TransformerMixin
import scipy
def close(X: np.ndarray):
if X.ndim == 2:
return np.divide(X, np.sum(X, axis=1)[:, np.newaxis])
else:
return np.divide(X, np.sum(X, axis=0))
def nancov(X, method='replace'):
"""
Generates a ... | true |
b0b8ae6cfc887563ced48394bed4f4909694574f | annafeferman/colloquium_2 | /13.py | UTF-8 | 506 | 4.34375 | 4 | [] | no_license | """Створіть масив з 15 цілочисельних елементів і визначте серед них
мінімальне значення.
Anna Feferman"""
from random import randint # імпортуємо рандом
array = []
for i in range(15):
array.append(randint(-20, 20)) # заповнюємо список рандомом
print(f'{array}\n'
f'Мінімальне значення: {min(array... | true |
b276d162d4039ccacc9488248dae05460a3c2258 | KGC9175/codeup_Python_100 | /89.py | UTF-8 | 89 | 2.75 | 3 | [] | no_license | a, r, n = map(int, input().split())
m = a
for _ in range(1, n):
m = m * r
print(m) | true |
1d14825cba4be88b545e7471a292fb1410bd3764 | Aasthaengg/IBMdataset | /Python_codes/p02850/s040362351.py | UTF-8 | 676 | 2.890625 | 3 | [] | no_license | from collections import deque
n = int(input())
g = [[] for _ in range(n)]
ab = []
for _ in range(n-1):
a, b = map(int, input().split())
a, b = a - 1, b - 1
g[a].append(b)
g[b].append(a)
ab.append((a, b))
q = deque([0])
chk = [False] * n
chk[0] = True
res = [0] * n
par = [0] * n
while q:
x = ... | true |
9b284064a3210a34ff5c87624163d4045fa882d7 | hamiltonhart/swd_engineering | /project_drives/tests.py | UTF-8 | 3,654 | 2.578125 | 3 | [] | no_license | from django.test import TestCase
# from .models import FeatureProjectDrive, SeriesProjectDrive
# from rental_projects.models import Feature, Series
# from harddrives.models import RentalDrive
# class ProjectDriveTests(TestCase):
# def setUp(self):
# # Project setup
# self.feature = Feature(
# ... | true |
bf3e42cecd6a828125234c3fbebbdcf09c24f311 | MrVishnu78/TextUtils-learn | /textutils/arsum.py | UTF-8 | 249 | 2.90625 | 3 | [] | no_license | #created by vishnu
from django.http import HttpResponse
# Complete the diagonalDifference function below.
def diagonalDifference(request):
sum=0
f1= input("Enter number 1")
f2= input("Enter number 2")
sum=f1-f2
return HttpResponse(sum)
| true |
f623efed52c75fb294eb904ec85b50a33846c065 | ukaserge/python-lesson | /01 if for while/04_while_loop.py | UTF-8 | 157 | 3.234375 | 3 | [] | no_license | # for loop: a аас b хүртэлх бүх тоог хэвлэх
a, b = input().split()
c = max(a, b)
d = min(a, b)
while d <= c:
print(d)
d += 1
| true |
37a20fb2e638c053e434858dc3c762378e7d5196 | Vdiungaro/Algoritmos-Inspirados-pela-Natureza | /ACO&PSO/Functions.py | UTF-8 | 8,431 | 2.875 | 3 | [] | no_license | # Vitor Diungaros - Funções para o PSO
import statistics
import numpy as np
import matplotlib.patheffects as pe
import matplotlib.pylab as pl
import matplotlib.gridspec as gridspec
from matplotlib import pyplot as plt
from scipy.interpolate import interp1d
plt.style.use('ggplot')
# **********************... | true |
5e28a89bf2333e3298be855cc4acee55def7b66f | PARKJUHONG123/turbo-doodle | /BOJ/bitmask.py | UTF-8 | 718 | 3.40625 | 3 | [] | no_license | import sys
A = list(map(int, sys.stdin.readline().strip()))
B = list(map(int, sys.stdin.readline().strip()))
length = len(A)
and_arr, or_arr, xor_arr = [0 for _ in range(length)], [0 for _ in range(length)], [0 for _ in range(length)]
not_A_arr, not_B_arr = [0 for _ in range(length)], [0 for _ in range(length)]
for i ... | true |
cc254a6241d840806b1639690e913e4c61b6e9c1 | programmingHumour/interviewPractice | /pythonPractice/LinkedListNthNode.py | UTF-8 | 1,203 | 4.1875 | 4 | [] | no_license | class SinglyLinkedList():
def __init__(self,value):
#ste the vale to the Node
self.value = value
#set the next Node
self.next_Node = None
#create two pointers then set the pointer at a distance of n-1 blocks from pointer1
#Then move along the both pointers until the pointer2 reaches... | true |
1f0de3dabaf18e372503b74b6eac33b6fa338a98 | lenskit/lkpy | /lenskit/batch/_train.py | UTF-8 | 2,335 | 2.515625 | 3 | [
"MIT"
] | permissive | import logging
from lenskit.sharing import persist, persist_binpickle
from lenskit.util.parallel import run_sp
from lenskit.util import Stopwatch
_log = logging.getLogger(__name__)
def _train_and_save(algo, file, ratings, kwargs):
"Worker for subprocess model training"
_log.info('training %s on %d ratings',... | true |
963c0d794afd129fa8821803c0c744806f2bdee7 | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Python/dutch-national-flag-problem-4.py | UTF-8 | 169 | 2.578125 | 3 | [] | no_license | def dutch_flag_sort3(items, order=colours_in_order):
'counts each colour to construct flag'
return sum([[colour] * items.count(colour) for colour in order], [])
| true |
7cea3e1d385e50db4903b08ea90573a2e5623ec8 | UknowYunmo/Python-Algorithm | /2020-10-04 베르트랑 공준(+pass와 continue 차이, sqrt() 함수).py | UTF-8 | 2,343 | 3.96875 | 4 | [] | no_license | """
1. 베르트랑 공준은 임의의 자연수 n에 대하여, n보다 크고, 2n보다 작거나 같은 소수는 적어도 하나 존재한다는 내용을 담고 있다.
이 명제는 조제프 베르트랑이 1845년에 추측했고, 파프누티 체비쇼프가 1850년에 증명했다.
예를 들어, 10보다 크고, 20보다 작거나 같은 소수는 4개가 있다.
(11, 13, 17, 19) 또, 14보다 크고, 28보다 작거나 같은 소수는 3개가 있다. (17,19, 23)
n이 주어졌을 때, n보다 크고, 2n보다 작거나 같은 소수의 개수를 구하는 프로그램을 작성하시오.
입력은 여러 개의 테스트 케이스로 이루어져 있다... | true |
8fb3904b336dbbe275ab069bde1faed86a3b84a3 | scjudd/Yakr | /Yakr/Networking.py | UTF-8 | 1,684 | 2.75 | 3 | [] | no_license | import gevent
from gevent import socket, queue
from gevent.ssl import wrap_socket
from Logger import logger
'''
https://gist.github.com/676306
'''
class Tcp(object):
'''Handles TCP connections, `timeout` is in secs.'''
def __init__(self, host, port, timeout=300):
self._ibuffer = ''
self._o... | true |
329963825fcdc5d4076b7644903272fd9e89780f | loganbek/rotki | /rotkehlchen/data/importer.py | UTF-8 | 7,164 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | import csv
from pathlib import Path
from typing import List
from rotkehlchen.assets.asset import Asset
from rotkehlchen.constants.assets import A_USD
from rotkehlchen.constants.misc import ZERO
from rotkehlchen.db.dbhandler import DBHandler
from rotkehlchen.errors import DeserializationError, UnknownAsset
from rotkehl... | true |
c06e676609489425c5f00e15778a2acc831e37cf | Dvshah13/Machine-and-Deep-Learning-Code-Notes | /data_munging_basics-categorical.py | UTF-8 | 1,701 | 4.1875 | 4 | [] | no_license | ## You'll be working often with categorical data. A plus point is the values are Booleans, they can be seen as the presence or absence of a feature or on the other side the probability of a feature having an exhibit (has displayed, has not displayed). Since many ML algos don't allow the input to be categorical, boole... | true |
32ad7e7856d4163c68d5977ab420e1577cc63be5 | pbellino/CinePy | /modules/point_kinetics/io_acritico.py | UTF-8 | 1,769 | 3.390625 | 3 | [] | no_license | #! /usr/bin/env python3
import numpy as np
def read_acritico(filename):
'''
Función para leer los archivoss grabados por el programa "contador_pulsos"
Cada dato es la cantidad de pulsos registrado en un dado dt.
El formato en que está grabado es entero sin signo de 32 bits con
codificación big-e... | true |
157eedd526559c22323ef2d9fc4c2161a7fbcaf5 | nikhilkumawat1991/python_example | /firstoccurence.py | UTF-8 | 1,095 | 4.28125 | 4 | [] | no_license | #First Recurring Character in a string
st="ABCAB"
def first_recurring_character(st):
for i in st:
char = i
print(f"current character is {char}")
next_value = st.index(i)+1
while next_value < len(st):
print(f"next value is: {st[next_value]}")
if char == st[... | true |
292ea342aaf9b23c7d8d21bc62f05e8cd57a8ec0 | oliver-johnston/advent-of-code-2020 | /22.1.py | UTF-8 | 814 | 3.625 | 4 | [] | no_license | from queue import Queue
def play_round(deck1, deck2):
card1 = deck1.get()
card2 = deck2.get()
if card1 > card2:
deck1.put(card1)
deck1.put(card2)
else:
deck2.put(card2)
deck2.put(card1)
def get_deck(data):
q = Queue()
for x in (int(x) for x in data.splitlines... | true |
866116b3c41c1defc970a90f4346e1fc07b373cc | zhjngli/coding_puzzles | /20170908-war/war.py | UTF-8 | 4,804 | 3.328125 | 3 | [] | no_license | # https://fivethirtyeight.com/features/riddler-nation-goes-to-war/
# based on http://www.bicyclecards.com/how-to-play/war/
from collections import deque
import random
from datetime import datetime
class OutOfCardsError(Exception):
def __init__(self, name):
self.name = name
def __str__(self):
r... | true |
adf7b35e7f91ed7065ba2d063552c71cfdfbaed6 | GoogleCloudPlatform/python-docs-samples | /vision/snippets/detect/beta_snippets.py | UTF-8 | 15,765 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | true |
afe3b8652561f52fc268bd6c1ff25849fe113282 | RChloe/Web-Design-Challenge | /csv-to-html.py | UTF-8 | 339 | 2.9375 | 3 | [] | no_license | # Dependencies
import pandas as pd
# Store filepath in a variable
file_one = "Resources/cities.csv"
# Read our Data file with the pandas library
# Not every CSV requires an encoding, but be aware this can come up
file_one_df = pd.read_csv(file_one)
file_one_html = file_one_df.to_html("Resources/cities.html", index=F... | true |
8d5e8eb7e951821f0e438b92a16a92753cd0885a | topia47/circleci-orbs | /terraform/cmp.py | UTF-8 | 163 | 2.59375 | 3 | [
"MIT"
] | permissive | import sys
with open(sys.argv[1]) as f:
first = f.read()
with open(sys.argv[2]) as f:
second = f.read()
exit(0 if first.strip() == second.strip() else 1)
| true |
988fe4bbbc04db9189ac45e4fb41f0b5359fa949 | CyberPassionate/SkillSantaPython | /largestnumberinlist.py | UTF-8 | 102 | 3.390625 | 3 | [] | no_license | numlist = [20, 50, 10, 100, 80, 56, 201]
print("The Largest Number in the list is: ", max(numlist)) | true |
3073b672baf84a10f65ae788ef55c0161435184a | ethanjli/phylline | /phylline/pipelines.py | UTF-8 | 11,387 | 2.84375 | 3 | [
"MIT"
] | permissive | """Classes for building pipelines of layered links."""
# Builtins
# Packages
from phylline.links.links import GenericLinkAbove, GenericLinkBelow
from phylline.pipes import AutomaticPipe, ManualPipe
from phylline.processors import proceed, wait
from phylline.util.interfaces import SetterProperty
from phylline.util.it... | true |
d6cc07e878218d0ff61921e23103d3131b360512 | team1306/OMAR | /src/formatting/bintonum.py | UTF-8 | 5,886 | 3.375 | 3 | [] | no_license | import os
f = open("report.dat", 'r') # open report in binary (filled in/not filled in)
lines = f.readlines() # read all lines
f.close() # close file
# the first line is always the list of tags or, in excel, the column headers
tags = lines[0].rstrip('\n').split(';') # strip the first tag line of newline characters and... | true |
3caa7d6e40498448345c00a9e194b97560a87234 | Darin-Hamouda/Python-Course | /Week 2/Practice2-B.py | UTF-8 | 1,299 | 3.640625 | 4 | [] | no_license |
# coding: utf-8
# In[13]:
print(" welcome to our Money Converter App, Please enter the amount of money you want to convert")
print("and the currencies you want to convert, as the following:")
print("write JD for Jordanian Dinar,")
print("write TL for Turkish lira,")
print("write US for Dollar")
print("-------------... | true |
381f1f59f4e2a734c10c0318919c694d5ce6e4c0 | subhodeep/hackerrank | /Python/Numpy/Easy/Np Shape Reshape/reshape.py | UTF-8 | 100 | 2.75 | 3 | [
"MIT"
] | permissive | import numpy
l = list(map(int,input().strip().split()))
arr = numpy.array(l).reshape(3,3)
print(arr) | true |
49af79cbbdff2bcbefae9955893a7b650bb1c7fd | renaissanceplanning/Miami-TOD-PMT | /PMT_tools/download/census.py | UTF-8 | 13,931 | 2.53125 | 3 | [] | no_license | """
The `census` modules provides several helper methods to acquire and aggregate LODES data
for use in the TOC tool.
"""
import os
import re
from datetime import datetime
import numpy as np
import pandas as pd
from six import string_types
from PMT_tools.download.helper import download_file_from_url
from PMT_tools.co... | true |
2d24e3fca86da0131a628b9f55643f99428657e0 | ohmygaugh-crypto/geojson-quirks | /tests/test_tweaks.py | UTF-8 | 1,935 | 2.75 | 3 | [
"MIT"
] | permissive | import pytest
from geojson_quirks import tweak_feature
@pytest.fixture
def feature():
return {
'id': 1,
'type': "Feature",
'properties': {
'fid': 9001,
'nest': {
'a': 1,
'b': 2}},
'geometry': {
'type': "Point",
... | true |
0ad1a9f52336dd3f8c3bb82350ff2a46b260c239 | yoshikipom/to_light_blue | /051.py | UTF-8 | 896 | 2.640625 | 3 | [] | no_license | # https://atcoder.jp/contests/joi2014yo/tasks/joi2014yo_d
N = int(input())
S = input()
# dp[day][person having key]
dp = [[0 for i in range(1 << 3)] for _ in range(N+1)]
dp[0][1] = 1
JOI = ['J', 'O', 'I']
for day in range(N):
for bit in range(1 << 3):
for next_bit in range(1 << 3):
ok = Tru... | true |
2c1676c68043eb8d842ceeeae605a2c4477c7276 | LavishKothari/MyAllCodes---Lavish | /codechef/MAY16/FORESTGA.py | UTF-8 | 719 | 2.828125 | 3 | [] | no_license | MAX_T=1000000000000000000L
MAX=100001
n=0
w=0
l=0
h=[]
r=[]
def findNew(t):
maxredeemption=0
for i in range(0,n):
newh=h[i]+r[i]*t
if newh>=l:
maxredeemption=maxredeemption+newh
if maxredeemption>w:
return maxredeemption
return maxredeemption;
def findAnswer():
startt=0
endt=MAX_T
if findNew(0)>=w:
... | true |
c99097f0885e4e6be0d453191544e7eb9e3c594f | Som-Debnath/amazon-review | /source_data_download.py | UTF-8 | 630 | 2.921875 | 3 | [] | no_license | #####################################################################
##
## Name : source_data_download.py
## Desc: Downlading source data file
##
#####################################################################
import sys
import os
import urllib.request
import wget
def file_download(url,dest_file_with_path... | true |
cc5b7ba6af51183b7a116056f2b6cb676943fbf7 | Hu-chi/Retrieval-Based-Chatbot | /src/dataset/LCCC_dataset.py | UTF-8 | 2,069 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | import json
import pickle
from tqdm import tqdm
from dataset.base_dataset import PairUtils, PairDataset
class LCCCPairUtils(PairUtils):
def __init__(self, txt_path, tokenizer):
super(LCCCPairUtils, self).__init__(txt_path, tokenizer)
def read_raw_file(self):
with open(self.txt_path, "r", en... | true |
31b23002c68e96e2e90c630710ed4842ed34edea | Aasthaengg/IBMdataset | /Python_codes/p03821/s922799306.py | UTF-8 | 210 | 2.890625 | 3 | [] | no_license | n=int(input())
ab = []
for _ in range(n):
a, b = (int(x) for x in input().split())
ab.append([a, b])
ans = 0
for i in range(n-1,-1,-1):
ans += (ab[i][1]-(ab[i][0]+ans)%ab[i][1])%ab[i][1]
print(ans) | true |
2e5774b5d3b5bdd21adbf0f2934ab2a5f3d85b6e | ophintor/AoC2020 | /day11/part1.py | UTF-8 | 1,424 | 3.546875 | 4 | [] | no_license | import sys
def show_data(data):
for line in data:
print(''.join(line))
print("")
def get_occupied_seats(data,i,j):
occupied_seats = 0
for x in range(i-1, i+2):
for y in range(j-1, j+2):
if ((x != i) or (y != j)) and (x >= 0) and (y >= 0) and (x < len(data)) and (y < len(d... | true |
7bec4da60563c855f23669d95dc7d225934ff9ff | aeternallife/Examples-of-Python-Spiders | /phone_scrapy.py | UTF-8 | 1,947 | 3.078125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# 本爬虫利用selenium的PhantomJ或Chromedriver爬取手机号码信息
# 导入模块
import datetime
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.common.exceptions import *
# 开始时间
d1 = datetime.datetime.now()
# 配置浏览器加载项
service_args=[]
service_args.append('--load-images=no') ##关闭... | true |
4c00916c136ba2fcde25ff24551d42807691bc62 | Hamsik2rang/Python_Study | /Mini_programming_project/Pong/main.py | UTF-8 | 1,242 | 2.875 | 3 | [] | no_license | from turtle import Turtle, Screen
import time
from player import Player
from enemy import Enemy
from referee import Referee
from collider import Collider
from ball import Ball
FRAME = 0.1
def draw_line():
line = Turtle(shape="square")
line.speed("fastest")
line.penup()
line.pencolor("white")
lin... | true |
042581e4c58ca891216c82e52ba353959501dd9e | kissmyuzi/keydra | /src/keydra/clients/aws/kinesisfirehose.py | UTF-8 | 5,199 | 2.65625 | 3 | [
"MIT"
] | permissive | import boto3
import boto3.session
from botocore.exceptions import ClientError
class UpdateSecretException(Exception):
pass
class FirehoseClient(object):
def __init__(self, session=None, region_name=None, **kwargs):
if not session:
session = boto3.session.Session()
self._client ... | true |
e55d8df678f411d81e070f910aa33886943f9e73 | ajyoon/drone | /chance/rand.py | UTF-8 | 7,889 | 3.8125 | 4 | [] | no_license | #!/usr/bin/env python
from __future__ import division
import copy
import random
# from . import nodes
class Weight:
def __init__(self, outcome, weight):
self.x = outcome
self.y = weight
def weighted_rand(input_weights, run_type='interpolated', do_round=False):
"""
Ge... | true |
164e586a8cce64d5226ebb01288ebc83cf5e07ed | michaelpatrickpurcell/balanced-nontransitive-dice | /exhaustive_search.py | UTF-8 | 6,070 | 2.703125 | 3 | [
"MIT"
] | permissive | import numpy as np
from itertools import combinations
import numba
from numba.core import types
from numba.typed import Dict
from utils import compare_dice
int_array = types.int64[:]
int_2d_array = types.int64[:,:]
from scipy.special import binom
@numba.njit
def compare_dice2(first, second):
return np.sum(np.ex... | true |
934a732aa1d1da73dcc6ed2a20a834052b3a9d30 | jgat/tutorials | /csse1001/solutions/week10.py | UTF-8 | 5,267 | 3.3125 | 3 | [] | no_license | from Tkinter import *
class SettingsFrame(Frame):
"""A frame which allows users to change settings of the application
Settings to change include line width (thickness), and whether or not a
line preview is shown.
"""
def __init__(self, parent):
"""Initialise the widget, with its subwidget... | true |
3f147a0a76bd9c76cccf83303c2d7fada22eefe3 | asarolia/ShipAI | /opencv-lambda/service.py | UTF-8 | 541 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from obj_dim import *
def lambda_handler(event, context):
# url = "http://answers.opencv.org/upfiles/logo_2.png"
url = event['url']
ppm = pixelsPerMetric_finder()
print(event)
h,w = obj_dimensions(ppm, url)
print("height is:")
print(h)
return str(" object has he... | true |
8239a81a9acad070926ce011911c63133ac979ec | mohitsaroha03/The-Py-Algorithms | /src/5.1Trees/build postorderinordertoBST.py | UTF-8 | 2,070 | 4.0625 | 4 | [
"MIT"
] | permissive | # Link: https://www.geeksforgeeks.org/construct-a-binary-tree-from-postorder-and-inorder/
# IsDone: 1
# Python3 program to construct tree using
# inorder and postorder traversals
# Helper function that allocates
# a new node
class newNode:
def __init__(self, data):
self.data = data
self.left = self.right =... | true |
dfc147027c251fa749fba7726e4a72fee303a7f4 | imyizhang/mridataPy | /mridatapy/data/subsample.py | UTF-8 | 13,712 | 3.109375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import abc
import contextlib
import math
from typing import Optional, Sequence, Tuple, Union
import numpy as np
import numba as nb
@contextlib.contextmanager
def _temp_seed(
random_generator: np.random.RandomState,
seed: Optional[Union[int, Sequence[int]]] = Non... | true |
b3b2b0e1bac6815fe8ccc88400315b390ebe7290 | forrestjan/Labos-MCT-19-20 | /2019-prog-labooefeningen-forrestjan/week10/oefening2/model/Voertuig.py | UTF-8 | 1,484 | 3.03125 | 3 | [] | no_license | class Voertuig():
_aantal_voertuigen = 0
def __init__(self, parid, parmerk, parbouwjaar, parkmstand):
self._id = parid
self._merk = parmerk
self._bouwjaar = parbouwjaar
self.kmstand = parkmstand
self.reisbestemming = ""
Voertuig._aantal_voertuigen += 1
@prop... | true |
d74abf5238786ee79d789c007c89b5fb3916e385 | volpatto/barril | /src/barril/units/exceptions.py | UTF-8 | 797 | 3.015625 | 3 | [
"MIT"
] | permissive | class QuantityValidationError(ValueError):
def __init__(self, message, caption, value, operator, limit_value):
"""
QuantityValidationError inherits from ValueError
with helpers attributes (message, caption, value, operator, limit_value)
:param str message:
the ful... | true |
17820cb37420680b7ad8ed6bfb544c9a072ac350 | raulng9/TestGrader | /data_retriever.py | UTF-8 | 555 | 3.5625 | 4 | [] | no_license | class Student:
def __init__(self, name, listOfMarks):
self.name = name
self.listOfMarks = listOfMarks
def retrieve_students():
f = open("students.txt", "r")
listOfStudents = []
for student in f:
studentData = student.split()
listOfMarksForStudent = []
name = studentData[0... | true |
29f5b58a856f50349aebc802187f3f4d07957df7 | jaber-tech/jab-public | /cal-pal.py | UTF-8 | 265 | 2.921875 | 3 | [] | no_license | # This program is simple calculator for VAT in Python
num=0
numvat
i=""
num=input ("enter the price before VAT: ")
numvat = num + (num*0.05)
print ("Total price with VAT is : " + str(numvat))
print ("desgined by jab-public")
print ("updated by Jaber developer")
| true |
7c333db2a180353702845501c1cd2faa0c30dad5 | priyanka-111-droid/100daysofcode | /Day012/12-5.py | UTF-8 | 1,984 | 4.71875 | 5 | [] | no_license | ###<<<PROJECT>>>###
'''
Number Guessing Game Objectives:
1.Include an ASCII art logo from
2.Allow the player to submit a guess for a number between 1 and 100.
3.Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer.
4.If they got the answer correct, show the actual a... | true |
8bf0c5940270540870c05ee49640167d4b1976b0 | tinhnguyen20/4to0solver | /hw1.py | UTF-8 | 1,726 | 3.265625 | 3 | [] | no_license | from enum import Enum
class Primitive(Enum):
DRAW = 'D'
WIN = 'W'
UNKNOWN = 'U'
LOSE = 'L'
TIE = 'T'
def init_pos(n=4):
"""
Returns the initial position
"""
return n
def primitive(pos):
if pos == 0:
return Primitive.LOSE
return Primitive.UNKNOWN
def generate_moves(pos):
if pos ==... | true |
2c23e888b4786ae05024b5a405e1d453e768ff63 | phejimlin/emotion_intensity_survey | /db/feedback.py | UTF-8 | 2,807 | 2.515625 | 3 | [
"MIT"
] | permissive | import json
import decimal
from datetime import datetime
from db import dynamodb
from botocore.exceptions import ClientError
from botocore.exceptions import ClientError
from boto3.dynamodb.conditions import Key
table = dynamodb.Table('feedback')
# Helper class to convert a DynamoDB item to JSON.
class DecimalEncoder(j... | true |
fb3dd273b325237fbf94bb27ba6b7dd7eb6faa00 | seungjulee/brush-up-algo-ds | /hackerrank/recursion/7.SubsetOfASet.py | UTF-8 | 206 | 3.1875 | 3 | [] | no_license | def powerset(lst):
res = [[]]
for x in lst:
newset = [subset + [x] for subset in res]
res.extend(newset)
return res
def main():
lst = [1,2,3]
print powerset(lst)
main() | true |
638b01469187171dc06689d2c278d0f7b0e804ba | Arain-sh/RBNN | /BPPGenerator.py | UTF-8 | 1,691 | 3.03125 | 3 | [] | no_license | import numpy as np
import random
class BPPGenerator():
# Input: number of items N,
# size of optimal bin(cube/square) Bin = [L, W, H] / [L, W] ( cube / square ),
#. batch_size
# Output: batch_items, batch_rotation
def __init__(self, N, Bin, batch_size, random_seed = None):
self.N = N
self.Bin = Bin
... | true |
f1cd503c9456e2e65aa0ac67854af0e5c360d616 | obabawale/my_python_codes | /removeDuplicatesInList.py | UTF-8 | 876 | 4.625 | 5 | [] | no_license | """
Write a function remove_duplicates that takes in a list and removes elements of the list that are the same.
For example: remove_duplicates([1, 1, 2, 2]) should return [1, 2].
Don't remove every occurrence, since you need to keep a single occurrence of a n
umber.
The order in which you prese... | true |
243cb70fd3116643e40492478fcb83b7583fdec8 | EnyaKitakagaya/Forecast_gadget | /ltika.py | UTF-8 | 488 | 2.65625 | 3 | [] | no_license | #!/use/bin/python3
# -*- coding: utf-8 -*-
# モジュールのロード
import time
import RPi.GPIO as GPIO
# GPIOの設定
GPIO.setmode(GPIO.BCM)
# 出力LEDのGPIOピン番号
GPIO_LED = 17
# GPIOのピン番号を出力に設定
GPIO.setup(GPIO_LED, GPIO.OUT)
try:
while(1):
GPIO.output(GPIO_LED, GPIO.HIGH)
time.sleep(1)
GPIO.output(GPIO_LED... | true |
af45e6e608135b6830460b4a766a24ed5e519788 | adhidharmawan/Python-Projects-Protek | /praktikum 6/latihan no 3.py | UTF-8 | 349 | 4.25 | 4 | [] | no_license | def factorial(n):
facto=1
while(n>0):
facto=facto * n
n = n - 1
return facto
def kombinasi(p,q):
kombinasi = factorial(p) / (factorial(q) * factorial(p-q))
print(kombinasi)
def permutasi(s,t):
permutasi = factorial(s) / factorial(s-t)
print(permutasi)
komb... | true |
8cf9befc70eac6445fbe4e345dacacab703baa73 | AK-1121/code_extraction | /python/python_17478.py | UTF-8 | 145 | 3.546875 | 4 | [] | no_license | # Create Variables Inside Program
name = raw_input("Name the variable:")
value = raw_input("And the value?")
exec("{} = {}".format(name, value))
| true |