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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
00756c170529caf80449aa2e41783c60b2a14dad | Python | yennanliu/CS_basics | /leetcode_python/Binary_Search/find-smallest-letter-greater-than-target.py | UTF-8 | 1,226 | 4.03125 | 4 | [] | no_license | # V0
# V1
# https://blog.csdn.net/fuxuemingzhu/article/details/79137225
# IDEA : LINEAR SEARCH
class Solution(object):
def nextGreatestLetter(self, letters, target):
"""
:type letters: List[str]
:type target: str
:rtype: str
"""
for letter in letters:
# ca... | true |
d1987ff6983d4926594a40f89cfaa46e1b255f50 | Python | edge555/Online-Judge-Solves | /AtCoder/Beginner Contest/137/B - One Clue.py | UTF-8 | 99 | 3.359375 | 3 | [] | no_license | n,m=map(int,input().split())
mn=m-n+1
mx=m+n-1
for i in range(mn,mx+1):
print("%d "%(i),end="") | true |
464578cefc05a084c570e4f00f39a7a235d58d7e | Python | oliveirajonathas/python_estudos | /pacote-download/pythonProject/exercicios_python_guanabara/ex005.py | UTF-8 | 209 | 3.859375 | 4 | [
"MIT"
] | permissive | numero = int(input('Digite um número inteiro: '))
antecessor = numero - 1
sucessor = numero + 1
print('O antecessor e o sucessor de {} são, respectivamente, {} e {}.'.format(numero, antecessor, sucessor))
| true |
7e775e054cbbb6aa1810473d6191d282ce6d6b52 | Python | priyansh19/pytype | /pytype/tests/test_errors.py | UTF-8 | 34,937 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | """Tests for displaying errors."""
from pytype import file_utils
from pytype.tests import test_base
class ErrorTest(test_base.TargetIndependentTest):
"""Tests for errors."""
def testDeduplicate(self):
_, errors = self.InferWithErrors("""\
def f(x):
y = 42
y.foobar
f(3)
f(4)... | true |
1599db72572c54a999eb97ebf4d5f09604868ef6 | Python | altareen/csp | /10Files/stockprices.py | UTF-8 | 370 | 3.296875 | 3 | [] | no_license | # analysing the stock price of baidu.com, ticker symbol: BIDU
total = 0.0
num = 0
fhand = open("bidu.csv")
fhand.readline() # discards the first line of column labels
for line in fhand:
line = line.rstrip()
line = line.split(",")
price = float(line[-2])
total += price
num += 1
average = total/num... | true |
fb463d8f64c18b8a634aa3692ed1c07fd5d7ca42 | Python | rodrigolins92/exercicios-diversos | /letras_sao_iguais.py | UTF-8 | 268 | 3.96875 | 4 | [
"Apache-2.0"
] | permissive | def SaoIguais(a, b, c):
if (a == b) and (b == c):
return print("São Iguais")
else:
return print("São diferentes")
x1 = input("Primeira letra: ")
x2 = input("Segunda letra: ")
x3 = input("Terceira letra: ")
resposta = SaoIguais(x1, x2, x3)
| true |
30570d3eeaeebfd4f82b0b092efe909dd0ba6e5a | Python | Shatki/easydoc | /users/models.py | UTF-8 | 3,881 | 2.515625 | 3 | [] | no_license | from django.db import models
from django.contrib.auth.models import AbstractUser, BaseUserManager
from easydoc.validators import phone, alpha_all, login, email
# Класс менеджера должен переопределить методы create_user() и create_superuser().
class UserManager(BaseUserManager):
def create_user(self, username, nam... | true |
832954655d8855600a5bd92b8438de1ad5470ebf | Python | willymonee/IFB104-News-Feed-Aggregator | /news aggregator/news_aggregator.py | UTF-8 | 38,036 | 3.140625 | 3 | [] | no_license |
#-----Assignment Description-----------------------------------------#
#
# News Feed Aggregator
#
# In this assignment you will combine your knowledge of HTMl/XML
# mark-up languages with your skills in Python scripting, pattern
# matching, and Graphical User Interface design to produce a useful
# applic... | true |
005592bca3d79b92250cc19d2c6a704fc86c0c72 | Python | gaborvecsei/Neural-Network-Dreams | /utils.py | UTF-8 | 3,952 | 2.703125 | 3 | [] | no_license | import os
import subprocess
import tempfile
from pathlib import Path
from typing import Tuple, Callable
import cv2
import matplotlib.pyplot as plt
import numpy as np
import youtube_dl
def create_rnn_data(data: np.ndarray, time_steps: int) -> Tuple[np.ndarray, np.ndarray]:
if time_steps >= len(data):
rais... | true |
12db42b8070bc948b07083208ea1e2a250ca7cb1 | Python | eliaspk/Pygame-Genetic-Algorithm | /population.py | UTF-8 | 1,902 | 3.78125 | 4 | [] | no_license | import random
from rocket import Rocket
class Population:
"""
Class that represents the population of the rockets.
Attributes
----------
rockets : list
List of all rockets in game
mating_pool : list
List that will contain a distribution of rockets that depends on their fitness
"""
def __ini... | true |
2a4f61db8a9fc77e22355f197a551a7c2189a88f | Python | Shoter99/Projects | /PythonProjects/Ciphers/vigenera.py | UTF-8 | 423 | 3.046875 | 3 | [] | no_license | import sys
keyword = ""
keyword = sys.argv[1:]
if(keyword == ""): quit()
keyword = str("".join(keyword)).lower()
print("")
keyword = sorted(keyword+"a")
keyword = list(dict.fromkeys(keyword))
for letter in keyword:
letter = ord(letter)
if(96>letter>122):
continue
for _ in range(26):
if(letter <= 122):
prin... | true |
10cdf06df496bb40508df0ac58857ec0f0a04bdb | Python | FelSiq/machine-learning-learning | /deep-learning-algorithm-implementation/from-scratch/deprecated/dl-concepts/regularization.py | UTF-8 | 1,436 | 3.53125 | 4 | [] | no_license | """Implement different types of regularizations."""
import numpy as np
def l2(W: np.ndarray, lambda_: float = 0.01, exclude_bias: bool = False) -> float:
"""Ridge (L2) regularization.
It is defined as the sum of element-wise squared weights.
It has the property of encouraging models with distributed
... | true |
984582fbf9b50b920c2e13f8555598e4065c6479 | Python | robotics-in-concert/rocon_devices | /rocon_device_tools/rocon_iot_bridge/src/rocon_iot_bridge/connector.py | UTF-8 | 1,511 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env python
#
# License: BSD
# https://raw.github.com/robotics-in-concert/rocon_devices/license/LICENSE
#
#################################################################################
from abc import ABCMeta, abstractmethod
class Connector(object):
"""
Abstract base class that defines the AP... | true |
b121e25076403c2a3c1520a8ce852fd47a7f603c | Python | extremecoders-re/simuvex | /simuvex/procedures/libc___so___6/strcpy.py | UTF-8 | 646 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | import simuvex
from simuvex.s_type import SimTypeString
class strcpy(simuvex.SimProcedure):
#pylint:disable=arguments-differ
def run(self, dst, src):
self.argument_types = {0: self.ty_ptr(SimTypeString()),
1: self.ty_ptr(SimTypeString())}
self.return_type = self.... | true |
a3e058dad6eb788389eaf9036f1b948c1289e986 | Python | kdogyun/machine_learning | /HW#4.4.py | UTF-8 | 1,623 | 2.9375 | 3 | [] | no_license | import tensorflow as tf
from tensorflow import keras
import numpy as np
# Data Augmentation (3가지 기법 이상 적용)
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
train_images = train_images / 255.0
test_images = test_images / 255.0
train_imag... | true |
4e1148bac32856a404ce9ad2fdef79cb4632ba5f | Python | oolsson/oo_eclipse | /Practise_stuff/pandas/df/time_series/random_holdings.py | UTF-8 | 383 | 2.703125 | 3 | [] | no_license | import random
import pandas as pd
import numpy as np
import time
import heapq
df=pd.DataFrame(np.random.uniform(0,1,11))
x=heapq.nlargest(2, df.values)
df2=pd.DataFrame(index=df.index)
for i in range(0,5):
df=pd.DataFrame(np.random.uniform(0,1,11))
x=heapq.nlargest(2, df.values)
df2[i]=(df... | true |
a66c0ed48b358dafebdb84786833505eeb75a4d7 | Python | yknot/adventOfCode | /2016/18_01.py | UTF-8 | 1,273 | 3.859375 | 4 | [] | no_license | def trap(l, c, r):
"""calculate if there is a trap at the specified spot"""
if l == "^" and c == "^" and r == ".":
return True
elif l == "." and c == "^" and r == "^":
return True
elif l == "^" and c == "." and r == ".":
return True
elif l == "." and c == "." and r == "^":
... | true |
714e3498a803734ecd7f2bd1369cd2d32493362a | Python | doomcatLee/pythonScript | /main.py | UTF-8 | 1,867 | 3.421875 | 3 | [] | no_license | import csv
# instantiate empty array
rowArray = [];
# pull out
with open('test.csv', 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in spamreader:
rowArray.append(', '.join(row))
#print(rowArray);
# ABOVE RETURNS ['policyID,statecode,county,eq_site_limit,hu_si... | true |
f2e8b6a9a09d9a62d627e581a81b29f6193978d2 | Python | kokoakuma/algorithm_practice | /AOJ/Part5_Search/hash.py | UTF-8 | 1,638 | 3.4375 | 3 | [] | no_license | class Dictionary:
def __init__(self):
self.elements = set()
def insert(self, x):
self.elements.add(x)
def find(self, y):
if y in self.elements:
print('yes')
else:
print('no')
dic = Dictionary()
N = int(input())
for i in range(N):
command = input()
if command[0] == 'i':
dic.in... | true |
954abe57127c01dd6a85db39326e97ba0e566ef5 | Python | NightKirie/MULTIMEDIA-CONTENT-ANALYSIS | /hw1/src/4_Edge_Detection.py | UTF-8 | 3,908 | 2.6875 | 3 | [] | no_license | import os
import numpy as np
import cv2
import matplotlib.pyplot as plt
import math
import collections
from Ground_Truth import *
def Edge_Detection(file_list, t):
entering_ratio = []
exiting_ratio = []
shot_change_list = []
img_1 = cv2.GaussianBlur(cv2.cvtColor(cv2.imread(file_list[0]), cv2.COLOR_BGR... | true |
6fa56e1a69c0f5dcbb93dc139ed05e6ade7c3772 | Python | ericmoritz/gittest | /utils.py | UTF-8 | 172 | 2.75 | 3 | [] | no_license | """This is a common utils file"""
def add(x, y):
return x + y
def sub(x, y):
return x - y
def multi(x, y):
return x * y
def divide(x, y):
return x / y
| true |
d5b47817498d6cd0a6d50868609566ec9b5d2653 | Python | WoodsChoi/algorithm | /al/al-336.py | UTF-8 | 5,514 | 3.796875 | 4 | [] | no_license | # 回文对
# hard
'''
可拼接成回文串。
示例 1:
输入: ["abcd","dcba","lls","s","sssll"]
输出: [[0,1],[1,0],[3,2],[2,4]]
解释: 可拼接成的回文串为 ["dcbaabcd","abcddcba","slls","llssssll"]
示例 2:
输入: ["bat","tab","cat"]
输出: [[0,1],[1,0]]
解释: 可拼接成的回文串为 ["battab","tabbat"]
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/palindrome-pairs
著作权归领扣... | true |
80bfd04b9ee9b214487d2821c5974416ec81f907 | Python | tzlaine/flat_map | /perf/linux_gcc_data/std_map.py | UTF-8 | 2,039 | 2.6875 | 3 | [] | no_license | int_timings = [
{'size': 8, 'insert': 0.0082838,'iterate': 0.0010476,'find': 0.0056996,},
{'size': 16, 'insert': 0.016761,'iterate': 0.0009918,'find': 0.0102254,},
{'size': 32, 'insert': 0.035271,'iterate': 0.0017184,'find': 0.0195838,},
{'size': 64, 'insert': 0.0716708,'iterate': 0.0033526,'find': 0.04... | true |
a3db65c060368d960fc5dd0666b9ea99e52a78f9 | Python | tonidezman/sleep-settings | /joan_sleep/dashboard/tests/test_forms.py | UTF-8 | 1,736 | 2.671875 | 3 | [] | no_license | from django.test import TestCase
from datetime import time
from dashboard.models import SleepSetting
from dashboard.forms import SleepSettingsForm
class SleepSettingsFormTest(TestCase):
def setUp(self):
setting = SleepSetting()
setting.monday = True
setting.save()
def test_valid_form_... | true |
91cb53ace91de425fb4bf83859eb8b62c69d6de2 | Python | sullivat/primer-calc | /test_primer_calc.py | UTF-8 | 1,417 | 3.1875 | 3 | [
"MIT"
] | permissive | from primer_calc import *
# Testing Primer class initialization
def test_normal_primer_init_str():
primer = Primer('Test', 'aaacccgggttt')
assert primer.name == 'Test'
assert primer.sequence == 'aaacccgggttt'
def test_abnormal_primer_init():
primer = Primer('Test Primer', 'qewropiuqerattdfcgckljaaaafd... | true |
fe3e6cd9d0a8e49fa589c80b4823ce0eeb8b5ea3 | Python | BoxuanMa/vis-for-course | /lda.py | UTF-8 | 1,417 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
chachedWords = stopwords.words('english')
from nltk.stem.porter import PorterStemmer
from gensim import corpora, models
import gensim
import csv
import numpy as np
np.set_printoptions(threshold=np.inf)
doc_set=[]
f=open(... | true |
5cf6c86218a8b87122f3ed1433f21a1bf3c2f11e | Python | mighty1231/stamina | /data.py | UTF-8 | 5,159 | 3.21875 | 3 | [] | no_license |
class Data:
def __init__(self, fname):
pos = []
neg = []
alphabet_size = -1 # 0 to alphabet_size-1
with open(fname, 'rt') as f:
for line in f.readlines():
tokens = line.split(' ')
if tokens[-1] == '\n':
tokens = tokens[:-1]
# evaluate maximum alphabet
string = bytes(map(int, tokens[... | true |
d76d50e69f2a98ae5975aca357519057e450706b | Python | ehauckdo/marioGraph | /helper/reachability.py | UTF-8 | 1,067 | 3.03125 | 3 | [] | no_license | import logging, inspect
logger = logging.getLogger(__name__)
def is_reachable(p1, p2, n, dist=4):
logger.debug(" (CALL) {}".format(inspect.stack()[0][3]))
def area(p1_x, p1_y, p2_x, p2_y, p3_x, p3_y):
return abs((p1_x*(p2_y-p3_y) + p2_x*(p3_y-p1_y)
+ p3_x*(p1_y-p2_y))/2.0)
def inside_triangle(n1, n2... | true |
b394ca68f5fff753311b909b4dc3de458492f7e8 | Python | uetiko/Algoritmos | /abarrientos/algoritmos.py | UTF-8 | 1,130 | 3.640625 | 4 | [] | no_license | class Ordenamiento(object):
aux = None
listaNoOrdenada = None
sizeList = None
def __init__(self):
self.aux = 0
self.listaNoOrdenada = list()
self.sizeList = 0
def crearLista(self):
lengthList = int(raw_input('Cuantos elementos tendra su lista?'))
for index ... | true |
a07145efc692d3aa58b4ff213404890ef2e8ba9d | Python | gorilik324/ctax | /src/BalanceQueue.py | UTF-8 | 4,616 | 3.296875 | 3 | [
"MIT"
] | permissive | from collections import deque, defaultdict
from decimal import Decimal
from enum import Enum
from functools import reduce
from src.NumberUtils import currency_to_string
from src.bo.SellInfo import SellInfo
from src.bo.Transaction import TransactionType
class QueueType(Enum):
"""
Type of queue.
"""
FI... | true |
33d664698aedf51ae0d93815dcb3cf414c7f9be8 | Python | zh414/python-core | /8/excise8-8.py | UTF-8 | 122 | 3.109375 | 3 | [] | no_license | #jie cheng
def jie(n):
s=1
print n,'! = ',
while n >= 1:
s = s*n
n = n-1
print s
jie(4) | true |
38c29c4c06f932c1ffaf39beaa977d157a200e6b | Python | GeekStudioHIT/PythonHack | /Python3Test/re/ReTest.py | UTF-8 | 456 | 2.90625 | 3 | [] | no_license | import re
# m = re.match('foo', 'foo')
# m = re.match('foo', 'seafood')
# m = re.search('foo', 'seafood')
# m = re.match('.abc', ' abc')
# if m is not None:
# print(m.group())
# pattern = '\w+@\w+\.com'
# print(re.match(pattern, 'nobody@gmail.com').group())
# pattern = '\w+@(\w+\.)?\w+\.com'
# print(re.match(pat... | true |
9ae42c09ebb7728aa35e1b89801805a808a7e31b | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_155/1114.py | UTF-8 | 335 | 3.296875 | 3 | [] | no_license | t = int(raw_input())
x = 1
for _ in xrange(t):
smax, s = raw_input().split(" ")
smax = int(smax)
y = 0
total = 0
for i, si in enumerate([int(i) for i in s]):
if i >= total:
y += (i - total)
total += (i - total)
total += si
print "Case #{}: {}".format(x,... | true |
6439e67095443b418268f89da89acf94103fccd0 | Python | Aasthaengg/IBMdataset | /Python_codes/p03239/s748239513.py | UTF-8 | 175 | 2.546875 | 3 | [] | no_license | N,T=map(int,input().split())
cost=10**9
for _ in range(N):
c,t=map(int,input().split())
if t<=T:
cost=min(cost,c)
ans=cost if cost!=10**9 else "TLE"
print(ans) | true |
1b8f1c4583aa178d129c88a4f69c541a6d3433f7 | Python | jonkoi/QNN-Evaluation | /nnUtils_ABC.py | UTF-8 | 19,898 | 2.734375 | 3 | [] | no_license | import tensorflow as tf
import math
from tensorflow.python.training import moving_averages
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.framework import ops
def binarize(x):
"""
Clip and binarize tensor using the straight through estimator (STE) for the gradient.
"""
g = tf... | true |
2a32938b66771087a974f5f3037ede1908537c34 | Python | nikky4D/Zero-Shot-Detection-via-Vision-and-Language-Knowledge-Distillation | /modules/load_data.py | UTF-8 | 2,958 | 3.015625 | 3 | [] | no_license | import os
import pickle
import numpy as np
from numpy.core.defchararray import array, decode
def load_feature(feature_path, label_path):
r"""
load features extracted from ResNet101 to a two demension array
it can create an .npy file containing all the feature and it can be load at a super fast speed,so us... | true |
f74c33b7d94c81ec1cadfbb2f495336ad6632715 | Python | kaschaefer/proj5-karaoke | /karaoke/pre.py | UTF-8 | 830 | 3.359375 | 3 | [] | no_license | """
Pre-process POIs from a text file to load onto the map
"""
import logging
logging.basicConfig(format='%(levelname)s:%(message)s',
level=logging.INFO)
log = logging.getLogger(__name__)
def process(raw):
cooked = []
for line in raw:
x = {}
log.debug("Line: {}".format(line)... | true |
7eb64b66f2321c7a33447d01171a9d4e58be3a15 | Python | seoul-ssafy-class-2-studyclub/GaYoung_SSAFY | /test/line_2020/programming4.py | UTF-8 | 3,367 | 3 | 3 | [] | no_license | from collections import deque
def solution(maze):
answer = 0
return answer
# maze = [[0, 1, 0, 1], [0, 1, 0, 0], [0, 0, 0, 0], [1, 0, 1, 0]]
# maze = [[0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]
# maze = [[0, 1, 0, 0, 0, 0], [0, 0, 1,... | true |
21dadec4337a331547c68afed7d1c3f1cc307251 | Python | vkuznet/WMCore | /test/python/WMCore_t/Services_t/UUID_t.py | UTF-8 | 1,373 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | #!/bin/env python
from __future__ import print_function
from builtins import str
import unittest
import time
from WMCore.Services.UUIDLib import makeUUID
class UUIDTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testUUID(self):
listOfIDs = []... | true |
8f4a40ea36305c514e395ac2ae8cd3eba469aff5 | Python | RobotNo42/old_coed | /project/python_fullstack/day21/test1.py | UTF-8 | 314 | 3.3125 | 3 | [] | no_license | from threading import Thread
import time
class MyThread(Thread):
def __init__(self, num):
super().__init__()
self.num = num
def run(self):
print("running on number:%s" % self.num)
time.sleep(3)
t1 = MyThread(56)
t2 = MyThread(78)
t1.start()
t2.start()
print("ending") | true |
ca66630affc3f93b5316fce769d5ea02b4b211c2 | Python | sammypudjianto/PythonLib | /Games/Platformer/asset_loader.py | UTF-8 | 2,120 | 2.796875 | 3 | [
"MIT"
] | permissive | import os
import re
import pygame as p
class AssetLoader():
"""
Scan asset folders and import images
"""
ASSETSPATH = './Assets/'
PNGEXT = '.png'
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super(AssetLoader, cls).__new__(cls)
... | true |
76a173e73b9bc71f4e0dcf0c1442ec5ea535936d | Python | wxqhphy/udacity | /find_lane_lines/color_selection.py | UTF-8 | 1,582 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 09:56:33 2019
@author: wxq
"""
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
image = mpimg.imread('test.jpg')
print('This image is:',type(image), 'with dimensions:', image.shape)
ysize = image.shape[0]
xsize = image.shape[1]
color... | true |
09893514ea14f059c651988f42a0099b40f20e51 | Python | Eduardo271087/python-udemy-activities | /section-10/multiple-inheritance.py | UTF-8 | 521 | 4 | 4 | [] | no_license | class Primera:
def __init__(self):
print("Yo soy la primera clase")
def primera(self):
print("Este es el método heredado de Primera")
class Segunda:
def __init__(self):
print("Yo soy la segunda clase")
def segunda(self):
print("Este es el método heredado de Segunda")
class Tercera(Primera, S... | true |
9ae888815014da16952c953dbcb8f391d0e05ff8 | Python | vishalbelsare/torchsde | /examples/cont_ddpm.py | UTF-8 | 11,421 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | true |
dcfa3c162a5f243d67a42ccdb36736fcbc043020 | Python | mrgrit/Tensorflow | /tensorboard_test.py | UTF-8 | 1,472 | 2.71875 | 3 | [] | no_license | import tensorflow as tf
import numpy as np
x = [[0,0], [0,1], [1,0], [1,1]]
y = [[0], [0], [0], [1]]
learning_rate = 0.01
X = tf.placeholder(tf.float32, [None, 2], name="X-input")
Y = tf.placeholder(tf.float32, [None, 1], name="Y-input")
with tf.name_scope("Layer") as scope:
W = tf.Variable(tf.rando... | true |
fee8834e4f8e9510ea6a17db096535d78bf75087 | Python | q36762000/280201102 | /lab4/example3.py | UTF-8 | 75 | 3.25 | 3 | [] | no_license | nums = [8, 60, 43, 55, 25, 134, 1]
x = 0
for i in nums:
x += i
print(x) | true |
27a3d52ee6eb0382840650734d38592f2fb216a9 | Python | zcding001/stroll | /script/utils/file_util.py | UTF-8 | 6,034 | 2.921875 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: UTF-8 -*-
# author : zc.ding@foxmail.com
# desc : 文件操作工具类
import re
import os
import logging
import shutil
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
def create_file(file_path, content=""):
"... | true |
6e1f0d2a1ba5696dd5ec5e08142866ce90b06c11 | Python | Khangaroooo/ITI1120 | /A5_300007277/a5_part1_300007277.py | UTF-8 | 1,143 | 4 | 4 | [] | no_license | def largest_34(a):
'''
(List) -> int
returns the sum of the 3rd and 4th largest values in
the list a
'''
a.sort(reverse= True)
return (sum(a[2:4]))
def largest_third(a):
'''
(List) -> int
computes the sum of the len(a)//3 of the
largest values in the list a
'''
a.sort(reverse= True)
return ... | true |
df4c4ce3939918c17b2de93d6d4e9572af3fd226 | Python | komuro-zero/get-trade-data | /bitflyer_csv.py | UTF-8 | 3,789 | 2.515625 | 3 | [] | no_license | from __future__ import unicode_literals, print_function
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pybitflyer
import time
import pytz
from quoine.client import Quoinex
from datetime import datetime, timezone, timedelta
import bitmex
import csv
import os
class bitflyer_BTCJPY():
... | true |
90285c623c739740f06e4ccd160df9946cee80d9 | Python | rapid7/insightconnect-plugins | /plugins/ipinfo/icon_ipinfo/actions/ip_lookup/action.py | UTF-8 | 904 | 2.640625 | 3 | [
"MIT"
] | permissive | import komand
from .schema import IpLookupInput, IpLookupOutput, Input
# Custom imports below
import requests
class IpLookup(komand.Action):
def __init__(self):
super(self.__class__, self).__init__(
name="ip_lookup",
description="Lookup IP Address Information",
input=I... | true |
7fda72a52ba2ffcc768805ac315c626caa420a05 | Python | wdczz/APF_Swarm_Control_Simulator | /python_code/Quadrotor/Bird.py | UTF-8 | 510 | 2.921875 | 3 | [
"MIT"
] | permissive | import numpy as np
import sys
sys.path.append('../')
from Obstacle import Obstacle
class Bird(object):
def __init__(self, initialPosition):
self.position = np.array(initialPosition)
def getBodyPosition(self):
return np.array([self.position, self.position], dtype="object")
def connect... | true |
88f44530bbfa544a034906edb9f8e8126432448d | Python | kevin41307/Python | /Decorator/Decorator_and_Logging.py | UTF-8 | 846 | 3.390625 | 3 | [] | no_license | #!/usr/bin/python
'''
利用Decorator與Logging
紀錄程式執行經過
'''
import logging
import time
def Big(func):
def Mid(*args,**kwargs):
logger = logging.getLogger('decorator')
logger.setLevel(logging.INFO)
f_handle = logging.FileHandler("/tmp/test")
formatter = logging.Formatter('%(asctime)s %(na... | true |
940cadfc6f61551f7a4f80c16c5f759a731698ad | Python | ameya-salankar/similarities | /helpers.py | UTF-8 | 1,824 | 3.46875 | 3 | [] | no_license | from nltk.tokenize import sent_tokenize
def lines(a, b):
"""Return lines in both a and b"""
li = []
set_a = set([])
set_b = set([])
st = ""
t = 0
ln_a = len(a)
ln_b = len(b)
for i in a:
t += 1
if (i == '\n' or t == ln_a):
if t == ln_a:
... | true |
7d2837e90f1b11b316f751aa066d904e78bdb565 | Python | Holmes-pengge/asyncio_demo | /domain_test/domain_test_v1.0.2.py | UTF-8 | 1,803 | 2.640625 | 3 | [] | no_license | import json
import socket
import asyncio
from pythonping import ping
import time
"""
{
"domains": [{
"url": "www.baidu.com",
"isalvie": 0,
"finalurl": ""
}, {
"url": "www.sina.com",
"isalvie": 1,
"finalur... | true |
5590ac623b8b6e64da126c90f6b7c435ac99501e | Python | irisfffff/SentimentAnalysis-MovieReviews | /spaCy.py | UTF-8 | 305 | 2.765625 | 3 | [
"MIT"
] | permissive | import spacy
spacy_nlp = spacy.load("en_core_web_sm")
article = "OMG #Twitter is sooooo coooool <3 :-) <– lol...why do i write like this idk right? :) 🤷♀️😂🤖"
doc = spacy_nlp(article)
tokens = [token.text for token in doc]
print('Original Article: %s' % article)
print()
print(tokens) | true |
80df1388a2faec33f9d6868864d151e31d5c4e0f | Python | TPose-Labs/Smart_mirror_interface | /src/utils.py | UTF-8 | 1,821 | 2.859375 | 3 | [] | no_license | from tkinter import Tk, Frame
DAYS = {
"Sun": "Sunday",
"Mon": "Monday",
"Tue": "Tuesday",
"Wed": "Wednesday",
"Thu": "Thursday",
"Fri": "Friday",
"Sat": "Saturday",
"Sun": "Sunday"
}
MONTHS = {
"Jan": "January",
"Feb": "February",
"Mar": "March",
"Apr": "April",
"M... | true |
3a9c8ac9d54a15245adbd1793c2824e734aca287 | Python | chenchuk77/pokerbot | /__OLD/plot_tester.py | UTF-8 | 3,258 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This program is dedicated to the public domain under the CC0 license.
"""
First, a few callback functions are defined. Then, those functions are passed to
the Dispatcher and registered at their respective places.
Then, the bot is started and runs until we press Ctrl-C on... | true |
e9976883a7ac28fc3ef5d8afadad3cc2ade27037 | Python | budebulai/LightGCS | /tools/sql_tool.py | UTF-8 | 11,750 | 3.21875 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import os
import sqlite3
from functools import wraps
import copy
"""
待优化:
1、字符串拼接时保留引号
劣法:参数填充时字符串值使用单双引号两层包裹
最优:
values = [str(tuple(item)) for item in values]
values = ",".join(values)
较优:对需要保留引号的字符串检出并更改为"'xxx'"形式,怎么实现呢?
def str_convert(s)... | true |
e7466ee45b01b929429bc53eae66f70640be4690 | Python | michaeldmoser/Backcountry-Tracks | /services/Adventurer/adventurer/users.py | UTF-8 | 1,962 | 3 | 3 | [] | no_license | import uuid
import copy
class Users(object):
def __init__(self, bucket = None):
self.bucket = bucket
def get_by_id(self, user_id):
'''Will retrieve a user by their id'''
userobj = self.bucket.get(str(user_id))
if not userobj.exists():
raise KeyError("No such user")... | true |
39c627b25c886d08677459446df54dd499b221f1 | Python | Preethi-design/python_assignment_1 | /dictionary_TBI.py | UTF-8 | 1,235 | 4.40625 | 4 | [] | no_license | print("Dictionary Methods")
d = {1: "one", 2: "two"}
print(d)
print("#clear")
d.clear()
print('d =', d)
print("#copy()")
original = {1:'one', 2:'two'}
new = original.copy()
print('Orignal: ', original)
print('New: ', new)
print("#From Keys")
keys = {'a', 'e', 'i', 'o', 'u' }
vowels = dict.fromkeys(keys)
print(vowels)... | true |
7ff350cf75f3582215b776a9c6f524dfdca9d706 | Python | donniet/ros_pantilt_pkg | /scripts/track.py | UTF-8 | 4,049 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python3
import argparse
from functools import partial
import rospy
from pantilt_pkg.msg import Detect
from geometry_msgs.msg import Pose, Quaternion, Vector3
from pantilt_pkg.msg import Pose
# from here: https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/
def bb... | true |
76d362c2de9c8f04cb7f6f1c6760f4bb77d14d28 | Python | palmarytech/Python_Snippet | /Snap7_Exer/Test.py | UTF-8 | 3,960 | 2.515625 | 3 | [] | no_license | import snap7.client
import mySnap7, byte_array
nameKey = "name"
dataTypeKey = "datatype"
offsetKey = "offset"
if __name__ == "__main__":
# =================== Connection ======================
plc = snap7.client.Client()
plc.connect('10.101.100.45', 0, 0)
# =================== Load Config =... | true |
a1e311506afd0298c3bc550b03350302183010e2 | Python | zoraZz/Test | /clearText.py | UTF-8 | 419 | 2.796875 | 3 | [] | no_license | from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://www.baidu.com')
driver.find_element_by_id('kw').send_keys('selenium')
time.sleep(5)
try:
#清除文本内容
driver.find_element_by_id('kw').clear()
#刷新当前页面
driver.refresh()
print('test passed')... | true |
2798d8048ad724bb84de7e26f4b6df9057ba9284 | Python | marszed1997/LeetCode | /LeetCode 820.py | UTF-8 | 1,290 | 3.375 | 3 | [] | no_license | # https://leetcode-cn.com/problems/short-encoding-of-words/
class Trie:
def __init__(self):
self.p = 0
self.trie = [[0 for _ in range(100000)] for _ in range(26)]
class Solution:
def __init__(self):
self.T = Trie()
def InTrie(self, word):
pos = 0
for i in range(... | true |
d1aa75e96d0ea6c17b9509e0f30cfecd30be5707 | Python | falecomlara/CursoEmVideo | /ex009 - tabuada.py | UTF-8 | 245 | 4.09375 | 4 | [] | no_license | #entre com um número e retorne sua tabuada
n1 = int(input('Entre com um número: '))
n2 = 0
contador = 0
for tabuada in range(11):
resultado = n1 * n2
print ('A tabuada de {}x{}={}'.format(n1,n2,resultado))
contador += 1
n2 += 1 | true |
668c34fcb78b85c3ab383b712cb6fd889c94c944 | Python | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/njschafi/Lesson07/html_render.py | UTF-8 | 3,244 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env python3
# NEIMA SCHAFI, LESSON 7 Assignment - HTML RENDERER
"""
A class-based system for rendering html.
"""
# This is the framework for the base class
class Element(object):
"""Main class for object"""
tag = 'html'
indent = ' '
def __init__(self, content=None, **kwargs):
"... | true |
aaf7d257d113cd34596dc8e00e4b55e60a62293c | Python | Chive/adventofcode | /day1/counter.py | UTF-8 | 1,301 | 4.03125 | 4 | [] | no_license | import sys
def sum_recurring_digits(sequence: str):
"""
Reviews a sequence of digits and finds the sum of all digits that match the
next digit in the list. The list is circular, so the digit after the last
digit is the first digit in the list.
"""
total = 0
i = 0
count = len(sequence)
... | true |
a13fbbbc4c6dabacd5c510ac18c3be1c8210fae4 | Python | WeaselE/WebScraping | /WebScraperPractice.py | UTF-8 | 1,421 | 2.609375 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
url = 'https://realpython.github.io/fake-jobs/'
param = 'jobs/'
job = 'senior-python-developer-0.html'
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
results = soup.find(id='ResultsContainer')
# print(results.prettify())
job_elements = results.fi... | true |
0ad4828d3189086a1a02066b04e05f423e0b5b8e | Python | bitflow-stream/python-bitflow | /bitflow/marshaller.py | UTF-8 | 6,126 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | import datetime
import struct
from bitflow.sample import Sample, Header
class BitflowProtocolError(Exception):
def __init__(self, description, expected=None, received=None):
msg = "Bitflow binary protocol error: {}.".format(description)
if expected is not None:
msg += " Expected: {} (... | true |
4394158213f5cb0b34c249c72a7e36d7eac6c80d | Python | saeschdivara/ArangoPy | /arangodb/tests/user.py | UTF-8 | 742 | 2.75 | 3 | [
"MIT"
] | permissive | from arangodb.tests.base import ExtendedTestCase
from arangodb.api import Database
from arangodb.user import User
class UserTestCase(ExtendedTestCase):
def setUp(self):
self.database_name = 'testcase_user_123'
self.db = Database.create(name=self.database_name)
def tearDown(self):
D... | true |
d5b0c36ccc7ba5121e4d1aaa5cef83266003a5f6 | Python | SprintGhost/LeetCode | /697.数组的度.py | UTF-8 | 1,527 | 3.046875 | 3 | [
"Unlicense"
] | permissive | #
# @lc app=leetcode.cn id=697 lang=python3
#
# [697] 数组的度
#
# Accepted
# 89/89 cases passed (152 ms)
# Your runtime beats 95.78 % of python3 submissions
# Your memory usage beats 14.29 % of python3 submissions (15.4 MB)
# @lc code=start
class element:
def __init__(self,start_index, end_index):
self.start... | true |
c74ea8a65c762aefdd0d51e0e6e5108e810f44a4 | Python | KATO-Hiro/AtCoder | /typical90/bd/main.py | UTF-8 | 1,056 | 3.21875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # -*- coding: utf-8 -*-
def main():
import sys
input = sys.stdin.readline
n, s = map(int, input().split())
a, b = [0] * n, [0] * n
dp = [[False] * (s + 10) for _ in range(n + 10)]
dp[0][0] = True
for i in range(n):
a[i], b[i] = map(int, input().split())
for i in range(1... | true |
8a25ec713001335804b83bf86b8add70c86d4e50 | Python | Mateusz-Grzelinski/logit-formula-generator | /logic_formula_generator/generators/contraint_solver/first_order_logic/cnf_constraint_solver.py | UTF-8 | 1,223 | 2.96875 | 3 | [] | no_license | import random
from abc import abstractmethod
from typing import Iterable, List, Dict
from logic_formula_generator.generators.utils._range import IntegerRange
class CNFConstraintSolver:
def __init__(self, allowed_clause_lengths: List, number_of_clauses: IntegerRange, number_of_literals: IntegerRange):
sel... | true |
d8b3f901ff13ccb30cc4802b94267ad1f9d210f2 | Python | Cosmo65/organizador | /file_organizer/date.py | UTF-8 | 1,242 | 3.125 | 3 | [] | no_license | import os
from datetime import date
class OrganizerByDate:
def __init__(self, current_dir: str = os.getcwd(), target_dir: str = './'):
self._current_dir = os.path.abspath(current_dir)
self._target_dir = os.path.abspath(target_dir)
def start(self):
"""
Função responsavel pelo s... | true |
b60a20e847445facb1a7733e9442d5ea5c51f7f0 | Python | elsampsa/valkka-examples | /api_level_2/qt/demo_analyzer.py | UTF-8 | 5,665 | 3.046875 | 3 | [
"MIT"
] | permissive | """
analyzer.py : A base class for analyzing image streams using OpenCV and an example movement detector.
Copyright 2018 Sampsa Riikonen
Authors: Sampsa Riikonen
This file is part of the Valkka Python3 examples library
Valkka Python3 examples library is free software: you can redistribute it and/or modify it under ... | true |
639f0a46ca3f2f3711f5ba0dfe670365537b98a7 | Python | caoliang/ISSM-CA3 | /py_src/signal_functions.py | UTF-8 | 12,055 | 2.640625 | 3 | [] | no_license | '''
def pltDistances(dists, title, xlab="X", ylab="Y", clrmap="viridis"):
#imgplt = plt.figure(figsize=(4, 4))
plt.suptitle(title, fontsize=20)
plt.imshow(dists, interpolation='nearest', cmap=clrmap)
plt.gca().invert_yaxis()
plt.xlabel(xlab)
plt.ylabel(ylab)
plt.grid()
plt.colorbar()
... | true |
6894fe4b94b03ed198aaa9d6fa082d150c18bba3 | Python | sauravgarg540/executors | /jinahub/encoders/text/SpacyTextEncoder/spacy_text_encoder.py | UTF-8 | 4,711 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | __copyright__ = "Copyright (c) 2020-2021 Jina AI Limited. All rights reserved."
__license__ = "Apache-2.0"
from typing import List, Dict, Optional
import numpy as np
import torch
import spacy
from jina import Executor, DocumentArray, requests
from jina.logging.logger import JinaLogger
class SpacyTextEncoder(Execut... | true |
906e1bea08173e63fdcde7bbc8cb540026bf5112 | Python | corylstewart/courseraAlgo | /Algorithms2/Week3/knapsack.py | UTF-8 | 2,714 | 3.265625 | 3 | [] | no_license | import sys
from operator import itemgetter
import time
sys.setrecursionlimit(99000)
def get_items(filename):
items = list()
with open(filename) as f:
capacity = [int(x) for x in f.readline().split()][0]
for item in f.readlines():
items.append([int(x) for x in item.split()])
... | true |
87aebb60f713e45b4a359b39cdbc790a7c130f0a | Python | Ianssmith/data-structures | /origamiViz_project/origamiViz/protoviz.py | UTF-8 | 487 | 2.71875 | 3 | [] | no_license |
# coding: utf-8
# In[103]:
import numpy as np
import pandas as pd
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import seaborn as sns
# In[104]:
df = pd.read_json("data/crane.json")
df.head()
# In[107]:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# In[108]:
ax.... | true |
538c4c306786175ae7b33182e199fdac86ee100a | Python | markbirss/cardkb | /ascii_codes.py | UTF-8 | 4,123 | 2.703125 | 3 | [] | no_license | import uinput
ascii = {
# number row
0x1B: [uinput.KEY_ESC],
0x31: [uinput.KEY_1],
0x32: [uinput.KEY_2],
0x33: [uinput.KEY_3],
0x34: [uinput.KEY_4],
0x35: [uinput.KEY_5],
0x36: [uinput.KEY_6],
0x37: [uinput.KEY_7],
0x38: [uinput.KEY_8],
0x39: [uinput.KEY_9],
0x30: [uinput.... | true |
abc507b58d50c45919d9c7aeddee37e10a2d17d7 | Python | tinproject/adventofcode2018 | /6/day.py | UTF-8 | 4,411 | 3.171875 | 3 | [] | no_license | from collections import Counter
from itertools import chain
from functools import partial
# import string
def get_coordinates(data):
clean_data = (l.strip() for l in data if l.strip())
coords = []
for d in clean_data:
x = int(d.split(",")[0].strip())
y = int(d.split(",")[1].strip())
... | true |
3485d5567c328d32332831501cd6d9feaa158d8a | Python | vishnusak/DojoAssignments | /PylotMVC-NinjaGold/app/controllers/Ninja.py | UTF-8 | 1,899 | 2.671875 | 3 | [] | no_license | from system.core.controller import Controller, redirect, request, session
from random import randint
from time import strftime
from json import dumps
class Ninja(Controller):
def __init__(self, action):
super(Ninja, self).__init__(action)
def reset(self):
session.clear()
return redirec... | true |
365ca6563ecd2b67db6d81bf57fabded6d24161b | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_135/3977.py | UTF-8 | 819 | 2.796875 | 3 | [] | no_license | import os, sys
lines = tuple(open(sys.argv[1], 'r'))
testCasesCount = int(lines[0])
linesI = 1
while testCasesCount > 0:
guess1 = lines[linesI].rstrip()
guess1Rows = [lines[linesI+1].rstrip(),lines[linesI+2].rstrip(),lines[linesI+3].rstrip(),lines[linesI+4].rstrip()]
guess2 = lines[linesI+5].rstrip()
guess2Row... | true |
8323753d4c8f5e6a7b6d67de7db386ee0f0ef1d6 | Python | PingchuanMa/Respect-Learning | /tools/plot_rewards.py | UTF-8 | 1,261 | 2.78125 | 3 | [] | no_license | from argparse import ArgumentParser
import os
import matplotlib.pyplot as plt
import numpy as np
import json
base_dir = os.path.dirname(os.path.abspath(__file__)) + '/../'
result_path = base_dir + 'results/'
def plot_rewards(reward_list, title, order=6):
x = np.arange(len(reward_list))
plt.figure('Training R... | true |
8782a37e2f3ace34b10b812e16fb3e8a3fb87057 | Python | mariabg/rentalClassifier | /scripts/playWithData.py | UTF-8 | 953 | 2.90625 | 3 | [] | no_license | import sys
import pandas as pd
import numpy as np
def main():
df = pd.read_csv('15_03_2017_calendar.csv')
# ['listing_id' 'date' 'available' 'price']
print "calendar listing head", df.columns.values
# print df.head()
# print df["date"].max(), df["date"].min()
print
# print "\n\n\n"
# ... | true |
41ce4d2c863f16d8ba2b3f53740a984cc26e7d73 | Python | githubfun/stockcat | /spider/stock/stock/spiders/qqusdaily.py | UTF-8 | 3,029 | 2.671875 | 3 | [] | no_license | #!/usr/bin/python
#-*- coding: UTF-8 -*-
#author: fox
#desc: 抓取qq上每股的每日总览数据
#date: 2014/10/04
import sys, re, json, random
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.http import Request
from stock.items import StockDataItem
class QQUsDailySpider(BaseSpider):
nam... | true |
5b01b955ae6bdd04335a73d87be562a6c75f88be | Python | iSaikyou/Praktikum_GUI | /Modul 3/Aritmatika.py | UTF-8 | 462 | 3.796875 | 4 | [] | no_license | class Aritmatika :
@staticmethod
def tambah(a,b) :
return a + b
@staticmethod
def kurang(a,b) :
return a - b
@staticmethod
def bagi(a,b) :
return a / b
@staticmethod
def bagi_int(a,b) :
return a // b
@staticmethod
def pangkat(a,b) :
return a ** b
... | true |
24fae5b7c7a690ca302c7b5d199ca165594adca3 | Python | anderson-github-classroom/csc-369-student | /labs/Lab2.py | UTF-8 | 3,929 | 3.46875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,md,py
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.8.0
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# + ... | true |
a1a0ee1b304a7a2b58d79b924f27520febff3f50 | Python | snprpc/R_Interpreter | /snprpc/grammar/test_parserstruct.py | UTF-8 | 7,739 | 2.921875 | 3 | [] | no_license | from snprpc.grammar.ParserStruct import *
from snprpc.grammar.R_Parser import *
from snprpc.grammar.Parser import *
from snprpc.grammar.Statement import *
# 单元测试——测试简单的语法匹配器1.0
# 测试 Concat 类
# 定义关键子的tag值 ‘RESERVED’
# 通过 Contat 定义简单的加法文法匹配器 parser1
# 通过运算符重载定义简单的加法文法匹配器 parser2
# 模拟词法分析器的输出 tokens
# 构建抽象语法树 ast
def un... | true |
1d295d5c15722362e801763244abe6adf0b82948 | Python | nnocsupnn/python-webscraper | /src/components/RedisClient.py | UTF-8 | 738 | 2.71875 | 3 | [] | no_license | import redis
import sys
class RedisClient:
client = None
pubsub = None
isSub = False
host = '127.0.0.1'
password = 'Ccnkbq9V4KDVCyT5FfYpH7ZPhcvisYCf' # Ccnkbq9V4KDVCyT5FfYpH7ZPhcvisYCf
def __init__(self):
self.client = redis.Redis(host=self.host, port=6379, password=self.password)
... | true |
27b75335f663f8315f11cee4d234084dc2b89b87 | Python | Chuckletowski/Personal-Projects | /04_shipping_fee_calculator.py | UTF-8 | 775 | 4.3125 | 4 | [] | no_license | # Calculate shipping charges for a shopper. Ask the user to enter the amount for their total purchase.
# If their total is under $50, add $10. Otherwise, shipping is free.
# Tell the user their final total including shipping costs and format the number so it looks like a monetary value.
# Don’t forget to test your solu... | true |
140d6d256435c858e9cce74c2a109f0bb2d3ef77 | Python | prescottwhite/112-prog3 | /tli.py | UTF-8 | 9,398 | 3.328125 | 3 | [] | no_license | #! /usr/bin/env python3
import fileinput
import sys
# used to store a parsed TL expressions which are
# constant numbers, constant strings, variable names, and binary expressions
# operators: num, str, var, +, -, *, /, ==, <, >, <=, >=, !=
class Expr:
def __init__(self, lineNum, op1, operator, op2=None):
... | true |
cfc464a3239ab856d0c7d8660096b0026098601f | Python | hnz71211/Python-Basis | /com.lxh/learning/10_function_param/__init__.py | UTF-8 | 3,643 | 4.1875 | 4 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 默认参数
# 当调用power(5)时, 相当于调用power(5, 2)
def power(x, n=2):
s = 1
while n > 0:
n = n - 1
s = s * x
return s
# 定义默认参数要牢记一点:默认参数必须指向不变对象!
# 多次调用add_end(),结果是不一样的
def add_end(L=[]):
L.append('END')
return L
def add_end2(L=None):
if L i... | true |
a808121de4e326de57c884e2d4509fff9d95e267 | Python | jbrownxf/mycode | /lab_input/input_ip.py | UTF-8 | 281 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!usr/bin/env python3
#author- josh brown
# to collect user ip information and display it back to them
#user's input for thier ip address
user_input = input('Please enter an IPv4 IP address:')
##prints the user's input to verify
print("You told me teh IPv4 address is:" + user_input) | true |
e6a965fe73791f892744afbd4fb1b81e79de9761 | Python | AuroraFeng/Deep-actor-based-reinforcement-learning-for-portfolio-management | /codes/network.py | UTF-8 | 3,130 | 2.8125 | 3 | [] | no_license | ### Aurora
"""
Neural network architecture
Reference: https://github.com/wassname/rl-portfolio-management/blob/master/keras-ddpg.ipynb
"""
# numeric
import numpy as np
from numpy import random
import pandas as pd
import tensorflow
import keras
# reinforcement learning
import gym
from gym import error, spaces, utils
... | true |
92858234834cf6ad2df2fd097425f97a0019d0e0 | Python | aaronabebe/DOPP | /data_extension_edu.py | UTF-8 | 2,259 | 2.921875 | 3 | [] | no_license | import pandas as pd
import streamlit as st
st.markdown("# Extending the base dataset with different data")
st.markdown("## Base Data")
with st.echo():
# LOAD BASE DATA
base = pd.read_csv("transformed.csv", index_col="Unnamed: 0")
st.write(base)
st.write(base.shape)
st.markdown('## Education Data')
st... | true |
b24827dbf007c96d4d32b6b3d052d9e2d56e424d | Python | BZukerman/StepikRepo | /Python_Programming/Basics and use/Temp_Dict.py | UTF-8 | 991 | 3.21875 | 3 | [] | no_license | variables = {"": []}
print("1", variables) # 1 {'': []}
set = ["a"]
key = "global"
pair = {key: set}
variables = pair
print("2", variables) # 2 {'global': ['a']}
set1 = ["b"]
pair = {key: set1}
variables.update(pair)
print("3", variables) # 3 {'global': ['b']}
data = variables.items()
print("4", data)... | true |
6607cd9cf5f5be5b6a993dbe6a64df652ca8dd10 | Python | CaioFRodrigues/Formais | /lib/libGrammarReader.py | UTF-8 | 5,514 | 3.578125 | 4 | [] | no_license | #!/usr/bin/env python3
import re
from lib.libExcept import *
"""
Grammar type specifications:
grammar is a dictionary X => Y where
X is 'terms', 'rnames', 'start' or 'rules'
Y depends on the value of X:
'terms' => Y is a set of strings representing terminal symbols
'rnames' => Y is a set of strings ... | true |
9aec94d069a1b7464416807f2e5ea78fa0032b6e | Python | jlh040/Cook-It-Up-Capstone-1 | /models.py | UTF-8 | 6,218 | 2.84375 | 3 | [] | no_license | from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from secret_keys import API_KEY
from helper_funcs import make_additional_calls, get_ingredients_from_recipe
import requests
import json
db = SQLAlchemy()
bcrypt = Bcrypt()
def connect_db(app):
db.app = app
db.init_app(app)
class User(db.... | true |
ad1a5b440df8385b742d4c2042584449375e144f | Python | VinayakBagaria/Personal-Blogging | /src/models/post.py | UTF-8 | 1,554 | 2.890625 | 3 | [] | no_license | import datetime
import uuid
from API.src.common.database import Database
class Post(object):
def __init__(self, blog_id, title, content, author, created_date=datetime.datetime.utcnow(),_id=None):
self.blog_id=blog_id
self.title=title
self.content=content
self.author=author
... | true |