blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
eb90de937217a3f1f359917a4c71544c495b97cf | Python | Dulou/leetcode-python | /Python/easy/1207. Unique Number of Occurrences.py | UTF-8 | 354 | 2.921875 | 3 | [] | no_license | class Solution:
def uniqueOccurrences(self, arr: List[int]) -> bool:
count = {}
for i in arr:
count[i] = count.get(i, 0) + 1
occur = {}
for k in count:
if count[k] in occur:
return False
else:
occur[count[k]... | true |
14632a42a4a3486a74750a2fdd202f7176700a33 | Python | pnq93/PythonProject | /neurons/neuronNetworkPyBrain.py | UTF-8 | 1,243 | 2.8125 | 3 | [] | no_license | from pybrain.datasets.supervised import SupervisedDataSet
from pybrain.structure.connections.full import FullConnection
from pybrain.structure.modules.linearlayer import LinearLayer
from pybrain.structure.modules.sigmoidlayer import SigmoidLayer
from pybrain.structure.networks.feedforward import FeedForwardNetwork
from... | true |
06b36525eff80f22fae8661933d4740968d9e488 | Python | daren996/HCI_AI_Med | /Analysis/Symptoms.py | UTF-8 | 2,415 | 2.640625 | 3 | [] | no_license |
import json
import jieba
source_path = "../DataSet/"
data_set = "dial.txt"
rst_file_name = "rst.txt"
# symptom
symptoms = {}
with open(source_path + rst_file_name, "r") as in_file:
for line in in_file.readlines():
rst = json.loads(line)
if not rst["attachment_dict"]:
continue
... | true |
619ef50e024103654888968a3304bc1b732dcfa8 | Python | kosciej16/other | /playground/python/morsels/adv/fuzzy_string.py | UTF-8 | 765 | 3.65625 | 4 | [] | no_license | import unicodedata
def normalize_caseless(text):
return unicodedata.normalize("NFKD", text.casefold())
class FuzzyString(str):
def __eq__(self, other):
return normalize_caseless(self) == normalize_caseless(other)
def __ne__(self, other):
return not self.__eq__(other)
def __lt__(sel... | true |
353bae111fe729ae856fabfa76d9e2e36018ac90 | Python | EYRA-Benchmark/comic | /app/tests/storage.py | UTF-8 | 5,092 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | import os
from io import BytesIO, StringIO
from django.conf import settings
from django.core.files import File
from django.core.files.storage import FileSystemStorage
def fake_file(filename, content="mock content"):
""" For testing I sometimes want specific file request to return
specific content. This is m... | true |
8ec13544b620f6e0afd0441f7075e8796541223f | Python | gabrielaporti88/Proyecto_3 | /proyecto_final.py | UTF-8 | 13,210 | 2.828125 | 3 | [] | no_license | """ PROYECTO FINAL """
import os
import sys
import librosa
import librosa.display
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pywt
import scipy.signal as signal
from scipy.stats import ttest_ind, mannwhitneyu
import seaborn as sns
from linearFIR import filter_design, mfreqz
from wavel... | true |
2fefb9d3b95488677debd2e8d7dadd7adc3b2129 | Python | heithof3/notes | /python/bottage/module-2/python-env/invoice.py | UTF-8 | 5,453 | 3.78125 | 4 | [] | no_license | # # class Invoice: #class are object of data and function within them
# # def greeting(self): # when using classes you need to have self in the pram()
# # return 'Hi there'
# # # Instasation (check spelling)
# # inv_one = Invoice()
# # print(inv_one.greeting())
# # inv_two = Invoice()
# # print(inv_... | true |
648d93a1dc4fe46842fd0b2a4b43fdc54e2ebf6e | Python | nicktsan/elliptic | /elliptic.py | UTF-8 | 5,288 | 3.5 | 4 | [] | no_license | """
Nicholas Tsang
V00805615
Program for obtaining a normalized elliptic transfer function and plotting
its loss characteristic.
All equations are based off of the ones found in the textbook:
"Digital Signal Processing: Signals, Systems, and Filters"
written by Andreas Antoniou.
Run this program by navigating to t... | true |
68c22055d795a2b5d4ab8dc2f8b6b6235dc91698 | Python | rohithpr/genetic-algorithms | /2d-particle/config.py | UTF-8 | 1,172 | 2.90625 | 3 | [
"MIT"
] | permissive | # The possible moves that can be made by the particle
MOVES = ['l', 'r', 'u', 'd', 's']
# No. of generations
GENERATIONS = 500
# No. of specimens per generation
POPULATION = 100
# Number of moves per turn, per particle
CHROMOSOME_LENGTH = 50
# Probability that a given move in the chromosome will be replaced with a ... | true |
f747e8481bfa646ee976716e024f6067c1f4a383 | Python | rosalesjahaziel/otus_integration_test | /Test_assessment_response.py | UTF-8 | 3,966 | 2.8125 | 3 | [] | no_license | import json, unittest
from regexValidation import AssessmentIdRegexValidation, AssessmentTypeRegexValidation, AssessmentGradingValidation, AssessmentDistrictValidation, AssessmentTypeNameValidation
class Test_assessment_by_id(unittest.TestCase):
assessment_id = 202089
FilePath = "assessmentResponse.json"
... | true |
e77f206d87ae431548c7941e21be67657f95a5ef | Python | JemboDev/cs50-x-2020 | /pset6/readability/readability.py | UTF-8 | 803 | 3.9375 | 4 | [] | no_license | # https://cs50.harvard.edu/x/2020/psets/6/readability/
# Program that computes the approximate grade level needed to comprehend some text (31.05.20)
from cs50 import get_string
# getting input from user
text = get_string("Text: ")
letters, words, sentences = 0, 0, 0
# iterating the text
for char in text:
if cha... | true |
8315bdadb65d95c2390e92dbc234d8aa67248c67 | Python | tomdotorg/docker-weewx | /dist/weewx-4.0.0b1/bin/wee_import | UTF-8 | 38,763 | 2.71875 | 3 | [
"GPL-3.0-only",
"GPL-1.0-or-later",
"Apache-2.0"
] | permissive | #!/usr/bin/env python
#
# Copyright (c) 2009-2019 Tom Keffer <tkeffer@gmail.com> and
# Gary Roderick
#
# See the file LICENSE.txt for your rights.
#
"""Import WeeWX observation data from an external source.
Compatibility:
wee_import can import from:
- a Comma Separated Val... | true |
011cb2460afff8b219bb4a99578c760007be323f | Python | Athanasios-G-Ritas/python_arduino_projects | /tkinter_led.py | UTF-8 | 852 | 3.09375 | 3 | [] | no_license | from pyfirmata import Arduino, util
from tkinter import *
board = Arduino("COM4")
it = util.Iterator(board)
it.start()
led = board.get_pin("d:13:o")
m = Tk()
def led_on():
while True:
led.write(1)
refresh(m)#this causes a problem which can removed by removing 'm'
#but then the window will clos... | true |
849a78321e29df40c07b1274c6d5b08122c794ea | Python | ikeshou/PyEus | /pyeus.py | UTF-8 | 55,990 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python2
# coding: utf-8
"""
ライブラリバージョンのpyeus
"""
import socket, shlex, subprocess, time, atexit, struct
import re
import pyeus_util as util
from pyeus_util import EusError
if __name__ == "pyeus":
command = "irteus eus_server.l"
eus_process = subprocess.Popen(shlex.split(command)) # shlex.s... | true |
a4288c0d72aa6973b307197ed1699f1da8075233 | Python | orangeblock/euler | /problems/prob7/prob7.py | UTF-8 | 738 | 3.59375 | 4 | [] | no_license | # http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
def is_prime(num, repeat=5):
if num == 2 or num == 3: return True
if num <= 1 or num % 2 == 0: return False
s, d = 0, num-1
while d % 2 == 0:
s, d = s+1, d//2
from random import randint
for _ in xrange(repeat):
... | true |
fd66d8f096bef4808d0784f7f5b1246586a3678a | Python | DaiJitao/machine_learning | /NLP/word2vector/mycode/myword2vec.py | UTF-8 | 5,534 | 2.8125 | 3 | [] | no_license | import os
import os
import numpy as np
import zipfile
import collections
import random
import tensorflow as tf
# http://mattmahoney.net/dc/textdata.html
dataset_link = 'http://mattmahoney.net/dc/text8.zip'
zip_file = 'text8.zip'
def read_data(text8):
with open(text8, encoding='utf-8', mode='r') as fp:
re... | true |
62adc4372f9afa72a7b7da07963012c2ad9effdc | Python | Educorreia932/FEUP-LBAW | /database/population/download_images.py | UTF-8 | 1,335 | 2.65625 | 3 | [] | no_license | import json
import sys
from image_processing import ImageProcessor
# Constants
root = 'database/population/'
populationUserInfoFilename = root + 'population_users.json'
populationAuctionInfoFilename = root + 'population_auctions.json'
# Config
download_users = True
start_users = 1
end_users = None
download_auction... | true |
17c2dd4ff1b97fcd81338ec09f943faf5a3a4a57 | Python | cos30degreees/pythonlearning | /simple/loop-through-string.py | UTF-8 | 262 | 4.21875 | 4 | [] | no_license | print('Looping through a list')
fruits = ('apple','banana','orange','pineapple','mango')
for fruit in fruits:
print("Here's an item:",fruit)
print()
print('Looping through a string')
name='Billy Jones'
for char in name:
print("Here's an item:",char)
| true |
707b48db9cd12180d0d4c1dbcec368ff8a12b8fb | Python | nbdyn/DeepLearning_FlowerRecognition | /input_data.py | UTF-8 | 5,318 | 2.703125 | 3 | [
"MIT"
] | permissive | # coding:utf-8
import os.path
import sys
import re
import os
import json
import tensorflow as tf
import numpy as np
from sklearn import preprocessing
import pickle as pickle #python pkl 文件读写
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
class MyData():
def __init__(self):
self.... | true |
8526e2354451d49658b03e9927351c52975a607d | Python | halekyl/261-A2 | /dynamic_array.py | UTF-8 | 13,711 | 4.34375 | 4 | [] | no_license | # Course: CS261 - Data Structures
# Student Name: Kylee Hale
# Assignment: #2 Part 1 Dynamic Array
# Description: Program that implements a Dynamic Array class.
class DynamicArrayException(Exception):
"""
Custom exception class to be used by Dynamic Array
DO NOT CHANGE THIS METHOD IN ANY WAY
"""
p... | true |
3284c52be8464f11236699fba1b582951be2aca2 | Python | michal-franc/CodingKatas | /cracking-coding-interviews/arrays/test_string_permutation.py | UTF-8 | 925 | 3.71875 | 4 | [] | no_license | import unittest
def is_permutation(main, check):
if len(main) != len(check):
return False
return sorted(main) == sorted(check)
class SimpleTest(unittest.TestCase):
def test_crude(self):
main_string = "abzy"
check_string = "zyba"
expected_result = True
actual_res... | true |
7e93b1833a44c88e67adc3467e60fff3afcafa35 | Python | glennpierce/horus | /tests/datetime_test.py | UTF-8 | 639 | 2.65625 | 3 | [] | no_license | #!/usr/bin/python
import datetime
from pytz import timezone
import pytz
utc = pytz.utc
uk = timezone('Europe/London')
tz = timezone('America/St_Johns')
dt = datetime.datetime(year=2012, month=6, day=1, hour=14, minute=1, second=1, tzinfo=utc)
print dt.astimezone(uk).astimezone(utc)
dt = datetime.datetime(year=201... | true |
84a58dd4c37e96092f551662fc27f13fe354262d | Python | sherryxiata/SwordOffer | /Str/ReplaceSpace.py | UTF-8 | 1,939 | 4.40625 | 4 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2019/11/29 19:56
# @Author : wenlei
'''字符串:替换空格
请实现一个函数,将一个字符串中的每个空格替换成“%20”。
例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
'''
#解法1:直接替换
class Solution:
# s 源字符串
def replaceSpace(self, s):
# write code here
s1 = s.replace(' ','%2... | true |
8c67e422cd4df22ec62ed9d075f7ba09f2530feb | Python | simranjeetdua/WebCamMotionDetector | /Practice/script.py | UTF-8 | 1,364 | 3.546875 | 4 | [] | no_license | # practice script to get familiar with opencv library.
import cv2 #importing the open source computer vision library
img=cv2.imread(r"C:\Users\Simranjeet\Desktop\WebCamMotionDetector\Practice\mountains.jpg",0) #reading(imread==image read) the image from the project folder and giving argument as 0 to read the image in... | true |
25d2532574bb3d0bcae8ff4e28a22cd2083007dc | Python | maxmiles/WOTD_Discord | /main.py | UTF-8 | 13,011 | 2.734375 | 3 | [] | no_license | import discord
from decouple import config
from urllib.request import urlopen
import time
from bs4 import BeautifulSoup
import requests
from PyDictionary import PyDictionary
url = "https://www.merriam-webster.com/word-of-the-day/"
req = requests.get(url)
soup = BeautifulSoup(req.text, "html.parser")
psoup = soup.prett... | true |
14762fec9a0a69f6701b81e1516a74dd8bdf4819 | Python | DonghyunSung-MS/motion_filter | /py36/assets/scale_file.py | UTF-8 | 932 | 2.765625 | 3 | [] | no_license | import os
from numpy import float64
asset_dir = os.path.dirname(os.path.abspath(__file__))
file = os.path.join(asset_dir, "Vive_Tracker.obj")
new_file = os.path.join(asset_dir, "Vive_Tracker_meter.obj")
new_file = open(new_file, "w")
def isDigit(x):
try:
float(x)
return True
except ValueError... | true |
74c06394e75614e6559dd8de75af6f1050832290 | Python | yatengLG/leetcode-python | /question_bank/zi-fu-chuan-de-pai-lie-lcof/zi-fu-chuan-de-pai-lie-lcof.py | UTF-8 | 1,560 | 3.53125 | 4 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
# @Author : LG
"""
执行用时:220 ms, 在所有 Python3 提交中击败了34.50% 的用户
内存消耗:18.6 MB, 在所有 Python3 提交中击败了49.56% 的用户
解题思路:
回溯。将字符串转为列表,排序后,跳过重复元素
"""
class Solution:
def permutation(self, s: str) -> List[str]:
n = len(s)
s = list(s)
s.sort()
result = []
def ... | true |
6dc976f4598be80b6bfa355dedb754d8039be160 | Python | leantony/learing-python | /files.py | UTF-8 | 133 | 3 | 3 | [] | no_license | data = open('alice.txt', 'r')
content = data.read()
i = 0
s = []
for line in content.split():
i +=1
s.append(line)
print(len(s))
| true |
6ebc0b4117ff6107abffc33e52bd3171731899b8 | Python | Grinch101/data_structure | /data_structures/Hash.py | UTF-8 | 5,773 | 3.703125 | 4 | [] | no_license | # Although searching # for an element in a hash table can take as long as searching
# for an element in a linked list O(n) time in the worst case—in practice, hashing performs extremely
# well. Under reasonable assumptions, the average time to search for an element in
# a hash table is O(1).
# The downside of direct ... | true |
dce76233d1d1f3b20c1e3747114fbe124e623ac0 | Python | matejm/advent-of-code-2020 | /day10.py | UTF-8 | 686 | 3.28125 | 3 | [] | no_license | import sys
l = [0]
for line in sys.stdin:
n = int(line.strip())
l.append(n)
l.sort()
l.append(l[-1] + 3)
jolt1 = 0
jolt3 = 0
for i in range(1, len(l)):
diff = l[i] - l[i - 1]
if diff == 1:
jolt1 += 1
elif diff == 3:
jolt3 += 1
elif diff > 3:
print('Invalid')
... | true |
33f3654b5c12aca2776cdc44d89295767d5e1bf8 | Python | oozk/pyeuler | /pyeuler/p106.py | UTF-8 | 800 | 3.359375 | 3 | [] | no_license | from math import factorial
def p106(n):
n_choose_r = lambda n, r: factorial(n) / factorial(r) / factorial(n-r)
totaltests = lambda n: sum(n_choose_r(n, i) * n_choose_r(n - i, j)
for i in range(1, n)
... | true |
b234759d8f904172619536c113c3a18b9ccefb9f | Python | Mrsterius/python_training | /merge_sort/merge_sort.py | UTF-8 | 752 | 3.203125 | 3 | [] | no_license | import sys
n = sys.stdin.read()
arr = [int(x) for x in sys.stdin.read().split()]
def merge(first, second):
i = 0
j = 0
li = []
while (i < len(first) and j < len(second)):
if (first[i] < second[j]):
li.append(first[i])
i += 1
else:
li.append(second[j])... | true |
34c22148e0382d618fe33f1c7c055beafdf667a4 | Python | kozobrodov/algcomplexity | /sort.py | UTF-8 | 732 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
def sort(data):
# Implement your sorting algorithm here
# `data` contains array of integer numbers
# This function must return sorted array
return data
def sort_data():
data = []
with open('data.txt', 'r') as f:
for line in f... | true |
9f7a36ac7965a0b2a52d61a5e2d42ac053f94366 | Python | Mohammed-wsabi/b00401062.github.io | /Projects/strp/Evaluator.py | UTF-8 | 3,669 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
from numpy import random
from pandas import (DataFrame, Series, concat)
from sklearn.metrics import confusion_matrix
from strp.Constants import *
class Evaluator:
def __init__(self, preprocessor):
self.preprocessor = preprocessor
self.title = "".join([c for c in preprocessor... | true |
89933366dd0dfdadbc329f2bb276f99c135b89e0 | Python | SimonAble/django_exam | /apps/mainApp/models.py | UTF-8 | 3,731 | 2.578125 | 3 | [] | no_license | from __future__ import unicode_literals
from django.db import models
from datetime import datetime
import re
now = str(datetime.now())
EMAILREGEX = re.compile(r'^[a-zA-Z0-9.+-]+@[a-zA-Z0-9_.+-]+.[a-zA-Z]+$')
# Create your models here.
#<<------------------------USER MANAGER CLASS------------------------>>
#Create ... | true |
dd66b25f7374c64c61527f89339346ccf5ff32a7 | Python | Anritab/Olymp79 | /Bank.py | UTF-8 | 109 | 2.96875 | 3 | [] | no_license | m=int(input())
p=int(input())
y=int(input())
for i in range(0, y):
a=m/100*p
m=m+a
m=int(m)
print(m)
| true |
2a852ae1ba000030edf8b8c9faae0b8f55fddbdc | Python | AndreyVialichka/infa_2021_velichko | /lab3/1_draw.py | UTF-8 | 1,393 | 2.765625 | 3 | [] | no_license | import pygame
from pygame.draw import *
pygame.init()
FPS = 30
screen = pygame.display.set_mode((400, 400))
bg_color = (230, 230, 230)
screen.fill(bg_color)
N = 10
white = (255, 255, 255)
red = (255, 0, 0)
black =(0, 0, 0)
green = (9, 148, 65)
brown = (101, 67, 33)
blue = (0, 0, 176)
yellow = (255,204,0)
sky_blue = ... | true |
6108248ee53676b802f46251a6ed8d58a032c5a3 | Python | WuLC/LeetCode | /Algorithm/Python/477. Total Hamming Distance.py | UTF-8 | 1,456 | 3.140625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Author: WuLC
# @Date: 2016-12-19 17:44:48
# @Last modified by: WuLC
# @Last Modified time: 2016-12-19 19:43:49
# @Email: liangchaowu5@gmail.com
# naive solution and deal with duplicate numbers
# still TLE
from collections import Counter
class Solution(object):
def totalHammingDista... | true |
e5ee05d6e4891b4726515ba718cbb5c68e16c884 | Python | cole0227/Terrain-Project | /Python Tile Generation/main_v1.py | UTF-8 | 5,623 | 3.015625 | 3 | [] | no_license | import random
import thread
import time
from numpy import *
import pylab
import scipy
import scipy.misc
from functions import *
#
# Water-based Erosion takes place in four phases
# 1. Adding new water
# 2. Water eroding the rock
# 3. Water transporting itself and the sediment
# 4. Water evaporates
# 5. depositing s... | true |
ab36c3d2e3d08aa26ca10259d183feb42bbf5af2 | Python | vikram-vijay/Exercism_python | /allergies/allergies.py | UTF-8 | 544 | 3 | 3 | [] | no_license | class Allergies:
def __init__(self, score):
self.score = score
self.all_allergens_dict = {'eggs': 1, 'peanuts': 2, 'shellfish': 4, 'strawberries': 8, 'tomatoes': 16,
'chocolate': 32,
'pollen': 64, 'cats': 128}
def allergic_to(self, allerge... | true |
b58d698dac29019777ec8a59e0498431217e5061 | Python | ffffffuck/Jumptopy | /bigdata/hitomi.py | UTF-8 | 4,810 | 2.8125 | 3 | [] | no_license | #히토미 크롤러
import os
import sys
import requests
import time
import multiprocessing
import urllib.request
from multiprocessing import Pool
from requests import get
from bs4 import BeautifulSoup
def rep(a): #파일 이름 특수문자 처리
rep=""
b = ['\\','/',':','*','?','"','<','>','|',' ']
for c in a:
if c in b... | true |
5e92400003362eb8c300f86394785d39443c4634 | Python | muditgupta68/Codewayy_python_series | /Python_Task5/quest 4.py | UTF-8 | 627 | 3.5625 | 4 | [] | no_license | # ----------------------------------------------------START-------------------------------------------------------------
# writing into file
# ----------------------------------------------------------------------------------------------------------------------
# writing th... | true |
d67b5ba2e0ebf7db9eea9e878f55a93c37c15865 | Python | carbon-ahs/python_OOPConceptPractice | /class_var_and_instance_var.py | UTF-8 | 653 | 3.5625 | 4 | [] | no_license | class AnyClass:
class_var = 100
def __init__(self):
self.instance_var1 = 10
self.instance_var2 = 20
a = AnyClass()
b = AnyClass()
print(f'a.class_var = {a.class_var} b.class.var = {a.class_var}')
AnyClass.class_var = 500
print(f'a.class_var = {a.class_var} b.class.var = {a.class_var}'... | true |
ab3f55597e90f1252c7d8055ebf374a096779680 | Python | urmilshah1/Leetcode | /246.py | UTF-8 | 518 | 3.90625 | 4 | [] | no_license | class Solution:
def isStrobogrammatic(self, num: str) -> bool:
d = {'0':'0','1':'1','6':'9','8':'8','9':'6'}
ans = ''
for n in num:
if n not in d:
return False
ans += d[n]
print(ans)
return ans[::-1] == num
#Crea... | true |
b12c214beb7dbdb5b193338c5420efd9408a0b23 | Python | madhulika9293/cspp1-assignments | /m22/assignment5/frequency_graph.py | UTF-8 | 677 | 4.375 | 4 | [] | no_license | '''
Write a function to print a dictionary with the keys in sorted order along with the
frequency of each word. Display the frequency values using “#” as a text based graph
'''
def frequency_graph(dictionary):
'''
Function to print out the frequency graph of a given dictionary
'''
dict_list = []
fo... | true |
f1d7b9681e1a8a537ba96026d70216a8369bff70 | Python | mirandamots/online-bowling | /online2.py | UTF-8 | 1,032 | 3.6875 | 4 | [] | no_license | '''
Created on Feb 24, 2016
@author: Miranda Motsinger
Evaluates and prints the current score of a bowling game as it recieves
rolls one-by-one. The current score is the combined score of each
complete (fully-totalled) frame at that point in the game. Manages a list
of rolls representing the current frame that needs ... | true |
e05fb18f9f2c361a5c98f82d9d9daa1f7c21dc24 | Python | helsonxiao/Algorithms-DataStructure | /Sort/QuickSort.py | UTF-8 | 1,519 | 3.609375 | 4 | [] | no_license | class Solution:
"""
@param A: an integer array
@return: nothing
"""
def Partition(self, L, low, high):
pivot_key = L[low]
while (low < high):
while low < high and L[high] >= pivot_key:
high -= 1
L[low] = L[high]
while low < high a... | true |
1061f405dabef4a203051a95aa184b85dcbdefb7 | Python | albinman/voice-conversion | /compute_mcd.py | UTF-8 | 3,846 | 2.59375 | 3 | [] | no_license | """
This module calculates the mel-cepstral distortion between synthesized
sampels and their reference samples based on Samuel Broughton's repository
https://github.com/SamuelBroughton/Mel-Cepstral-Distortion.
"""
import os
import librosa
import numpy as np
import math
import csv
alpha=0.65
fft_size=512
mcep_size=34
S... | true |
ea940d90a7a546ff3c84a205863a3fb6eeb70856 | Python | txqgit/LeetCode | /CodePython/Graph/1345_Jump Game IV.py | UTF-8 | 1,411 | 3.109375 | 3 | [] | no_license | class Solution:
def minJumps(self, arr) -> int:
from collections import defaultdict
def build_graph(edges):
graph = defaultdict(set)
for u, v in edges:
graph[u].add(v)
graph[v].add(u)
return graph
def create_edges(arr):
... | true |
1fe94f4f69aecc559e8b3b8b794f5879ba3bbaac | Python | Durrantula/autopipe | /src/autopipe.py | UTF-8 | 11,083 | 2.875 | 3 | [] | no_license | #!/usr/bin/env python3
import numpy as np
import pandas as pd
import os, sys
from pathlib import Path
import regex as re
import subprocess
def load_path(rel_path):
"""
Gets the exact file path relative to this script executable location
Used with a scripting environment (e.g. google colab or jupyter note... | true |
df8db7515a27787d63eb2d804a8d56d23309cd46 | Python | Manvesh-P/CodeVita_Catch22_problem. | /CodeVita_Catch22.py | UTF-8 | 1,349 | 3.25 | 3 | [] | no_license | forward = []
backward = []
distance_covered = 0
def ways_forward(f, b, t, fd, bd):
forward.append(f * t)
backward.append(b * t)
global distance_covered
distance_covered += (f - b)
if (distance_covered + f) >= fd:
forward.append((fd - distance_covered) * t)
return
... | true |
b833c245667e13ae132d020d5fda82398b45c36f | Python | 542774114/taichi_ray_tracing | /3_1_blinn_phong_with_shadow.py | UTF-8 | 4,896 | 2.53125 | 3 | [] | no_license | import taichi as ti
import numpy as np
import argparse
from ray_tracing_models import Ray, Camera, Hittable_list, Sphere, PI
ti.init(arch=ti.gpu)
# Canvas
aspect_ratio = 1.0
image_width = 800
image_height = int(image_width / aspect_ratio)
canvas = ti.Vector.field(3, dtype=ti.f32, shape=(image_width, image_height))
li... | true |
defdf854da148ea39a38337dc049a1bc0aacf088 | Python | vnpavlukov/Study | /Geekbrains/1 четверть/Алгоритмы и структуры данных на Python. Базовый курс/Lesson_1/Урок 1. Пример практического задания/task_5.py | UTF-8 | 3,267 | 4.40625 | 4 | [] | no_license |
"""
Задание 6.
Задание на закрепление навыков работы со стеком
Примечание: в этом задании вспомните ваши знания по работе с ООП
и опирайтесь на пример урока
Реализуйте структуру "стопка тарелок".
Мы можем складывать тарелки в стопку и при превышении некоторого значения
нужно начать складывать тарелки в новую стопку... | true |
698b237c8cf614d1026c7ea86e003c87b4efa455 | Python | Lucie23/pyladies | /10/homework_meal.py | UTF-8 | 534 | 3.875 | 4 | [] | no_license | class Meal:
def __init__(self, name):
self.name = name
def eat(self, food):
print("{} are tasty.".format(food))
class breakfast(Meal):
def food(self):
print('{} are healthy.'.format(self.name))
class dinner(Meal):
def food(self):
print('{} are from Italian cuisine.'.fo... | true |
64acfbcfd7a348539fac9168a36d1e88bc0cac48 | Python | navin106/20186106_cspp-1 | /cspp1-assignments/GuessMyNumber/guess_my_number.py | UTF-8 | 635 | 3.796875 | 4 | [] | no_license | '''
#gnuess My Number Exercise
@author = navin106
guessing game
'''
def main():
'''
function to find correct number
'''
low_n = 0
mid_n = 50
high_n = 100
i = 'l'
while i != 'c':
print(mid_n)
i = input("enter 'h' if gnuess is too high,\
'l' if i... | true |
b85616544992dcb5e395c2a68635a9aac8d5ab8f | Python | Jules-Boogie/controllingProgramFlow | /Skip/func.py | UTF-8 | 1,481 | 4.71875 | 5 | [] | no_license | """
Module with for-loops that loop over positions.
Author: Juliet George
Date: 8/3/2020
"""
def skip(s,n): #for-loop
"""
Returns a copy of s, only including positions that are multiples of n
A position is a multiple of n if pos % n == 0.
Examples:
skip('hello world',1) returns 'hello world... | true |
dbc7cf97624162494c81c4a135e971c5ebed01e5 | Python | midaef/Stone_Scissors_Paper | /main.py | UTF-8 | 3,022 | 3.65625 | 4 | [] | no_license |
from ezprint import p
import random
import time
import os
def win(isDrow = False, whowin = 'Player 1'):
cls()
p('Rock')
time.sleep(0.5)
p('Scissors')
time.sleep(0.5)
p('Paper')
time.sleep(0.5)
p('1')
time.sleep(0.5)
p('2')
time.sleep(0.5)
p('3')
time.sleep(0.5)
if isDrow:
print('Drow')
else:
print... | true |
1dbfa0c0305b10421a7b314d761417d3ba8c6396 | Python | renyi1314/Source-code | /plus/网络编程/进程/Pool_僵尸进程2.py | UTF-8 | 209 | 2.65625 | 3 | [] | no_license | import time
from multiprocessing import Pool
def genProcess(n):
print("Test---{n}".format(n))
time.sleep(1)
p = Pool(10)
for i in range(100):
p.apply_async(genProcess, (i,))
p.close()
p.join()
| true |
67fc51741faa51d265d4452084bf62eb7ca2c4e0 | Python | Donggexiu/Python_learning_path | /进程和线程/练习题.py | UTF-8 | 1,210 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env/python
# _*_coding:utf-8_*_
# @Time : 2018/12/7 11:53
# @Author : Dxd
# @Site :
# @File : 练习题.py
# @Software: PyCharm
# 练习题:改写下面程序,分别实现下述打印效果
from multiprocessing import Process
import time
import random
def task(n):
time.sleep(random.randint(1,3))
print('-------->%s' %n)
if __name__ == '__mai... | true |
678538d4077b455f4cfd6ab6b6c0791238612caa | Python | webbpinner/openrvdas | /logger/writers/text_file_writer.py | UTF-8 | 5,750 | 3.140625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"CC-BY-NC-4.0",
"BSD-2-Clause",
"MIT"
] | permissive | #!/usr/bin/env python3
import os.path
import sys
import datetime
from os.path import dirname, realpath
sys.path.append(dirname(dirname(dirname(realpath(__file__)))))
from logger.utils.formats import Text # noqa: E402
from logger.writers.writer import Writer # noqa: E402
class TextFileWriter(Writer):
"""Write ... | true |
8dd3900e7d4f99f85f0095359b3c4fdb0215b1c4 | Python | tzahishimkin/extended-hucrl | /rllib/environment/mujoco/reacher_3d.py | UTF-8 | 5,890 | 2.625 | 3 | [
"MIT"
] | permissive | """Mujoco Reacher environment from https://github.com/kchua/handful-of-trials."""
import os
import numpy as np
import torch
from gym import utils
from torch import cos, sin
from rllib.reward.state_action_reward import StateActionReward
class ReacherReward(StateActionReward):
"""Reward of Reacher Environment.""... | true |
70dad9d4220ff3173068931f6995d8c328250237 | Python | roberodin/ha-samsungtv-custom | /custom_components/samsungtv_custom/samsungctl_080b/upnp/UPNP_Device/xmlns.py | UTF-8 | 597 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
ENVELOPE_XMLNS = 'http://schemas.xmlsoap.org/soap/envelope/'
def strip_xmlns(root):
def iter_node(n):
nsmap = n.nsmap
for child in n:
nsmap.update(iter_node(child))
return nsmap
xmlns = list('{' + item + '}' for item in iter_node(root).values())
... | true |
738d8a94b77851db8c50c03ae9076e2a270cf9d8 | Python | sudhi001/wireless-debugging | /server/tests/parser_tests.py | UTF-8 | 5,049 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | """
Tests for the Parsing Library
"""
import json
from datetime import datetime
import parsing_lib
def _test_case_parser(test_case):
""" Parses test case JSON.
Corrects some of the default parsing functionality to work better with the
given test cases
Args:
test_case: the test case to parse... | true |
332f9f9769d81e2f468a764074b5e66d8569e84f | Python | wesnjazz/CS-370 | /Hw05/hw_practice01_backup/code/evalBoVW.py | UTF-8 | 1,153 | 2.875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import utils
from constructDictionary import constructDictionary
from encodeImage import encodeImage
from montageDigits import montageDigits
from linearTrain import linearTrain
from linearPredict import linearPredict
data = utils.loadmat('data.mat')
# convert the tr... | true |
6adba52ef91e4f135877827b04fa1babf2e2fb4b | Python | rprospero/pyAbel | /vf.py | UTF-8 | 1,151 | 2.703125 | 3 | [] | no_license | #!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
from scipy import misc
from scipy.fftpack import ifftshift,fftshift
from scipy.cluster.vq import kmeans2
import sqlite3
from sys import argv
def queryK(image,k):
shape = image.shape
mask = np.where(image==k)
return float(len(mask[0]))/sh... | true |
2e6bb73eca2ff3b9628d5f7fad182c7aa99ed640 | Python | TinaCXu/Leetcode | /206-reverse-linked-list.py | UTF-8 | 1,491 | 3.25 | 3 | [] | no_license | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
cur = head
cnt = 0
# loop
# 1 -> 2 -> 3 -> 4
#
# ppprev <- pprev <- prev ... | true |
dbe1a4ed7381abbf5f1c566514eeab9a932b16bb | Python | Mdrakibsarkar/Python_practice001 | /t11_set.py | UTF-8 | 789 | 3.484375 | 3 | [] | no_license | # sets value dosent change, define via () but access via [], retain only unique values -- imp
s = set()
#print(type(s))
l = [1,2,3,4,4,4]
l = [1,2,2,3,4,4,4]
set_list = set(l)
#print(set_list)
#print(type(set_list))
#set_list.add(5)
set_list.add(100)
#print(set_list)
#set_list.add(10)
#s1 = set_list.union({11,21})
# s... | true |
4f7171a192eee1763e4d6fa4781f0c1f6ea871e1 | Python | j0hnson-he/Moonlander | /landerFuncs.py | UTF-8 | 3,821 | 3.8125 | 4 | [] | no_license | # For every function write purpose statement and signature
# Project 2 - Moonlander Functions
#
# Author: Rohith Dara
# Instructor: S. Einakian
# Section: 01
#Show the necessary Welcome message when the program starts
#none->none
def showWelcome():
print ("Welcome aboard the Lunar Module Flight Simulator"... | true |
bb8ffde930ea5611af0e5922ed29ba0383968358 | Python | azuyes/HOG | /gradient.py | UTF-8 | 2,383 | 3.03125 | 3 | [] | no_license | import cv2 as cv
import copy
import numpy as np
def gaussian():
img = cv.imread('elev2.jpeg')
# 高斯滤波
# img_gray = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
img = np.float32(img) / 255.0 # 归一化
img_Guassian = cv.GaussianBlur(img, (5, 5), 0)
return img_Guassian
def conv1D(img, mask1D):
width = i... | true |
60abb81b42213df671be9e384f569d8e8f3196a2 | Python | WSJI0/BOJ | /10000-99999/15482.py | UTF-8 | 318 | 2.765625 | 3 | [] | no_license | a='0'+input()
b='0'+input()
dp=[[0 for _ in range(len(b)+1)] for _ in range(len(a)+1)]
ans=0
for i in range(1, len(a)):
for j in range(1, len(b)):
if a[i]==b[j]:
dp[i][j]=dp[i-1][j-1]+1
else:
dp[i][j]=max(dp[i-1][j], dp[i][j-1])
ans=max(ans, dp[i][j])
print(ans) | true |
2f6774618ede27766d633761e54a95a017f869b0 | Python | capncrockett/beedle_book | /Ch_06 - Functions/face_scrubber.py | UTF-8 | 1,634 | 3.9375 | 4 | [] | no_license | # face_scrubber.py
from graphics import *
import math
def draw_face(center, size, win):
eye_size = 0.15 * size
eye_off = size / 3.0
mouth_size = 0.8 * size
mouth_off = size / 2.0
head = Circle(center, size)
head.setFill("yellow")
head.draw(win)
left_eye = Circle(center, eye_... | true |
4c55bf81792f99edd1d65353c0d6a05e3cde13af | Python | Ragib95/my_work | /python_michigan/Assignment_RE.py | UTF-8 | 325 | 3.421875 | 3 | [] | no_license | #Finding Numbers in a Haystack
import re
head = raw_input('Enter file name: ')
files = open(head)
total = 0
count = 0
for line in files:
line = line.rstrip()
#print line
number = re.findall(('[0-9]+'), line)
#print number
for num in number:
num = int(num)
total = total + num
count = count + 1
print total, c... | true |
e8e7444107807b8a738dbc51fa593e6ca7553f69 | Python | wkown/pytest27 | /xml_html/BeautifulSoup/test_lxml.py | UTF-8 | 300 | 2.515625 | 3 | [] | no_license | # -*- coding:utf-8 -*-
__author__ = 'walkskyer'
from bs4 import BeautifulSoup
"""
测试 bs4使用lxml解析器
"""
if __name__ == "__main__":
f = open('../lxml/lxml.html/test.html')
soup = BeautifulSoup(f.read(),'lxml')
f.close()
print soup.select('a')
print type(soup.builder) | true |
0ede7af240868f4ffc5b5de00b549afa0c3bed73 | Python | hotoku/samples | /python/jinja/1.py | UTF-8 | 219 | 2.546875 | 3 | [] | no_license | from jinja2 import Template
tpl_text = "{{ greeting }}! from {{ name }}"
template = Template(tpl_text)
data = dict(
greeting="Hello World",
name="hotoku"
)
disp_text = template.render(data)
print(disp_text)
| true |
af5565f26fd986cc5e04bceb43c0d5500e82db04 | Python | GaspardQin/bigan_SRL | /representation_plot.py | UTF-8 | 12,920 | 2.6875 | 3 | [] | no_license | from __future__ import print_function, division
import json
import argparse
from textwrap import fill
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from sklearn.decomposition import PCA
# from sklearn.manifold import TSNE
# Faster implementation of t-... | true |
a61ba484d62855bb8a1a3ec8db17ce2bde79a76d | Python | comorina/Ducat_Assignment | /p36.py | UTF-8 | 21 | 2.546875 | 3 | [] | no_license | x=ord(10)
print(x)
| true |
53b602ce9a4efa57c82f2d461ebb5211bb43ef23 | Python | tpt5cu/python-tutorial | /libraries/scikit-learn/k_means/simple_2d.py | UTF-8 | 1,552 | 3.796875 | 4 | [] | no_license | """
https://stackabuse.com/k-means-clustering-with-scikit-learn/
https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
"""
import matplotlib.pyplot as plt
import numpy as np
from sklearn.cluster import KMeans
# The toy 2D dataset that I want to cluster.
X = np.array([[5,3], [10,15], [... | true |
27c715b21fc97b954fc1fc77bf81c1d9d984c6b1 | Python | mikewynn2/show_lineup-creator | /lineupv2.py | UTF-8 | 5,301 | 2.765625 | 3 | [] | no_license | import random
# barge knowledge
a = ['acro 2', 'acro 3', 'acro 4', 'acro 11', 'acro 14']
b = ['acro 1', 'acro 5', 'acro 9', 'acro 10', 'acro 12', 'acro 15']
c = ['acro 4', 'acro 6', 'acro 9', 'acro 11', 'acro 13', 'acro 14']
d = ['acro 5', 'acro 6', 'acro 7', 'acro 8', 'acro 10', 'acro 15']
e = ['acro 5', 'acro... | true |
020b9789885aeb4a537c64cf449e030880f9b662 | Python | JoeyBannenberg/RESSSPI | /General_modules/func_General.py | UTF-8 | 6,599 | 2.859375 | 3 | [
"MIT"
] | permissive |
#Miguel Frasquet
import numpy as np
#from matplotlib import pyplot as plt
def calc_hour_year(mes,dia,hora):
mes_string=("Ene","Feb","Mar","Apr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dec")
mes_days=(31,28,31,30,31,30,31,31,30,31,30,31)
num_days=0
cont_mes=mes-1
if mes<=12:
... | true |
3080be1432a9102866f088103c31b7c6a6474922 | Python | zzeden/Learn-Python | /selfpy/6.2.0.py | UTF-8 | 142 | 2.96875 | 3 | [] | no_license | my_subject = 'chemistry'
chemical_elements = ["hydrogen", "helium", "lithium", "beryllium"]
print(my_subject * 4)
print(chemical_elements * 2) | true |
c123099fece355e06267a22d6b4070883968b615 | Python | rishirelan/design_embeddings_idetc_2016 | /deep_network.py | UTF-8 | 22,085 | 2.6875 | 3 | [
"MIT"
] | permissive | """
Builds and trains autoencoders.
Author(s): Wei Chen (wchen459@umd.edu)
"""
from functools import partial
from keras.models import Sequential
from keras.layers.core import Dense, AutoEncoder
from keras.layers import containers
from keras.optimizers import SGD
from keras.regularizers import l1, l2
from sklearn.metr... | true |
32c00299ffe2406bd638c1a38cc251365d8f0d65 | Python | rjherrera/IIC2233 | /Actividades/AC27/main.py | UTF-8 | 1,974 | 3.125 | 3 | [] | no_license | # coding=utf-8
import requests
from argparse import ArgumentParser
# Debe tener los atributos:
# * _id (string)
# * name (string)
# * votes (diccionario string: int)
class Table:
def __init__(self, json_dict):
self._id = json_dict['_id']
self.name = json_dict['name']
self.votes = json_d... | true |
1e1b7ee4c59f6525628b65120793a0978dadbd9d | Python | amrgharib/my_leetcode_challenges_solutions | /Python/118_pascals_triangle_ii.py | UTF-8 | 326 | 3.03125 | 3 | [] | no_license | class Solution:
def getRow(self, rowIndex: int) -> List[int]:
if rowIndex == 0:
return [1]
r1 = [1,1]
for i in range(3, rowIndex+2):
r2 = [1] * i
for j in range(1,i-1):
r2[j]= r1[j-1]+r1[j]
r1 = r2
retu... | true |
5201a2184a53154b0905a58978eb0ff607129b85 | Python | yz-chen18/AndrewML | /PCA.py | UTF-8 | 1,141 | 3.078125 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
def loadData(filename):
dataArr = []
fr = open(filename, 'r')
for line in fr.readlines():
line = line.strip().split()
dataArr.append([float(data) for data in line])
return np.array(dataArr)
def draw(datamat, reconMat):
x1 = [data[... | true |
793cb711e7a17185244b2ac7d49793becaeb0ba9 | Python | my-xh/DesignPattern | /03行为型模式/23访问模式/访问模式_old.py | UTF-8 | 1,131 | 3.84375 | 4 | [] | no_license | from abc import ABCMeta, abstractmethod
class DesignPatternBook:
"""《从生活的角度解读设计模式》一书"""
@property
def name(self):
return '《从生活的角度解读设计模式》'
class Reader(metaclass=ABCMeta):
"""访问者(读者)"""
@abstractmethod
def read(self, book):
pass
class Engineer(Reader):
"""工程师"""
d... | true |
078437ea7ccf4eaf26ec6b4308cd1d516bd5432a | Python | romulovieira777/Programacao_em_Python_Essencial | /Seção 08 - Funções em Python/Exercícios da Seção/Exercício_03.py | UTF-8 | 643 | 5 | 5 | [] | no_license | """
3) Faça uma função para verificar se um número é positivo ou negativo.
Sendo que o valor de retorno será 1 se positivo, -1 se negativo
e 0 se for igual a 0
"""
def positivo_ou_negativo(number):
"""
Função que retorna o valor 1 caso o número recebido seja positivo,
-1 se negativo e se for igual a 0
... | true |
e5c9f2249de11a9f6055d833ff33a67f5a30d7a1 | Python | L-avender/AID1905 | /PycharmProjects/python_file/month2/day14/data-dict.py | UTF-8 | 692 | 3.140625 | 3 | [] | no_license | """
将字典存入数据库中
"""
import pymysql
# 链接数据库
db=pymysql.connect(host='localhost',
port=3306,
user='root',
password='123456',
database='dict',
charset='utf8')
# 获取游标(操作数据库,执行sql语句)
cur=db.cursor()
f=open("dict.txt")
id=0
for lin... | true |
43493ca23456471bf42381734453f4e752a93c6e | Python | elad-allot/Udemy | /cake/recursive_string_permutations.py | UTF-8 | 902 | 3.625 | 4 | [] | no_license | def get_permutations(string):
# Generate all permutations of the input string
if len(string) <= 1:
return set([string])
all_chars_except_last = string[:-1]
last_char = string[-1]
permutations_of_all_chars_except_last = get_permutations(all_chars_except_last )
permutations = set()
... | true |
f914229748ec5ab665211df5d56934f93a51e83c | Python | JoseCaarlos/Python | /Seção 12 - Módulos e pacotes/pacotes.py | UTF-8 | 624 | 3.078125 | 3 | [] | no_license | """
Pacotes
Módulo -> É apenas um arquivo pyhton que pode ter diversas funções para utilizarmos;
Pacote -> É um diretório contendo uma coleção de módulos;
OBS: Nas versões 2.x do python, um pacote deveria conter dentro dele um
arquivo chamado __init.py
nas versões do Python 3.x, não é mais obrigatoria a utilização ... | true |
d3a56bae1ee6020966ddb81a1f7f3dd30f2ee645 | Python | tomoyk/feedChecker | /main.py | UTF-8 | 2,119 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import datetime
import feedparser
import os
import sys
import urllib.request
import time
from feeder import Feeder
argv=sys.argv
argv.sort()
def has_argv(check_name):
for a in argv:
# Has check_param on argv
if( a==check_name ):
return True
return False
def d... | true |
68772a11e43ac486390b2a8d275ff8ef6b08f555 | Python | MOON-CLJ/learning_python | /llm/exercises_1_3_10_ext_clj.py | UTF-8 | 1,209 | 3.34375 | 3 | [] | no_license | from link_stack import LinkStack
prior = {
'+': 0,
'-': 0,
'*': 1,
'/': 1
}
def divide_str(s):
l = []
last = None
for i in s:
if i in ["(", ")", "+", "-", "*", "/"]:
l.append(i)
elif i.isdigit():
if last and last.isdigit():
l[-1] +=... | true |
3148247d08dedc062a2d5753dc5b2f92c8ee6066 | Python | 15194779206/practice_tests | /education/A:pythonBase_danei/1:python基础/9:第九天/1.4:return判断是否为素数.py | UTF-8 | 875 | 4.125 | 4 | [] | no_license | #5定义函数,返回指定范围内的素数
def get_price(begin, end):
list_number = []
for number in range(begin, end+1):
if number < 2:
pass
else:
for num in range(2, number):
if number%num == 0:
break
else:
list_number.a... | true |
e1dc754d1762fa0508605e72826ef66bfe6dafc2 | Python | zyc1gq/1117 | /sklearn_lr.py | UTF-8 | 2,072 | 3.015625 | 3 | [] | no_license | #使用max,min等时间统计特征做分类测试
#需要重新做数据统计,使用逻辑回归
#单纯的统计特征可能无法应对扩缩容之类问题,流量波峰(等比增加,归一化可以解决)可以应对
import pandas as pd
import numpy as np
import pymysql
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn import linear_model, ... | true |
c7d9965cc3c95d9e36c3941bdcb05d51234f2815 | Python | L0919/leetcode | /test15.py | UTF-8 | 497 | 3.484375 | 3 | [] | no_license | # 合并两个有序链表 link:https://leetcode-cn.com/problems/merge-two-sorted-lists/
class Solution:
def mergeTwoLists(self, l1, l2):
res = ListNode(None)
node = res
while l1 and l2:
if l1.val<l2.val:
node.next,l1 = l1,l1.next
else:
node.n... | true |
a2f865b183c1146a91472dafaf8da6748059c0c7 | Python | mvelikikh/Keypirinha-Plugin-SQLPlus | /src/tns_provider.py | UTF-8 | 2,516 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | from os import environ
from os.path import join as pjoin
from pathlib import Path
import re
class TNSProvider(object):
aliases = []
alias_re = re.compile('^\s*(\w+)')
visited_files = set()
ifiles = set()
def get_tnsnames_location(self, sqlplus_location):
"""Obtain location of tnsnames.or... | true |
9c495e4a099d7ecf56b0707cb8b3d881a84a7b5d | Python | bplank/bleaching-text | /src/myutils.py | UTF-8 | 5,228 | 3.15625 | 3 | [] | no_license | __author__ = "bplank"
import nltk
from sklearn.base import TransformerMixin
import numpy as np
import json
PREFIX_WORD_NGRAM="W:"
PREFIX_CHAR_NGRAM="C:"
TWEET_DELIMITER = " NEWLINE "
def get_size_tuple(ngram_str):
"""
Convert n-gram string to tuple
:param ngram_str: "1-3" (lower and upper bound separat... | true |
9704929e8c15a7690ba3741f1d2c1b5e33937b33 | Python | scottespich/HPM573S18_ESPICH2_HW3 | /HW3.py | UTF-8 | 2,906 | 4.09375 | 4 | [] | no_license | #roblem 1:A Simple Hospital(Weight 1).
# We are interested in modeling a simple hospital where patients are admitted all
# together in the morning and are discharged all together in the evening. The hospital
# serves two types of patients: those who visit the emergency department and those who get
# hospitalized fo... | true |
9e207334214ccc5e21230f2968060a41ac170498 | Python | reed7/genesys_branching_tool | /myProgressBar.py | UTF-8 | 928 | 3.359375 | 3 | [] | no_license | """
Performance is awful
"""
from Tkinter import *
class MyProgressBar(Canvas):
def __init__(self, width=560, height=30, color="blue", outline_color="blue", bd=0):
Canvas.__init__(self, width=width, height=height, bd=bd)
self.progress_bar_width = width
self.progress_bar_color = color
... | true |
64949265dc4c2ab1ee330e13fe2d45ede7932889 | Python | Brausen42/RandomPython | /sim.py | UTF-8 | 4,194 | 3.359375 | 3 | [] | no_license | #!/usr/bin/python3
from tkinter import Tk,Canvas
import random,time
class Cell(object):
"""docstring for Cell."""
def __init__(self, x, y, color):
super(Cell, self).__init__()
self.pos = (x,y)
self.color = color
def getX(self):
return self.pos[0]
def getY(self):
... | true |
cdc9c8cc8faa4b34dd5b98d67cce5e5aebc9d939 | Python | Coscos12/Python_HW | /week4/problem4.py | UTF-8 | 275 | 2.765625 | 3 | [] | no_license | def my_encrypt(path, string):
new_lst = []
f = open(path + '/temp.bin', 'wb')
f.write(bytearray(string, 'utf-8'))
f.close()
f = open(path + '/temp.bin', 'r')
for i in f.read():
new_lst.append(ord(i))
f.close()
return new_lst
| true |