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 |
|---|---|---|---|---|---|---|---|---|---|---|
02035453cae6a233c35fa17d1ea61f48254bfa9d | zghafoori/Deep-Multi-Sphere-SVDD | /src/datasets/iterator.py | UTF-8 | 1,261 | 2.53125 | 3 | [
"MIT"
] | permissive | import numpy as np
from picklable_itertools import imap
from picklable_itertools.extras import partition_all
from fuel.schemes import BatchScheme
def iterate_batches(inputs, targets, batch_size, shuffle=False):
n = len(targets)
for (batch, idx) in indices_generator(shuffle=shuffle,
... | true |
9f7e3dcad4dcb381f428139b7ae705acd64bf5ec | hellboy0621/beautysoup | /guibing_sort.py | UTF-8 | 2,257 | 3.953125 | 4 | [] | no_license | '''
递归函数的两个要件:
1、基线条件
问题可以被分解为最小的问题,当满足基线条件时,递归就不再执行了
2、递归条件
有继续将问题分解的条件
它的整体思想是,讲一个大问题分解为一个个的小问题,知道问题无法分解时,再去解决
小问题,从而解决大问题
'''
# def merge_sort(arr, l, r):
# if l == r:
# return
# mid = (l + r) >> 1
# merge_sort(arr, l, mid)
# merge_sort(arr, mid + 1, r)
# ... | true |
0f71c3dd03130c49c998de2fc149a79cf73b4805 | lgan1989/leetcode | /Plus One.py | UTF-8 | 418 | 2.890625 | 3 | [] | no_license | class Solution:
# @param digits, a list of integer digits
# @return a list of integer digits
def plusOne(self, digits):
digits = digits[::-1]
i = 0
l = len(digits)
while i < l and digits[i] + 1 > 9:
digits[i] = 0
i = i + 1
if i == l:
... | true |
ece64f59d5f3005b8e54b2a2c4eba13b0df21d30 | NoOneUST/Aerial-photography-Semantic-Segmentation-with-Deeplab-v3-and-FCN-based-on-TensorFlow | /infer.py | UTF-8 | 3,277 | 2.734375 | 3 | [] | no_license | import sys
from matplotlib import pyplot as plt
import numpy as np
from PIL import Image
import tensorflow as tf
from deeplab.utils import get_dataset_colormap
LABEL_NAMES = np.asarray([
'background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus',
'car', 'cat', 'chair', 'cow', 'diningtable', '... | true |
e67c8599c730014295d04c1cc9f55c28ffd1268f | CFreeman217/School | /Instruments_ME352/Lab_11/me352_lab11.py | UTF-8 | 414 | 2.890625 | 3 | [] | no_license | import os
import re
import numpy as np
import matplotlib.pyplot as plt
def main():
for file_name in os.listdir('.'):
time, temp = np.loadtxt(file_name,
unpack=True,
skiprows=1)
plt.plot(time,temp)
plt.xlabel('Time')
... | true |
dd1700e2ea612da1612c7bef82f9c5db9312b470 | binggu56/lime | /lime/spin_boson.py | UTF-8 | 1,979 | 3.15625 | 3 | [
"MIT"
] | permissive | import numpy as np
import sys
class Spin_boson(object):
def __init__(self, beta, omegac=1.0, reorg=2.0):
self.beta = beta # temperature
self.omegac = omegac
self.reorg = reorg
def pure_dephasing(self, t):
"""
Compute the exact decoherence function for the pure-dephasing... | true |
b8ae07b5f5ddca6e7234573f4c4bfa3b317a83c3 | vibhuk16/6.00.1x | /Pset2/Problem1.py | UTF-8 | 1,111 | 4.28125 | 4 | [] | no_license | """
Paying Debt off in a Year
Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month.
The following variables contain values as described below:
1) balance - the outstanding balance on the credit card
2) annu... | true |
8438679bb82404bc23f366163575fba7f5c58ee1 | kasulani/jc | /jc/parsers/uname.py | UTF-8 | 3,576 | 3.171875 | 3 | [
"MIT"
] | permissive | """jc - JSON CLI output utility `uname -a` command output parser
Note: Must use `uname -a`
Usage (cli):
$ uname -a | jc --uname
or
$ jc uname -a
Usage (module):
import jc.parsers.uname
result = jc.parsers.uname.parse(uname_command_output)
Schema:
{
"kernel_name": string,
... | true |
7aba0ef8144bb9256160a665c92e72e4498344b8 | MSJYYT/code | /data structure&algorithm-python/tree/priority queue.py | UTF-8 | 376 | 3.359375 | 3 | [] | no_license | class PrioQueueError(ValueError):
pass
class PrioQue:
def __init__(self,elist=[]):
self._elems = list(elist)
self._elems.sort(reverse=True)
def enqueue(self,e):
i = len(self._elems) - 1
while i >= 0:
if self._elems[i] <= e:
i -= 1
else:... | true |
a8c1e014130a538a66f2073f30e321f6c9461e2e | tomosh22/practical-2 | /uniplot/analysis.py | UTF-8 | 717 | 3.296875 | 3 | [] | no_license | def average_len(records):
"""Returns the average len for records."""
totalLength = 0
for record in records:
totalLength += record["length"]
return round(totalLength / len(records))
def average_len_taxa(records,depth):
"""Returns the average length for each taxa, down to passed depth"""
... | true |
18388b2d87d3f15269523fd350d09658350b791a | kibrian/junk-repos | /anything.py/oopfile6.py | UTF-8 | 441 | 3.59375 | 4 | [] | no_license |
class Students:
def __init__(self,name,regNo,stdclass):
self.name=name
self.regNo=regNo
self.stdclass=stdclass
class brian(Students):
def stdclass(self):
print(brian)
class Geofry(Students):
def regNo(self):
print(Geofry)
student1=brian("kip","xxx09ax99","... | true |
9c252b3194f06806dd2752c778514eaea7377f74 | abucus/clustering-classification | /test/draw.py | UTF-8 | 428 | 2.8125 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
data = np.random.multivariate_normal([5, 5], [[1, 0], [0, 0.5]], 300)
plt.plot(*zip(*(data)), marker="8", ls='', markersize=8, markerfacecolor='w', markeredgecolor='b', markeredgewidth=2)
for i in data:
if(i[0] - i[1] > 0):
plt.text(i[0] - 0.01, i[1] - 0.... | true |
eaea47ace73e61448c864f77cb2e530d2aebbe72 | mauricio/python-examples | /lib/mat/so.py | UTF-8 | 132 | 3.1875 | 3 | [] | no_license | def quadrado( x ):
return x * x
def fatorial( n ):
if n == 1:
return 1
else:
return n * fatorial(n - 1) | true |
08266291ff65f2060a3cf4dc1fe5f2027ef9b3fb | yoloseem/padak | /padak/html5/tag.py | UTF-8 | 10,719 | 2.890625 | 3 | [
"MIT"
] | permissive | """:mod:`padak.html5.tags` --- HTML5 tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
class EmptyValue():
pass
class Element(object):
"""Base class of all of HTML tags."""
# The global attributes below can be used on any HTML5 element.
_global_attributes = (
'accesskey', 'class', 'contente... | true |
9c2f18251419213651ce345920b46f1574d16ecf | pxai/mocos | /src/04/ejercicios/4.0.py | UTF-8 | 151 | 2.6875 | 3 | [] | no_license | def dias ():
print("Buenos días")
def tardes ():
print("Buenos tardes")
def noches ():
print("Buenos noches")
dias()
tardes()
noches()
| true |
31588f0876f193687aaec3a9dff11e5647e59157 | rohithkutty/python-assign | /ex2.py | UTF-8 | 539 | 3.34375 | 3 | [] | no_license | import argparse
def isWhiteLine(line):
if line.strip() !="":
return line
elif line.strip() =="":
return True
elif " " and '\t' in line:
return True
elif line in ['\n', '\r\n']:
return True
else:
return line
if __name__ == "__main__":
parser = argparse.A... | true |
731a14f1dbfc682ed9fae1c25c895b750e31bbb1 | cuongmv88/ProjectEuler | /problem32.py | UTF-8 | 1,299 | 3.765625 | 4 | [] | no_license | import time
import math
def calculate_time(func):
def inner1(*args, **kwargs):
begin = time.time()
returned_value = func(*args, **kwargs)
end = time.time()
print("Total time taken in : ", func.__name__, end - begin)
return returned_value
return inner1
... | true |
e34637e266d935832d42af8799e96ce5a71f0ccf | funkybookends/udacity_courses | /cs215_intro_to_algorithms/actor_centraility.py | UTF-8 | 5,926 | 3.484375 | 3 | [] | no_license | #Take in imdb-1 and calculate the top 20 central actors
# using tha average centrality measurement
#centraility is defined as the average distance to all the other nodes
f = "imdb-4.tsv"
debug = False
debug_max_import = 3000
## imdb-1 through 4, each with a larger graph
##contains tab seperated values of the form
#Bl... | true |
ba55aabdfe13c04e9bede838749ec5b5ea1f56f3 | michaelcyng/python_tutorial | /assignment1/question5.py | UTF-8 | 146 | 2.53125 | 3 | [] | no_license | # TODO: Modify the last part of question 4 so that the following triangle is print out when
# the number of rows is 3.
# *
# ***
# *****
| true |
3e0afd631c9b131535c0b79bb1a9d260f7a07680 | libus1204/bigdata2019 | /01. Jump to python/chap05/5_5/239~243.py | UTF-8 | 586 | 4.03125 | 4 | [] | no_license | print(hex(234)) # 정수값을 입력 받아 16진수로 변환
a=3
print(id(3)) # 객체를 입력 받아 객체의 고유 주소값(레퍼런스)을 리턴
print(id(a)) # b = a = 3 이므로 셋다 같은 객체를 가리킴
b=a
print(id(b))
class Person: pass
a = Person()
print(isinstance(a,Person)) # a가 Person 의 클래스에 의해서 생성된 인스턴스임을 확인시켜 줌
b = 3
print(isinstance(b,Person)) # b 는 거짓
print(len('python')... | true |
7f67768c2fb8445b2b9317c250062b751cbee588 | LucasLiulu/DeepLearningAPIByLucas | /MLRLucas/MLR_model_eval.py | UTF-8 | 1,370 | 2.59375 | 3 | [] | no_license | # coding=utf-8
import tensorflow as tf
from sklearn.metrics import roc_auc_score
from MLR import get_data, MLRClass
import os
class Eval_MLR_Model(object):
def __init__(self):
self.mlr = MLRClass()
def evaluate(self, m=2):
_, _, X_test, y_test = get_data()
X_dim = X_test.shape[1]
... | true |
0ef3a2a725390bd949c87f3e3062acaed138d47b | YorickSpenrath/PKDD2020 | /functions/data_integrity.py | UTF-8 | 4,815 | 3.453125 | 3 | [] | no_license | import hashlib
import os
from pathlib import Path
from functions import file_functions
"""
Creates, prints, and verifies 'hash_dict's,
Which capture the structure of a folder and save hashes of files in the folder
A Hash Dict is a dictionary, created from a folder. The keys of the Hash Dict are the children (folders... | true |
f2619e1ea958c1b0ecf25af20ff3de686701c87c | Didden91/Coding-Projects-For-Practice | /Pokestats.py | UTF-8 | 1,957 | 2.921875 | 3 | [] | no_license | import sqlite3
def convtostr(org_list, seperator=' '):
return seperator.join(org_list)
conn = sqlite3.connect('pokeDB.sqlite')
cur = conn.cursor()
cur.executescript('''
DROP TABLE IF EXISTS Pokestats;
CREATE TABLE Pokestats (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
NationalDex INTEGER,
... | true |
c026510656d53fbbe4472732a9a4d1874b8f3d4e | accforaus/TIL | /nlp/tutorials-ipynb/word2vec_tutorial.py | UTF-8 | 912 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | import codecs
from bs4 import BeautifulSoup
from konlpy.tag import Twitter
from gensim.models import word2vec
# In[7]:
# 파일 열기
def run():
t = Twitter()
print("go")
readFp= codecs.open('wiki.txt', 'r', encoding='utf-8')
wakati_file = 'wiki.wakati'
writeFp = open(wakati_file, 'w', encoding='utf-8'... | true |
c60ad7f0d7713c0538aa4d1fb76291711b6f8ba2 | popovanaz/fogstream_vl | /строка 3.py | UTF-8 | 239 | 3.640625 | 4 | [] | no_license | Дана строка. Замените в этой строке все цифры 1 на слово one.
s = str(input('введите строку:\n'))
print(s.replace('1', 'one'))
или
S='1 home 1 dome'
S.replace ('1', 'one')
| true |
a16d589a557be863b158285dfb8f5823a470057c | rsloot/algorithms | /Sorting and Order Stats. (I & II)/priority_queues.py | UTF-8 | 3,608 | 3.53125 | 4 | [] | no_license | from heaps import *#heap, left, right, parent
def heap_maximum(a):
## assuming a is max heap
assert type(a) is heap, 'parameter should be a max_heap'
assert a.heapList[0] == max(a.heapList), \
"Incorrect, make sure it is a max heap"
return a.heapList[0]
## testing heap_maximum
# a = heap([3,2,1,4,5,62,1,4,3... | true |
92975f6f3d9a95735338a034ba65cefc2aa75b7c | JagadeeshVarri/learnPython | /Basics/prob_20.py | UTF-8 | 207 | 4.0625 | 4 | [] | no_license | # Write a Python program to get a string which is n (non-negative integer) copies of a given string.
str1 = input("Enter a string : ")
count = int(input("Enter how many copies needed : "))
print(str1*count) | true |
29b1140aeb5b11811ceba1968adfe5d64b49d95e | AyanDogra/OpenCV- | /Video_Reading_13.py | UTF-8 | 394 | 2.609375 | 3 | [] | no_license | import cv2
import time
cap=cv2.VideoCapture('myvid.mp4')
if cap.isOpened()==False:
print('File path incorrect')
while cap.isOpened():
ret,frame = cap.read()
if ret:
time.sleep(1/20)
cv2.imshow('frame',framd)
if cv2.waitKey(1) & 0xFF==ord('q'):
... | true |
e88070be29f3faaa81df3c98029a21385d432549 | elchigi/electiva4 | /ejercicio3.py | UTF-8 | 258 | 3.625 | 4 | [] | no_license | def numMenor(Numero):
arr = []
for i in range(1, (Numero + 1)):
arr.append(i)
return arr
num = input("Digite un numero: ")
arrNumeros = numMenor(num)
print arrNumeros
sum = 0
for u in range(0, (num + 1)):
sum = sum + u
print(sum)
| true |
0ce57fc5296a09864fb1e75080a20c684bceef98 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/car_truck_suv_demo.py | UTF-8 | 1,521 | 3.890625 | 4 | [] | no_license | # This program creates a Car object, a truck object, and an SUV object
import vehicles
import pprint
def main():
# Create a Car object
car = vehicles.Car('Bugatti', 'Veyron', 0, 3000000, 2)
# Create a truck object
truck = vehicles.Truck('Dodge', 'Power Wagon', 0, 57000, '4WD')
# Create... | true |
1e84879156ddcd15fa62e45ac1a16039b4467df2 | adiggo/leetcode_py | /paint_fence_276.py | UTF-8 | 321 | 2.75 | 3 | [] | no_license | def get_total_paint(n, k):
# n posts, k colors
if k <= 0:
return 0
first = k
second = k * k
if k < 3:
return first if k == 1 else return second
for i in xrange(3, n + 1):
third = (k-1) * first + (k-1) * second
first = second
second = third
return third... | true |
0b14f07c89045f7a105fee5dda2cff3b5f4a7f2f | yotaiyo/music-auto-tagging | /utils.py | UTF-8 | 761 | 2.5625 | 3 | [] | no_license | import numpy as np
import pickle
def load_feature_size(df, feature_name_list):
index = 0
split = df.split[index]
clip_id = df.clip_id[index]
feature_size_dict = {}
for feature_name in feature_name_list:
feature_dir = 'features/%s_%s_%d_1.txt' %(feature_name,split,clip_id)
feature = ... | true |
29e51ce9e7b3868946f5842b91036077bff5f10f | InnaBlahodyr/python_course | /practice 5/HomeWork2.py | UTF-8 | 296 | 3.484375 | 3 | [] | no_license | from num2words import num2words
#ModuleNotFoundError: No module named 'num2words'
# гадаю треба явно додати модуль 'num2words', або зробити власну реалізацію
enterNum = input("Введіть число : ")
print(num2words(enterNum, lang='uk')) | true |
ca101c665b7b5ea0dbedcc10ccffec1d8da84a5d | yanbinkang/problem-bank | /interview_cake/find_repeat.py | UTF-8 | 943 | 3.984375 | 4 | [] | no_license | def find_repeat(the_array):
floor = 1
ceiling = len(the_array) - 1
while floor < ceiling:
midpoint = floor + ((ceiling - floor) / 2)
lower_range_floor, lower_range_ceiling = floor, midpoint
upper_range_floor, upper_range_ceiling = midpoint+1, ceiling
items_in_lower_range = ... | true |
a83b546f90a6d2cee497f12d7afb47a85c090098 | xrw560/learn-pyspark | /basic_python/machine_learn/chapter01/plotlist.py | UTF-8 | 509 | 3.375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
1.4.2 表与线性结果的可视化
"""
import sys
import os
import numpy as np
import matplotlib.pyplot as plt
# 配置utf-8输出环境
reload(sys)
sys.setdefaultencoding('utf-8')
# 曲线数据加入噪声
x = np.linspace(-5, 5, 200)
y = np.sin(x) # 给出y与x的基本关系
yn = y + np.random.rand(1, len(y)) * 1.5 # 加入噪声的点集
# 绘图
fig = plt.figur... | true |
968d0a93b0c264dc02541be16a4da8dbe5cec9f1 | IshaySela/PubSub | /pytest/Subscriber.py | UTF-8 | 2,059 | 2.859375 | 3 | [
"MIT"
] | permissive | import socket
import Settings
import json
from ClientType import ClientType
from response.SubscriberHandshakeResponse import SubscriberHandshakeResponse
class Subscriber:
messages_count = 0
__raw_client: socket.socket
__endpoint_id:str
__callback:callable
handshake_response:SubscriberHandshakeResp... | true |
03ec68ab4d4d9173202c346d34313a29dbd63340 | byunseob/python-study | /파이썬 코딩의 기술/chapter-06-Built-in module /47. Use decimal when precision is important/main.py | UTF-8 | 633 | 3.109375 | 3 | [] | no_license | from decimal import Decimal, ROUND_UP
rate = Decimal('1.45')
seconds = Decimal('222')
cost = rate * seconds / Decimal('60')
print(cost)
rounded = cost.quantize(Decimal('0.01'), rounding=ROUND_UP)
print(rounded)
rate = Decimal('0.05')
seconds = Decimal('5')
cost = rate * seconds / Decimal('60')
print(cost)
rounded... | true |
c84d274a7a9b0225f72fc0faef8d4d1061a01afd | asemwal/thesis-project | /bgp-python/src/string_tool.py | UTF-8 | 652 | 3.09375 | 3 | [] | no_license | class String_Tool():
def __init__( self ):
return
def get_words_after_substring( self, full_text = None, sub_text_before_words = None, numberOfWords = None ):
full_text = str(full_text)
sub_text_before_words = str(sub_text_before_words)
if sub_text_before_words not in full_text:
return list()
index = ... | true |
979a4873706b71d9a7773c336578759d6be8cd10 | lukehinds/bandit | /examples/try_except_continue.py | UTF-8 | 360 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | # bad
for i in {0,1}:
try:
a = i
except:
continue
# bad
while keep_trying:
try:
a = 1
except Exception:
continue
# bad
for i in {0,2}:
try:
a = i
except ZeroDivisionError:
continue
except:
a = 2
# good
while keep_trying:
try:
... | true |
7e4b59bacd8ebb9c6967a69e9ddcdfa6299c0e7b | EkaterinaBazhanova/Python | /Les3Ex6.py | UTF-8 | 689 | 4.09375 | 4 | [] | no_license | def int_func(y="text"):
"""Делает прописной первую букву слова, состоящего из маленьких латинских букв."""
l = list(y)
m = len(l) - 1
i = 0
while i <= m:
if ((ord(l[i]) >= 1040) & (ord(l[i]) <= 1103)) or ((ord(l[i]) >= 65) & (ord(l[i]) <= 90)):
print("Error: The word must include... | true |
5b41a4b0b3d1c987c145dfe33507bb5e8340f014 | oneChuuforya/deeplearning | /lab4/pysine.py | UTF-8 | 2,787 | 2.953125 | 3 | [] | no_license | from __future__ import print_function
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import matplotlib.pyplot as plt
SEED = 1
np.random.seed(SEED)
torch.manual_seed(SEED)
T = 20
L = 1000
N = 100
x = np.empty((N, L), 'int32')
x[:] = np.array(range(L)) + np.random.randint(-4 * T, 4 *... | true |
bebd29488421c1bb957f972396c909d2ed72c48c | DonutSSS/NEU-CCIS | /CS5001/hw03/fever_diagnosis.py | UTF-8 | 2,783 | 3.171875 | 3 | [] | no_license | def megigitis():
print("Possibilities include megigitis")
def digestive_infection():
print("Possibilities include digestive tract infection")
def pneumonia_infection():
print("Possibilities include pneumonia or infection of airways")
def viral_infection():
print("Possibilities include viral infection... | true |
696292a52106cc9c2cf7e2f9c8700d8684248133 | kavyasingh05/Documents | /secondarray.py | UTF-8 | 222 | 3.109375 | 3 | [] | no_license | def my_sort(a):
for y in range(0,len(a)):
for x in range(y+1,len(a)):
if a[y] > a[x]:
temp = a[y]
a[y] = a[x]
a[x] = temp
return a
| true |
3b353687e24fa703354b3900cb89cb873a55729c | jcscheide/NBA-Win-Totals | /main.py | UTF-8 | 9,257 | 2.734375 | 3 | [] | no_license | import pandas as pd
master_season_dfs = list()
for year in range(1991,2019):
master_season_dfs.append(pd.read_excel("Resources/" + str(year) + "/Master_" + str(year) + ".xlsx"))
standings_dfs = list()
for year in range(1991,2019):
standings_dfs.append(pd.read_excel("Resources/" + str(year) + "/Standings_" + str(ye... | true |
e022bf957079b5c53e7bfad80a845b89700f6564 | Juunlee/Palaung_scripts | /tools/save_XML.py | UTF-8 | 1,806 | 2.890625 | 3 | [] | no_license | #from node import Node
def XML_node(the_node, depth=0):
"""counter keeps track of how many Nodes have been created."""
XML_data = ''
if depth == 0:
XML_data += "<root>"
if not the_node:
return
lefts_name = None
rights_name = None
if the_node.has_left():
lefts_name = ... | true |
197cf1567228a2890d04f873cd48e544a2ea8b61 | realbakari/python-program | /software technologies/Workshop 1/problem_13.py | UTF-8 | 749 | 4.40625 | 4 | [] | no_license | # Say that a "clump" in a list is a series of 2 or more adjacent elements of the
# same value. Print the number of clumps in the given list.
# Input a list of nums, map them as ints to inputlist and split them.
inputlist = list(map(int, input("Input a list of numbers: ").split()))
def clumpfinder(x): # Input list i... | true |
c9cba2a3c0e3d8e19236b6497ee1a17360ed731e | century-arcade/xd | /queries/xdstats.py | UTF-8 | 2,354 | 2.96875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import os
import zipfile
import itertools
import xdfile
EOL = '\n'
def get_blank_grid(xd):
emptygrid = ""
for row in xd.grid:
for c in row:
if c == xdfile.BLOCK_CHAR:
emptygrid += xdfile.BLOCK_CHAR
else:
emptygrid += "."
... | true |
bc046d54f80f000d98bafeff0275752cc02679bb | bonkpr00/wordcounter_2.0 | /wordcounter_bonk_oprava_python.py | UTF-8 | 2,180 | 3.125 | 3 | [] | no_license | import urllib.request
import sys
import argparse
def main():
pb_parser = argparse.ArgumentParser(description='počítadlo slov, znaků a řádků pro webovou stránku')
pb_parser.add_argument("stranka", help="Název stránky")
pb_parser.add_argument("--znaky",action="store_true")
pb_parser.add_argument("--s... | true |
ae10a2747f66014697e7ec7602e088d33b955506 | abc125/erdaepfel | /test/SeleniumTest.py | UTF-8 | 586 | 2.875 | 3 | [] | no_license | from pages.MainPage import MainPage
from pages.ResultsPage import ResultsPage
from test.BaseSeleniumTest import BaseSeleniumTest
class MyTestCase(BaseSeleniumTest):
item = "D-Link DIR-826L"
def test_something(self):
main_page = MainPage(self.driver)
main_page.open()
main_page.search_f... | true |
f79c9223ab7e40484f6cfdc835ac02ad0fdd4d63 | fengdy/python_data | /pandas/write.py | UTF-8 | 894 | 3.15625 | 3 | [] | no_license | # coding: utf-8
import pandas as pd
from openpyxl import load_workbook
class Data(object):
"""
将dataFrame数据写入已有的excel中,参考:
http://stackoverflow.com/questions/20219254/how-to-write-to-an-existing-excel-file-without-overwriting-data-using-pandas
优点:可将dataFrame直接写入excel中
缺点:openpyxl不支持 2003 excel
... | true |
1882e7192e778c970fa93a23348201569ff02e23 | natbrood/scripts-and-such | /python/2. Python challenges/2.1 Python principles/20. Custom zip.py | UTF-8 | 541 | 4.125 | 4 | [] | no_license | # https://pythonprinciples.com/challenges/Custom-zip/
def zap(a,b):
return [(a[i], b[i]) for i in range(0, len(a))]
zap(
[0, 1, 2, 3],
[5, 6, 7, 8]
)
# Solution from site
# ugly but understandable solution
def zap(a, b):
result = []
for i in range(len(a)):
item_from_a = a[i]
... | true |
7717983bdab61704352373c825b01200c1b8b6a7 | ananya2011/AnanyaPythonPractice | /question file.py | UTF-8 | 165 | 3.484375 | 3 | [] | no_license | x = input('whats ur name' )
y = input('how many biscuits you eat')
z = int(y) + 10
message = ' hello ' + x +' good day you ate '+ str(z)+' biscuits '
print(message) | true |
656e1ce1d7067ffc4d0f3092473b8c631710849d | odonnellryan/Goracle-Public | /write_from_db.py | UTF-8 | 6,812 | 2.546875 | 3 | [] | no_license | import MySQLdb
from _mysql_exceptions import OperationalError
import os
import time
import subprocess
import pwd
from datetime import datetime
import sys
# append datetime to all prints (so I don't have to replace them now)
old_f = sys.stdout
class F:
def write(self, x):
old_f.write(x.replace("\n", " [%s... | true |
a7d265a6a996e8df09f3a7e9734001213d243e3f | Panagiwta-fournari/ergasies | /exercise7.py | UTF-8 | 3,491 | 3.9375 | 4 | [] | no_license | # coding=utf-8
import random
from sys import exit
def check_for_winning_triad(board_):
for row in board_: # rows
if not row[0] is None and row[0] == row[1] and row[1] == row[2]:
return row[0]
for i in range(3): # columns
if not board_[0][i] is None and board_[0][i] == board_[1][i... | true |
df2c165f881dd60b63870b1918fa6bd5f0402686 | JMine97/BAEKJOON | /rest/9012.py | UTF-8 | 428 | 3.296875 | 3 | [] | no_license | import sys
input=sys.stdin.readline
for _ in range(int(input())):
arr=list(input().rstrip())
stack = []
for i in arr:
if not stack:
stack.append(i)
else:
if stack[-1]=='(' and i==')':
stack.pop()
else:
stack.ap... | true |
2ae56e5f2469261df7971aa1d30a401ff3e31f8e | Nehaadnekar/calculator | /calculator.py | UTF-8 | 1,236 | 3.984375 | 4 | [] | no_license |
#BLL
import math
class Calc:
def __init__(self):
self.n1 = 0
self.n2 = 0
self.res = 0
def add(self):
self.res=self.n1+self.n2
def sub(self):
if self.n1 > self.n2:
self.res = self.n1-self.n2
else:
self.res = self.n2-self.n1
def mul... | true |
342bdb52b8c6b759438ebba288f3dcb9427d4e08 | MrzvUz/Python | /Python_Entry/while_and_for_loop.py | UTF-8 | 1,762 | 4.21875 | 4 | [] | no_license | # is_learning = True
# while is_learning:
# # print("You're learning")
# user_input = input("Are you still learning?: ")
# is_learning = user_input == "yes"
# user_input = input("Do you wish to run the program? (yes/no): ")
# while user_input == "yes":
# print("We're running")
# user_input = inp... | true |
a63c6315e886c94ca07369d28955a7e7af5da1e5 | sadipgiri/Database-Management-Systems | /Python References For DBMS/dataset_to_list.py | UTF-8 | 346 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env python3
"""
dataset_to_list.py - Python3 program
Author: Sadip Giri (sadipgiri@bennington.edu)
created: 9/12/2017
"""
lst = []
my_file = open("CatalogDump.txt", errors="ignore") # ignored encoding errors of the file
for i in my_file:
lst.append(i)
my_file.close()
print(lst[0]) # printed particul... | true |
3ed207ef64eb9037570b0d9bb1437a30b128d22b | johnkle/FunProgramming | /Leetcode/动态规划/1143最长公共子序列.py | UTF-8 | 1,809 | 3.609375 | 4 | [] | no_license | class Solution(object):
def longestCommonSubsequence(self, text1, text2):
m = len(text1)
n = len(text2)
memo = [[-1]*n for i in range(m)]
def helper(i,j):
#空串的base case
if i == -1 or j == -1:
return 0
#状态转移
if memo[i][j]... | true |
510280c6d52293e84203cec79f9b3973e065caa0 | MrMino/paddler | /paddler/tui/controls.py | UTF-8 | 1,153 | 2.8125 | 3 | [] | no_license | """
Higher-level control classes for TUI components.
"""
from ..console import InputField, OutputField
from ..agenda import AgendaPane
from . import TextArea, ScrollablePane
from typing import Callable, Any
class TUIInputField(InputField):
__slots__ = ('accept_callback', '_text_area')
def __init__(self, tex... | true |
8342f44da34606464bfcc5f793a6e89aeeb73d90 | PirosB3/DHT | /table.py | UTF-8 | 3,817 | 3.265625 | 3 | [] | no_license | import itertools
import random
import unittest
from collections import deque, Counter
from node import Node, random_32bytes
class RoutingTable(object):
N_RETRIES = 3
def __init__(self, node, bootstrap=None):
self._unavailabilities = Counter()
self.node = node
self.buckets = [deque() ... | true |
2e91957ce15e07ec7cbed5a30eda1b37eb5b8a3a | luislama/algoritmos_y_estructuras_de_datos | /algoritmos/10_Factor_primo_mayor/factor_primo_mayor.py | UTF-8 | 959 | 4.28125 | 4 | [] | no_license | '''
Cual es el factor primo mayor del numero 600851475143
'''
NUM = 600851475143
def es_primo(numero):
#if numero < 2 :
if numero < 2:
return False
elif numero in [2,3]:
return True
else:
aux = 2
mitad = numero/2
while(aux <= mitad):
if numero % a... | true |
b1ef002af136d93315c8ef62ecca7b86e6d1b44a | k1414st/sandbox | /rl_sample_test.py | UTF-8 | 780 | 3.59375 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Bellman方程式の漸化式を用いて
簡単な例で
価値テーブルを計算してみる
"""
import numpy as np
# 割引率
GAMMA = 0.9
# 報酬テーブル
# rewards = np.array([0, 2, 1, 3, 1.1, 2, 2, 2.2, 2])
rewards = np.array([2, 1, 1, 3])
# 報酬テーブル長
L = len(rewards)
# 更新式(左右端は別処理)
def update(v, i):
if i == 0:
return rewards[i] + GAMMA * v[... | true |
fbefe2e094e696bba46de8702f28b8726e11eee8 | robinsharma1911/pythonfiles | /python5.py | UTF-8 | 155 | 3.75 | 4 | [] | no_license | #find letter is vowel or consonant
letter="e"
vowel=("a","e","i","o","u")
for x in vowel:
print("vowel") if letter==x else print("consonant")
break | true |
3afb39fcaa41fc1d7198cd653784310cf57e77c3 | ryosuke071111/algorithms | /AtCoder/ABC/three_letter_acronym.py | UTF-8 | 90 | 3.265625 | 3 | [] | no_license | s1,s2,s3 =input().split()
print(s1[0].capitalize()+s2[0].capitalize()+s3[0].capitalize())
| true |
85ec5f3d91cf4037bda43c3813a273f5acfe5fdb | dctongsheng/TensorFlow_BP_network | /bp_demo02.py | UTF-8 | 3,720 | 3.078125 | 3 | [] | no_license | # -- encoding:utf-8 --
"""
Create by ibf on 2018/5/12
"""
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
## 设置字符集,防止中文乱码
mpl.rcParams['font.sans-serif'] = [u'simHei']
mpl.rcParams['axes.unicode_minus'] = False... | true |
15b873513896f56425e8545fd742d9051ab8c1c7 | lfundaro/Melon-Interpreter | /Exceptions.py | UTF-8 | 880 | 2.625 | 3 | [] | no_license | #! /usr/bin/python
# -*- coding: utf-8 -*-
class TokenError(Exception):
def __init__(self,token):
self.token = token
class SyntaxError(Exception):
def __init__(self,token):
self.token = token
class FunctionError(Exception):
def __init__(self,messg):
self.messg = messg
c... | true |
6868a71a68a7024288e2eaf8fc22f105f361e25e | emz0/discord-server-analyzer | /analyzer/analyzer.py | UTF-8 | 2,020 | 2.65625 | 3 | [] | no_license | from analyzer.sql_stats import SQLStats
from analyzer.discussions import DiscussionAnalyzer
from analyzer.activity import Activity
import settings
import time
import pathlib
import csv
class Analyzer:
def __init__(self):
pass
def run(self):
"""
Run analysis and export results to an o... | true |
4b65a8a90f99e84a05ad4d1be83c25d7986b2128 | hankdikeman/CombustionProj3 | /demo/demo_vN_state.py | UTF-8 | 2,945 | 3.078125 | 3 | [] | no_license | """
Shock and Detonation Toolbox Demo Program
Calculates the frozen shock (vN = von Neumann) state of the gas behind
the leading shock wave in a CJ detonation.
################################################################################
Theory, numerical methods and applications are described in the follo... | true |
3e298a1b2f4a233363b1c5f4b368307013c30a38 | Gagalaga/Gagalaga | /src/Naves/NaveEnemy.py | UTF-8 | 1,633 | 3.296875 | 3 | [] | no_license | import math
import pygame
from src.Naves.Nave import Nave
class NaveEnemy(Nave):
"""
A class that abstracts the nave from the user.
Inherits from pygame.Sprite.
"""
def __init__(self, screen, position, velocidade_inicial=0, hardness = 2):
image_dir = "static/Images/Enemies/Cherry/skull-... | true |
c6ce7eba407b5708ff4f287506dca60a316eb790 | Arijitbera213/python-cab-booking-system | /login_connect.py | UTF-8 | 896 | 2.953125 | 3 | [] | no_license | from tkinter import *
from tkinter import messagebox
def Ok():
uname = e1.get()
password = e2.get()
if(uname == "" and password == "") :
messagebox.showinfo("", "Blank Not allowed")
elif(uname == "Admin" and password == "123"):
messagebox.showinfo("","Login Success")
... | true |
a65833d8162a4769bff7dea332d660f9a96e8eb3 | varunkumar032/lockdown-leetcode | /july2020/solutions/day27_ConstructBinaryTreeFromInorderAndPostorderTraversal.py | UTF-8 | 771 | 4.03125 | 4 | [] | no_license | # Given inorder and postorder traversal of a tree, construct the binary tree.
# Note:
# You may assume that duplicates do not exist in the tree.
# For example, given
# inorder = [9,3,15,20,7]
# postorder = [9,15,7,20,3]
# Return the following binary tree:
# 3
# / \
# 9 20
# / \
# 15 7
# Definit... | true |
dd6b10ddd054e54e523f2553aa2866fa01a9dbc5 | weizhen167/python_training | /07_xml_etree_dom/etree_sample.py | UTF-8 | 6,663 | 3.390625 | 3 | [] | no_license | import xml.etree.ElementTree as ET
import xml.dom.minidom as MD
import warnings
warnings.filterwarnings("ignore")
# Quick functions to print out a ET. Feel free to use it; it's here to show
# results later on in a readable manner
def rec_print(root):
attr_text = ""
for key in root.attrib:
attr_text +=... | true |
f9d669bef331c0b9f6db6f5929a0d120dc2ddbdc | samuelmale/Levenshtein | /scripts/LevenshteinUtils.py | UTF-8 | 2,489 | 3.484375 | 3 | [] | no_license | import math
import Levenshtein
from scripts.patient import Patient, Matcher
# these are columns of patient properties
patient_props = ['given_name', 'middle_name', 'family_name', 'district', 'county', 'sub_county', 'parish', 'village',
'birthdate', 'gender', 'tel_num', 'supporter_tel_num', 'first_enc_... | true |
c49017ba0412382d108570e8f442b30a5910e229 | MariaGabrielaReis/Python-for-Zombies | /List-09/L9-ex010.py | UTF-8 | 1,319 | 4 | 4 | [] | no_license | # J. alarm_clock #
# day: 0=domingo, 1=segunda, 2=terça, ..., 6=sábado
# vacation = True caso você esteja de férias
# o retorno é uma string que diz quando o despertador tocará
# dias da semana '07:00'
# finais de semana '10:00'
# a menos que você esteja de férias, neste caso:
# dias da semana '10:00'
# finais de seman... | true |
35165d6d3e52ca7a8bc366e349fbf3f5a35cc69c | willjbowman/research-code | /python/gaussian.py | UTF-8 | 2,807 | 2.6875 | 3 | [] | no_license | from scipy import signal
from scipy.fftpack import fft, fftshift
from scipy.interpolate import spline
import matplotlib.pyplot as plt
import numpy as np
# window = signal.gaussian(62, std=7, sym=True)
# plt.plot(window)
# plt.title(r"Gaussian window ($\sigma$=7)")
# plt.ylabel("Amplitude")
# plt.xlabel("Sampl... | true |
d6983c3675228f405d10fcec1f7bd9e6090be0bd | 5l1v3r1/Financial-Cibersecurity-Analysis | /Otros/extraer_terminos_symantec.py | UTF-8 | 4,058 | 2.75 | 3 | [] | no_license | import re
import os
import json
def limpiar_html(raw_html):
cleanr = re.compile('<.*?>')
cleantext = re.sub(cleanr, ' ', raw_html)
cleantext = cleantext.split("\n")
diccionario_terminos = dict()
linea_anterior = ''
termino_anterior = ''
for linea in cleantext:
elems_linea = linea.s... | true |
9c3d2b2f32e7be32667f7d6a4ec7a1e3e6710633 | aciie/aciie.github.io | /VASP/Cij.py | UTF-8 | 1,441 | 3.265625 | 3 | [] | no_license | import re
import numpy as np
filename = input("Please input your matrix file name: ")
f = open(filename)
# the below part was learnt from https://blog.csdn.net/u014453898/article/details/73378463
Cij = np.zeros((6,6),dtype = float)
lines = f.readlines()
Cij_row = 0
for line in lines:
list = line.strip('\... | true |
af37fed156dde71877f49ded9d841a845d2abcbe | chen-fly/python | /01-python高级/高级2/02-生成器2.py | UTF-8 | 117 | 2.734375 | 3 | [] | no_license | def test():
i = 0
while i<5:
temp = yield i
print(temp)
i+=1
t = test()
t.__next__()
| true |
2a063c39a0b91769170b080ef36d2372ade518ff | abhishekravi777/Sansad | /utils/roman.py | UTF-8 | 777 | 3.9375 | 4 | [
"MIT"
] | permissive | # Module to convert roman numerals
roman_numerals = [('M', 1000), ('CM', 900), ('D', 500), ('CD', 400),
('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10),
('IX', 9), ('V', 5), ('IV', 4), ('I', 1)]
def from_roman(roman_numeral):
"""
:param roman_numeral: string - Rom... | true |
3daeee72179e7235b515be5acb6ef021f0c43fe3 | a358003542/wxpython_examples | /test_wizard.py | UTF-8 | 5,913 | 2.84375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*-coding:utf-8-*-
import wx
import wx.adv
from wx.adv import Wizard as wiz
from wx.adv import WizardPage, WizardPageSimple
#----------------------------------------------------------------------
def makePageTitle(wizPg, title):
sizer = wx.BoxSizer(wx.VERTICAL)
wizPg.SetSizer(sizer)
... | true |
755ce42b068d3638bf48643446ebb6058dfdfdc5 | borstell/make_sign_stills | /make_sign_stills.py | UTF-8 | 3,966 | 2.578125 | 3 | [] | no_license | import cv2,sys,math,os
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
from PIL import Image
def hist(img):
"""
Returns a histogram analysis of a single image (in this case, a video frame)
"""
return cv2.calcHist([img],[0],None,[256],[0,256])
def read_frames(video):
"""
Reads a video... | true |
8e4e9f18460551df86d68749ccd4bd321473f3a1 | wsgharvey/piecewise-linear-scale | /piecewise_scale/scale.py | UTF-8 | 2,105 | 2.625 | 3 | [] | no_license | import numpy as np
from numpy import ma
import matplotlib as mpl
from matplotlib import scale as mscale
from matplotlib import transforms as mtransforms
from matplotlib.ticker import FixedLocator, ScalarFormatter, NullFormatter
class PiecewiseScale(mscale.ScaleBase):
name = 'piecewise-linear'
def __init__(se... | true |
cdb6f10f2a284bd21b874ca209e9c81b97facb37 | jbwillis/sandbox | /python/rm_minus_r/rmr.py | UTF-8 | 813 | 3.75 | 4 | [] | no_license | import os
DIRECTORY_STAT = 16384 # the stat value for a directory
def is_dir(path):
"""returns True if item at `path` is a directory, otherwise returns False"""
stat = os.stat(path)
if stat[0] == DIRECTORY_STAT:
return True
else:
return False
def joinpath(path1, path2):
"""join... | true |
3ae138e9966a940f22b6dcb398582f281241f303 | PlanteVodu/system | /server/Refresher.py | UTF-8 | 843 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python
#-*- coding: utf-8 -*-
import time
import datetime
import sqlite3 as lite
def monthdelta(date, delta):
m, y = (date.month+delta) % 12, date.year + ((date.month) + delta-1) // 12
if not m:
m = 12
d = min(date.day, [31,
29 if y%4==0 and not y%400==0 else 28,31,30,31,30... | true |
6e888883d75cda94530b0157e4b2fbaaa0933045 | stjordanis/dynamic-transformer-ensembles | /research/coverage_and_density_analysis/utils.py | UTF-8 | 4,894 | 2.59375 | 3 | [] | no_license | import os
import json
import pickle
import datetime
import codecs
import gzip
import io
import csv
import random
import shutil
random.seed(24)
csv.field_size_limit(1000000)
def force_mkdir(path):
if os.path.exists(path):
shutil.rmtree(path)
os.mkdir(path)
def wipe_file(path):
with open(path, '... | true |
918b3605668eeef9a6f699281109a1f72439a8ce | vampire2155/Python_basic_knowledge | /Test_file/装饰器.py | UTF-8 | 898 | 4.25 | 4 | [] | no_license | import time #函数没有被调用 是不会执行的。
def foo(): #1、代码是从上到下依次执行,首先会执行到这里,但是这个是一个函数,并没有被调用,所以不会进入到函数内部
print ('执行用例')
time.sleep(1)
def show_time(func): #2、然后代码会执行到这里,但是这也是一个函数,并没有被调用,所以不会进入到函数内部
def inner(): #这里的 inner()函数就是一个 装饰器。 装饰器返回值是一个 函数对象。
begin_time = time.time()
print ('begin_time:... | true |
09903a900f8faeef076fc132f356826c7532a855 | Nayald/algorithm-portfolio | /leetcode/daily challenges/2020-10/20-clone-graph.py | UTF-8 | 721 | 3.5 | 4 | [] | no_license | """
# Definition for a Node.
class Node:
def __init__(self, val = 0, neighbors = None):
self.val = val
self.neighbors = neighbors if neighbors is not None else []
"""
class Solution:
def cloneGraph(self, node: 'Node') -> 'Node':
if not node:
return None
... | true |
8db7937a55e4a1a99c054082fc3de24e26e71114 | motleytech/crackCoding | /hard/wordTrans.py | UTF-8 | 1,531 | 3.46875 | 3 | [] | no_license | 'solution for the word transformer problem'
from collections import defaultdict
from itertools import combinations
def areOneAway(a, b):
'true if a and b differ in only 1 character'
if len(a) != len(b):
return False
diff = 0
for x, y in zip(a, b):
if x != y:
diff += 1
r... | true |
3a43bcecd5b527bba6c83aea77687108f59ab464 | VVVVictorJ/Python_Test | /flask_code_learn/request_app.py | UTF-8 | 1,405 | 2.96875 | 3 | [] | no_license | import requests
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello world'
@app.route('/user/<username>')
def user_index(username):
print('User-Agent:', request.headers.get('User-Agent'))
print('time:', request.args.get('time'))
print('q:', request.args... | true |
3d73d9c1809c1e323d31188db9363385db7bc3bf | bradyc59/Python | /CA268/student.py | UTF-8 | 243 | 3.484375 | 3 | [] | no_license | #
# Determine how many nodes are visited while searching for a particular value
#
def how_many_searched(val, bst = 0):
if val is None:
return bst
return how_many_searched(val.left, how_many_searched(val.right, bst + 1)) | true |
ae39b01ed2c8c79b5672b1a754bfce7f3a506da3 | Casperinous/Lena | /test/classes.py | UTF-8 | 353 | 2.953125 | 3 | [
"MIT"
] | permissive | class Dummy:
@staticmethod
def dum():
return 3*4
class A(object):
def __init__(self, val):
self.test1 = val
self.callback = Dummy.dum
class B(A):
def __init__(self):
A.__init__(self,3)
self.test2 = 2
print self.test1
class C(B):
def __init__(self):
B.__init__(self)
print self.test1
... | true |
aaccff0f637302887219f669fca7b85ff8b01867 | Blaze2017/Object-Detection-with-SSD | /object_detection_Fan.py | UTF-8 | 3,882 | 3.1875 | 3 | [] | no_license | # Object Detection
# Importing the libraries
import torch
from torch.autograd import Variable
import cv2 # to draw the rectangles
from data import BaseTransform, VOC_CLASSES as labelmap
from ssd import build_ssd
import imageio
# Defining a function that will do the detections
def detect(frame, net, transform):
he... | true |
013c94194d40e1abb4f59b0ed1eb80ea2c27dd31 | Evantf1/Outpost_Mars | /Outpost_Mars/dictionary.py | UTF-8 | 173 | 3.078125 | 3 | [] | no_license | __author__ = 'Justin'
dict = {}
for x in range(0, 10):
for y in range(0, 10):
for z in range (0, 10):
dict[(x, y, z)] = 'whee'
print dict | true |
614975491df56c8ef0d3d55d81a92bf100f07d56 | wgx3/pytorch | /Naive_Bayes.py | UTF-8 | 808 | 2.59375 | 3 | [] | no_license | from sklearn.datasets import fetch_20newsgroups
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import classification_report
news=fetch_2... | true |
f77c9f2e41c3b09382275d0f0db573121283f515 | Aasthaengg/IBMdataset | /Python_codes/p03043/s665791864.py | UTF-8 | 202 | 2.859375 | 3 | [] | no_license | N, K = list(map(int, input().split()))
Pd = 1 / N
Pc = 0.5
ans = []
def f(i):
P = Pd
while(i<K):
P = P * Pc
i = 2 * i
return P
for j in range(1,N+1):
ans.append(f(j))
print(sum(ans)) | true |
4d37a157a6504eebc4768826f50198d7d3fd59ed | Kai-Bailey/machinelearnlib | /machinelearnlib/models/neuralNet.py | UTF-8 | 5,899 | 3.171875 | 3 | [
"MIT"
] | permissive | import numpy as np
from .. import loadModel
from .. import activationFunc
def cost(features, labels, weights, reg):
"""
Compute the cost for the neural network based on the current weights.
:param features: Numpy matrix of input data used to make prediction.
Each row is a training ex... | true |
0b91ca6f5009d06435c851aee783e9e6a0fa7888 | ChallengerCY/Python-OperatorDemo | /PythonOperator/OperatorDemo3.py | UTF-8 | 1,048 | 4.59375 | 5 | [
"Apache-2.0"
] | permissive | #'~'按位翻转
# 公式: ~x=-(x+1)
a=18
print(~a)
#'<<'左移运算
#将运算数值转换成二进制,整体向左移动一位,左移一个单位相当于乘2,俩个单位相当于乘4,三个单位相当于乘8,左移n个单位相当于乘2的n次幂
#左移符号的右面的数字是向左移动几个单位
b=18<<1
print(b)
#'<<'右移运算
#将运算数值转换成二进制,整体向右移动一位,右移一个单位相当于除2,俩个单位相当于除4,三个单位相当于除8,右移n个单位相当于除以2的n次幂
c=18>>2
print(c)
#'<=' 小于等于号,返回一个布尔值
d=3<=3
print(d)
#'>=' 大于等于号,返回一个布尔值
f=4>... | true |
1378602b3bf1c2ef81ad766a5f56576578d9777c | renjithbaby23/tf2.0_examples | /00_xor_gate.py | UTF-8 | 1,637 | 3.765625 | 4 | [
"MIT"
] | permissive | """
Implement XOR gate using neural networks
Use tensorflow 2.x
"""
import tensorflow as tf
import numpy as np
# # Generating a dummy data - XOR Gate
x = tf.constant([[0, 0], [0, 1], [1, 0], [1, 1]], dtype=tf.float32)
y = tf.constant([[0], [1], [1], [0]], dtype=tf.float32)
# Creating the model
# Methode 1 - impleme... | true |
fb504045b8f6cc81adb29839534de766081c3ec3 | allisterb/jparacrawl-finetune | /scripts/nfkc_normalizer.py | UTF-8 | 110 | 2.8125 | 3 | [] | no_license | import sys
import unicodedata
for line in sys.stdin:
print(unicodedata.normalize("NFKC", line.rstrip()))
| true |