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 |
|---|---|---|---|---|---|---|---|---|---|---|
fb1673787db21697b391fe6535ae5bcd784a701a | achvanov7/linear_algebra_project | /src/graph_algorithms/expander.py | UTF-8 | 1,581 | 2.578125 | 3 | [] | no_license | from src.utils import *
from src.tridiagonal import *
from src.qr_algorithms import *
def build_nxn(n):
A = Matrix.zero(n * n, n * n)
def num(i, j):
i %= n
j %= n
return i + j * n
for x in range(n):
for y in range(n):
v = num(x, y)
for i, j in [
... | true |
303f29da9f8c0ff381fbef8740912ff74c45808b | xcyi2017/exercise | /201877-1.py | UTF-8 | 701 | 3.765625 | 4 | [] | no_license | def bubleSort(nums):
for i in range(len(nums) - 1):
for j in range(len(nums)-i-1):
if nums[j] < nums[j+1]:
nums[j], nums[j+1] = nums[j+1], nums[j]
return nums
nums = [5,2,45,6,8,2,1]
print(bubleSort(nums.copy()))
list1 = [3*x for x in nums]
print(list1)
del list1[0]
print(list1)
knights = {'gallahad': 'the... | true |
9852e50e4bbced76a32fa02ab2187cefadcc253b | jeantardelli/math-with-python | /mathematical-plotting-matplotlib/basic-plotting-with-matplotlib.py | UTF-8 | 341 | 3.640625 | 4 | [
"MIT"
] | permissive | """
This module illustrates how to create a basic plot using matplotlib library.
"""
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return x*(x-2)*np.exp(3-x)
x = np.linspace(-0.5, 3.0, 100) # 100 values between -0.5 and 3.0
y = f(x)
ax = plt.plot(x, y)
plt.show()
lines = plt.plot(x, f(x), x, x**2... | true |
122c81e9091b0798ba8e87cfd91412af0e0d1838 | ShreyasJamadagni/QuantumEngine | /Engine.py | UTF-8 | 2,543 | 3.296875 | 3 | [] | no_license | from Board import Board
from Pieces import Pawns, Rooks, Bishops, Knights, Queen, King, Pieces, BoardPiece
class Engine:
def __init__(self, color, board):
self.color = color
self.board = board
self.grid = self.board.grid
colorIndex = {"w": 1, "b": -1, "n": 0}
for c, val in c... | true |
388fcf5b0cbd17fc750c539361cb7ab638e3d845 | bergtholdt/jigna | /examples/list_of_primitives.py | UTF-8 | 2,432 | 3.484375 | 3 | [] | no_license | """
This example shows two-way data binding for the `List` traits whose items are of
the primitive type.
"""
#### Imports ####
from traits.api import HasTraits, Str, List
from jigna.api import HTMLWidget, Template
from jigna.qt import QtGui
from jigna.utils.gui import do_after
#### Domain model ####
class Basket(Ha... | true |
28e2fba43cad033994c79654a311c1303e1c42aa | mdryden/110yards | /yards_py/domain/services/schedule_service.py | UTF-8 | 9,604 | 2.609375 | 3 | [
"MIT"
] | permissive | from yards_py.domain.entities.roster import Roster
from pydantic.main import BaseModel
from yards_py.domain.entities.schedule import Matchup, MatchupType, PlayoffType, ScheduleWeek, WeekType
from yards_py.core.exceptions import NotSupportedException
from typing import List
class ScheduledMatchup(BaseModel):
away:... | true |
42bac11809c37c6687af9697fcc8e2a89514d84e | thorwhalen/ut | /ut/pplot/my.py | UTF-8 | 957 | 3.09375 | 3 | [
"MIT"
] | permissive | """What matplotlib has already -- but with the interface I'd like"""
from numpy import *
import matplotlib.pylab as plt
def vlines(
x,
ymin=0,
ymax=None,
marker='o',
marker_kwargs=None,
colors='k',
linestyles='solid',
label='',
hold=None,
data=None,
**kwargs
):
if ymax... | true |
5126519b61d40c430f95a1a038ae82f4c4303013 | csreehari/corepy | /strings.py | UTF-8 | 1,369 | 3.265625 | 3 | [] | no_license | print(len("oiuroiweurn983498kljkldfje"))
# use str.join() instead of concatenation as concatenation with + results in temporaries
# which results in consequent costs of memory, allocations and copies
colors = ';'.join(['#45ff23','#77ff23', '#1298a3'])
print(colors)
print(colors.split(';'))
print(''.join(['high', 'way',... | true |
d07705c96fa7aec6bb6a876295adaa5ee90869dc | LinusCDE/AdventOfCode2019 | /puzzle2.py | UTF-8 | 4,240 | 3.390625 | 3 | [] | no_license | from itertools import permutations
from abc import ABC, abstractmethod
class OperationInfo:
'''
Provides information about the current operation
and is subscriptable for parameter access which respects
the respective parameter modes.
'''
MODE_POSITION = 0 # Pointer-ish
MODE_IMMEDIATE = 1 #... | true |
231535096e81aa267bd105246c17a97cc6336929 | mridulR/Computer_Networks | /Assignment_2/PartB/analysis_pcap_tcp.py | UTF-8 | 9,007 | 3.171875 | 3 | [] | no_license | '''
dpkt will give string of bytes so struct will be used to pack it into integer and string data types.
While unpacking, struct can be passed with >/< so that endianess is taken care of.
'''
## https://pymotw.com/2/struct/
import struct
import dpkt
## https://www.pacificsimplicity.ca/blog/reading-packet-hex-dumps-man... | true |
2fe1e5ac3846a0e1a3b60fe43b7dd7e9dfbc8b6e | LucasBarbosaSilva/desafio01-GSO | /batalha.py | UTF-8 | 706 | 3.921875 | 4 | [] | no_license | #Status do monstrinho 1
atk1 = int(input()) # Valor de ataque
def1 = int(input()) # Valor de defesa
#Status do monstrinho 2
atk2 = int(input()) # Valor de ataque
def2 = int(input()) # Valor de defesa
'''Verifica se o ataque e a defesa do
oponente são iguais, e redefine o
valor para a variável de ataque'''
atk1... | true |
defa3bd2c55368d04e25f799910268e2070b9c10 | ahampt/simpleRESTDB | /simplerestdb/webapp/views/core.py | UTF-8 | 5,838 | 2.59375 | 3 | [
"MIT"
] | permissive | import cgi, json, logging, sys
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.http import HttpResponse, Http404
from webapp.models import Data
site_logger = logging.getLogger('log.site')
database_logger = logging.getLogger('log.database')
# Retrieve... | true |
504d7e9a096bc7580d103d3a1d2b5860fd24cb9f | wugenshui/demo-python | /TalkRobot/robot.py | UTF-8 | 1,123 | 2.875 | 3 | [
"MIT"
] | permissive | import speech_recognition as sr
# 指定要转换的音频源文件(english.wav)
from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "english.wav")
# 定义SpeechRecognition对象并获取音频源文件(english.wav)中的数据
r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
audio = r.record(source) # read the entire audi... | true |
a59afb77cb1bf144e6cf801d0cfd575babd777a2 | alexsfo/uri-online-judge-python | /URI_1153.py | UTF-8 | 99 | 3.40625 | 3 | [] | no_license | n = int(input())
x = n
while x > 1:
x = x - 1
atual = (n * x)
n = atual
print(atual)
| true |
eec4d855902d42e1f59f7fa79e06ecf80c3a1629 | fathhrohman/Tubes | /Semester_5/DAA/rod cutting.py | UTF-8 | 630 | 3.171875 | 3 | [] | no_license | import random
import time
import matplotlib.pyplot as plt
def cutRod(price, n):
val = [0 for x in range(n + 1)]
val[0] = 0
for i in range(1, n + 1):
max_val = 0
for j in range(i):
max_val = max(max_val, price[j] + val[i - j - 1])
val[i] = max_val
return... | true |
6c6a6a396b6fb584b2cf7b00f64633c68698d8b2 | JeromeLefebvre/ProjectEuler | /Python/Problem028.py | UTF-8 | 704 | 4.0625 | 4 | [] | no_license |
'''
Problem 28
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the d... | true |
31d854b80f3ce516d0e169ad391923e28850aa08 | kaka-go/Programming | /python/basic/loop_infinite.py | UTF-8 | 104 | 3.125 | 3 | [] | no_license | import random
while True:
rand = random.randint(0, 10)
if rand > 8:
print('.' * rand)
| true |
4d89ab8b9eeec5a9bf4d82c62c49aa6c37e28812 | olegfateev13/Find_contact_information | /lib/train.py | UTF-8 | 2,836 | 2.65625 | 3 | [] | no_license | import pandas as pd
from lightgbm import LGBMClassifier
from sklearn import preprocessing
import phonenumbers
import pickle
le = preprocessing.LabelEncoder()
df_train = pd.read_csv('data/train.csv')
df_train = df_train
df_train = df_train
df_train.dropna(inplace = True)
df_train.reset_index(drop = True... | true |
68d8a12cae62e5f2b4f90b0b223a8d31469c6583 | shadowusr/ml-course | /1 - Nearest neighbors algorithm/recognition.py | UTF-8 | 2,149 | 2.734375 | 3 | [
"MIT"
] | permissive | from PIL import Image
import sys
import random
im = Image.open('test-2.png')
pixelMap = im.load()
sys.setrecursionlimit(30000)
sz = im.size
def flood_fill(img, x, y):
# print(img[x, y])
if x < 0 or x >= sz[1] or y < 0 or y >= sz[1] or img[x, y] == (255, 255, 255):
return img
img[x, y] = (255, 255... | true |
389f85949d7eff6b178ebbb5b5bb9e685422bf69 | 999higor/Similarity_func_CSV | /main.py | UTF-8 | 2,748 | 2.640625 | 3 | [] | no_license | import csv
import function
def main():
arquivo = open('arquivo.csv')
arquivo = csv.DictReader(arquivo)
Similarity = ['Hamming',
'MLIPNS',
'JaroWinkler',
'Jaro',
'StrCmp95',
'Jaccard',
'Sorensen',
'Tversky',
'Overlap',
'Cosine',
... | true |
4a885d626a4e625082abc12da0fb482bcc68ead5 | AleksandrSl/Bioinformatic_inst_Math | /homework_3_test.py | UTF-8 | 650 | 3.03125 | 3 | [] | no_license | import Homework_3 as g
graph = g.OrientedGraph()
graph.add_edge(1, 2)
graph.add_edge(3, 4)
graph.add_edge(2, 3)
graph.add_edge(6, 7)
graph.add_edge(7, 8)
graph.add_edge(8, 9)
graph.add_edge(9, 10)
graph.add_edge(10, 3)
graph.add_edge(10, 11)
graph.add_edge(11, 12)
graph.add_edge(12, 5)
graph.add_edge(11, 13)
graph.add... | true |
5bfd01afc0cbc2330442756fa72d6134f3a955d7 | kingname/LeetCode | /isomorphic-strings.py | UTF-8 | 1,333 | 3.8125 | 4 | [] | no_license | """
https://leetcode.com/submissions/detail/149345916/
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two c... | true |
beb4bfa43791e4d19305730675efa18f5b34ddbb | gbattra/ML_Framework | /models/data_model.py | UTF-8 | 674 | 2.703125 | 3 | [] | no_license | # model structure for the data to pass to classifier
import numpy as np
from services.data_preprocessor_service import DataPreprocessorService as dps
class DataModel:
def __init__(self, data: dict, num_classes: int, image_size: list):
self.x_train = dps.preprocess_imageset(data['x_train'], image_size)
... | true |
af941d3cbc0fe451f47ab68c475dad251e539572 | touzariLiticia/Natural-Language-Processing | /classes_TME3.py | UTF-8 | 7,324 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 6 16:52:05 2020
@author: TOUZARI
"""
import TextRepresenter as TR
import json
import numpy as np
from math import *
from statistics import *
from classes_TME1 import *
from classes_TME2 import *
"""--------------TME3 """
class Query():
de... | true |
2d05da8fc326ee3b1ed12c7d982a340143afc5fb | chuyanga/absorption | /Spectroscopy/hstfos_xy2fits.py | UTF-8 | 2,638 | 2.84375 | 3 | [
"MIT"
] | permissive | """
Convert *.xy files to fits file
"""
# http://lithops.as.arizona.edu/~jill/QuasarSpectra/
# A Uniform Analysis of the Lyman Alpha Forest at z = 0 - 5: III. HST FOS Spectral Atlas
# http://lithops.as.arizona.edu/~jill/QuasarSpectra/HSTFOS/table.html
# Units:
# -- The wavelength is given in units of angstroms.
# ... | true |
c224160a07fa5e05fa97ed2349d7f897169e6330 | scontain/sgx-pyspark-demo | /input/enc-wordcount.py | UTF-8 | 1,358 | 2.71875 | 3 | [] | no_license | #
# Access to this file is granted under the SCONE SOURCE CODE LICENSE V1.0
#
# Commercial use of any product using this file requires a commercial
# license from scontain UG, www.scontain.com.
#
# also see https://sconedocs.github.io
#
# Copyright (C) 2019 Scontain UG
#
from __future__ import print_function
import... | true |
97da1506d660034e5e642fd0753cd95685627040 | sandromirr/trustpilot-scraper | /Review.py | UTF-8 | 2,770 | 2.96875 | 3 | [] | no_license | from bs4 import BeautifulSoup
import requests
import csv
class Review:
def __init__(self,name,photo,location,rate,title,text):
self.name = name
self.photo = photo
self.location = location
self.rate = rate
self.text = text
self.title = title
def __str__(self):
... | true |
e3cd411c8bb7bae36efd89084f9bd903665e8f3f | SajiTibi/parachute-game | /ParachuteController.py | UTF-8 | 734 | 3.3125 | 3 | [] | no_license | from ParachuteModel import ParachuteModel
class ParachuteController:
def __init__(self):
self.parachute_model = None
def set_model(self, model: ParachuteModel):
if model is None:
raise Exception("Invalid model")
self.parachute_model = model
def fall(self):
"""... | true |
349adc1a7d771dcd65decee618617e3515c3662f | dwagon/pydominion | /dominion/cards/old/Card_Ill-Gotten_Gains.py | UTF-8 | 2,365 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env python
import unittest
from dominion import Card, Game, Piles
###############################################################################
class Card_IGG(Card.Card):
def __init__(self):
Card.Card.__init__(self)
self.cardtype = Card.CardType.TREASURE
self.base = Card.Card... | true |
b37bd03ccafc379df7501628366ff0f4deee45c8 | Reiyyan/PythonChallenges | /pyramid_blocks.py | UTF-8 | 182 | 3.296875 | 3 | [] | no_license | def pyramid_blocks(n, m, h):
result = 0
for _ in range(h):
result += n*m
n+=1
m+=1
return result
print(pyramid_blocks(10**6,10**6,10**6)) | true |
a2aceff0abc8642e037a0ede0064624790e349ce | sumsur/Prediction-of-Quality-of-wine | /prediction_quality_wine.py | UTF-8 | 4,753 | 3.578125 | 4 | [] | no_license | #For prediction we will use:
#1. Random Forest Classifier
#2. Stochastic Gradient Descent Classifier
#3. Support Vector Classifier(SVC)
#For crossvalidation evaluation tecnique we will use:
#1. Grid Search CV
#2. Cross Validation Score
#packages:
import pandas as pd
import seaborn as sns
import matplotlib... | true |
e666b824c43fc4fe49349f4e6f60a24ef5819509 | brucemingxinliu/Image_Classification | /Image_Classfication_Keras/classifier_from_little_data_script_1/prediction.py | UTF-8 | 2,029 | 2.734375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 22 15:12:45 2017
@author: TWang
after traning model, make prediction
"""
from keras.models import load_model
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras.prep... | true |
545158357bff16eb50e13f2f415e449763d05564 | JBN-cloud/Parsers | /bot/src/main.py | UTF-8 | 5,192 | 2.625 | 3 | [] | no_license | from telebot import TeleBot
import telebot
import constants
from bs4 import BeautifulSoup
import requests
import os
from sql import SQLighter
from aiogram import Bot, types, Dispatcher, executor
bot: TeleBot = telebot.TeleBot(constants.token)
bot.remove_webhook()
secbot = Bot(token=constants.token)
dp = Dispatcher(se... | true |
96a0b35d89d09b4b08237add23a2bb1ad6176116 | Mintas/diving-deep-learning | /plots/plotUi.py | UTF-8 | 1,176 | 2.53125 | 3 | [] | no_license | import os
import matplotlib
from matplotlib import pyplot as plt
import matplotlib.backends.backend_pdf as pltpdf
class ShowPlotUi():
def __init__(self, figsize=(10,10)) -> None:
super().__init__()
self.figsize = figsize
def toView(self, plot):
fig = self.figure()
plot()
... | true |
28d7d027f4e578eda930996d54f7adb9a56aa93b | anishshanbhag/AutomatedAttendanceSystem | /Practice/videoCapture.py | UTF-8 | 724 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 12 15:04:40 2018
@author: anish
"""
import cv2
def main():
windowName='Anish'
cv2.namedWindow(windowName)
cap = cv2.VideoCapture(0)
print("Width : "+str(cap.get(3))) # width of resolution
print("Height : "+str(cap.get(4))... | true |
a5a4ed50deef8fefe63a4f3e57cc0afe8eacecb9 | timtingwei/prac | /gh/caDesign/01_list_01_py.py | UTF-8 | 354 | 3 | 3 | [] | no_license | #01_list_01_py.py
format = "point_%s" #///可以现在外部写好format
dpoints = []
for i in range(10):
dpoints.append(format % str(i))
print (dpoints)
#['point_0', 'point_1', 'point_2', 'point_3', 'point_4', 'point_5', 'point_6', 'point_7', 'point_8', 'point_9']
dpindex = list(range(len(dpoints)))
print (dpindex)
#[0, 1, 2, 3,... | true |
fa4f73cc19c0388460f14b6bb5f4b45433571045 | alvaro-root/pa2_2021 | /banking_example.py | UTF-8 | 5,305 | 3.46875 | 3 | [
"MIT"
] | permissive | """
Implement abstract classes, static methods and multiple inheritance
A mini banking system
In a banking system the following elements exist:
Accounts
Current accounts
Deposit Accounts
Credit cards
Accounts have
Balance
Rate of interest
Customer
An ability to lodge money
An abi... | true |
7fdb62c8ef1c16a99d9ae350b17bd87e79d7fb85 | rafaelperazzo/programacao-web | /moodledata/vpl_data/440/usersdata/311/97505/submittedfiles/listas.py | UTF-8 | 184 | 3.21875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#Função que calcula a altura do degrau
n=int(input('Digite um numero abaixo: '))
while (n<2):
n=int(input('Digite um numero abaixo: '))
| true |
6695a298b550d21df26c300891704d2716c449e3 | LiHengofChina/_python | /002.Artificial_Intelligence/worspace/month04/day06/03_poly_3.py | UTF-8 | 992 | 3.28125 | 3 | [] | no_license | '''
多项式回归、API
"最高次幂"是一个超参数,它的值是多少合适 在所以不能给太高
可以使用for循环的方式,看看哪个得分高,再决定
'''
import pandas as pd
import sklearn.preprocessing as sp # 数据预处理
import sklearn.pipeline as pl # 管线模块
import sklearn.linear_model as lm # 线性模型
import sklearn.metrics as sm # 评估模块
import numpy as np
data = pd.read_csv('../... | true |
f0fddccb336f5acd8d93bd021b6059f7e8036ade | lilymara-onesignal/rust-demo | /read-file.py | UTF-8 | 363 | 3.359375 | 3 | [] | no_license | import sys
import json
import time
start = time.time()
xy_count = 0
z_count = 0
for line in sys.stdin:
data = json.loads(line)
if data['x'] > 0:
if data['y'] % data['x'] == 0:
xy_count += 1
if data['z']:
z_count += 1
end = time.time()
print(f'xy: {xy_count}')
print(f'z: {z_... | true |
399d565cc699bb3c27cff5e56a7215199c9c6f74 | DaMIRka-Oo/MonsterX | /main_menu.py | UTF-8 | 5,509 | 2.96875 | 3 | [] | no_license | import pygame, sys
from pygame.locals import *
from Draw_Text import DrawText, drawText
from Fraction_Image import FractionImage, PlayingCard
mainClock = pygame.time.Clock()
pygame.init()
pygame.display.set_caption('game base')
screen = pygame.display.set_mode((500, 500),0,32)
font = pygame.font.SysFont(None, 50)
... | true |
007bd66a38b174c4d817d4cbe6c88e45404a57ad | pearlmilktea/PhotoToGpx | /scr.py | UTF-8 | 3,024 | 3.078125 | 3 | [] | no_license | #! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Create a KML file based on exif data
Requires exiftool to have been installed
Usage: exif2kml.py *.jpg > output.kml
python scr.py *.JPG
"""
import os
import sys
import re
import time
def decimalat(DegString):
# This function requires tha... | true |
6d9f449312a335671fd358bf0482486d59eab245 | SoniaB77/Exercise_12_Collections | /exercise12.2.py | UTF-8 | 267 | 4.09375 | 4 | [] | no_license | tup = 'Hello'
print(len(tup))
print(type(tup))
# this is a string so the length is checking the iterables of the string which is 5.
tup = 'Hello',
print(len(tup))
print(type(tup))
# this is a tuple so it is checking the iterables but of a tuple so this outputs 1. | true |
6992c6d81a4a01bc55b90d7acd36143d6d405c3f | catalina85/leetcode | /algorithms/python/_170_TwoSumIII_DataStructureDesign/Solutions.py | UTF-8 | 829 | 4.03125 | 4 | [] | no_license | class TwoSum:
def __init__(self):
self.nums = {}
def add(self, number):
"""
@param number: An integer
@return: nothing
"""
# write your code here
if number in self.nums:
self.nums[number] += 1
else:
self.nums[number] = 1
... | true |
ddfa852037d3a25f7bb52f75b2305b1dc64566b0 | cubeopen7/algorithm | /union_find.py | UTF-8 | 2,571 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import random
import numpy as np
class UnionFind(object):
# With Quick-union, Weighting, and Path compression
def __init__(self, N):
self.id = np.arange(N, dtype=np.int64)
self.sz = np.ones(N, dtype=np.int64)
a = 1
def root(self, x):
while x != se... | true |
999985f66487c1aaad88cc55a576cb300bac9c92 | Rolo96/Arqui2-Proyecto1-CoherenciaCache-RAQ | /cacheBus.py | UTF-8 | 2,892 | 2.890625 | 3 | [] | no_license | ##########################################
# Tecnologico de Costa Rica #
# Arquitectura de computadores 2 #
# Proyecto 1 #
# Cache Bus component #
# Raul Arias #
##########################################
"""
T... | true |
ada1f0dfac4645922d10d62ae0db6273e35a05f6 | TianDehua/pythonLearn | /selfmodule/itertoolsTest.py | UTF-8 | 1,103 | 4.375 | 4 | [] | no_license | import itertools
# count 创建一个无限的迭代器,用于数字,第一参数start,第二个参数step默认1
natuals = itertools.count(1, 2)
for n in natuals:
print(n)
if(n > 10):
break
# takewhile表示取出一部分
ns = itertools.takewhile(lambda x: x<=20, natuals)
print(list(ns))
print(type(natuals))
# cycle 创建一个无限循环序列, 参数是一个iterable
cs = itertools.cyc... | true |
5ef339b94e2f783bcb8c87a036a1f4aa89d6708f | xXxAntikvarxXx/jetbrains-academy-python | /Problems/Types/task.py | UTF-8 | 122 | 3.21875 | 3 | [] | no_license | # the variable "args" is already defined
my_list = [int(number) for number in args[1:]] # your code here
print(my_list)
| true |
d930b3dd69713b4aeb19f97b5f3fbb02c3f07dc8 | qazz625/Competitive-Programming-Codes | /Codeforces/1475/A.py | UTF-8 | 128 | 3.421875 | 3 | [] | no_license | t = int(input())
for _ in range(t):
n = int(input())
while n%2 == 0:
n //=2
if n == 1:
print("NO")
else:
print("YES") | true |
1ac3a2084bd0290a49c6ebf5fc8cd7505da405f5 | moonsbtt/vps-stock-monitor | /vps/management/commands/run.py | UTF-8 | 1,622 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
'''
运行方法:
python .\manage.py run
'''
from django.core.management.base import BaseCommand, CommandError
from vps.models import Company ,Goods
import requests , time
import sys,threading
lock = threading.Semaphore(12)
class Command(BaseCommand):
def handle(self, *args, **options... | true |
fce94921eca69848f7370a81dfce8889e88223dc | dir01/bookworm | /tests/test_directory_importer.py | UTF-8 | 2,551 | 2.671875 | 3 | [] | no_license | import unittest2
from mock import Mock
from book_file_processors import UnsupportedBookFileType
from file_importer import BookFileImporter
from settings import TESTS_DATA_ROOT
class FakeBookFileProcessorFactory(object):
is_valid = None
def __init__(self, *args, **kwargs):
pass
def get_book_fil... | true |
ebf0e8eaaa60b97aa8d1753bcef0a7f12ed2d695 | jbrouw2/Character_Collider | /modules/domain_variables.py | UTF-8 | 2,593 | 3.28125 | 3 | [] | no_license | """
Converts domain text variables into lists of Facet class objects
"""
from modules.domain_texts import domain_text_array
class Facet(object):
def __init__(self, _name, _description, _lowDescript, _highDescript):
self.name = _name
self.description = _description[0].upper() + _description[... | true |
1608302fa6f26b5dc2211cf5cfd923bc10b96ecd | IswaryaNidadavolu/python | /divisible.py | UTF-8 | 142 | 3.546875 | 4 | [] | no_license | x=int(input("enter the number"))
y=int(input("enter the number"))
if x%y==0:
print("divisible")
else:
print("not divisible")
| true |
a9d17e2d2e44102953fa8be3e86e8f8ae4292dbd | clumsyme/learn | /python/heap.py | UTF-8 | 4,029 | 3.1875 | 3 | [] | no_license | class Min:
def __lt__(self, other):
return True
def __gt__(self, other):
return False
def __repr__(self):
return '-'
class Heap:
def __init__(self, values=None):
self.nodes = [Min()]
if values != None:
for value in values:
self.insert(v... | true |
3a468f0f37133b56576f251a62fd142426700230 | Pked01/openvino_work | /Notebooks/utilities/res_thresh_util.py | UTF-8 | 865 | 2.8125 | 3 | [] | no_license | import cv2
def get_resolution_thresh(image):
"""
return resolution thresholds for an image
image : image
"""
cv2.namedWindow("preview",cv2.WINDOW_NORMAL)
font = cv2.FONT_HERSHEY_SIMPLEX
org = (20, 20)
fontScale = 1
color = (255, 0, 0)
thickness = 2
image1 = cv2.putText(image.copy(),... | true |
868824a9ddc4496f17816b0eb07e927fa0a5f27a | dcreemer/adventofcode | /2021/python/aoc2021/twelve/tests/test_twelve.py | UTF-8 | 430 | 3.0625 | 3 | [] | no_license | # tests for day Twelve
from ..twelve import parse_input, part_one_calc, part_two_calc
input = """
start-A
start-b
A-c
A-b
b-d
A-end
b-end
"""
def test_parse_input() -> None:
data = parse_input(input)
assert len(data) == 6
def test_part_one() -> None:
data = parse_input(input)
assert part_one_calc(... | true |
88a0ed2a89b34689d115651b10d788427d77a0b7 | HosanLee/Gimpro | /gimpro/gimproapp/upbit_price.py | UTF-8 | 451 | 2.859375 | 3 | [] | no_license | import pyupbit
# 티커 '거래통화 - 코인명' => list 반환
def get_ticker(input=""):
return pyupbit.get_tickers(fiat=input)
def get_price(input):
return pyupbit.get_current_price(input)
ticker = get_ticker('KRW')
# usdt_btc = get_price('USDT-BTC')
coins_price = get_price(ticker)
coin_list = {}
for k, v in coins_price.ite... | true |
b6f9baab9b617fbcbdd2bef8cc16a929caa6f2e2 | qrogers/pyscape | /bin/game_objects/places/field.py | UTF-8 | 1,828 | 2.921875 | 3 | [] | no_license | from bin.game_objects.places.place import Place
class Field(Place):
def __init__(self, number, area, name, description, difficulty, level, info):
super(Field, self).__init__(number, area, name, description, difficulty, level, info)
#Fiber that can be picked here
self.fiber = info['fiber']
... | true |
81bb35c245924a2dbb6043da4e1d8d774f775776 | huachao2017/goodsdl | /goods/freezer/keras_yolo3/util/iou_util.py | UTF-8 | 534 | 2.75 | 3 | [
"Apache-2.0"
] | permissive |
def IOU (predictBox,Box):
cx1 = predictBox[0]
cy1 = predictBox[1]
cx2 = predictBox[2]
cy2 = predictBox[3]
gx1 = Box[0]
gy1 = Box[1]
gx2 = Box[2]
gy2 = Box[3]
carea = (cx2 - cx1) * (cy2 - cy1) # C的面积
garea = (gx2 - gx1) * (gy2 - gy1) # G的面积
x1 = max(cx1, gx1)
y1 = max... | true |
42e7ff4f4d049a308e32a039c2f9e94b3a534b3e | jpic/lookupy | /lookupy/lookupy.py | UTF-8 | 10,908 | 2.859375 | 3 | [
"MIT"
] | permissive | """
lookupy.lookupy
~~~~~~~~~~~~~~~
This module consists of all of the functionality of the package
"""
import re
from functools import partial
from .dunderkey import dunder_get, dunder_partition, undunder_keys, dunder_truncate
class QuerySet(object):
"""Provides an interface to filter data and selec... | true |
0a5d5ac335c1422587f59e5a434d59e245239ed4 | CodingWithUday/Password-Generator-Using-Python | /Password Generator/main.py | UTF-8 | 154 | 2.578125 | 3 | [] | no_license | import random
lis = 'jakljpodifsphqhwdjpdahfpda;hfygpp843iweogfrywpqud;fw'
passlen = 6
passwd = "".join(random.sample(lis, passlen))
print(passwd) | true |
94228088ecbcd610582504eef0ed4dfff861c086 | Open-EO/openeo-eodc-driver | /gateway/tests/users/test_users_get.py | UTF-8 | 4,867 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | import json
import datetime
from service import db
from service.model.user import User
from service.tests.base import BaseTestCase
from service.tests.utils import add_user, id_generator, add_random_user
class TestUserServiceGET(BaseTestCase):
''' Tests for GET on Users Service. '''
def test_get_... | true |
11c7ecaca1984e564165423a533d3d6d99524b56 | beautytiger/project-euler | /python/python_combinations.py | UTF-8 | 202 | 3.234375 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import itertools
my_list = range(1, 7)
target = 10
comb = itertools.combinations(my_list, 3)
re_list = [i for i in comb if sum(i)==target]
print(re_list)
| true |
8a3a0ea1cb5f7f5fdc2deabb8ab31d319c42907a | bpachev/proj_euler | /e68.py | UTF-8 | 855 | 2.9375 | 3 | [] | no_license | import itertools
for inner in itertools.combinations(range(1,10),5):
s = sum(inner)
if s % 5:
continue
k = 11 + s / 5
for ordered_inner in itertools.permutations(list(inner)):
digit_mask = {d:1 for d in range(1,11)}
for i in inner:
digit_mask[i] = 0
digit_mask[10] = 0
os = []
if n... | true |
92fdbd85e2497b11a3ca4e449829f4ed0cdef95f | jrief/django-sass-processor | /sass_processor/apps.py | UTF-8 | 1,177 | 2.53125 | 3 | [
"MIT"
] | permissive | import re
import os
from django.apps import apps, AppConfig
from django.conf import settings
from django.contrib.staticfiles.finders import AppDirectoriesFinder
APPS_INCLUDE_DIRS = []
class SassProcessorConfig(AppConfig):
name = 'sass_processor'
verbose_name = "Sass Processor"
auto_include = getattr(sett... | true |
4686481474d975d5293f60ed67b22c6e62a60f74 | EugeneJenkins/pyschool | /Dictionaries/5.py | UTF-8 | 229 | 2.875 | 3 | [] | no_license | def mRNAtranscription(dna_template):
dna2rna = {'A':'U', 'T':'A', 'C':'G', 'G':'C' }
mRNA = ''
result=[]
for base in dna_template:
mRNA = dna2rna.get(base)
result.append(mRNA)
return ''.join(result)
| true |
a77dde26a84397e392bb0008363c61c29f847290 | MariaAfanaseva/Tasks_Python | /standard_library/task_3.py | UTF-8 | 865 | 4.40625 | 4 | [] | no_license | """
3. Create two lists with different elements.
The first should contain the keys, the second - the values.
It is necessary to write a function that creates a dictionary
from the data of keys and values.
If the key lacks a value,
in the method, it must be stored as None.
Values that did not have enough keys should ... | true |
0f3f03f25760360860902b1291f3572bccab31a4 | aman-sahai/python-level2 | /Packages/validator.py | UTF-8 | 446 | 2.6875 | 3 | [] | no_license | import re
def phonenumvalid(num):
pattern = '^[06789][0-9]{9}$|^[+91][6-9][0-9]{9}$'
if re.match(pattern,str(num)):
return True
return False
phonenumvalid(9565033528)
import re
def emailvalid(email):
pattern = '^[0-9a-z][0-9a-z_.]{4,13}[@][a-z0-9]{3,18}[.][a-z]{2,4}$|^[0-9a-z][0-9a-z_.]{4,13}[@... | true |
4fcffcdeee95c9fb67ffc95373ea3c03a274160c | canl/algo-trading | /src/utils/common.py | UTF-8 | 258 | 2.59375 | 3 | [
"MIT"
] | permissive | # special_instruments' pip is the second place after the decimal (0.01) rather than the fourth (0.0001).
SPECIAL_INSTRUMENTS = ('XAU', 'JPY', 'BCO')
def has_special_instrument(instrument):
return any(inst in instrument for inst in SPECIAL_INSTRUMENTS)
| true |
f36aadf0a7fe7680a697e3646d7da2e19488a3ac | italoh623/Food_Collector | /Map.py | UTF-8 | 3,024 | 3.203125 | 3 | [] | no_license | from Mapa1 import maps
import math
class Map():
def __init__(self):
self.tile_size = 20
self.grid = []
self.wall_color = color(51,51,51)
self.sand_color = [color(255,248,220), color(255,248,180), color(255,248,100)]
self.water_color = [color(0,102,153), color(0,70,153), colo... | true |
6c3f97a3a0a53d12be3ab3cd19954cd3671c7c3f | DuB0k/Statistics | /ex5_standar_deviation.py | UTF-8 | 515 | 3.296875 | 3 | [] | no_license | from sys import stdin
from math import sqrt
#arrayLength = int(stdin.readline())
#array = stdin.readline().split()
arrayLength = 5
array = "10 40 30 50 20".split()
sumNum = 0
mean = 0.0
sumSquaredMean = 0
array = list(map(int, array))
for item in array:
sumNum = sumNum + item
mean = sumNum / arrayLength
#print... | true |
4762af381ddffc25916db6dfbcb2d8f88c64893c | nikpaa/compress_project | /src/io.py | UTF-8 | 1,426 | 3.015625 | 3 | [] | no_license | from deflate import defl_encode, defl_decode
import sys
def deflate_file(input_filename: str):
output_filename = input_filename + '.defl'
input_data = bytearray()
with open(input_filename, 'rb') as f:
byte = f.read(1)
while byte:
input_data.append(int.from_bytes(byte, 'big'))
... | true |
848a0fe16b06f8941f03468f6d5ec7349529c2cd | egortcevasofia/the_basics_of_programming_in_python | /5_week/Последний максимум.py | UTF-8 | 149 | 3.328125 | 3 | [] | no_license | a = input().split()
max = int(a[0])
pos = 0
for i in range(len(a)):
if int(a[i]) >= max:
max = int(a[i])
pos = i
print(max, pos)
| true |
75e2c69c299db247a52f1ef16a520dfaa53520c0 | aconbere/uf | /tests/test_parser.py | UTF-8 | 398 | 2.609375 | 3 | [] | no_license | import sys
sys.path.append(".")
from uf.parser import Parser
def test_parser():
parser = Parser()
assert(parser)
def test_parser_open_stream():
parser = Parser()
stream = parser._open_stream("string")
assert(stream == "string")
def test_parser_parse():
parser = Parser()
stream = "string"... | true |
2dc38f8806f7b56f155e063920bd72ba03ecf385 | facku24/MyS2016 | /Final/9-2.py | UTF-8 | 1,777 | 3.375 | 3 | [] | no_license | from random import random
from scipy.stats.distributions import chi2
import math
#---------------------------------------------
# CONSTANTES
#---------------------------------------------
N = 6
REPET = 1000
npi = 500/float(3)
values = [158, 172, 164, 181, 160, 165]
probs = [1/float(6), 1/float(6), 1/float(6), 1/floa... | true |
6b244af305c106fc282070e93c98cb1bdcf9b153 | tengsun/analytics-tensorflow-demo | /img/img_preprocess.py | UTF-8 | 3,228 | 2.859375 | 3 | [] | no_license | import matplotlib.pyplot as plt
import tensorflow as tf
image_raw_data = tf.gfile.FastGFile('./data/swk_raw.jpg', 'rb').read()
def decode_encode_img():
with tf.Session() as sess:
# decode image
img_data = tf.image.decode_jpeg(image_raw_data)
print(img_data.eval())
# show on pl... | true |
fed11f31a595bee5e44dc9381bed5a3be6128828 | cloudmesh/cloudmesh-cloud | /tests/data/test_data_local.py | UTF-8 | 1,816 | 2.546875 | 3 | [
"Apache-2.0",
"Python-2.0"
] | permissive | from os.path import isfile
from cloudmesh.common.Benchmark import Benchmark
from cloudmesh.data.api.data import Data
Benchmark.debug()
# TODO: The directories and files for the test should be created on the fly.
# for example if a 1mb data file is needed it needs to be created if it does
# not exist. It neews do be... | true |
587cf752c68084ea3a590381a78146f3aecf3429 | rafaelfolco/leetcode-python | /string-to-int.py | UTF-8 | 1,873 | 3.515625 | 4 | [] | no_license | # https://leetcode.com/problems/string-to-integer-atoi
class Solution(object):
def myAtoi(self, str):
"""
:type str: str
:rtype: int
"""
if len(str)==0:
return 0
signal=0
num_str = ""
numbers = ['0','1','2','3','4','5','6','7','8','9']
... | true |
51177f3b0c5802a5ef68c9bf576db75d209e47cd | LinboCasia/paddle_POS | /network_conf.py | UTF-8 | 3,799 | 2.765625 | 3 | [] | no_license | # Copyright(c) 2018 PaddlePaddle. All rights reserved.
# Created on 2018
# Author:Lin_Bo
# Version 1.0
# filename: network_conf.py
import paddle
from paddle import fluid
import paddle.fluid as fluid
def window_net(data,
label,
dict_dim,
class_num,
... | true |
2e36167bd726bd4b388c63c785223e9a315afda8 | x-link-x/forestly | /controllers/areas_controller.py | UTF-8 | 1,543 | 2.546875 | 3 | [] | no_license | from flask import render_template, redirect, request
from flask import Blueprint
from models.area import Area
import repositories.area_repository as area_repository
areas_blueprint = Blueprint('area', __name__)
# INDEX
@areas_blueprint.route("/areas")
def areas():
areas = area_repository.select_all()
return ... | true |
165400da2e881dc0a61d9d344bd03d9b1951b758 | abidkhan484/hacerrankScraping | /scrapeHackerrankCode/codes/identify-smith-numbers201.py | UTF-8 | 797 | 3.75 | 4 | [] | no_license | # Wrong Answer
# Python 3
from math import sqrt
from math import floor
#the function return all prime factor in a num
def prime_factorization(n):
total = 0
ia = sqrt(n); j = 3
# this while loop make the number odd
while not (n&1):
total += 2
n = n >> 1
# this loop get another pri... | true |
7d1ad768b2da42d2ee036a877cf7409db7afd5c9 | utappoco/pyseto | /pyseto/versions/v2.py | UTF-8 | 3,864 | 2.53125 | 3 | [
"MIT"
] | permissive | import hashlib
from secrets import token_bytes
from typing import Union
# from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from Cryptodome.Cipher import ChaCha20_Poly1305
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
Ed25519PrivateKey,
Ed25519PublicKey,
)
from ..excep... | true |
aed73fddc553d4673eb413f056b3be965c91ff89 | Yaoaoaoao/LeetCode | /algorithms/42_trapping_rain_water.py | UTF-8 | 787 | 2.96875 | 3 | [] | no_license | class Solution(object):
def trap(self, height):
"""
:type height: List[int]
:rtype: int
"""
water = 0
left, right = 0, len(height)-1
leftmax, rightmax = 0, 0
while left < right:
if height[left] < height[right]:
if height[lef... | true |
b9fcde1b76e2ddf88951586ec3e6123256604aec | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/meetup/37265aa06228456d821c6185e3643cae.py | UTF-8 | 1,090 | 3.78125 | 4 | [] | no_license | import calendar
import datetime
# tried doing it in an iterative way that was somewhat naive about the structure of a month
# it's pretty ugly...
def nthday(cal, ordinal, day):
for (x, y) in cal:
if y == day and x > 0:
lastseen = x
if ordinal > 0:
ordinal -= 1
... | true |
b3fac570491040d704421c3301ab78b91a0e4fcf | sidd9768/Automate-with-Python | /Reading and writing files/fileSearch.py | UTF-8 | 596 | 3.078125 | 3 | [] | no_license | #! /usr/bin/env python3
import re, os
files = os.listdir(os.getcwd())
txt_files = []
reg = re.compile(r'.*\.txt')
for doc in files:
if reg.search(doc) is not None:
txt_files.append(doc)
# Write regex to match
search_regex = re.compile(r'\s?\w*\!') # Matches all words ending in !
for doc in txt_files:... | true |
df97344aff69e384b1e7254b98fb7dd9f6b25b78 | CGuichardMasterDL/MCS_DTW | /mcs_dtw/learningset.py | UTF-8 | 4,050 | 3.171875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Fichier permettant de gérer le jeu d'apprentissage lié au projet
"""
#========== IMPORT ==========#
from mcs_dtw.sound import Sound
from mcs_dtw.scandir import ScanDir
from mcs_dtw.yamlmanager import write_yaml, load_yaml
#========== CLASSE ==========#
class LearningSet(object):
... | true |
4a86702c916e1678271caaacefc86ece7823c44c | Milan-Chicago/ds-guide | /random_selection/climbing_stairs.py | UTF-8 | 915 | 4 | 4 | [] | no_license | """
Climbing Stairs
You are climbing a staircase. It takes n steps to reach the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example 1:
Input: n = 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Inp... | true |
50f2b3699d62979430953b9b7b6ee2b0fb28fae3 | eymin1259/Baekjoon_Python | /Step_15/1149.py | UTF-8 | 374 | 3.0625 | 3 | [] | no_license | num = int(input())
for i in range(num):
if i==0:
min_price = list(map(int, input().split()))
continue
first, second, third = map(int, input().split())
first += min(min_price[1], min_price[2])
second += min(min_price[0], min_price[2])
third += min(min_price[0], min_price[1])
min... | true |
d06daec31ddf1902e7b6c3e5dea82b11c02c87fc | littlemesie/spider_tearcher | /nan_kai/huan_jing_ke_xue.py | UTF-8 | 2,560 | 2.578125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import requests,json
from bs4 import BeautifulSoup
from data import conn_mysql
from xlwt import *
def start():
url = 'http://env.nankai.edu.cn/shiziduiwu/fujiaoshou/'
res = requests.get(url)
soup = BeautifulSoup(res.content, 'lxml')
li_list = soup.find('ul',class_='teacherList'... | true |
ef6323d97b00cd272aa43058bad33d0bdc61c684 | Tyler-Jon-Wong/Number-to-Binary-Converter | /NumToBinary/NumToBinary.py | UTF-8 | 868 | 3.578125 | 4 | [] | no_license | '''
Created on Feb 21, 2019
@author: tyler
'''
cont = True
while cont == True:
number = int(input("Please input a number to convert to binary "))
savenumber = number
continput = ""
binary = []
for x in range(8):
binary.append(int(number%2))
if binary[x] == 1:
... | true |
d81e2ccb45e2a59b8e68c6b6b883897185f4b6a3 | degconnect/deg_flasher | /deg_flasher/comm.py | UTF-8 | 2,964 | 2.609375 | 3 | [] | no_license | import requests
import urllib
import os
DOMAIN = os.environ.get('DOMAIN', 'flasher.degconnect.com')
def get_modded(card, auth):
"""
d = {'vram_size': 4, 'memory': 'SK Hynix', 'rom_size': 4, 'bios_version': '113-1E366FU-S4J', 'model_1': 'RX 580'}
http://flasher.degconnect.com/api/v1/core/rom-moddeds/?vra... | true |
4e00d8b176574944f8d197bf406d6cae533a7783 | DJever23/Detection-PyTorch-Notebook | /chapter3/test/3.1.3-pooling.py | UTF-8 | 425 | 3.140625 | 3 | [] | no_license | import torch
from torch import nn
# 池化主要需要两个参数,第一个参数代表池化区域大小,第二个参数表示步长
max_pooling = nn.MaxPool2d(2, stride=2)
aver_pooling = nn.AvgPool2d(2, stride=2)
input = torch.randn(1, 1, 4, 4)
print('input', input)
# 调用最大池化与平均池化,可以看到size从[1,1,4,4]变成了[1,1,2,2]
print('max', max_pooling(input))
print('avg', aver_pooling(input)) | true |
ce10ece5d468b0bd1400fb01b909765e36dc5aad | Zahidsqldba07/PythonExamples-1 | /conditionals/empregado.py | UTF-8 | 867 | 3.109375 | 3 | [] | no_license | # coding: utf-8
# Custo Empregado
# (c) Héricles Emanuel, UFCG, Programação 1
salario = float(raw_input())
dias = float(raw_input())
transporte = float(raw_input())
fgts = salario * 0.08
inss_patrao = salario * 0.12
if salario <= 1317.07:
inss_trab = salario * 0.08
elif salario >= 1317.08 and salario <= 2195.12:
i... | true |
75e10fe606c2ac7fe63127be0429f723194d4b3c | shrutibansal05/heart-attack-pred | /app.py | UTF-8 | 944 | 2.953125 | 3 | [] | no_license | import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
app = Flask(__name__) #Initialize the flask App
model = pickle.load(open('model.pkl', 'rb')) # loading the trained model
@app.route('/') # Homepage
def home():
return render_template('start.html')
@app.route('/information... | true |
66a68b9d8f695a274b7fbc45f20d4871024b9711 | lijianbo0130/My_Python | /python2_Grammer/src/basic/zhengze/rool/字符集和数量/字符集/3_数字.py | UTF-8 | 307 | 2.875 | 3 | [] | no_license | #coding=utf-8
'''
Created on 2015年8月4日
@author: Administrator
'''
from __future__ import division
import sys
reload(sys)
sys.setdefaultencoding('utf-8') # @UndefinedVariable
import re
#单个数字 [0123456789] \d
lis=re.findall("\d", "1d5d6f")
print lis # ['1', '5', '6']
# 非数字 \D=[^\d] | true |
3596cd9f69ba269382a08c75a523ccc105428fe0 | vinceajcs/all-things-python | /data_structures/tree/binary_tree/binary_tree_lists.py | UTF-8 | 658 | 3.84375 | 4 | [] | no_license | """Binary tree implementation using lists of lists."""
def binary_tree(root):
return [root, [], []]
def insert_left(root, new_tree):
t = root.pop(1)
if len(t) > 1:
root.insert(1, [new_tree, t, []])
else:
root.insert(1, [new_tree, [], []])
return root
def insert_right(root, new_... | true |
9876463b6ac5a66ba7e31a4b59d74d8e1028d34d | missdavid7/LPTHW | /Sort.py | UTF-8 | 591 | 4.34375 | 4 | [] | no_license | sort_list = [2,5,3,1,7]
print sorted(sort_list) # Method 1
after_sort = sort_list.sort()
print after_sort # None
sort_list.sort()
print sort_list #Method 2
# Sort is only used for list!
# Sort does not return any value but it changes from the original list.
# eg Sort
aList = [123,"xyz","abc","zara"]
aList.sort()
... | true |
308a9e0f6cf119a30ed7585ab99bdbd882fc3318 | runawayhorse001/PyAudit | /test/test.py | UTF-8 | 1,284 | 2.84375 | 3 | [] | no_license | from PyAudit.basics import missing_rate, zero_rate, dtypes_class
from PyAudit.basics import feature_variance, freq_items_df, feature_len
from PyAudit.basics import corr_matrix,numeric_summary, category_summary
import pandas as pd
import os, sys
output = os.path.abspath(os.path.join(sys.path[0])) + '/output'
print(outp... | true |
55f7a6244598e276411b15f29a038ab52c9d2b45 | BigeyeDestroyer/rnn-project | /RL/turing-machine/layers/ntm.py | UTF-8 | 4,046 | 2.515625 | 3 | [] | no_license | import h5py
import sys
sys.path.append('..')
from ntm_cell import *
from optimizers.optimizers import *
class NTM(object):
def __init__(self, input_dim=8, output_dim=8, mem_size=128,
mem_width=20, layer_sizes=[100], num_reads=1,
batch_size=16, num_writes=1, shift_width=3,
... | true |
8c84902b962ae45467d26528790a44f6e6aae7f9 | kartikay-bagla/MiniVGGNet-Trainer | /helper.py | UTF-8 | 2,893 | 3.109375 | 3 | [] | no_license | from keras.preprocessing.image import img_to_array
import imutils
import cv2
import numpy as np
import os
class ImageToArrayPreprocessor:
def __init__(self, data_format= None):
self.data_format = data_format
def preprocess(self, image):
return img_to_array(image, data_format= self.data_format... | true |