blob_id large_string | language 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
55a9ae4fcb8601a935aad537fd08d7ea2d4a6011 | Python | Quer-io/Quer.io | /tests/ml/test_expressionnode.py | UTF-8 | 1,119 | 3.015625 | 3 | [
"MIT"
] | permissive | import unittest
from parameterized import parameterized
from querio.ml.expression.feature import Feature
class TestExpressionNode(unittest.TestCase):
@parameterized.expand([
('Simple true', Feature('age') > 30, 'age', 40, True),
('Simple false', Feature('age') < 30, 'age', 40, False),
('S... | true |
a520103dd3a88e8a7e80077fa29719754173693e | Python | mathieu-lemay/aoc_2018 | /12.py | UTF-8 | 3,227 | 2.921875 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env python
import os.path
from time import time
class Pattern:
def __init__(self, in_, out):
self.in_ = in_
self.out = out
def fix_array(offset, arr):
if "#" not in arr:
return offset, arr
# Fix start
s = 0
for i in range(len(arr)):
if arr[i] == "#":... | true |
539ad78b0b990c5d80143d5ff9d4488a2f5c8964 | Python | syzdemonhunter/Coding_Exercises | /Leetcode/170.py | UTF-8 | 885 | 3.921875 | 4 | [] | no_license | # https://leetcode.com/problems/two-sum-iii-data-structure-design/
class TwoSum:
def __init__(self):
"""
Initialize your data structure here.
"""
self.dic = {}
# time: O(1)
def add(self, number: int) -> None:
"""
Add the number to an internal data structure... | true |
88adbfe8649912c9ceeee308ff261fe053a7ca10 | Python | ealataur/rcute-ai | /rcute_ai/tts_espeak.py | UTF-8 | 4,986 | 2.609375 | 3 | [] | no_license | # modified from github.com/gooofy/py-espeak-ng
import re
import subprocess
import tempfile
from . import util
from pyttsx3.voice import Voice
def lang_detect(txt):
return 'zh' if re.findall(r'[\u4e00-\u9fff]+', txt) else 'en'
class TTS:
"""text to speech on Linux"""
def __init__(self):
self.defau... | true |
40e8b41307a504d8f40e870935245d291e41a3eb | Python | unaguil/hyperion-ns2 | /experiments/interpolators/InterpolatorLoader.py | UTF-8 | 597 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | from interpolators.LinearInterpolator import LinearInterpolator
from interpolators.IntegerInterpolator import IntegerInterpolator
from interpolators.SetInterpolator import SetInterpolator
def loadInterpolator(entry):
interpolator = entry.getAttribute("interpolator")
if interpolator == 'LinearInterpolator'... | true |
df97d8b2c03941f97c24772f7c3fe50b4190e900 | Python | aliyyahna/opencv-exercise | /chapter 4/hstack.py | UTF-8 | 189 | 2.703125 | 3 | [] | no_license | import cv2
import numpy as np
citraA = cv2.imread('./img/baboon.png')
citraB = cv2.imread('./img/lena.bmp')
hasil = np.hstack((citraA, citraB))
cv2.imshow('Hasil', hasil)
cv2.waitKey(0) | true |
6f126dc92819ccf4c6c73b6cddfc5119adbce810 | Python | esix/competitive-programming | /acmp/page-03/0125/main.py | UTF-8 | 226 | 2.78125 | 3 | [] | no_license | n = int(input())
a = [list(map(int, input().split(' ')[:n])) for i in range(n)]
input()
b = list(map(int, input().split(' ')[:n]))
r = 0
for i in range(n):
r += sum([b[i] != b[j] for j in range(i,n) if a[i][j]])
print(r)
| true |
585054623a0ab223508ccb6727d44c4107d96e16 | Python | kristjanleifur4/kristjan | /test.py | UTF-8 | 219 | 3.6875 | 4 | [] | no_license | first = int(input("First: "))
step = int(input("Step: "))
the_sum = 0
i = 0
while the_sum <= 100:
i += step
the_sum = first + i
print(i, end=" ")
else:
print()
print("Sum of series:",the_sum)
| true |
53772c008e8d0ce0aeb2b1dc7f0019885cfd5765 | Python | thinh2904/Chuong4 | /Bai12.3.py | UTF-8 | 728 | 3.9375 | 4 | [] | no_license | import random
import numpy as np
import string
#Tạo bảng chữ cái in hoa
a=string.ascii_uppercase
#Tạo bảng chữ cái in thường
b=string.ascii_lowercase
#Random số phần tử của List từ 50 đến 100
n=random.randrange(50,101)
#Tạo List dạng dictionary có cấu trúc {0.0} với n phần tử
listdict=list(np.zeros(n))
#Hàm ... | true |
5da9e0ed201d9b197f074e45d4ca1a7b986a17cd | Python | dr-rodriguez/SIMPLE | /scripts/ingests/ingest_utils.py | UTF-8 | 63,958 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | """
Utils functions for use in ingests
"""
from astroquery.simbad import Simbad
from astropy.coordinates import SkyCoord
import astropy.units as u
from astroquery.gaia import Gaia
from typing import List, Union, Optional
import numpy as np
import numpy.ma as ma
import pandas as pd
from sqlalchemy import func, null
from... | true |
58efba2052299360dca036b514709ebb99e6a875 | Python | zyp19/leetcode1 | /秋招提前批/民生银行/2.py | UTF-8 | 335 | 3.4375 | 3 | [] | no_license | import sys
num = 0
t = input()
if t == "1":
# 统计行数
for line in sys.stdin.readline():
if not line:
continue
num += 1
print(num)
elif t == "Q":
print("Quit")
else:
print("Wrong input.Please re-choose")
print("Menu Function Test")
print("1:Count Lines")
print("Q:... | true |
bc13912d3f11f2c5df40c27276544892ad1835ab | Python | Alymostafa/OS--linux--Process-Manger | /os project/project.txt | UTF-8 | 998 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python3
import os
import sys
myhost = os.uname()[1]
z=1
while z:
print ("A. List all the processes in the system.")
print ("B. List all the processes grouped by user.")
print ("C. Display process ID of all the processes.")
print ("D. Run/stop a specific process.")
print ("E. Send specific signals t... | true |
e21c9dee11e21d0141aefa42a06617ac844ac23e | Python | stroxler/tdxutil | /tdxutil/exceptions.py | UTF-8 | 1,002 | 3.625 | 4 | [
"MIT"
] | permissive | """
Tools to make working with exceptions easier.
"""
def try_with_context(error_context, f, *args, **kwargs):
"""
Non-lazy version of `try_with_lazy_context`. Everything
is the same except `error_context` should be a string.
"""
return try_with_lazy_context(lambda: error_context,
... | true |
89309fa0695cfc6e3786ae9a667dbed221d85b3d | Python | Aasthaengg/IBMdataset | /Python_codes/p03700/s963066209.py | UTF-8 | 757 | 3.140625 | 3 | [] | no_license | import sys,math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,a,b = map(int,readline().split())
h = [int(readline()) for i in range(n)]
def is_ok(arg):
chk = 0
for i in h:
chk += max(0,math.ceil((-arg*b+i)/(a-b)))
return chk <= arg
def b... | true |
a9f500c64764f7d8fa2d0df70cbafd0c8eb0e521 | Python | IgnatIvanov/Generating-Randomness_JetBrains_Academy | /Generating Randomness/task/predictor/predictor.py | UTF-8 | 2,703 | 3.84375 | 4 | [] | no_license | import numpy as np
data = ''
while True:
print('Print a random string containing 0 or 1:', sep='\n')
user_in = str(input())
for digit in user_in:
if digit == '0' or digit == '1':
data += digit
if len(data) > 99:
break
else:
print('Current data length is {}, {} ... | true |
f955a9526fd3354818eb909ec9e2b4fc0edc18f2 | Python | Alibaba-Gemini-Lab/tf-encrypted | /examples/logistic/common.py | UTF-8 | 6,086 | 3.140625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """Provide classes to perform private training and private prediction with
logistic regression"""
import tensorflow as tf
import tf_encrypted as tfe
class LogisticRegression:
"""Contains methods to build and train logistic regression."""
def __init__(self, num_features):
self.w = tfe.define_private_... | true |
9543430deaca7d9104e5553dbd28fc6dd69f8d37 | Python | rileyjmurray/cvxpy | /cvxpy/reductions/solvers/conic_solvers/copt_conif.py | UTF-8 | 12,853 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | """
This file is the CVXPY conic extension of the Cardinal Optimizer
"""
import numpy as np
import scipy.sparse as sp
import cvxpy.settings as s
from cvxpy.constraints import PSD, SOC
from cvxpy.reductions.solution import Solution, failure_solution
from cvxpy.reductions.solvers import utilities
from cvxpy.reductions.s... | true |
21fc8d786d56cd1ad6886086d16bba490c1f89dd | Python | demi52/mandy | /BI_6.0.7_WebUI_AUTOTOOLS_003/BI_6.0.7_WebUI_AUTOTOOLS_03/BI_6.0.7_WebUI_AUTOTOOLS_03/addtestcase/_addtestall_func.py | UTF-8 | 2,720 | 2.734375 | 3 | [] | no_license | #author='鲁旭'
"""
默认执行test_case 目录下的所有用例,可根据配置过滤
"""
import os
import re
import importlib
import unittest
from config.conf import Suite as s
def case_list(case_dir=s.case_dir, suite_dir=s.suite_dir):
"""
获取待执行的目录下的所有测试用例脚本
:param casedir: 测试用例所在目录
:param suite_dir: 测试套件所在的目录
:return: 返回所有测试用例脚本名列... | true |
80b8b52eaef17deb0565aca80d66751eaa45e27e | Python | ryf1123/cpp-Compiler-for-Pascal-by-Python | /not_available/一些资料/ComPasc-master/project/src/ThreeAddrCode.py | UTF-8 | 4,225 | 3.078125 | 3 | [] | no_license | import os
import sys
# import SymTable as SymTab # Is it required ?
class ThreeAddrCode:
'''
Class holding the three address code, links with symbol table
'''
def __init__(self,symTab):
'''
args:
symTable: symbol table constructed after parsing
'''
... | true |
b51a02f191698a1ce511c3cfc10ff87d7e9a2c78 | Python | vnaveen0/practice_python | /String/reverseString.py | UTF-8 | 420 | 3.25 | 3 | [] | no_license | class Solution(object):
def reverseString(self, s):
"""
:type s: List[str]
:rtype: None Do not return anything, modify s in-place instead.
"""
L = len(s)
mid = L/2
for idx in range(mid):
# swap values
tmp = s[L-1-i... | true |
93a54baa33b7185171211be61652baa0581beaa9 | Python | christopherohit/Guess-Number | /Intro.py | UTF-8 | 2,461 | 3.734375 | 4 | [] | no_license | import sys
import Menu
def Intro():
while True:
print(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("~ //=== __ __ ____ ___ ___ || ==== ~")
print("~ || === || || ||__ ||__ ||__ || || ~")
print("~ ... | true |
509ef67931916af047250456cc83d9b0f6b0a4e9 | Python | pym7857/CodingTestStudy | /2020 KaKao Blind Recruitment/pang/괄호변환.py | UTF-8 | 986 | 3.28125 | 3 | [] | no_license | def split(p):
if p=='':
return ''
else:
count=0
for i,n in enumerate(p):
if n==")":
count-=1
else:
count+=1
if count==0:
break
return p[:i+1],p[i+1:]
def checkTrue(u):
count=0
for i in u... | true |
5f8b46af6ec7c3f5eea16474b2826b1d73b5e6e5 | Python | brunoisy/kaggle_quora | /model_2.py | UTF-8 | 992 | 2.734375 | 3 | [] | no_license | import ktrain
import pandas as pd
from sklearn.model_selection import train_test_split
MODEL_NAME = 'distilbert-base-uncased'
TRAINING_DATA_FILE = "data/train.csv"
max_qst_length = 100 # max number of words in a question to use
###
# data preparation
train = pd.read_csv(TRAINING_DATA_FILE)[:1000]
ids = train['qid']... | true |
467d6cbb5ff27446b5f91d0a73080c19fd97ef0c | Python | Erotemic/netharn | /netharn/layers/attention.py | UTF-8 | 6,542 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | """
References:
https://arxiv.org/pdf/1809.02983.pdf - Dual Attention Network for Scene Segmentation
https://raw.githubusercontent.com/heykeetae/Self-Attention-GAN/master/sagan_models.py
"""
import torch
from torch import nn
class SelfAttention(nn.Module):
"""
Self Attention Layer
References:
... | true |
9816894b2e45fa4e949701ce38003a0059d6c127 | Python | mprasu/Sample-Projects | /pythonprojects/Pyhton poc's/retail poc/trans.py | UTF-8 | 1,652 | 2.875 | 3 | [] | no_license | import MySQLdb
import csv
db=MySQLdb.connect("localhost","root","root","charan")
cursor=db.cursor()
fo=None
fo=open("trans.csv")
trans=csv.reader(fo)
data=list(trans)
sql="DROP TABLE IF EXISTS transactions"
cursor.execute(sql)
sql="create table transactions(id int,chain int,dept int,category int,company int,brand int,d... | true |
c5607288a678c183e4c0893c9d1795248737b279 | Python | sound-round/python-project-lvl2 | /gendiff/file_parser.py | UTF-8 | 385 | 2.921875 | 3 | [] | no_license | import json
import yaml
INPUT_FORMATS = ['json', 'yaml']
def parse(file_data, format):
if format == 'json':
return json.load(file_data)
if format in ['yaml', 'yml']:
return yaml.load(file_data, Loader=yaml.FullLoader)
raise ValueError(
f'Unknown input format: {format... | true |
58d3a85bcf64a4e2f4d37f704f2bc3d29bd1b40d | Python | Kederly84/PyhonBasics | /HomeWork/HomeWork1.py | UTF-8 | 1,222 | 3.984375 | 4 | [] | no_license | # задание №1
# Запрос ввода от пользователя в секундах
duration = int(input('Веди время в секундах'))
days = duration // 86400 # 86400 - это количество секунд в сутках, вычисляем кол-во суток
hours = (duration - days * 86400) // 3600 # 3600 количество секунд в часе, вычисляем кол-во часов
minutes = (duration - days... | true |
9fc8337ed3a160826752311bc90da11d4b957d65 | Python | Joldnine/know-your-house | /back-end/apis/prediction/api.py | UTF-8 | 2,235 | 2.703125 | 3 | [] | no_license | import os
import pickle
import json
import sklearn
import numpy
import scipy
class Prices(object):
def predict_price(self, town_area, flat_type, time_step, floor_area_sqm, age, floor, mrt_distance, num_mall, num_mrt,
num_school):
pkl_filename = "model.pkl"
des_filename = town... | true |
91ff6041f816c04425b46634c3bfd0d13041cdbe | Python | StarBrand/CC5114-Tareas | /tarea1/scripts/network_on_iris.py | UTF-8 | 3,416 | 2.953125 | 3 | [] | no_license | """network_on_iris.py: show performance of a neural network on iris dataset"""
import matplotlib.pyplot as plt
import numpy as np
import logging
from argparse import ArgumentParser
from random import seed
from neural_network import NeuralNetwork, NormalizedNetwork
from useful.math_functions import sigmoid, tanh
from us... | true |
3c9afc95a9999d1e2542c09646bb96ec5a107bf4 | Python | gsk120/ibk_python_progrmming | /mycode/lab/2age_cal.py | UTF-8 | 612 | 4.0625 | 4 | [] | no_license | """
나이 = 현재년도 - 태어난년도 + 1
태어난 년도는 input() 함수를 사용하여 입력 받는다.
"""
#from 모듈명 import 클래스명 또는 함수명
from datetime import datetime as dt
print(dt.today())
print(dt.today().year)
print(dt.today().month)
current_year = dt.today().year
print("태어난 년도를 입력하세요")
birth_year = int(input())
print(current_year, birth_year)
age = current_... | true |
f4cc0761578e4501650636dd7dee74c877ee9f5b | Python | Shin-jay7/LeetCode | /0451_sort_characters_by_frequency.py | UTF-8 | 419 | 3.359375 | 3 | [] | no_license | from __future__ import annotations
from collections import Counter
class Solution:
def frequencySort(self, s: str) -> str:
ans = ""
for char, freq in Counter(s).most_common():
ans += char * freq
return ans
test = Solution()
test.frequencySort("tree") # "eert"
test = Solutio... | true |
0c83b592d6d164347ac6e642cdd7ad0f3f5bd4c4 | Python | tsb4/dayTradingEnv | /gym_anytrading/envs/trading_env.py | UTF-8 | 5,178 | 2.5625 | 3 | [
"MIT"
] | permissive | import gym
from gym import spaces
from gym.utils import seeding
import pandas as pd
import numpy as np
from enum import Enum
import matplotlib.pyplot as plt
import csv
import gym_anytrading.datasets.b3 as b3
class TradingEnv(gym.Env):
def __init__(self):
self.n_stocks = 10
self.W = 2
self.... | true |
8a5ca5dc204978cb3cf4500fa3aa77b432ab271f | Python | mchrzanowski/ProjectEuler | /src/python/Problem060.py | UTF-8 | 2,922 | 3.578125 | 4 | [
"MIT"
] | permissive | '''
Created on Feb 5, 2012
@author: mchrzanowski
'''
from ProjectEulerPrime import ProjectEulerPrime
from time import time
def find5WayPrimes(primeList, primeObject):
for a in xrange(len(primeList) - 4):
first = str(primeList[a])
for b in xrange(a + 1, len(primeList) - ... | true |
4ac7c9112965fc6ac403f9badfd87889a2359658 | Python | imaimon1/Learn-Python-the-Hard-Way | /ex3.py | UTF-8 | 276 | 3.53125 | 4 | [] | no_license | print "I will now count my chickens:"
print "Hens", 25.+30./6.
print "Roosters", 100.-25.*3.%4.
print "Now I will count the eggs"
print 3.+2.+1.-5.+4.%2.-1./4.+6.
print "Is it true that 3+2< 5-7?"
print 3.+2.<5.-7.
print "what is 3+2",3.+2.
#more boring stuff
| true |
e65976723046095cbe711bd1c8a7c425775d21f8 | Python | timchu/myanimelist-scraper | /scraper.py | UTF-8 | 3,843 | 3.203125 | 3 | [] | no_license | """A scraper to identify shared voice actors/actresses in myanimelist."""
from lxml import html
import requests
import sys
from os import path
from urlparse import urlparse
# """ Takes as input a page, and outputs a list of (actor, character). """
# def getChars(tree):
# char_list = tree.xpath('//td/a[contains(@h... | true |
e81318fa0a4930a4c98adf1a7ff6784eb90fcb7a | Python | statsmodels/statsmodels | /statsmodels/tsa/arima/estimators/innovations.py | UTF-8 | 9,639 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | """
Innovations algorithm for MA(q) and SARIMA(p,d,q)x(P,D,Q,s) model parameters.
Author: Chad Fulton
License: BSD-3
"""
import warnings
import numpy as np
from scipy.optimize import minimize
from statsmodels.tools.tools import Bunch
from statsmodels.tsa.innovations import arma_innovations
from statsmodels.tsa.statto... | true |
2ef215cd82995b997a3f5e5d4b65773d0520dd2c | Python | gustkdxo007/Solving-Algorithm | /PROGRAMMERS/GREEDY/섬연결하기.py | UTF-8 | 660 | 3.140625 | 3 | [] | no_license | def solution(n, costs):
answer = 0
parent = [x for x in range(n+1)]
costs.sort(key=lambda x: x[2])
def find_parent(x, parent):
if parent[x] != x:
parent[x] = find_parent(parent[x], parent)
return parent[x]
def union(a, b, parent):
x = find_parent(a, parent)
... | true |
7aef427e917bc0e466ccd3adf85d019b95597f8c | Python | RadkaValkova/SoftUni-Web-Developer | /Programming Basics Python/02 Simple_Conditions_Exam Problems/Sleepy_Tom.py | UTF-8 | 426 | 3.828125 | 4 | [] | no_license | rests_days = int(input())
work_days = 365-rests_days
minutes_in_year = work_days * 63 + rests_days * 127
if minutes_in_year >= 30000:
print('Tom will run away')
print(f'{(minutes_in_year - 30000) // 60} hours and {(minutes_in_year - 30000)% 60} minutes more for play')
else:
print('Tom sleeps well')
pri... | true |
0d3e9ef1797c9467916fbb420a2066829fb2159a | Python | NathanaelCarauna/UriResolucoesPython | /1131.py | UTF-8 | 806 | 3.328125 | 3 | [] | no_license | continuar = 1
grenais = 0
interVitorias = 0
gremioVitorias = 0
empates =0
while continuar ==1:
grenais +=1
golsInter, golsGremio = map(int,input().split())
if golsInter>golsGremio:
interVitorias+=1
elif(golsInter==golsGremio):
empates+=1
else:
gremioVitorias+=1
new... | true |
6f18dcaa7ad2e87e8d8b9160626246e15ead357f | Python | alxmancilla/data_migrator | /employee_migration.py | UTF-8 | 3,423 | 2.8125 | 3 | [] | no_license | import datetime
import mysql.connector
import pymongo
def get_MySQL_Cnx():
# For local use
cnx = mysql.connector.connect(user='demo', password='demo00',
host='127.0.0.1',
database='employees')
return cnx
def get_MDB_cnx():
# For local use
... | true |
2749fb360331454345a30cde57213266d181c50f | Python | BennyJane/python-demo | /SqlIndex/A4p3.py | UTF-8 | 2,724 | 2.984375 | 3 | [] | no_license | import random
import sqlite3
import time
from settings import DB_NAMES
from utils import load_country_data
from utils import get_average
from utils import change_index
# PART3 查询随机选择的国家中最大price的值
EXECUTE_NUMS = 100
SELECT_SQL = "SELECT * FROM Parts WHERE madeIn = '{}' order by partPrice desc limit 1;"
# SELECT_SQL = ... | true |
7d269c6c2ad74df44f5f4adf39374d75c709fd8d | Python | HalfMoonFatty/L | /007. HashTable.py | UTF-8 | 1,989 | 4.09375 | 4 | [] | no_license | """Thread-safe hash table.
"""
from threading import Lock
class HashTable(object):
def __init__(self, capacity):
self.data = [[] for _ in range(capacity)]
self.capacity = capacity
self.size = 0
self.lock = Lock()
def __str__(self):
return '\n'.join(str(bucket) for bucket in self.data)
def _... | true |
d2bba206432a3c0290dfec85bc07c03603df4560 | Python | seminvest/investment | /daily_scan_pricewarning_5_11_2019.py | UTF-8 | 2,819 | 2.90625 | 3 | [] | no_license | #https://stackoverflow.com/questions/48071949/how-to-use-the-alpha-vantage-api-directly-from-python
#https://www.profitaddaweb.com/2018/07/alpha-vantage-preprocessed-free-apis-in.html
import requests
import alpha_vantage
import json
import pandas as pd
import datetime
import numpy as np
import time
from mpl_finance imp... | true |
4a2994e626e8edba470a16e7eb39b97a9a61038a | Python | ranqiu92/ReorderNAT | /util.py | UTF-8 | 2,043 | 2.765625 | 3 | [] | no_license |
import random
import numpy as np
import torch
import torch.nn as nn
class Transformer_LR_Schedule():
def __init__(self, model_size, warmup_steps):
self.model_size = model_size
self.warmup_steps = warmup_steps
def __call__(self, step):
step += 1
scale = self.model_size ** -0... | true |
049e754dc40f80c0997fd6aef453bc91f4d914ea | Python | Andy-Fraley/investment_scraper | /investment_data_json2csv.py | UTF-8 | 4,417 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python
import argparse
from util import util
import sys
import os
import re
import json
import csv
def ListDatasets(investment_json_filename):
investment_data = json.load(investment_json_filename)
dataset_names = []
for trading_symbol in investment_data:
for dataset_name in investm... | true |
5530fa1e694854a8190418131fed32d9f95dd5a8 | Python | jeffvswanson/LeetCode | /0557_ReverseWordsInAString3/python/test_solution.py | UTF-8 | 615 | 2.875 | 3 | [
"MIT"
] | permissive | import pytest
import solution
@pytest.mark.parametrize(
"s,expected",
[
("Let's take LeetCode contest", "s'teL ekat edoCteeL tsetnoc"),
("God Ding", "doG gniD"),
("h", "h"),
],
)
def test_initial_solution(s, expected):
got = solution.initial_solution(s)
assert got == expec... | true |
9fff032c0cfa0697cfa94bff52ee1b2648391987 | Python | namujinju/study-note | /python/Hon Gong Pa/200627.py | UTF-8 | 839 | 4.34375 | 4 | [] | no_license | # 파이썬은 변수에 자료형을 지정하지 않지만 TypeError가 발생할 확률이 높기 때문에
# 하나의 변수에는 되도록 하나의 자료형을 넣어 활용하는 것이 좋다.
string = "안녕하세요"
string += "!"
string += "!"
print(string)
# number = input("인사말을 입력하세요> ") # 사용자가 무엇을 입력해도 결과는 무조건 문자열 자료형이다.
# print(type(number))
a = input("첫 번째 숫자")
b = input("두 번째 숫자")
c = float(a) + int(b)
print(c)
a = i... | true |
515a737624becc148aa4bd67633a3e5eedaba469 | Python | fallengravity/python-playground | /main.py | UTF-8 | 1,032 | 3.109375 | 3 | [] | no_license | from web3 import Web3
import urllib.request, json
import decimal
w3 = Web3(Web3.HTTPProvider("https://rpc.ether1.cloud"))
# Replace the address below with your own
address = Web3.toChecksumAddress('0xfbd45d6ed333c4ae16d379ca470690e3f8d0d2a2')
balance = w3.eth.getBalance(address)
balance_formatted = w3.fromWei(balan... | true |
efb851d541b987e54701ecdace48e443abb97c2a | Python | KRMA-Radio/Server-Side-Analytics | /Access.py | UTF-8 | 3,974 | 2.859375 | 3 | [] | no_license | import json
import time
__author__ = 'Isaac'
class Access:
def __init__(self, ip, at: time.struct_time, http_method, host, page, response_code, http_referer, user_agent, length):
self.ip = ip
self.time = at
self.http_method = http_method
self.host = host
self.page = page
... | true |
8b9fbfcaa527ae461b0041a04db5975cbe8041ba | Python | Davy971/PhylEntropy | /phylogene_app/utils.py | UTF-8 | 4,511 | 3.171875 | 3 | [] | no_license |
###############################
# UPGMA #
###############################
# lowest_cell:
# Locates the smallest cell in the table
def lowest_cell(table):
# Set default to infinity
min_cell = float("inf")
x, y = -1, -1
# Go through every cell, looking for the lowest
for i in range(len(... | true |
bda0c3815530ec76b7fff36779c801fa79fada40 | Python | Noisynose/adventofcode | /day1/day1_part2.py | UTF-8 | 1,141 | 3.53125 | 4 | [] | no_license | def variationsFromFile(fileName):
variations = []
for variation in open(fileName, 'r'):
variations.append(int(variation))
return variations
# day1_part1
def totalFrequency(variations):
frequency = 0
for variation in variations:
frequency += variation
return frequency
# day1... | true |
49942cf3785125b79a7ae0a6279557097a1e45b7 | Python | whaleygeek/bitio | /src/try/test_GPIO.py | UTF-8 | 454 | 2.796875 | 3 | [
"MIT"
] | permissive | # WORK IN PROGRESS - DO NOT USE
import microbit.GPIO as GPIO
import time
GPIO.setmode(GPIO.MICROBIT)
BUTTON = 0
LED = 1
GPIO.setup(LED, GPIO.OUT)
GPIO.setup(BUTTON, GPIO.IN)
try:
while True:
if GPIO.input(BUTTON) == False: # active low
print("Button pressed")
GPIO.output(LED, T... | true |
45ec6d4cc16555bac86449b3a43d048bf7ad68f3 | Python | lomoeg/lksh-2015 | /day8/b.py | UTF-8 | 402 | 2.796875 | 3 | [] | no_license | def metbefore(seq):
s = set()
len1 = len(s)
for i in range(len(seq)):
s.add(seq[i])
if len(s) == len1:
print('YES', file = f_out)
else:
len1 = len(s)
print('NO', file = f_out)
f_in = open('metbefore.in')
seq1 = list(map(int, f_in.readline().split... | true |
1faac0c393418c4180cb0d0c5d4130450423a9ff | Python | zubairAhmed777/python | /calc.py | UTF-8 | 132 | 2.984375 | 3 | [] | no_license | def add(x,y):
# return x+y
pass
def sub(x,y):
# return x-y
pass
def mul(x,y):
return x*y
# pass
def div(x,y):
return x/y
# pass
| true |
25f1cb618615a5ea2502e20858dbc8439ad73149 | Python | siberian122/kyoupuro | /practice/Wanna-go-back-home.py | UTF-8 | 418 | 3.03125 | 3 | [] | no_license | s=list(input())
count=[0 for i in range(4)]
for i in s:
if i=='N':
count[0]+=1
elif i=='S':
count[1]+=1
elif i=='E':
count[2]+=1
elif i=='W':
count[3]+=1
if count[0]>0 and count[1]==0:
print('No')
elif count[1]>0 and count[0]==0:
print('No')
elif count[2]>0 and co... | true |
10e7e66bcf93b13b230798cd4396b17a367cf48b | Python | Loveashik/Music-classification | /classification/model_training.py | UTF-8 | 1,640 | 2.65625 | 3 | [] | no_license | """
Основной цикл обучения модели
"""
from functools import partial
import torch
from sklearn.metrics import f1_score, accuracy_score
from torch.nn import BCELoss
from torch.optim import Adam
from tqdm import tqdm
from data_loaders import train_dataloader, val_dataloader
from model import resnet_model
from tools imp... | true |
027f6e6f2fe78ba51a83264d71acff3fc8cdb389 | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2593/60620/258198.py | UTF-8 | 636 | 2.65625 | 3 | [] | no_license | t=int(input())
for i in range(t):
n=int(input())
s=input()
if(s[1]==','):
a=list(map(int,s.split(',')))
else:
a=list(map(int,s.split()))
b=[]
result=[]
num=0
for j in range(n-1):
for k in range(j+1,n):
b.append(a[j]+a[k])
for j in b:
if(b.c... | true |
e92158775e0ed0e0ddb835129e3b0c68b4f807a6 | Python | 35sebastian/Proyecto_Python_1 | /CaC Python/EjerciciosPy1/Ej9.py | UTF-8 | 981 | 4.09375 | 4 | [] | no_license | #
# Mi resolución:
#
# inversion = float(input("Introduce la cantidad a invertir: "))
# interes= int(input("Introduce el porcentaje de interés anual: "))
# anos= int(input("Introduce el número de años de inversión: "))
#
# '''
# capital = 0
#
# for i in range(anos):
# inversion = inversi... | true |
b3193c34abf17c2d4a5b106a14bf97a212539d6f | Python | rajlath/rkl_codes | /Hackerrank/construct_an_array.py | UTF-8 | 835 | 2.9375 | 3 | [] | no_license | '''
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
signed main()
{
//freopen("input.txt", "r", stdin);
ios::sync_with_stdio(0);
cin.tie(0);
int n, k, x;
cin >> n >> k >> x;
assert(3 <= n && n <= 100000);
assert(2 <= k && k <= 100000);
assert(1 <= x && x <= k);
... | true |
9e66248773a52a58b940e7b70376c79db254cbfe | Python | JanBezler/Spaceships | /menu.py | UTF-8 | 3,811 | 2.90625 | 3 | [] | no_license | import run
import pygame as pg
import sys
class Menu(object):
def __init__(self):
self.screen = pg.display.set_mode((0,0),pg.FULLSCREEN)
pg.font.init()
pg.display.set_caption("Main Menu")
pg.font.init()
self.click = (0,0)
self.size = self.screen.get_size()
se... | true |
5076a282a5d17becb128c9fc751e4c95d9c4b8c5 | Python | sutha001/sickness_pj | /comparison.py | UTF-8 | 3,121 | 2.546875 | 3 | [] | no_license | import csv
import pygal
data51 = csv.reader(open("2551.txt"))
data52 = csv.reader(open("2552.txt"))
data53 = csv.reader(open("2553.txt"))
data54 = csv.reader(open("2554.txt"))
data55 = csv.reader(open("2555.txt"))
sick51 = []
sick52 = []
sick53 = []
sick54 = []
sick55 = []
givesick1 = []
givesick2 = ... | true |
61b970be50eb3e8cda7427b9179490e51739b21f | Python | miko1004/freepacktbook | /freepacktbook/pushover.py | UTF-8 | 1,159 | 2.53125 | 3 | [
"MIT"
] | permissive | import json
import requests
class PushoverNotification(object):
def __init__(self, pushover_user, pushover_token):
self.pushover_api = "https://api.pushover.net/1/messages.json"
self.pushover_user = pushover_user
self.pushover_token = pushover_token
def get_image_content(self, image_u... | true |
86e873edfdb7851a1f73eb52db26bcc37e50fc66 | Python | nancydyc/Code-Challenge | /reversell.py | UTF-8 | 1,553 | 4.1875 | 4 | [] | no_license | """
Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL
"""
class Node():
def __init__(self, value):
self.value = value
self.next = None
class LinkedList():
def __init__(self):
self.head = None
def reverse_ll(head):
"""Given a singly linked list, return its... | true |
95b4e1e640106e96f7f271d35b46f5a57f1921b1 | Python | bjgiraudon/pyNamo | /simulate.py | UTF-8 | 13,750 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 17 16:25:04 2020
@author: Benjamin Giraudon
STATUS : - To add : - for the executable simulation : user input payoff matrices
better toggle and idle of plotting options
... | true |
8bab97e207cdeb842eeb487fd52f1a1ecbcfebd4 | Python | lion963/SoftUni-Python-Fundamentals- | /Exercise Dictionaries/ForceBook.py | UTF-8 | 876 | 3.078125 | 3 | [] | no_license | force_book_dict = {}
users = {}
command = input()
while not command == 'Lumpawaroo':
if '|' in command:
flag = False
side, user = command.split(' | ')
if user not in users:
users[user] = side
elif '-' in command:
user, side = command.split(' -> ')
users[use... | true |
69e93397ad60a70ed4e43020a1b1317d0583589d | Python | frclasso/turma3_Python1_2018 | /Cap06_estruturas_decisao/03_elif.py | UTF-8 | 157 | 3.890625 | 4 | [] | no_license | #!/usr/bin/env python3
x = 6
y = 6
# if ==> se
if x > y:
print('x é o maior')
elif x < y:
print('x é menor que y')
else:
print('Sao iguais') | true |
3142e8056c15cea5ca9ae5bd1cfc3b4ff679f528 | Python | cilame/any-whim | /auto_minewin7/CreateCate.py | UTF-8 | 6,619 | 2.96875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import os, pickle
from collections import OrderedDict
import cv2
import numpy as np
class CreateCate(object):
"""
categorical_crossentropy 训练的样本生成器
功能:
读取根据文件夹名字进行图片的读入
*生成对应的完整的 one-hot 训练数据集
*将其作为可进行训练的 numpy 数据类型直接使用
e.g: >>>s = CreateCate(picp... | true |
d2b9eb73ee06fb05ec3dd6ac3d8fdc9d8ee8adf7 | Python | gnboorse/binpacking | /tools/generator/generate_all.py | UTF-8 | 1,267 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env python3
import subprocess
import shutil
import os
import os.path
'''
Python script used for generating all of the
JSON files needed for the test plan.
'''
# algorithms in use
ALGORITHMS = [
"NextFit",
"FirstFit",
"FirstFitDecreasing",
"BestFit",
"BestFitDecreasing",
"PackingCo... | true |
fff01d0f2741ee2e815758cca6f1b7a6234ea693 | Python | student50/ssbm-top50-api | /melee.py | UTF-8 | 1,410 | 3.53125 | 4 | [] | no_license | import csv
def print_player(player):
matchup_data = []
json = {}
csvFile = open('2018h2h.csv')
csvReader = csv.reader(csvFile)
csvData = list(csvReader)
csvData[0] = list(filter(None, csvData[0])) #filters all the empty strings
opponents = csvData[0] #csvData[... | true |
79759c3f32bdfd53f1d2133c8333a9fdf7494827 | Python | crylearner/PythonRpcFramework | /rpc/json/message/Response.py | UTF-8 | 1,596 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | '''
Created on 2015-5-25
@author: 23683
'''
import json
from rpc.json.message.RpcMessage import RpcMessage, MSG_KEY_ID, MSG_KEY_ERROR, \
MSG_KEY_RESULT, MSG_KEY_PARAMS
class Response(RpcMessage):
'''
classdocs
'''
def __init__(self):
'''
Constructor
... | true |
84fa7818585339e24a63d4ff1e3fce742c8a2848 | Python | NarishSingh/Python-3-Projects | /randnumfileIO/RandNumIO.py | UTF-8 | 2,107 | 3.84375 | 4 | [] | no_license | # Random Number Generator File IO
# Date Created: 6/12/20
# Last Modified: 6/18/20
import math
import random
import sys
NUMBER_FILE = "nums.txt"
DELIMITER = " "
def write_nums(num_limit, rand_min, rand_max):
"""
write random numbers within range to file in rows of 10 digits
:param num_limit: number of ra... | true |
338e05845964c9c72e483aece71f4ca3465aef10 | Python | ethan9carpenter/Python-Crash-Course | /alienInvasion/gameFunctions.py | UTF-8 | 7,229 | 2.84375 | 3 | [] | no_license | import pygame
import sys
from bullet import Bullet
from alien import Alien
from time import sleep
class GameFunctions():
def __init__(self, settings, screen, ship, bullets, playButton, stats, aliens, scoreboard):
self.settings = settings
self.screen = screen
self.ship = ship
se... | true |
3c3128644abdcaa3ced60494f7f4295afe25e72a | Python | santosh-code/decision_tree | /diabetes.py | UTF-8 | 1,353 | 3.125 | 3 | [] | no_license | import pandas as pd
import numpy as np
from sklearn.model_selection import RandomizedSearchCV, GridSearchCV
data = pd.read_csv("C:/Users/USER/Desktop/DT/Diabetes.csv")
dum1=pd.get_dummies(data['_Class_variable'],drop_first=True)
data .columns = [c.replace(' ', '_') for c in data .columns]
final=pd.concat([data,... | true |
02598cc5cef97391d0bf86f3e1ecc3707ca74af2 | Python | jeethesh-pai/Computer-Vison-and-ML-Assignments | /sheet6/utils.py | UTF-8 | 3,235 | 2.828125 | 3 | [
"MIT"
] | permissive | import cv2
import matplotlib.pyplot as plt
import numpy as np
def showImage(img, show_window_now=True, _ax=None):
img, color_img = convertColorImagesBGR2RGB(img)
if _ax is None:
plt_img = plt.imshow(img, interpolation='antialiased', cmap=None if color_img else 'gray')
else:
plt_img = _ax.i... | true |
c3ba0af4e0b4f02463989196ba7df4827770dcbc | Python | BhatnagarKshitij/Algorithms | /LinkedList/mergeTwoSortedList.py | UTF-8 | 1,323 | 3.78125 | 4 | [] | no_license | '''
Question link: https://leetcode.com/problems/merge-two-sorted-lists/
Merge two sorted linked lists and return it as a sorted list.
The list should be made by splicing together the nodes of the first two lists.
'''
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next... | true |
ea9393de2256ebfd5192c2b5a93f3d066fc7d7ac | Python | zinsmatt/Programming | /CodeForces/785A-Anton_and_Polyhedrons.py | UTF-8 | 279 | 3.8125 | 4 | [] | no_license | n = int(input())
s = 0
for i in range(n):
p = input()
if p == "Tetrahedron":
s += 4
elif p == "Cube":
s += 6
elif p == "Octahedron":
s += 8
elif p == "Dodecahedron":
s += 12
elif p == "Icosahedron":
s += 20
print(s) | true |
e11863f6f99d081feb8273fa4e3cb35d7a5a066a | Python | dimDamyanov/PythonOOP | /Exams/2-apr-2020/skeleton/tests/test_controller.py | UTF-8 | 4,260 | 2.859375 | 3 | [] | no_license | import unittest
from project.controller import Controller
from project.player.advanced import Advanced
from project.player.beginner import Beginner
from project.card.magic_card import MagicCard
from project.card.trap_card import TrapCard
class TestBattleField(unittest.TestCase):
def initialize_players_with_cards(... | true |
4aa384178957b1e1fa9b4d3241a7eba0cd3e3226 | Python | mrobotique/python_dash | /indoortemp_sender.py | UTF-8 | 1,865 | 2.546875 | 3 | [] | no_license | #!/usr/bin/python
"""
Created on Tue Oct 17 16:32:14 2017
@author: mromero
"""
import yaml #Pefs load
import paho.mqtt.client as paho #mqtt lib
import os
import glob
import time
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0... | true |
4a922cfa19614ad1f88fd9c37b17318d8aaaf263 | Python | mark-ni/competitive-programming | /usaco/Contests/usaco_silver_3.py | UTF-8 | 644 | 2.84375 | 3 | [] | no_license | with open('mountains.in', 'r') as fin:
count = int(fin.readline().strip())
mountainList = []
for i in range(count):
line = fin.readline().strip().split(' ')
x = int(line[0])
y = int(line[1])
b1 = x + y
b2 = y - x
fax = False
for mountain in mountainList:
if b1 <= mountain[0] and ... | true |
efb298a8c2b5f3a229f55fdc4cb0d3ac941de97d | Python | frank2019/tech_note_blog | /common/python/tts.py | UTF-8 | 612 | 2.75 | 3 | [] | no_license | import win32com.client as wincl
from tkinter import *
def text2Speech():
text = e.get()
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak(text)
#window configs
tts = Tk()
tts.wm_title("Text to Speech")
tts.geometry("600x400")
tts.config(background="#708090")
f=Frame(tts,height=600,width=800,bg="#bebebe")
f.grid... | true |
fd46b19a421208a1df74ebdd198f63e18395ddc1 | Python | Exorust/Fuzzy-Time-Series-Analysis | /plot.py | UTF-8 | 587 | 2.75 | 3 | [] | no_license | import pandas
import numpy as np
import matplotlib.pyplot as plt
df = pandas.read_csv('newdata.csv')
# print(df)
X = df["Days"].values
# print(X)
Y_Mactual = df["Mactual"].values
Y_Mpred = df["Mpred"].values
Y_Tactual = df["Tactual"].values
Y_Tpred = df["Tpred"].values
plt.plot(X,Y_Mactual,color="red",label="Actual V... | true |
f1580cb6fbfff1391975c69caf447f3c0b5ba846 | Python | starman011/python_programming | /02_Lists&tuples/01_lists.py | UTF-8 | 152 | 3.71875 | 4 | [] | no_license | #creating a list using []
a = [1,3,23,4,3]
#print the list with index using a[0]
print(a[0])
#using different types
b = [1,'saqlain' ,1.50]
print(b[0:]) | true |
43ab2123d1ae3d9ea4d6dbb5baec12260607d3ff | Python | sai-kumar-peddireddy/PythonLearnigTrack | /Strings/DocStrings.py | UTF-8 | 729 | 4 | 4 | [] | no_license | """
Sun Jul 22 15:13:47 IST 2018
source :- https://www.geeksforgeeks.org/python-docstrings/
It’s specified in source code that is used, like a comment, to document a specific segment of code.
Unlike conventional source code comments, the docstring should describe what the function does, not how.
"""
def additionfun(p... | true |
6f2efc2bb79c1da14a8a5830fecc6f262b0043f7 | Python | alexwork13/python_lessons | /statements/compr_list_2.py | UTF-8 | 208 | 3.90625 | 4 | [] | no_license | for i in range(1,100):
if i % 3 == 0:
print(f"{i} - Fizz div 3")
if i % 5 == 0:
print(f"{i} - Buzz div 5")
if i % 3 == 0 and i % 5 == 0:
print(f"{i} - FizzBuzz div 3and5") | true |
ed07c5d0cabf2b1b274622f933c78e7133ffd472 | Python | arsezzy/python_base | /lesson3/lesson3_5.py | UTF-8 | 1,461 | 4.15625 | 4 | [] | no_license | #!/usr/bin/python3
def summarization(current_sum, digits_list, symbol):
'''Summarize integers in digit_list and add it to current_sum
current_sum - integer
digits_list - list of digit, where digit is string
symbol - special symbol for exit. If special symbol is met,
stop to sum and return one_mo... | true |
b5f2f41401766568f09b4bed39d468acd24e9651 | Python | code4tots/simple-amixer-gui | /simple_amixer_gui.py | UTF-8 | 1,951 | 3.15625 | 3 | [] | no_license | #!/usr/bin/python
'''
Should be compatible with both Python 2 and 3.
From what I understand, the only issue is the tkinter package name.
'''
import sys
from os import popen
if sys.version_info >= (3,0):
from tkinter import *
else:
from Tkinter import *
'''
callbacks
'''
def on_new_scale_value(v):
popen('amixer ... | true |
113bbfe7afed99f60474419ec2bcf5a79255c90b | Python | ZhengkaiZ/Summer-Project-Data-Processing- | /graph_helper.py | UTF-8 | 2,630 | 3.109375 | 3 | [] | no_license | """ Data Analysis based on Graph
This code will generate grapg.out file to print out our desired graph
"""
import sys
import networkx as nx
import pylab as plt
from sets import Set
def read_device(file_name, static_device):
"""
this module is to read the device list from disk and remove noise.
... | true |
bf62bf514a66ed993fe7d696423a743da3f5d4a5 | Python | CyborgVillager/Learning_py_info | /basic info/Diction/dicti0.py | UTF-8 | 589 | 3.171875 | 3 | [] | no_license | month_Convert = {
'Jan': {'January', '31'},
'Feb': 'February',
'Mar': 'March',
'Apr': 'April',
'May': 'May',
'Jun': 'June',
'Jul': 'July',
'Aug': 'August',
'Sep': 'September',
'Oct': 'October',
'Nov': 'November',
'Dec': 'December',
}
day_Convert = {
'Jan': '31',
'... | true |
3f55dfb7b05bae020e5e6960d08da984ddb59f3c | Python | rbunge-nsc/it111-demos | /Modify/ModifyFile.py | UTF-8 | 212 | 3.578125 | 4 | [] | no_license | filename = input("Enter a file name:")
f = open(filename, "a")
print("File name " + filename + " has been opened.")
textinput = input("Enter some text to add to the file:")
f.write(textinput)
f.close()
| true |
16982f2479f252a3df1e6db5ccbd60c8d959e669 | Python | ErenBtrk/Python-Fundamentals | /Numpy/NumpyLinearAlgebra/Exercise13.py | UTF-8 | 253 | 3.921875 | 4 | [] | no_license | '''
13. Write a NumPy program to calculate the QR decomposition of a given matrix.
'''
import numpy as np
m = np.array([[1,2],[3,4]])
print("Original matrix:")
print(m)
result = np.linalg.qr(m)
print("Decomposition of the said matrix:")
print(result) | true |
dac79a3997dec9bfaea7cd88364f949af61b8870 | Python | nekapoor7/Python-and-Django | /PythonNEW/Practice/StringVowelsSet.py | UTF-8 | 156 | 3.625 | 4 | [] | no_license | """Python program to count number of vowels using sets in given string"""
import re
s = input()
s1 = s.lower()
ss = re.findall(r'[aeiou]',s1)
print(set(ss)) | true |
a8547e75ba2ceb5c70d74f3c25cfa37b94adffc8 | Python | gk1914/neural-network-mnist | /neural_network.py | UTF-8 | 4,923 | 3.15625 | 3 | [] | no_license | import numpy as np
import random
class NeuralNetwork(object):
def __init__(self, layer_sizes):
"""Neural network consisting of 'self.num_layers' layers. Each layer has
a specific number of neurons specified in 'layer_sizes', which defines
the architecture of the NN.
Weig... | true |
03b548397b906cc5f1edd9fad1382c646fdaca2a | Python | pacellig/personal | /RSA_AES_key_encryption.py | UTF-8 | 2,809 | 3.46875 | 3 | [] | no_license | """
Created on: 30/05/18
Author : pacellig
Requires pycryptodome ($ pip install pycryptodome) in order to use 'AES.MODE_EAX' mode.
1) Produce a private/public key couple
2) Use the public key (RSA) to encrypt the generated OTP
3) Use the generated OTP to encrypt, via AES, the desired message
4) Decrypt the message... | true |
988ac42e624903a79be427b4aef9d0b5ccc6aa02 | Python | 6/jcrawler | /2ch_parser.py | UTF-8 | 4,750 | 2.71875 | 3 | [
"MIT"
] | permissive | import glob
import os
import re
import csv
import operator
from datetime import datetime
# Source: http://stackoverflow.com/questions/3217682/checking-validity-of-email-in-django-python
REGEX_EMAIL = re.compile("[\w\.-]+@[\w\.-]+\.\w{2,4}")
def analyze_2ch():
files = glob.glob(os.path.join("data/2ch/", "*.data"))
... | true |
61d9cbaa5f17203ee490e9ce1ee17cdf4d3b7c4e | Python | Bgh0602/learn-python | /dice.py | UTF-8 | 422 | 3.75 | 4 | [] | no_license | # 주사위 게임
'''주사위 번호를 맞출 수 있도록 함. 무한반복을 하고 만약 맞추면 반복을 탈출한다.'''
import random
diceN = random.randint(1, 6)
trial = 1
while True:
guess = int(input('What is the dice number?(1~6):'))
if guess != diceN:
print('again!')
trial += 1
if guess == diceN:
print('correct!')
print('your tr... | true |
388c09e071b8ac5efc4e90623c3c892a6070db69 | Python | jarinfrench/iprPy | /iprPy/tools/get_mp_structures.py | UTF-8 | 3,740 | 2.671875 | 3 | [] | no_license | # Standard Python libraries
from pathlib import Path
import uuid
# https://github.com/usnistgov/DataModelDict
from DataModelDict import DataModelDict as DM
# https://github.com/usnistgov/atomman
import atomman as am
# iprPy imports
from .. import libdir
def build_reference_crystal_model(name, ucell, sourcename, sou... | true |
3381741e9b71620ce4ab918482d1f92128f967aa | Python | 18303585361/Zero | /11.面向对象-高阶/5.面向对象-高阶-魔术方法(二).py | UTF-8 | 2,801 | 4.40625 | 4 | [] | no_license | # 面向对象 魔术方法(二)
'''
1. __len__
触发机制:当使用 len 函数去检测当前对象的时候自动触发
作用:可以使用 len 函数检测当前对象中某个数据的信息
参数:一个 self 接收当前对象
返回值:必须有,并且必须是一个整型
注意事项:len 要获取什么属性的值,就在返回值中返回哪个属性的长度即可
2. __str__
触发机制:当使用 str 或者 print 函数对对象进行操作时,自动触发
作用:代替对象进行字符串的返回,可以自定义打印的信息
参数:一个 self 接收当前对象
返回值:必须有,而且必须是字符串类型
3. __repr... | true |
8bcebebedc397ac01b890b5f512168fa1cb1ab0b | Python | m-bronnikov/Cryptography | /lab3/variant_number.py | UTF-8 | 681 | 3.171875 | 3 | [] | no_license | # Made by Bronnikov Max
from pygost import gost34112012256
import sys
def number_from_str(family):
if not isinstance(family, str):
return -1
# Working only with .encode() method, else TypeError
last = gost34112012256.new(family.encode()).digest()[-1]
last &= 15
if last >= 10:
return... | true |
c7d17c63824819379698788245f00753c1300ca7 | Python | youaresoroman/pp1 | /01-TypesAndVariables/duringclass/21.py | UTF-8 | 61 | 2.90625 | 3 | [] | no_license | C = float(input('Podaj liczbe:'))
F = (C * 1.8) + 32
print(F) | true |
0e946aa3697e721ce27671d8b2ca36a5993ae644 | Python | andreamatranga/building-damage | /damage/models/cnn.py | UTF-8 | 2,284 | 2.703125 | 3 | [] | no_license | from tensorflow.keras.layers import Conv2D, MaxPooling2D, Dense, Flatten, BatchNormalization
from tensorflow.keras.models import Sequential
from damage.models.losses import *
from damage.models.base import Model
class CNN(Model):
metrics = ['accuracy', recall, specificity, precision, negatives]
def __init_... | true |