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 |
|---|---|---|---|---|---|---|---|---|---|---|
b990b495e0ef71433fb396bcc8d9cbd4626f99cc | jingxu94/Effectivepy | /src/demo_unpacking.py | UTF-8 | 377 | 3.546875 | 4 | [] | no_license | snack_calories = {
"chips": 140,
"popcorn": 80,
"nuts": 190,
}
items = tuple(snack_calories.items())
print(items)
def bubble_sort(a):
for _ in range(len(a)):
for i in range(1, len(a)):
if a[i] < a[i - 1]:
a[i - 1], a[i] = a[i], a[i - 1]
names = ["pretzels", "carro... | true |
da3f797c73fc12449f9bbaf380aa8cfe6a077beb | ShantoNoor/Graph-Theory-Algorithms | /dfs eulerian path and circuit.py | UTF-8 | 1,182 | 3.3125 | 3 | [] | no_license | g = [
[], #0
[2, 3], #1
[2, 4, 4], #2
[1, 2, 5], #3
[3, 6], #4
[6], #5
[3], #6
]
n = len(g)
ind = [0]*n
outd = [0]*n
edge = 0
path = []
def calInOutDegree():
global edge
for i in range(n):
for j in range(len(g[i])):
outd[i] += 1
ind[g[i][j]] += 1
edge += 1
def graphHasEu... | true |
4f4016bc0dd31be41cac27523693dbc865a939c3 | ZFhuang/DiveIntoDLSketches | /Chapter5/Chapter5_10.py | UTF-8 | 7,354 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | # coding=utf-8
# 导入自己的函数包d2lzh_pytorch,注意要先将目标包的父路径添加到系统路径中
import sys
sys.path.append(r".")
from d2lzh_pytorch import train, data_process,layers
import torch.nn.functional as F
import torch
import time
from torch import nn, optim
"""
这一节介绍了在训练途中的批量归一化,让训练和预测的时候中间数据更稳定从而让下降更有效
"""
# 加上这个限定才能支持多线程读取
if __name__ == "... | true |
a5bb76be14a80b54cc7500d91dcd01ade101ce71 | suraj19/Hackerrank-Codes | /program22.py | UTF-8 | 1,276 | 3.578125 | 4 | [] | no_license | '''ohn works at a clothing store. He has a large pile of socks that he must pair by color for sale.
Given an array of integers representing the color of each sock,
determine how many pairs of socks with matching colors there are.
For example, there are n=7 socks with colors ar=[1,2,1,2,1,3,2]. There is one pair ... | true |
46f5652a55ecea415c147b199753e91cebc8ac17 | Rostyk1404/Codewars | /Find the divisors!.py | UTF-8 | 951 | 4.4375 | 4 | [] | no_license | """
Kata source :
https://www.codewars.com/kata/find-the-divisors/train/python/5d27613df9092c000f7b8d43
Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the
integer's divisors(except for 1 and the number itself), from smallest to largest.
... | true |
206235627a1916bd0c30a6bb8532cb7bf954da67 | vmgmarv/Different-fitting-algorithms-and-ROC-for-deep-seated-landslide-sensors | /lstm_subsurface.py | UTF-8 | 4,865 | 2.609375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 29 16:37:41 2019
"""
import subsurface_plotting as db
import filterdata as filt
import math
import pandas as pd
import mysql.connector as sql
import matplotlib.dates as md
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import mean_squ... | true |
5fc1f4710b2727059b30e7d1c5ccd5ffc2ed2595 | pum-purum-pum-pum/octopus | /Visualization/predict_octoproba.py | UTF-8 | 759 | 2.65625 | 3 | [] | no_license | import sys
import pandas as pd
from trueskill import Rating
import argparse
sys.path.append("..")
from Model.octorate import win_probability_by_rate
def win_prob_from_csv(octorate, pid1, pid2):
p1 = octorate[octorate['ID']==pid1].as_matrix()[0]
p2 = octorate[octorate['ID']==pid2].as_matrix()[0]
return win_... | true |
c4ac6326422fa1fe1a6823ee9754b1bb360c16d5 | diwadd/sport | /cc_racing.py | UTF-8 | 522 | 3.40625 | 3 | [] | no_license | t = int(input())
for _ in range(t):
xrm = input().split(" ")
x = int(xrm[0])
r = int(xrm[1])*60
m = int(xrm[2])*60
if r > m:
print("NO")
elif x >= r:
print("YES")
else:
n = r // x
needed_time = n * x + (n - 1) * x
# print(f"n: {n} needed_time: {n... | true |
4274352ab57ff80af8913f4e25f943f0024da70b | omochibuster/project_euler | /41-50/47_Distinct_primes_factors/main.py | UTF-8 | 910 | 3.375 | 3 | [] | no_license | #-*-coding:utf-8-*-
#answer is 134043(83.5秒) 2015/2/1
from time import time
def isPrime(number):
if number == 2:return 1
if number % 2 == 0:return 0
for i in range(3,number,2):
if number % i == 0:return 0
return 1
def getPrimeFactors(number):
global NUMBER
primeFactorsList = []
if number % 2 == 0:
primeF... | true |
39d0036c6de9e59cfa8974cfb5ac8f5dfebf3ce9 | misoniiii/PythonClass | /PythonVariable/ch5_list&dictionary.py | UTF-8 | 21,197 | 4.25 | 4 | [] | no_license |
#ex71) emp_list라는 비어있는 리스트 변수를 선언한 후, input명령어를 이용해서 emp_list라는 리스트변수에 요소 추가 구문을 통해 추가하시오
#emp_list 리스트에 추가할 요소를 입력하세요~ a
#a
emp_list=[]
k=input('emp_list에 추가할 요소를 입력하세요')
emp_list.append(k)
print(emp_list)
#ex72)emp_list에 추가된 요소를 삭제하는 코드를 구현하시오
#emp_list에 삭제할 요소를 입력하세요
k=input('emp_list에 추가할 요소를 입력하세요')
emp_list.rem... | true |
188e654a01a3329407315c49679f6252eabf35d9 | DevooKim/algorithm-study | /week8/book/55prayme.py | UTF-8 | 1,272 | 3.5625 | 4 | [] | no_license | import collections
import heapq
import functools
import itertools
import re
import sys
import math
import bisect
from typing import List
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
heap = list()
for n in nums:
heapq.heappush(heap, -n)
print(heap)
... | true |
4243b58c8db50e115148f5bcadf4c2d672ecc1b4 | pingpan2013/coding-exercises | /python/twoSum.py | UTF-8 | 1,690 | 4.3125 | 4 | [] | no_license | #!/usr/bin/python
'''
Given an array of integers, find two numbers such that they
add up to a specific trget number, return (index1, index2) with index1 < index2. Note that returned indexes should not be 0 based
i.e.
Input: [2, 7, 11, 15], target = 9
Output: (1, 2)
Assume that each input has exactly one solution
'''... | true |
99ca459178fdf80d24ffaafaaca29816000b9cc2 | madYuqi/MasteringPythonScirntificComputing | /Chapter4/B02092_04_11.py | UTF-8 | 179 | 3.578125 | 4 | [] | no_license | import sympy
x=sympy.Symbol('x')
a = 1/x + (x*sympy.exp(x) - 1)/x
print(sympy.simplify(a))
print(sympy.simplify((x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)))
# exp(x)
# x - 1
| true |
ff4f1300b5f77e8cb01a140db2368f4a98a5f258 | suprviserpy632157/zdy | /ZDY/Jan_all/pythonbase/January0116/afternoon/myprint.py | UTF-8 | 452 | 3.734375 | 4 | [] | no_license | import sys
def myprint(*args,sep=' ',end='\n',file=sys.stdout,flush=False):
# 如果是第二次打印,则执行此语句
flag=False #当第一次循环后,将此变量置为True
for x in args:
if flag:
file.write(sep)
file.write(str(x))
flag=True
# 打印ned
file.write(end)
# return s
myprint("hello world")
my... | true |
8ced44419e3b190f2cf8fcd388e0dd4b8f6be19b | shegmatech/QrCodeGenerator | /QrCodeGenerator.py | UTF-8 | 709 | 3.109375 | 3 | [] | no_license | import os
import pyqrcode
import png #pyqrcode cant generate png images so i need to use this module to generate png.
# getting document path with os
path = 'C:\\Users\\MSE\\PycharmProjects\\qrcode_gen\\Passport' #change this path to where your passports are located
# using os to get the file name without exte... | true |
851cb11e59a66ea4465b6c558ed9ac2333e92820 | pythonion/learning | /fileutils/fileutils.py | UTF-8 | 1,277 | 3.40625 | 3 | [] | no_license | import os
WORD_DELIM = " "
def grep(search, filename, name=False, line=False):
""" This module is similar to grep in UNIX. It searches a string in a file and
returns all the lines that search string contains. We can specify filename
and linenumber if we want them in the grep results
"""
... | true |
1f8c397abf10be25c06351500192675fd5c36f4a | shyam96s/python1 | /loops.py | UTF-8 | 114 | 3.359375 | 3 | [] | no_license | n=int(input("enter the limit"))
rn=0
while(n!=0):
r=n%10
rn=(rn*10+r)
n=n//10
print("Revised num",rn)
| true |
5dd5d0feae5ec631aa73010c77d560b5540c4962 | prasanna86/fun_with_programming | /uncategorized_or_partial_solutions/2d_arrays.py | UTF-8 | 1,017 | 3.65625 | 4 | [] | no_license | #!/bin/python3
import sys
def findMaxHourglassSum(arr):
# Array size
arr_size = len(arr)
# Hourglass window size
hg_win_size = 3
# num_hg = (arr_size - hg_win_size + 1) ** 2 = 4 * 4 = 16
num_hg_rows = (arr_size - hg_win_size + 1)
# initialize hg_sum as empty array
hg_sum = []
# loo... | true |
f2e911bcf8f8d06d07dd28418689355e2d7138a3 | mcgaw/psychic-garbanzo | /4/week1/trie_matching_extended/trie_matching_extended.py | UTF-8 | 1,546 | 3.171875 | 3 | [] | no_license | # python3
import sys
class Node(dict):
def __init__(self):
self.end_node = False
def __repr__(self):
if self.end_node:
return '-'+ super().__repr__() + '-'
else:
return super().__repr__()
def build_trie(patterns):
tree = Node()
tree[0] ... | true |
03d3a264d0105acc2607e21d574f379ffc25354a | Hillary060/Text-Based-QA | /textqa/model/CQA/test.py | UTF-8 | 473 | 2.609375 | 3 | [] | no_license | # -*- coding:utf-8 -*-
from textqa.model.CQA.tbqa import TBQA
import time
import json
def performance_test(text):
start = time.time()
tbqa = TBQA()
end = time.time()
print('creating model time:', end - start)
start = time.time()
res = tbqa.get_answer(text)
json_data = json.dumps(res, ensu... | true |
da27e59b71e3e0862f406aab3461e607e345690d | InkubatorTieto/melvil | /tests/test_description.py | UTF-8 | 2,308 | 2.703125 | 3 | [] | no_license | from flask import url_for
from models import LibraryItem
from models.users import RoleEnum, Role
from models.library import BookStatus
def test_status_code(client, db_book, app_session):
resp = client.get(url_for("library.item_description", item_id=db_book.id))
assert resp.status_code == 200
def test_user_... | true |
070e133df195bf5f0c11fd7b03a9e80b81bb2c7a | AdrianFRadulescu/Entity-Recognition-Natural-Language-Processing- | /src/tagging.py | UTF-8 | 932 | 2.625 | 3 | [] | no_license |
import pickle
import name_tagger
from brill_tagger_wrapper import train_brill_tagger
from nltk.corpus import brown,treebank,reuters
from nltk.tag import BigramTagger
from nltk.tag import TrigramTagger
from nltk.tag import UnigramTagger
from nltk.tag import pos_tag
def tag(args):
return pos_tag(args)
def co... | true |
68c5c30b266385a1f9b669ed018903381daf7765 | scls19fr/openphysic | /python/oreilly/cours_python/chap14/scrolled_text.py | ISO-8859-1 | 1,951 | 3.046875 | 3 | [] | no_license | #! /usr/bin/env python
# -*- coding: Latin-1 -*-
# Petite dmo pour l'utilisation du widget ScrolledText :
from Tkinter import *
import Pmw
def action(event=None):
"""dfilement du texte jusqu' la balise <cible>"""
index = st.tag_nextrange('cible', '0.0', END)
st.see(index[0])
# Instanciation d... | true |
727691068384d2ccdcd14c8b2d9db9b418790578 | ageelg-mobile/100py | /Week005/d032_33_quiz.py | UTF-8 | 116 | 3.203125 | 3 | [] | no_license | #Ageel 9/29/2019
#100 Days of Python
#Day 32-33 - Quiz
for x in range(3,19,2):
print(str(x-1)+" "+str(x))
| true |
3f4d38cc97ffd5136fce2f3a01e857adf6ac4a30 | SPARSHAGGARWAL17/flask | /notes_api/code/resources/notes.py | UTF-8 | 1,300 | 2.59375 | 3 | [] | no_license | from flask_jwt import jwt_required
from models.notes import NoteModel
from flask_restful import Resource,reqparse
from datetime import datetime
class Notes(Resource):
parser = reqparse.RequestParser()
parser.add_argument('user_id',type=int,required=True,help='This field is required')
parser.add_argument('... | true |
77bf06a9e9f837fec3afb79c0cad682f9ef04bf0 | degleris1/cmfpy | /tests/test_grads.py | UTF-8 | 1,730 | 2.546875 | 3 | [] | no_license | import pytest
import numpy as np
import numpy.linalg as la
from numpy.testing import assert_allclose
from cmfpy import CMF
from cmfpy.model import ModelDimensions
from cmfpy.initialize import init_rand
from cmfpy.algs.gradient_descent import GradDescent, BlockDescent
from cmfpy.datasets import Synthetic
from scipy.o... | true |
d01245268b8195424330c660730604a81e5ad2ce | Captainnair/certification_flask | /flaskapp/forms.py | UTF-8 | 10,196 | 2.5625 | 3 | [] | no_license | from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField, TextAreaField, RadioField, SelectField
from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError, InputRequired
from flaskapp.models import Questions
from flaskapp import db
import rando... | true |
fd1f5f9d909238d5f02fe9ac9ca8f7e408eca6de | takuoki/dl4us_fc | /01_util.py | UTF-8 | 9,844 | 2.734375 | 3 | [] | no_license | # 01_util
import numpy as np
import pickle
import csv
from datetime import datetime as dt
from nltk.translate.bleu_score import sentence_bleu
# detoken
def detoken(detokenizer, seqs, join_char=True):
results = []
for seq in seqs:
detokened_seq = []
for i in seq:
if i ... | true |
0870cf623ece81fb448280c5c293ce81c7fdfebe | Jeanne-Chris/Func-missingNumbers | /bintonum.py | UTF-8 | 542 | 4.1875 | 4 | [] | no_license | """ A simple function that converts binary strings to regular integers."""
def bintoint(binary_string):
if binary_string.replace('0', '').replace('1', ''):
return False, 'Input string contains INVALID character, binary is 0 and 1.'
convert_num = 0
for char in binary_string:
convert_num ... | true |
0a866f6a156fec6e3ed7f718eb932e9e5255894a | spedas/pyspedas | /pyspedas/themis/spacecraft/fields/fgm.py | UTF-8 | 5,964 | 2.515625 | 3 | [
"MIT"
] | permissive |
from pyspedas.themis.load import load
from pytplot import options
def fgm(trange=['2007-03-23', '2007-03-24'],
probe='c',
level='l2',
suffix='',
get_support_data=False,
varformat=None,
coord=None,
varnames=[],
downloadonly=False,
notplot=False,
... | true |
68bae4b24ee64810039971aa919d6274aba8753e | KonssnoK/py-bh1792glc | /test.py | UTF-8 | 1,564 | 2.625 | 3 | [
"MIT"
] | permissive | from bh1792glc.driver import *
import logging
import time
def main():
drv = BH1792GLCDriver()
# Reset the chip just to be sure
drv.reset()
time.sleep(0.01)
# Test the chip to be there
drv.probe()
#do_single(drv)
do_sync(drv)
#do_nonsync(drv)
def do_sing... | true |
395b2d89683230823ab2996e0ed990639be43936 | bloonguyen1207/Protected-Shelf | /classes/user.py | UTF-8 | 2,267 | 3.03125 | 3 | [] | no_license | import bcrypt
from Crypto.PublicKey import RSA
import socket
import os.path
# s = "Hello world"
# new_key = RSA.generate(2048)
# public_key = new_key.publickey()
# private_key = new_key.exportKey("PEM")
#
# print(public_key.encrypt('Hello'.encode(), 32)[0])
class User:
def __init__(self, name, salt, psw):
... | true |
201173b8e0c91c2f77baabbebe11d4ffd7ef955e | ruan65/python_algorithms_and_problem_solving | /hacker_rank/python_practice/stack/histogramm_largest_rect.py | UTF-8 | 408 | 2.578125 | 3 | [] | no_license | def largest_rect(h):
mx = 0
def div_conq(k):
nonlocal mx
if not k:
return
mx = max(mx, min(k) * len(k))
i = k.index(min(k))
l, r = k[0:i], k[i+1:]
if len(l) > 1:
div_conq(l)
if len(r) > 1:
div_conq(r)
div_conq(h)
... | true |
a8e44b2fcd7e13bbde866d22bd963c0f923cd6d8 | lord-darcula/windows-rdp-telegram | /Core/Network/Information.py | UTF-8 | 1,114 | 2.75 | 3 | [] | no_license | # Import modules
import json
import datetime
import platform
import subprocess
import urllib.request
# Windows Version
def Windows():
System = platform.system()
Release = platform.release()
Version = System + ' ' + Release
return Version
# System Information
def Computer(Win32, Value):
... | true |
d6f2b8205dcef709c3267ae4167cecdcb7754bd0 | Lenauki/source | /6_mod2.py_210714/15-08.py | UTF-8 | 314 | 2.65625 | 3 | [] | no_license | from tkinter import *
window = Tk()
Label1 = Label(window, text="This is MySQL을")
Label2 = Label(window, text="열심히", font=("나눔고딕",30),fg='blue')
Label3 = Label(window, text="공부중입니다",bg='yellow',width=20,height=5,anchor=SE)
Label1.pack()
Label2.pack()
Label3.pack()
window.mainloop() | true |
d374177fe3afa8ed069e4aac0f0053a5e8bb92a8 | yosi058/NerualNetwork | /main.py | UTF-8 | 8,020 | 2.921875 | 3 | [] | no_license | import numpy
import pandas as pd
import numpy as np
import random as random
# learning rate
LR = 0.001
# Do run noise
NOISE = False
LOAD = False
class NeuralNetwork(object):
def __init__(self):
np.random.seed(42)
# parameters
self.inputSize = 3072
self.outputSize = 10
self... | true |
32c336a00217581d485ecbf9d0abc66158e02917 | colleen7n/SmartCarCapstone | /files up to 5:18/smartcarOBD.py | UTF-8 | 4,808 | 2.59375 | 3 | [] | no_license | # Smart Car Device Project
# Matthew Konyndyk, Jasjit Singh, Alex Mendez, Colleen Nhim
# Portland State University
# v0.0 created 02/25/2017
# Last update: v0.7 05/06/2017
# This script is used to interface a USB ELM327 OBDII with the Raspberry Pi
#MPG =VSS * 7.718/MAF
import serial
import time
import string
import... | true |
55916b514b2617a58226e15a1f851450cb97f9ec | EgbieAndersonUku1/the_Moodle_Project | /src/common/utils/comparer/compare.py | UTF-8 | 549 | 4.125 | 4 | [] | no_license | __author__ = 'Egbie Uku'
def compare_strings(string_one, string_two):
"""compare_strings(str, str) -> returns bool
Takes two strings and compares if they are equal
:param
`string_one`: The string to be compared with string two.
`string_two`: The string to be compared with string one.
:... | true |
6b1343ca7a2cf707092f9851dcb3ee21998df86a | jphalis/knoblinx | /accounts/management/commands/createschools.py | UTF-8 | 687 | 2.515625 | 3 | [] | no_license | from django.core.management.base import BaseCommand
from accounts.schools import schools
from accounts.models import School
# Create your commands here.
class Command(BaseCommand):
help = 'Creates a default list of schools.'
def handle(self, *args, **options):
for school in schools:
if n... | true |
fd915e728e4820296e896cea3b61ba58a4a5e765 | mcerwenetz/PYP_Barth_HS-Mannheim | /PyPrgs/Blatt5/menge.py | UTF-8 | 1,486 | 3.578125 | 4 | [] | no_license | class Set():
def __init__(self, liste=None):
self.runningIndex=0
self.liste=[]
if liste is not None:
for ele in liste:
self.add(ele)
def add(self, elem):
if elem not in self.liste:
self.liste.append(elem)
def union_update(self, s... | true |
557dea7ff4fe50645d4c4f71262cf8d6aa403c77 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2383/60737/305298.py | UTF-8 | 1,241 | 2.59375 | 3 | [] | no_license | maxn = 100005
y, nex, las, cnt, tot = [0]*(2*maxn), [0]*(2*maxn), [0]*maxn, [0]*maxn, 0
f, ans = [0]*maxn, True
N, K = 0, 0
def dfs(x):
global f, cnt, las, nex, y, K, ans
f[x] = 1
cnt[x] = 1
j = las[x]
while j:
if not f[y[j]]:
dfs(y[j])
if not ans:
r... | true |
1878e01833f15646ffb596b7a0ef7a9e9333d5c8 | samuelhei/spell-corrector-pt | /example.py | UTF-8 | 286 | 2.71875 | 3 | [
"MIT"
] | permissive | from spell_corrector_pt import SpellCorrector
spell = SpellCorrector()
try:
spell.load_model('dictionary')
print(spell.get_correct_word('abacat'))
print(spell.get_correct_word('senoura'))
except:
print('You need to train the model first, try python example-train.py')
| true |
4ca2eeac15a9551d66140e208c21e8b2ca63412f | marcomanciniunitn/Tasteme | /data/watch.py | UTF-8 | 412 | 3.015625 | 3 | [] | no_license | import sys
import pickle
objects = []
with (open(sys.argv[1], "rb")) as openfile:
while True:
try:
objects = pickle.load(openfile)
except EOFError:
break
for obj in objects:
print(obj)
print(objects[obj])
print("\n\n")
'''
for obj in objects:
print("Lenght obj:" + str(len(obj[sys.argv[2]])))
print("L... | true |
beda116bfcb8e362d7843ba91c2731cc0809b3af | ylkjick532428/qooeo-tool | /qooeo/include/china_utils.py | UTF-8 | 53,761 | 2.515625 | 3 | [] | no_license | # -*- coding:utf-8 -*-
#中国城市字典表
PROVICE_CITYS_NAME = {"北京":"北京",
"上海":"上海",
"天津":"天津",
"重庆":"重庆",
"黑龙江":"哈尔滨",
"吉林":"长春",
"辽宁":"沈阳",
"内蒙古":"呼和浩特",
"河北":"石家庄",
"新疆":"乌鲁木齐",
"甘肃":"兰州",
"青海":"西宁",
"陕西":"西安",
"宁夏":"银川",
"河南":"郑州",
"山东":"济南",
"山西":"太原",
"安徽":"合肥",
"湖北":"武汉",
"湖南":"长沙",
"江苏":"南京",
"四川":"成都",
"贵州":"贵阳",
"云南":... | true |
d87e6b07a12353218b168bf719e194a7440c6902 | cokeSchlumpf/thesis--text-sumarization | /lib/models/t5.py | UTF-8 | 1,862 | 2.734375 | 3 | [] | no_license | from lib.models import TextSummarizationModel
class T5SummarizationModel(TextSummarizationModel):
def __init__(
self, min_length: int, max_length: int, length_penalty: float,
num_beams: int, early_stopping: bool, label: str):
self.min_length = min_length
self.max_length =... | true |
b22dfca7b27f4c4c95d3c7da695d4d0a825fa7f6 | checkstock/AoC2020 | /day1/day1.py | UTF-8 | 580 | 3.78125 | 4 | [] | no_license | with open("input.txt") as file:
input = file.read().strip()
input = [int(x) for x in input.split("\n")]
lines = len(input)
print("Part 1:")
for i in range(0, lines):
for j in range(i+1, lines):
if input[i] + input[j] == 2020:
print("Answer: ", input[i] * input[j], "\n")
brea... | true |
e61d3ec5e9bfb4d312d049409f28303b5b2383e7 | WU731642061/LeetCode-Exercise | /python/code_1.py | UTF-8 | 1,344 | 3.921875 | 4 | [] | no_license | #!/usr/bin/env python3
"""
link: https://leetcode-cn.com/problems/two-sum/
给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。
你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。
"""
def twoSum(nums, target):
"""
这道题是leetcode题库的第一题,本身也是没有难度的,因为已经明确答案是一一对应的了,主要思路在于找到一个数,并且查找数组中是否存在target-num1的数
遍历是肯定需要的,问题在于,如何以最... | true |
2990d5380fed82d84b4ee546bd44a3d351fe7ec1 | 2patilsachin4/Blackjack | /games.py | UTF-8 | 886 | 3.8125 | 4 | [] | no_license | #Games module
class Player(object):
"""A player for a game"""
def __init__(self,name,score = 0):
self.name = name
self.score = score
def __str__(self):
rep = ""
rep += self.name + "\t" + str(self.score)
return rep
def ask_yes_no(question):
... | true |
d1cdf04015581d06a9957b1fb07d250835b2e874 | njjms/ref | /pandas_notes.py | UTF-8 | 3,321 | 3.34375 | 3 | [] | no_license | import os
import pandas as pd
os.chdir('/home/nick/numpy')
# loading data in pandas
df = pd.read_csv('pokemon.csv')
df.head(10)
df.tail(10)
df.shape
# get column headers
print(df.columns)
# get specific column
df[['Name', 'Type 1', 'Type 2']]
# get specific rows or columns
df.iloc[0:4, 1]
# iterate through rows
fo... | true |
bc8ca0bf59282d1338e68dc68b0a9af3447dfa9e | 0Roni0/labrab3 | /arithmetic.py | UTF-8 | 181 | 3.359375 | 3 | [
"MIT"
] | permissive | print('Решите пример: 4 * 100 - 54=?' )
otvet=input('Выше решение:')
prav=4*100-54;
print('Ваш ответ:',otvet,'Правильный ответ:',prav)
| true |
c7b9c80ab126754e10d6cd5ecc09fad9281ac47d | jagrvargen/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/square.py | UTF-8 | 1,774 | 3.546875 | 4 | [] | no_license | #!/usr/bin/python3
"""
This module ocntains the class definition for Square, which inherits from
the Rectangle class.
"""
from models.rectangle import Rectangle
class Square(Rectangle):
"""This is the Square class definition. It inherits the x, y, id, width
and height attributes from the Rectangle cl... | true |
dcf513e260d5aa7bc5299d46edbde13317055529 | karynaur/lyrics-game | /src/create_dataset.py | UTF-8 | 689 | 2.578125 | 3 | [
"MIT"
] | permissive | import pandas as pd
import numpy as np
import sys
artists=['kanye','beiber','ariana','drake','miley','21pilots','adele','21savage','backstreet','coldplay','edsheeran','eminem','linkinpark','weeknd']
for i in artists:
print(i)
path='data/{}'.format(i)
with open(path+'/{}.csv'.format(i),encoding="utf8", errors='i... | true |
840ccb97a999af3c26a7ccdf78661e3cdbce0757 | daniel-reich/turbo-robot | /neZRK58MeM3b5kMzL_4.py | UTF-8 | 970 | 4 | 4 | [] | no_license | """
A company asks a small-scale manufacturer to produce packaging in which they
can ship their cooking oil. The company also gives the design for how the
vessel should look (the shaded portion filled in the image below). Depending
upon the `volume` of oil to be packaged, the company requires vessels of
varying heig... | true |
e6320c5e35005d88d2224e01ca76f58412f150d2 | mbarisi/hackaton-algorithm | /id.py | UTF-8 | 1,432 | 2.5625 | 3 | [] | no_license | import csv,sys, operator, itertools
ids=[]
# #učitamo opt i z korigirani
opt_sup=[58,177,71,155,60,36,13,26]
z=[23, 15, 28, 64, 40, 15, 8, 12]
krvne_grupe=['0-', '0+', 'A-','A+', 'B-', 'B+', 'AB-', 'AB+']
koliko_fali_grupa=[]
for i in range(0, len(z)):
koliko_fali_grupa.append(opt_sup[i]-z[i])
print(koliko_fali_g... | true |
83d5a9b4493ac42640e11937dbe8027474f0c29f | Aasthaengg/IBMdataset | /Python_codes/p03599/s264205208.py | UTF-8 | 810 | 2.90625 | 3 | [] | no_license | a, b, c, d, e, f = map(int, input().split())
water = [0]*(f+1)
suger = [0]*(f+1)
water[0] = 1
suger[0] = 1
for i in range(f+1):
if water[i]:
if i+100*a <= f:
water[i+100*a] = 1
if i+100*b <= f:
water[i+100*b] = 1
if suger[i]:
if i+c <= f:
suger[i+c] ... | true |
bbb90175a1721dc309abed86cf61c47ed3d700ae | pydron/pydron | /pydron/translation/deglobal.py | UTF-8 | 5,240 | 2.890625 | 3 | [
"MIT"
] | permissive | '''
Created on Oct 15, 2014
@author: stefan
'''
import ast
import scoping
from pydron.translation.astwriter import mk_call, mk_str, mk_name
from pydron.translation import transformer
class DeGlobal(transformer.AbstractTransformer):
"""
Transforms the AST so that there are no more global variables.
... | true |
70c2e169b8cf42449de2f4947d77b6c31c35dcec | jithyan/undergraduate-projects | /Lexical Normalization of Twitter Data/code/std_ops.py | UTF-8 | 5,745 | 3.5 | 4 | [] | no_license | #*****************************************************************************
#* Functions for parsing corpuses and writing the processed output.
#*****************************************************************************
import cPickle
import re
import sys
##/*----------------------------------------------... | true |
1fef1fe3020e72ef789d50c602090d1fe8478aac | viniciusms29/PAA | /NewSkyline.py | UTF-8 | 3,015 | 3.78125 | 4 | [] | no_license | #----------------------------------------------------#
# Alg.: Skyline --------------------- Disciplina: PAA#
# Aluno: Vinícius Morais dos Santos ----- RA: 0002864#
#----------------------------------------------------#
# Posicao 0 = Esquerda
# Posicao 1 = Altura
# Posicao 2 = Direita
def skyline(buildings):
... | true |
3c4e81e28e1b99812267074647953bc31b6c9b99 | maxsmartofficial/ab_testing_strategy | /tests/test_main.py | UTF-8 | 578 | 2.53125 | 3 | [] | no_license | import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import pytest
import src.strategy
import src.page
import src.main
# Test data is correct format
def test_data():
trials = 1000
pages = src.page.getBernoulliPageList([0.1, 0.2])
agent ... | true |
c44f63aa06e85b14a518505b968791d9490ec0ce | chrisprobert/GenomicMusic | /createMusicFromWig.py | UTF-8 | 2,490 | 2.890625 | 3 | [] | no_license | import numpy as np
import Nsound as ns
from extractWig import readWIG
import sys
total_time = 30 # the length of track in seconds
sample_rate = 5000 # the sample rate to use
min_freq = 20 # the minimum frequency to use
max_freq = 20000 # the maximum frequency to use
window_size = 1000 # the sequence window size to... | true |
1bd36b76f4236e0174d4ea54dd3cd485e41e4ac4 | conorato/INF8775 | /tp2-A20/prototype/tabou.py | UTF-8 | 4,941 | 2.875 | 3 | [] | no_license | import numpy as np
STOP_CRITERIA = 100
MIN_TABOU = 7
MAX_TABOU = 10
def execute_tabou(blocs):
path = _execute_tabou(blocs)
return path
def _execute_tabou(candidates):
current_solution = np.array([]).reshape(0, 3)
current_solution_height = 0
best_solution = None
tabous = [[] for _ in range(... | true |
05d964406774ac061a486b166355136e18bbc227 | dzhao14/HackerRank_code | /practice/algorithms/strings/camelcase.py | UTF-8 | 262 | 3.5625 | 4 | [] | no_license | #https://www.hackerrank.com/challenges/camelcase
def solution(s):
count = 1
for char in s:
if ord(char) <= 90:
count += 1
return count
if __name__ == "__main__":
s = input().strip()
ans = solution(s)
print(str(ans))
| true |
ebd929aec56fb28cde9f586702b0a9136c0afe5b | seismoman/Web-Scraping | /baseball_scraper.py | UTF-8 | 1,349 | 3 | 3 | [] | no_license | from bs4 import BeautifulSoup as bsoup
import urllib2 as url
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
dum = []
h = []
k = []
y = []
quote_page = 'https://www.baseball-reference.com/leagues/MLB/bat.shtml'
page = url.urlopen(quote_page)
soup = bsoup(page,'html.parser')
for row in soup... | true |
c856ab2367a3c1de820d1e5beb8caac5b0fbc17d | mrlong/python_study | /test1.py | UTF-8 | 1,404 | 2.65625 | 3 | [] | no_license | #!/usr/bin/python
# coding=utf-8
import socket;
class mysocket(object):
"""docstring for mysocket"""
def __init__(self, sock=None):
super(mysocket, self).__init__()
if sock is None:
self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
else:
self.sock = sock
def connect(self,host,port):
sel... | true |
c1288047d8a177beb980093354c1d121a78260f4 | Jacobvs/ML-Music-Analyzer | /data_clean.py | UTF-8 | 13,040 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | import pickle
import re
import ujson
import collections
import antlr4
from chord_labels import parse_chord, chord_labels
from progressbar import ProgressBar, Bar, Percentage, AdaptiveETA, Counter
from numpy import sum
print("Opening files")
with open('dataset_values.pickle', 'rb') as values:
#print('opening value... | true |
d52a098424d822e5456ca407827edcb322d90b54 | SimplyLinn/PuddleBot | /cogs/rain.py | UTF-8 | 5,728 | 2.921875 | 3 | [] | no_license | import discord
from discord.ext.commands import group
from discord.ext.commands import bot
from discord.ext import commands
import asyncio
import requests
import cfg
import json
class Rain:
def __init__(self, bot):
self.bot = bot
try:
with open('rain.json') as f:
self.lookup = json.load(f)
except:
sel... | true |
e36a8a4dd13d79b3730e2d922f4148eb0b164520 | edt-yxz-zzd/python3_src | /seed/io/stdout_print.py | UTF-8 | 331 | 2.625 | 3 | [] | no_license |
__all__ = ['stdout_print']
#from sys import stdout
import sys
from io import StringIO
def stdout_print(*args, encoding='utf8', **kwargs):
sout = StringIO()
print(*args, **kwargs, file=sout)
string = sout.getvalue()
b_stdout = sys.stdout.buffer
bs = string.encode(encoding=encoding)
b_stdout.w... | true |
f07860907ef790393a4bc469fef86e0a3622782b | JorgeGarcia2/PythonTestbench | /Fers/Python_ind/PortTB.py | UTF-8 | 2,537 | 3.453125 | 3 | [] | no_license | #!/bin/python3.6
# !/bin/python3.8 --> From Jorge
import random
import string
class Port:
def __init__(self, port_def):
self.namePort = port_def[0] #Port Name
self.rangePort = port_def[1] - port_def[2] #Bus size -1
if (self.rangePort > 0):
self.downtoPort = True #Down ... | true |
5c5aaf38b8f34ce990c818783862ad2250a91cf6 | 464647730/CommunityHelp | /3.开发阶段/第一次迭代/python后台/code/handler/DeleterelativesHandler.py | UTF-8 | 897 | 2.921875 | 3 | [] | no_license | '''Yeqin Zheng, 09/07/2014'''
import tornado.ioloop
import tornado.web
import tornado.httpserver
import json
''' Delete a relation between two users. Succeed with "1" returned, else with "0". '''
class DeleterelativesHandler(tornado.web.RequestHandler):
def get(self):
self.write("<p>DeleterelativesHandler</p><form... | true |
155aa5c3be26743e8f2353f17e42c17fc63763cb | CHAIN-hash/gimbiseo | /gimbiseo/qadict.py | UTF-8 | 7,388 | 3.921875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
test1 = [
('"八公"是[狗]', ''),
('狗是一种[动物]', ''),
('动物是一种事物', '我知道了'),
('"八公"是狗吗?', '是'),
('狗是一种什么?', '动物'),
('狗[v喜欢]骨头', ''),
('狗狗我好喜欢', '能再说一遍吗?'),
('[骨头]是一种事物', '我知道了'),
('狗喜欢骨头', '不要重复'),
('狗喜欢骨头吗?', '是'),
('"八公"喜欢骨头吗?', '是')... | true |
c73527b55937c93b8237949100ee205ed750b41f | samyunwei/LearnPython | /catchThread.py | UTF-8 | 1,068 | 3.140625 | 3 | [] | no_license | # -*-coding:utf-8 -*-
# File Name: catchThread.py
# Author: Sam
# mail: samyunwei@163.com
#########################################################################
#!/usr/bin/env python
from myThread import MyThread
def catchstr(thestr,thecatch):
return thestr.count(thecatch)
def catchsplit(thestr,splitcount):
... | true |
2673043d2fe18dcfe805d536f2efbd1c62d05f1b | JoSlam/COMP_6801_A1 | /A1_Q3.py | UTF-8 | 1,228 | 3.6875 | 4 | [] | no_license | ##Course: COMP 6801
##Name: Joshua Lambert
##ID: 815007658
##Assignment_1
import math
def trial_division(n):
factorList = []
while (n % 2 == 0) :
factorList.append(2)
n = n // 2
for i in range(3, int(math.sqrt(n)), 2):
while (n % i == 0) :
factorList.append... | true |
6c271400abd3c8ac1cb59959b076c0850cec2cec | SlavicDeveloper/Algorithms_Python | /task_2_3.py | UTF-8 | 858 | 3.765625 | 4 | [] | no_license | """Код для проверки пароля пользователя"""
from uuid import uuid4
from hashlib import sha3_256
def pass_check(passwd):
"""Функция создает 'соленый хеш' пароля, а затем требует ввести пароль повторно для сравнения хешей"""
salt = uuid4().hex
user_salt = salt
user_hash = sha3_256(salt.encode() + passwd.... | true |
c01553d6941d8a9a00084fb0fdbbea6cbab1b833 | Aasthaengg/IBMdataset | /Python_codes/p02265/s151126943.py | UTF-8 | 433 | 3.234375 | 3 | [] | no_license | import collections
hoge = collections.deque()
n = int(input())
for _ in range(n):
commands = input().split()
if len(commands) == 1:
if commands[0] == 'deleteFirst':
hoge.popleft()
else:
hoge.pop()
else:
com, x = commands
if com == 'insert':
... | true |
ffe93ec10e9ee24fb615e2bb6a9a5b756a2348b6 | AWebZen/AdventOfCode_answers | /2019/Advent_3_2019.py | UTF-8 | 1,914 | 3.25 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from scipy.spatial.distance import cityblock #Manhattan distance
from collections import Counter
INPUT_DATA = [instr.split(",") for instr in open("Advent_3_2019_input.txt", "r").read().split("\n")]
#==============================================================================
# PART 1
#======... | true |
35b8b20510090e7a33fe94ce78ca38e9addcc10d | pangfeiyo/PythonLearn | /甲鱼python/课程代码/第9讲/for循环.py | UTF-8 | 285 | 3.671875 | 4 | [] | no_license | favourite = 'fishC'
for i in favourite:
print(i,end=" ")
print()
print()
#定义列表
nember = ['小甲鱼','小布丁','黑夜','迷途','恬静']
for each in nember:
print(each,len(nember))
#len 计算长度
print()
print()
for each in nember:
print(each,len(each))
| true |
e78eb8adda6049d07353f8d51134bff2034ba176 | chienzhiwang0831/chat | /convert3.py | UTF-8 | 311 | 3.09375 | 3 | [] | no_license |
lines = []
with open('3.txt', 'r', encoding='utf-8-sig') as f:
for line in f:
lines.append(line)
for line in lines:
s = line.split(' ')#s[0]__[13:34Allen]__[0123456789]
time = s[0][:5]#01234重0~4開始,到5以後都不要
name = s[0][5:]#01234重5開始算,到結尾無
print(name)
#print(name)
| true |
b5cedaf0cb241ad24b1945707a3ac8d253bbccf5 | daniel-reich/ubiquitous-fiesta | /PGqy3SRaobbtFfspW_18.py | UTF-8 | 311 | 3.234375 | 3 | [] | no_license |
def simple_pair(lst, n):
for i in range(len(lst)):
#lst2 = lst[i+1:]
for j in lst[i+1:]:
first = lst[i]
second = j
if check_multiply(first,second,n) == 1:
return [first,second]
return None
def check_multiply(x,y,n):
if x*y == n:
return 1
else:
return 0
| true |
505558aad88ec0492a504123aecf855ff5d6165d | ahmad-abdellatif/sparse-structured-attention | /pytorch/torchsparseattn/oscar.py | UTF-8 | 3,644 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | """Oscarmax attention
Clusters attention weights into groups with equal weight, regardless of index.
A Regularized Framework for Sparse and Structured Neural Attention
Vlad Niculae, Mathieu Blondel
https://arxiv.org/abs/1705.07704
"""
import numpy as np
import torch
from torch import nn
from torch import autograd as... | true |
6d783cf6df955cb78e3448ba4090e6cb44e0a76f | lvsdvale/ProjetoCondutor | /Problema_2/Problema_2.py | UTF-8 | 4,105 | 3.234375 | 3 | [] | no_license | from warnings import warn
import heapq
from math import exp
class No:
def __init__(self, posicao=None, pai=None):
self.posicao = posicao
self.pai = pai
self.g = 0
self.h = 0
self.f = 0
def __eq__(self, other):
return self.posicao == other.posicao
def __lt__... | true |
bde1e8991d05318037b6458698c1f55bc4011885 | lujulia/Gaussian-Dynamic-Convolution | /torchsegmentor/utils/vis/color_map.py | UTF-8 | 1,271 | 2.828125 | 3 | [
"MIT"
] | permissive | import numpy as np
def voc2012_color_map(N=21, normalized=False):
def bitget(byteval, idx):
return (byteval & (1 << idx)) != 0
dtype = "float32" if normalized else "uint8"
cmap = np.zeros((N, 3), dtype=dtype)
for i in range(N):
r = g = b = 0
c = i
for j in range(8):
... | true |
9721b3af2cffba5715548fe5cb8b4af23ac6bb0f | fliphilipp/compPhysics | /Homeworks/HW2/plot-task4-alpha.py | UTF-8 | 1,045 | 3.203125 | 3 | [] | no_license | # plot the displacements
# Created by Martin Gren 2014-10-25.
# imports
import matplotlib.pylab as plt
import numpy as np
# import data
data50 = np.loadtxt('file-alphaval50.dat')
data75 = np.loadtxt('file-alphaval75.dat')
data90 = np.loadtxt('file-alphaval90.dat')
data99 = np.loadtxt('file-alphaval99.dat')
iteration... | true |
7605d25dd9e1ebf0393c8b0e078d86c9af85178a | sreejath/Warri | /py4.py | UTF-8 | 73 | 3.328125 | 3 | [] | no_license | x = 42
y = x
x += 1
print(x, y)
x = [0, 1, 2]
y = x
x[0] = 4
print(x, y) | true |
fc3bac1269211e45fdd0da7483de9a9b1f29c151 | paulporto/tinyfox_raspberry_pico | /tinyfox_variables.py | UTF-8 | 1,616 | 2.71875 | 3 | [] | no_license | from machine import Pin, Timer
from machine import UART
import time
print("inicio")
#s = "%08x%04x" % (5,4)
#print(s)
import struct
import binascii
def float_to_hex(f):
return str( binascii.hexlify(struct.pack('<f', f)) ,"ascii")
#print( float_to_hex(17.5) )
tfox = UART(1, 9600) #usar el uart0 a 9600 baudios
t... | true |
77c43fa4e71687f2ba371c23cd433957dca72221 | pprp/SimpleCVReproduction | /tiny_classifier/utils/compute_mean_std.py | UTF-8 | 877 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | import argparse
import torch
import torchvision
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--root', type=str)
parser.add_argument('--sources', type=str)
args = parser.parse_args()
train_loader = torch.utils.data.DataLoader(
torchvision.datasets.ImageFolder(
... | true |
d70576e0207730baf3f605491095b9e8694d52fc | abhisheksingh24/random_codes_i_ever_wrote | /Bharath Secret Messages.py | UTF-8 | 224 | 3 | 3 | [] | no_license | n = int(input())
s = input()
k = int(input())
str = ''
for e in s:
asc = ord(e)
for i in [97, 65]:
if asc>=i and asc<i+26:
str+=chr((asc-i+k)%26+i)
else:
str+=e
print(str)
| true |
e604478d6cbe43953dded10d92b737b0510251d3 | twisted/epsilon | /epsilon/hotfixes/proto_helpers_stringtransport.py | UTF-8 | 341 | 2.59375 | 3 | [
"MIT"
] | permissive | from twisted.test import proto_helpers
class StringTransport:
def write(self, data):
if isinstance(data, unicode): # no, really, I mean it
raise TypeError("Data must not be unicode")
self.io.write(data)
def install():
proto_helpers.StringTransport.__dict__['write'] = StringTranspo... | true |
69be8d25ea70324f867ddc621ef27736049b791f | DLVIsualizer/dlvis | /util/file_util.py | UTF-8 | 193 | 2.8125 | 3 | [] | no_license |
class FileUtil:
def saveStrListTofile(strlist:list ,exportpath:str):
with open(exportpath ,"w") as f:
strnames = "\n".join(strlist)
f.writelines(strnames)
| true |
4a37ff3e2103069a1d73f336c5013e94f841396e | pavanmaganti9/v1 | /xmlparsing3.py | UTF-8 | 367 | 2.703125 | 3 | [] | no_license | import xml.etree.cElementTree as ElementTree
tree = ElementTree.parse('cefixime.xml')
root = tree.getroot()
for node in tree.findall('.//stuff'):
for sn in node.getchildren():
print(sn.tag, sn.text)
for child in root:
print(child.tag)
for node in tree.findall('.//section'):
for snode in node.getc... | true |
6e39d3be5981af8f4ae81b74989332bd0daa3eb5 | VladSpreis/home | /zad_3.py | UTF-8 | 289 | 3.578125 | 4 | [] | no_license | a = input("Введите число:")
b = a + a
c = b + a
e = int(a) + int(b) + int(c)
print(e)
#или же просто можно выводить сумму первых трех переменных не вводя при этом четвертую
print(int(a) + int(b) + int(c)) | true |
f5182746b0509a7c63f1ccd033b53dc33f5b9ed8 | sauravsapkota/HackerRank | /Interview Preparation Kits/1 Week Preparation Kit/Day 2/Counting Sort 1.py | UTF-8 | 666 | 3.28125 | 3 | [] | no_license | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'countingSort' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER_ARRAY arr as parameter.
#
def countingSort(arr):
# Write your code here
sol=[0]*100 # creates an arr... | true |
0b64ee645841ac16a6b870fd995e99e38a605705 | vasyanch/stepik | /Python_base_apply/Stepic_Buffer.py | UTF-8 | 340 | 3.03125 | 3 | [] | no_license | class Buffer:
def __init__(self):
self.spisok = []
def add(self, *a):
for i in a:
self.spisok.append(i)
if len(self.spisok) == 5:
print(sum(self.spisok[:5]))
self.spisok = []
def get_current_part(self):
... | true |
3cfa5de4bdb7c6a629f2b1f853b04cf4c625f708 | maspe36/Dimension | /DimensionPythonClient/client.py | UTF-8 | 649 | 2.953125 | 3 | [
"MIT"
] | permissive | import socket
import threading
ENCODING = "utf-8"
LOCAL_ENDPOINT = "127.0.0.1"
def listen():
while 1:
data = sock.recv(4096)
if data:
print("Server: " + data.decode(ENCODING))
def listen_to_keypress():
while 1:
message = input("Enter text (or Enter to quit): \n")
i... | true |
cdfaaea53378ffc4bdeee574b18c04bd4bba227a | allseeworld/web | /my_spider/day01/1.urllib的语法和使用.py | UTF-8 | 2,041 | 2.765625 | 3 | [] | no_license | import urllib.request
# urllib.request.urlopen( url,data,timeout)
# url 请求地址,data请求参数,timeout过期时间
# 只传url
# url = 'http://www.baidu.com'
# res = urllib.request.urlopen(url)
# print(res.read().decode())
#
# 传入 url和data
# url = 'http://www.baidu.com/s'
# data = 'wd=python'.encode()
# # urlopen(url,data)默认请... | true |
a068f93b9969ead371cd57385c39725fde2a7324 | gpauloski/kfac-pytorch | /testing/assignment.py | UTF-8 | 2,898 | 2.75 | 3 | [
"MIT"
] | permissive | """Lazy WorkAssignment implementation for testing."""
from __future__ import annotations
import torch.distributed as dist
from kfac.assignment import WorkAssignment
class LazyAssignment(WorkAssignment):
"""Lazy assignment where every worker is an inverse worker.
Used in unit tests force a KFACPreconditione... | true |
cfdcfb9062ed6aac3633d9200678bc60b1a1fae0 | Chalmiller/competitive_programming | /python/algorithms/matrix/winner_tic_tac_toe.py | UTF-8 | 1,001 | 3.46875 | 3 | [] | no_license | from typing import *
class Solution:
def tictactoe(self, moves: List[List[int]]) -> str:
def is_win(grid):
# Check a column win
col_list = zip(*grid)
print(list(col_list))
for col in list(col_list):
el = col[0]
for mark in col:
i... | true |
53a1f2e9b4d18a4dc48f211ba320063cae1ecbbe | orangutan78/pythonLearning | /orangutan/pygame/Tetris.py | UTF-8 | 9,642 | 2.96875 | 3 | [] | no_license | import tkinter as tk
import random
from PIL import Image,ImageTk
class Tetris:
'俄罗斯方块'
FPS=1000 #刷新速度
cell_size=30 #格子大小
blocks={
"O":{"pos":[(-1,-1),(0,-1),(-1,0),(0,0)],"color":["#3e7dff","#2313b9","#160a6f"]},
"L"... | true |
a22700cf2c3a962f459f7512627ae3d66909fc25 | wangqiangnpq/flash | /net/codec.py | UTF-8 | 373 | 2.703125 | 3 | [] | no_license | from abc import ABCMeta, abstractmethod
from utils.buffer import Buffer
class Codec(object):
__metaclass__ = ABCMeta
def __init__(self):
pass
# (buffer, conn) => object
@abstractmethod
def decode(self, buffer: Buffer, conn):
pass
# (msg, conn) => bytes
@abstractmethod
... | true |
cca35fd5e647b11170949e8863857e31d96a5b91 | luxuguang-leo/everyday_leetcode | /00_leetcode/336.palindrome-pairs.py | UTF-8 | 5,509 | 3.734375 | 4 | [] | no_license | #
# @lc app=leetcode id=336 lang=python
#
# [336] Palindrome Pairs
#
# @lc code=start
class Solution(object):
def isPalindrome(self, s):
'''
l, r = 0, len(s)-1
while l < r:
if s[l] == s[r]:
l +=1; r -=1
else:
return False
retu... | true |
6724bfd5b747153bac6d76212fa791bd69080cd4 | spisakni/minikubeBootstrap | /bootstrap.py | UTF-8 | 6,005 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
__author__ = 'Nick Spisak'
import subprocess, time, argparse, yaml, os, sys
from Logger import configure_console_logger
# Create the logger config
logger = configure_console_logger(name='default')
def cmdOut(cmd):
"""Utility function for running terminal commands."""
return subprocess.... | true |