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
d53a435f6642944721885c1234296992b5d2ef3e
Python
fullofhope336/Dungeon-Escape-RPG
/test_combat_round_with_boss.py
UTF-8
3,686
3.03125
3
[]
no_license
import io from unittest import TestCase from unittest.mock import patch from game import combat_round_with_boss class TestCombatRoundWithBoss(TestCase): @patch('random.randint', side_effect=[30, 15, 30, 30]) def test_is_character_hp_great_than_zero_when_defeat_boss(self, mock_randint): boss = {'hp': ...
true
0a356d686c76bd8ba3ebb3ad37460c3fd1183b32
Python
alexandsquirrel/Learnability-Semantic-Universals
/probing_classifier.py
UTF-8
3,529
2.53125
3
[]
no_license
import torch from transformers import BertTokenizer, BertModel import h5py import logging logging.basicConfig(level=logging.INFO) # put this method in "quant_verify" to save outputs def make_hdf5_file(self, out_fn: str): """ Given a list of sentences, tokenize each one and vectorize the tokens. Writ...
true
c4220d3f1481caaad904db59f56c0c1afd4ab2b8
Python
aa0228/fakeReviewFilterWeb
/fakeReviewFilterWeb/core/infoDatabase/loadFileToDatabase.py
UTF-8
5,149
2.84375
3
[]
no_license
from os import path from datetime import datetime from traceback import print_exc from .dbSession import dbSession as Session from .reviewModels import (Review, ReviewUser, ProductType, Product) from ..coreAlgorithm.textAnalyzer import TextAnalysisMaxSSaver class LoadReviewDataFromFileToDB: __valueMap = {'product...
true
e2a91d9b2a5187c623fc9c499a42f2716f337aa0
Python
Ketan14a/OMDB-Movies-project
/Printing_the_Imported_Data.py
UTF-8
567
2.90625
3
[]
no_license
# Importing PyMongo for accessing MongoDB import pymongo # Establishing the Connection to the database myclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclient["OMDB_movies_db"] mycol = mydb["my_OMDB_collection"] # Accessing Tweets from MongoDB for x in mycol.find(): print("Title:"+ x['Title'])...
true
ae4e20fec8d8cbbf465deee3298c8da0674e3dbd
Python
dnowuser/HAX121
/P024_06.py
UTF-8
524
3.359375
3
[]
no_license
# HAX 121 2020 Python (3.6.0) Submission Template # Please fill out the info fields below for identification # Do not modify any part of the template # Team Name: Copiolis # Team Number: P024 # Problem Number: 06 import array import math import re import string # Class and function definitions: # Mai...
true
418252665e71713da428cc1a592afd51dc600a25
Python
lacklust/coding-winter-session
/notes/week_1/functions.py
UTF-8
4,125
4.875
5
[ "MIT" ]
permissive
""" the purpose of this lesson is to learn about functions functions are of two forms (more than two but we will consider only two): built-in and user-defined functions built-in: (provided by the system - python) examples: --> print() --> type() in math: a function is a relation in which for every input, there is al...
true
ef8c67e4918fea2192e9143fca89a1ed49955dbb
Python
DominikBeese/DidAIGetMoreNegativeRecently
/Analysis/DistributionOfStance/DistributionOfNegativeStancePerYearAndVenue.py
UTF-8
2,552
2.75
3
[ "CC-BY-4.0" ]
permissive
from matplotlib import pyplot as plt from matplotlib import ticker as mtick import seaborn as sns import pandas as pd import numpy as np from scipy.ndimage import gaussian_filter1d sns.set_theme(style='whitegrid') VENUES = ['ACL', 'EMNLP', 'COLING', 'NAACL', 'SemEval', 'CoNLL', 'CL', 'TACL', 'NeurIPS', 'AAAI...
true
86c17e433676a06582e01acf50b084b9e828baa7
Python
tizz98/prospyr
/tests/test_nested_identified_resource.py
UTF-8
2,460
2.59375
3
[]
no_license
import mock from marshmallow import fields from nose.tools import assert_raises from prospyr.exceptions import ValidationError from prospyr.resources import NestedIdentifiedResource, Resource types = {'child': 'tests.test_nested_identified_resource.Child'} class NoneableParent(Resource): class Meta: pas...
true
0180b0d0334defcc19232dcb7f4c08a34fd94917
Python
hoybyte/100DaysOfPython
/Days22-24/port_scanner.py
UTF-8
491
3.203125
3
[]
no_license
from socket import * import time start_time = time.time() if __name__ == '__main__': target = input('Enter the host to be scanned: ') target_IP = gethostbyname(target) print('Starting scan on host: ', target_IP) for i in range(50,500): port = socket(AF_INET, SOCK_STREAM) connection =...
true
25ab5363713c0d2b040785e69af9a942038d64c9
Python
animewoman/py_ex
/expy13.py
UTF-8
230
3.21875
3
[]
no_license
#working with terminal input from sys import argv script, first, second, third = argv print("The script is called", script) print("Your first var is", first) print("Your second var is", second) print("Your third var is", third)
true
ecaa28143bcb2588557d560b41b2d849d0296340
Python
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/swnrei001/question3.py
UTF-8
642
3.703125
4
[]
no_license
def frameMessage(message, repeat, thickness): for i in range(thickness): print('|' * i + '+' + ('-'*(len(message) + 2* (thickness - i))) + '+' + '|' * i) for i in range(repeat): print('|' * thickness, message, '|' * thickness) for i in range(thickness): print('|' * (thickness -...
true
c0ea4b45dfffc850cb06b609687889227f2bb906
Python
CUBigDataClass/SportsCanary
/Twitter_Utils/TwitterAPIKeySwitcher.py
UTF-8
5,206
2.828125
3
[]
no_license
import json import os from Eternal_Utils.CommonUtils import CommonUtils import logging class TwitterAPIKeyHandler: def __init__(self): self.api_key_array = [] self.number_of_keys = int(CommonUtils.get_environ_variable('NUMBER_OF_TWITTER_KEYS_AVAILABLE')) wd = os.getcwd() pos = wd.f...
true
faecbc36ae014fd5ffbf523432519484bf664142
Python
andrew-epstein/jira-graph-viz
/jira_graph_viz_config.py
UTF-8
958
2.59375
3
[ "MIT" ]
permissive
import configparser import os import jira class Configs: def __init__(self): self._config = self._get_config() self._username = self._config.get('Auth', 'username') self._password = self._config.get('Auth', 'password') self._url = self._config.get('Basic', 'url') def _get_conf...
true
7a1cc9d1a40ebe7bda35a29992d85cfe64def4b2
Python
AlexandrT/instrument-ui-tests
/tests/test_product_list.py
UTF-8
1,457
2.515625
3
[]
no_license
import pytest import logging from helpers.utils import * from helpers.page import * logger = logging.getLogger('ui_site') PATH = '/instrument/' class TestAddProductFromList: """Test add product from list""" def setup_class(cls): logger.info('=========================================================...
true
99b76a7660d9601800de27e7952418d77136e99e
Python
wangxiaoyuwf/CoVigilantSystems
/json_to_sql_converter.py
UTF-8
1,626
2.828125
3
[]
no_license
#!/usr/bin/python3 # Author:Xiaoyu Wang # This file is used to convert the .json data to .sql data # data:11/12/2019 import json import codecs import argparse import os # read json file and write the context to the sql file def read_and_write_file(json_file_path, sql_file_path): json_f = open(json_file_path,"r",...
true
e43659be29373da03c76e828d86468c4430adef1
Python
bliiir/ras_python_core
/week_02/labs/05_functions/Exercise_03.py
UTF-8
280
4.34375
4
[]
no_license
''' Write a program with 3 functions. Each function must call at least one other function and use the return value to do something. ''' def first(val1): return(second(val1)*2) def second(val2): return(third(val2)*3) def third(val3): return(val3*4) print(first(2))
true
ba85742b42e78088dd7ccf4a20a7fecef33e9bd3
Python
ig248/s3migrate
/tests/test_api.py
UTF-8
1,512
2.59375
3
[ "MIT" ]
permissive
import s3migrate def test_yield_candidates(file_tree): """Test that pruning is done early.""" base_url, files = file_tree pattern = base_url + "/{ds}/type=three/{filename}.ext" candidates = list(s3migrate.api._yield_candidates(pattern)) assert len(candidates) == 2 def test_iterformats(file_tree)...
true
507ba1da92da5db51c2833c3329d77241b72cb9f
Python
JLMadsen/AdventOfCode
/2021/day09.py
UTF-8
1,413
3.234375
3
[ "MIT" ]
permissive
def get_adjacent(grid, i, j, pos=False): return [ grid[y][x] if not pos else [y, x] for a, b in [(1,0), (0,1), (-1,0),(0,-1)] if not ( (x := a + j) < 0 or (y := b + i) < 0 or x >= len(grid[0]) or y >= len(grid) )] low_points = [] def calc_risk(grid): global low_points risk = 0 for i, row in enumerate(...
true
a0758dc69a5542ca6a810faefa008dcaed728ba3
Python
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/3995/codes/1712_2504.py
UTF-8
215
3.171875
3
[]
no_license
v=int(input("virus:")) l=int(input("leucocitos:")) v1=float(input("percentual de v:")) l1=float(input("percentual de l:")) t=0 while(l<2*v): h=(v*v1)/100 v=v+h w=(l*l1)/100 l=l+w t=t+1 if(l>=2*v): print(t)
true
a53dbe183b39b271385565f5cede9815d7f8c591
Python
Red-Night-Aria/HIT-Compiler
/symbolTable.py
UTF-8
2,175
3
3
[]
no_license
class SymbolTable: # class entry: # def __init__(self, lexeme, Etype, offset): # self.lexeme = lexeme # self.Etype = Etype # self.offset = offset class SymbolError(Exception): pass def getType(self, lexeme): if self._entryDict.get(lexe...
true
b8da1302088e42c1ab3d3d22bf7c059880292526
Python
chysch/Phonetic-Pun-ishment
/synthesize.py
UTF-8
2,189
2.71875
3
[]
no_license
import sys from synthesize_funcs import * from rules import * # Runs the main synthesis module which finds phonetic # matches for the test data. def Synthesize(output, phon, back, rules): print("Synthesizing...") # Organize input rule_file = open(rules, 'r') rule_lines = rule_file.readlines() rule...
true
d4a8196367a0c741afe90691d7ee1a3c5085a82e
Python
JoeA42/programa-pymes
/master.py
UTF-8
79
2.71875
3
[]
no_license
def test(): if(1 == 1): print("yes") else: print("no")
true
40b4874b2461bc16608424d26b40ea91e6b25032
Python
MadhavJivrajani/HGQC_Assignment_Repo
/Week3/Naman Jain/naman jain week 3 gates.py
UTF-8
717
2.5625
3
[ "MIT" ]
permissive
import numpy as np import math random_matrix=np.array([[0,1,0,1],[1,0,1,0]]) '''Pauli gates''' X=np.array([[0,1],[1,0]]) Y=np.array([[0,1j],[-1j,0]]) Z=np.array([[1,0],[0,-1]]) '''Hadmard gate''' H=1/math.sqrt(2)*np.array([[1,1],[1,-1]]) '''Controlled NOT - CNOT''' CNOT=np.array([[1,0,0,0],[0,1,0,0],[...
true
9862b61176bc41e2302cf18a51d25587bc14b07b
Python
nlakritz/codingbat-python-solutions
/warmup-1/not_string.py
UTF-8
191
3.25
3
[]
no_license
def not_string(str): notString = "not" if (str.find("not") == 0): #returns starting index of search string if located, otherwise returns -1 return str else: return "not " + str
true
edb3656a0ab0f0b5e79a19abc11edfb5b395ba31
Python
stasych/study_algorithm
/hackerrank/algorithms/sorting/counting_sort_4.py
UTF-8
661
2.609375
3
[]
no_license
# -*- coding: utf-8 -*- ''' https://www.hackerrank.com/challenges/countingsort4 sample successfull passed INPUT 20 0 ab 6 cd 0 ef 6 gh 4 ij 0 ab 6 cd 0 ef 6 gh 0 ij 4 that 3 be 0 to 1 be 5 question 1 or 2 not 4 is 2 to 4 the RIGHT OUTPUT 0 ab 0 ef 0 ab 0 ef 0 ij 0 to 1 be 1 or 2 not 2 to 3 be 4 ij 4 that 4 is 4 the 5 ...
true
28887b49d65e0bb319302a8c2ff372d9b348c5a2
Python
onitonitonito/k_mooc_reboot
/module_pygame/assets/sprite.py
UTF-8
540
3.625
4
[]
no_license
import pygame # DEFINE FUNCTION def set_load(filename): return pygame.image.load(filename) def set_size(obj, width, height): return pygame.transform.scale(obj, (width, height)) def set_rotate(obj, angle): return pygame.transform.rotate(obj, angle) # GETHER ABOVES def set_sprite(filename, width=0, he...
true
1b6789611a2bad866ff46b7a7dd86dfd7d2f4050
Python
stg-tud/licma
/resources/test_cases/python/PyCrypto/TestRule5.py
UTF-8
2,371
2.75
3
[ "MIT" ]
permissive
from Crypto.Protocol.KDF import PBKDF2 from Crypto.Cipher import AES from Crypto.Random import random g_count = 999 def p_example1_hard_coded(password, data): key = PBKDF2(password, b"12345678", 16, count=999) cipher = AES.new(key, AES.MODE_ECB) cipher_text = cipher.encrypt(data) return cipher_text ...
true
b201cbacd12501a922c6adee3e55708aa2e72ab0
Python
824zzy/Leetcode
/K_DynamicProgramming/TimeSequential/L1_45_Jump_Game_II.py
UTF-8
729
3.078125
3
[]
no_license
""" https://leetcode.com/problems/jump-game-ii/ update maximum reach dp by: dp[i+j] = min(dp[i+j], dp[i]+1) Time complexity: O(n*k), where n<=10^4, k<=10^3 """ from header import * class Solution: def jump(self, A: List[int]) -> int: dp = [float('inf')] * len(A) dp[0] = 0 for i in range(le...
true
176ff8bfb28a4f159b90a291191b45918ea27cca
Python
saif43/python-oop
/inheritence+super.py
UTF-8
807
3.109375
3
[]
no_license
class Phone: # constructor def __init__(self,name,model,price): self.name = name self.model = model self.price = price class ButtonPhone(Phone): # constructor def __init__(self,name,model,price,a,b,c): self.a = a self.b = b self.c = c super().__i...
true
49bba97c587e212b0cf2982d1548712d9dea5ab0
Python
lauren-ai/CASIA
/code/df314-master/utils.py
UTF-8
954
3.109375
3
[]
no_license
import csv import math import numpy as np import json from datetime import datetime def write_event(log, step, **data): data['step'] = step data['dt'] = datetime.now().isoformat() log.write(json.dumps(data, sort_keys=True)) log.write('\n') log.flush() def check_crop_size(image_height, image_wid...
true
2c4abe5c436f86852b37dbcc95efc160f4b02971
Python
HLGhpz/WordCloud
/jieba_play.py
UTF-8
1,862
3.015625
3
[]
no_license
import jieba import wordcloud import PIL.Image as image import numpy as np from pprint import pprint def get_word_list(): with open('D:\python\play\word.txt', encoding='utf-8') as f: text_my = f.read().split() my_str = '' for text_str in text_my: my_str += text_str # pp...
true
e56135cffa2761ad32971dd7b1fcec8622c6b7cf
Python
lhbiao/weilai
/python_day03/源代码/实战二十三.py
UTF-8
217
3.296875
3
[]
no_license
number = int(input('请输入一个数字:')) while number == 0: print('') break while number < 100: print('命运给予我们的不是失望之酒,而是机会之杯\n'*number) break
true
1c135cccb784abf9c77b4124a4ad64283433b0e4
Python
mashiuka/seckyan-18
/client.py
UTF-8
492
2.90625
3
[]
no_license
import socket addres = ('localhost', 1234) max_size = 1000 masage = input() if len(masage) is 0: masage = "NO NAME" masage = '{0}'.format(masage).encode('utf-8') print(masage) #何を送るか try: client = socket.socket(socket.AF_INET,socket.SOCK_STREAM) client.connect(addres) client.sendall(masage) data ...
true
3cee9213f729594a59e1d3563677daec24719cbe
Python
chandan2710/kallisto
/src/kallisto/reader/strucreader.py
UTF-8
1,415
3.078125
3
[ "Apache-2.0" ]
permissive
# src/kallisto/reader/strucreader.py import click from kallisto.molecule import Molecule import kallisto.reader.turbomole as tm import kallisto.reader.xyz as xyz from kallisto.utils import errorbye def constructMolecule(geometry: str, out: click.File) -> Molecule: """Helper function to construct a Molecule.""" ...
true
01d4c609fce05673e2e411655d447a4eefbf92b0
Python
rgcalsaverini/safer-tags
/tag_server/collectors.py
UTF-8
4,192
2.625
3
[]
no_license
import json from time import time from flask import session, request from tag_server import gen_error valid_pagetypes = ['product'] def generic_data(store_id, tag_type): """ Assemble a generic data payload for the tag. Could be supplemented by specific tags. :param store_id: And arbitrary ID identifyi...
true
bc7e922ecddbf214e2fd8b995b1bdc22a954a1a5
Python
HowardOhMyGod/stock_back_end
/src/tech_signal_check/breakChecker.py
UTF-8
4,136
3.09375
3
[]
no_license
# coding: utf-8 from datetime import datetime from checker import BaseChecker, BaseStarter ''' 功能: 檢查該股當日交易資料是否符合均線糾結,向上突破的特徵 物件參數: 該股documet 回傳值: True or False ''' class TechChecker(BaseChecker): def __init__(self, stock, back_days = 1, options = None): super().__init__(stock, options=options) ...
true
04a26d5951fa2eaf7409547072ce0509684c7fe2
Python
EwenBorland/TwitchBot
/ircSocket.py
UTF-8
1,666
2.6875
3
[]
no_license
from socket import socket class IRCSocket: def __init__(self,host,port,auth,name): self.host = host self.port = port self.auth = auth self.name = name def setup(self,skt): self.skt = skt skt.connect((self.host,self.port)) skt.send(("".join(("PASS ", self...
true
8d08bc9e276e04b916ac05388b797531909f32b7
Python
kalyan-babu/Intrusion-Detection-system-IDS-
/classifer1.py
UTF-8
3,236
2.78125
3
[]
no_license
import math import operator import numpy as np import load_test_dataset1 as test import load_train_dataset1 as train def euclideandistance(instance1,instance2,length): distance=0 for x in range(length): distance+=pow((instance1[x]-instance2[x]),2) return math.sqrt(distance) #find...
true
cd7173894ff8c47b74fda6dbbcb428fc1a639a17
Python
rohit8871/Edwisor-1st-Project---Churn-Reduction
/churn Reduction.py
UTF-8
17,839
3.171875
3
[]
no_license
#!/usr/bin/env python # coding: utf-8 # In[288]: #Loan Library import os import pandas as pd import numpy as np import matplotlib.pyplot as plt from pandas import get_dummies # # 1) Data collection # In[363]: # set working directory os.chdir("D:/MY FIRST EDWISOR PROJECT\My first edwisor projects in python") #...
true
17d9590bddb5ba2491722c3fc4beb3c1543a6ab1
Python
Pebaz/coding-problems
/py/6-10-19.py
UTF-8
716
4.28125
4
[]
no_license
""" This problem was asked by Amazon. Given an integer k and a string s, find the length of the longest substring that contains at most k distinct characters. For example, given s = "abcba" and k = 2, the longest substring with k distinct characters is "bcb". """ def subber(s, k): if k == 0: return '' ...
true
6527e71cbf8e07bcc99bbdcc969c3982c716bc5f
Python
JoshChang8/EngHackHangmanWebsite
/idle_class.py
UTF-8
988
3.78125
4
[]
no_license
#Class for Hangman game class hangman: def __init__(self,word,location_list): self.word = word self.location_list = location_list def word_to_blanks(self,word): # converts the word to blanks to_guess = "" for letter in self.word: to_guess = to_guess + "-" ...
true
03f0acc3909f70c68e09e833c85da0ec5881b735
Python
itsabdiev/Final-project
/new.py
UTF-8
9,538
2.8125
3
[]
no_license
import pygame import random from pygame import mixer import math pygame.init() background = pygame.image.load('project back.jpg') screen = pygame.display.set_mode((1000, 600)) mixer.music.load('RUDE - Eternal Youth(MP3_160K).mp3') mixer.music.play(-1) #infinitive music pygame.mixer.music.set_volume(0.2) #PLa...
true
4718b814e5136f4c9ebe2be9f238646d6957d6d2
Python
Neb2/Text-RPG
/data/events.py
UTF-8
3,222
3.1875
3
[ "MIT" ]
permissive
import sys from data.battle import enemy_gen sys.setrecursionlimit(10**6) # test def events(character): if character.location == "d3": if character.d3_event_4: print("In the distance you see a man sitting down in the grass staring at you, maybe you should\n" "go t...
true
9d19d7325e5fc63b50dc62c5cb0b9118102cf089
Python
kamni/borg
/highlander.py
UTF-8
1,351
3.78125
4
[]
no_license
""" J Leadbetter <j@jleadbetter.com> MIT License An exploration of Python Borg pattern. Except these Borg are Highlanders. """ class ThereCanBeOnlyOne: """Implementation of the traditional Python Borg pattern""" __shared__ = {} def __init__(self, name, beheaded=None): self.__dict__ = ThereCanBe...
true
bda1ae0e8dd5196f7ea0e7232f64a0da6d5fd7d8
Python
dtConfect/resistance
/burstcompetition.py
UTF-8
13,758
2.875
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- import itertools import importlib import random import math import sys # Import the whole competition module so we can access the original, mutable global statistics import competition from competition import * from player import * import pseudonymgen cl...
true
e2521e1dc4fece36553f0463721049f6b51094c6
Python
mackoo13/pmp
/pmp/rules/weakly_separable.py
UTF-8
3,254
2.828125
3
[]
no_license
from .rule import Rule from .tie_breaking import random_winner from itertools import combinations class WeaklySeparable(Rule): """ Weakly Separable scoring rule """ def __init__(self, weights=None, tie_break=random_winner): Rule.__init__(self, tie_break) self.weights = weights def comput...
true
6077ef79bae16f19f337042bcb748a33f6b61cdc
Python
beitafive/python3
/pass.py
UTF-8
136
3.296875
3
[]
no_license
#!/usr/bin/python # -*- coding: utf-8 -*- arr = [1,2,3,4,5]; for x in arr: if x == 3: pass print("如何执行pass?") print(x)
true
22c79e14f80112d0181bea8624c8a93a40ca1f61
Python
snackdeng/python-crawler
/xiaoshuo/xiaoshuo/spiders/zww.py
UTF-8
1,001
2.8125
3
[]
no_license
# -*- coding: utf-8 -*- import scrapy from scrapy.linkextractors import LinkExtractor from scrapy.spiders import CrawlSpider, Rule class ZwwSpider(CrawlSpider): name = 'zww' allowed_domains = ['81zw.us'] start_urls = ['https://www.81zw.us/book/25483/'] rules = ( # //dl/dd[10]/a 只需...
true
4e461d2c09275e26a843b8d316c152bcc1354a5c
Python
kejingjing88212/Conflict-based-search
/test/testing.py
UTF-8
4,180
2.578125
3
[ "MIT" ]
permissive
import math import multiprocessing import os import time from src.a_star import A_star from src.cbs import CBS from src.cbs_ds import CBS_DS from src.cbs_h import CBS_H from src.cbs_pc import CBS_PC from src.map import Map from test.movingai import read_map_from_moving_ai_file, read_tasks_from_moving_ai_file from os i...
true
3ae27a90578fd2a559cd363216c52c4dc3b99a9a
Python
Navinsparrow/python
/strktimes.py
UTF-8
81
3.25
3
[]
no_license
[nav,bar]=input().split(); bar = int(bar); for i in range(bar): print(nav)
true
11ed864c732e01863de661a8624a7f37f9dd3a31
Python
icorrs/python_learning
/exec eval templates.py
UTF-8
319
3.203125
3
[]
no_license
# templates.py import re sco={} def replacement(m): code=m.group(1) try: return str(eval(code,sco)) except: exec code in sco return '' list1=['[x=1]','[y=2]','the sum of [x] and [y] is [x+y]'] str1='' for i in list1: str1+=i str2=re.sub(r'\[(.+?)\]',replacement,str1) print(str2)
true
4cda62e781dbf3bde7bae134da19e52c286d587d
Python
erikvanegmond/Machiavelli
/game/test_player.py
UTF-8
1,783
3.359375
3
[]
no_license
import unittest from game.player import * from game.card import * class TestPlayer(unittest.TestCase): def test_player_init(self): deck.read_deck() # resetting the deck player = Player("test player") actual_result = player.name correct_result = "test player" self.assertEq...
true
cf0ee237ec35ee83c657d16fc5a1fa6391c391b8
Python
ltakuno/arquivos
/python/URI/Basico/uri1185.py
UTF-8
305
3.859375
4
[]
no_license
# 1185 - acima da diagonal secundaria t = input() soma = 0.0 cont = 0 for i in range(12): for j in range(12): x = float(input()) if (j < 11 - i): soma += x cont += 1 if (t == 'S'): print("{:.1f}".format(soma)) else: print("{:.1f}".format(soma/cont))
true
5c3dbcb5196543047b0ea1d84acc76b0bd38f59e
Python
Mpogazi/Math-260
/experiments/exp4.py
UTF-8
1,635
2.546875
3
[]
no_license
from math260 import data_prep, recommend, score import numpy as np import scipy.spatial.distance as dist import json GAMES_FILE = "data/games.csv" REVIEWS_FILE = "data/reviews.csv" output = 'figures/k-varies.txt' def msd_similarity(u1, u2, rating_matrix, bool_matrix): u1_fixed = np.multiply(rating_matrix[u1], b...
true
c4eda2cb0c092937f014e170fef1825852274715
Python
green-fox-academy/bauerjudit
/week-3/monday/prim.py
UTF-8
192
3.171875
3
[]
no_license
num = 4 if num == 0 or num == 1: print("not prim") for x in range(2, num): if num % x == 0: print("not prim") break else: print("prim") break
true
669bdd5b80f3deff46a13f69cf25bac0894521da
Python
splch/Weather-Composition
/2conversion.py
UTF-8
1,815
2.96875
3
[]
no_license
from pretty_midi import PrettyMIDI, Instrument, Note from pandas import read_csv ''' Spencer Churchill 10/6/18 ''' num = 1 #number of csv's wsmin = 0.0 wsmax = 96.0 barmin = 800.7 barmax = 1110.0 sstmin = 0.0 sstmax = 50.0 colnames = ['ws', 'bar', 'sst'] #columns of storm#.csv def _scale(min_wd, max_wd, data, m...
true
7d4e885182fa3b3b5412aa3edc2174f8b9957dfa
Python
ssenior1/tsiintegration
/sendevents.py
UTF-8
1,837
2.625
3
[]
no_license
# python 3 sample to create metric definitions # importing the requests library, run "pip3 install requests" to install import requests import json import time import randomdata import random # api endpoint EVENT_SEND_URL = "https://api.truesight.bmc.com/v1/events" HEADERS = {'Content-Type': 'application/json'} APP_N...
true
c3acec22935791b0c6ba9bbd57cabc0b37b5a53e
Python
snowman1985/mypractice
/bayesian-mark.py
UTF-8
2,282
2.546875
3
[]
no_license
from bayesian import classify, classify_file from cutword import cutword import sqlite3 from collections import defaultdict conn = sqlite3.connect("w.sqlite3") c=conn.cursor() marktitle = open("marktitle.txt", "w") def toy(n): if n[-1] == 'y' or n[-1] == 'm': return n else: print "len:", len(n) print ...
true
adefc0db1fed383c6c25a8ace5e6c6de1dad2cef
Python
MikhailRyskin/python_base
/lesson_011/03_log_parser.py
UTF-8
7,388
3.125
3
[]
no_license
# -*- coding: utf-8 -*- # На основе своего кода из lesson_009/02_log_parser.py напишите итератор (или генератор) # который читает исходный файл events.txt и выдает число событий NOK за каждую минуту # <время> <число повторений> # # пример использования: # # grouped_events = <создание итератора/генератора> # Итератор ...
true
c4194f58c7261d08195b595729a7af7494044e3b
Python
jennylsmith/STAR-fusion-NF
/python_code/create_sample_sheet.py
UTF-8
5,222
3.078125
3
[]
no_license
#!/usr/bin/env python3 #Jenny Smith #Sept 23, 2020 #Purpose: create a sample sheet of files hosted on AWS S3. #import modules import os import re import itertools import boto3 import logging from botocore.exceptions import ClientError import numpy as np import pandas as pd def create_sample_sheet(bucket_name,pr...
true
ec880694dab8c38846cb8266cc479dc398a89f00
Python
azrazra0628/python_practice
/1日1件/リスト/PythonのCounterでリストの各要素の出現個数をカウント.py
UTF-8
6,002
4.125
4
[]
no_license
##PythonのCounterでリストの各要素の出現個数をカウント # Pythonでリストやタプルの全要素の個数は組み込み関数len() # 各要素の個数(要素ごとの出現回数)はcount()メソッドで取得できる。 #1.全要素数をカウント: len() 変数 = len(リストやタプル、文字列) # リスト #%% l = ['a', 'a', 'a', 'a', 'b', 'c', 'c'] print(len(l)) #7 # 文字列 #%% str = 'abcde' print(len(str)) #2.各要素の個数(要素ごとの出現回数)をカウント: count()メソッド # 変数.count(要素) ...
true
5a9a0457781db3d713db47bb195aeeaf9fa49d41
Python
hexcowboy/CVE-2020-8813
/exploit.py
UTF-8
1,426
2.75
3
[ "MIT" ]
permissive
#!/usr/bin/python3 import requests import click from rich import inspect from rich.console import Console from url_normalize import url_normalize from urllib.parse import quote console = Console() def shell_encode(string): return string.replace(" ", "${IFS}") @click.command() @click.option("-u", "--url", prompt...
true
259ed4eb22ee785bc42f272bff7dbdc86cf714cf
Python
houjunchen/hands-on-keras
/cnn/ans_python2/M2_cp32_7_m_d512.py
UTF-8
1,949
2.578125
3
[]
no_license
# libraries & packages import numpy import math import sys from keras.models import Sequential from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Conv2D, MaxPooling2D from keras.optimizers import SGD from keras.utils import np_utils # set dataset path dataset_path = '../ci...
true
15acd593418448df31028aa0c6453f9673201442
Python
fusion-research/Tensorflow-Advance
/Practice/MaskDetect/firstApp/app/cv2check.py
UTF-8
525
2.65625
3
[]
no_license
import cv2 from tensorflow.keras.preprocessing.image import load_img , img_to_array import matplotlib.pyplot as plt face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') img = load_img('test.jpg') img_arr = img_to_array(img) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = face_cascade.detect...
true
fa1cea1f7302cc8fbdaf73049ea661edea75b383
Python
Mahadev0317/Codekata
/capitalize.py
UTF-8
110
3.296875
3
[]
no_license
s=list(input().split()) lis=[] for i in range(len(s)): lis.append(s[i].capitalize()) print(" ".join(lis))
true
ee5cc6392b4b2a222034c8c42c29e4bc8a51b5a3
Python
qi77wang/mao_scripts
/20200831_del_invalid/ComSignalDataInvalidValue/del_invalid2.py
UTF-8
1,857
3.109375
3
[]
no_license
#!/usr/bin/env python # coding:utf-8 import sys if __name__ == '__main__': print("start to do work") # 从1的实现发现,发现处理list时,删除某个元素,后面的所有元素会平移,导致下标也随之变化 # 所以尽量不要直接删除list中的某个元素,可以选择新建list,把不需要的元素剔除; input_file = sys.argv[1] i = 0 with open(input_file, 'r') as fp: list_line = fp.readline...
true
65dd84bbb4db8c00b2f6e675928df1988454186d
Python
putterer/zx-optimization-framework
/zxopt/visualization/render_util.py
UTF-8
1,826
3.1875
3
[]
no_license
import math import re from typing import Tuple, List import cairo BLACK = "#000000" def color(ctx: cairo.Context, hex: str): cr_col = to_cairo_color(hex) ctx.set_source_rgb(cr_col[0], cr_col[1], cr_col[2]) def to_cairo_color(hex: str) -> List[float]: m = re.match(r"#?([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f]...
true
1e9f87dc657ec85a328fae9118bf8032fc03837d
Python
Haroong/Algorithm
/BaekJoon Online Judge/Silver/4949-균형잡힌 세상.py
UTF-8
947
4.03125
4
[]
no_license
import sys # 균형잡힌 문자열인지 여부 반환 def is_balanced_string(sentence): stack = [] for s in sentence: if s == '(' or s == '[': stack.append(s) elif s == ')': if not stack or stack.pop() != '(': return False elif s == ']': if not stack or ...
true
0518afd4aae8524a8b07d1da1118911878522c18
Python
paulkore/backend-python-test
/alayatodo/common.py
UTF-8
249
3.234375
3
[]
no_license
def empty(str_value): return str_value is None or str_value.strip() == '' def str_to_int(str_value, default): if empty(str_value): return default try: return int(str_value) except ValueError: return default
true
71bf219e097bc9bb98a268e90ee1594609dca6ee
Python
akswart/phys416code
/hw9/advect2.py
UTF-8
3,952
3.203125
3
[]
no_license
from __future__ import print_function, division import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D # advect2 - Program to solve the advection equation # using the various hyperbolic PDE schemes # clear all help advect2 # Clear memory and print header ...
true
ca5fcfbd4789511bc555fdcf8228e7ec5a061140
Python
Brianacl/ProgPLF
/sumaLista.py
UTF-8
92
2.984375
3
[]
no_license
def suma(l): return 0 if len(l) == 0 else l[0] + suma(l[1:]) print(suma([1,3,-1,7,0]))
true
1db0a3ad9c7dc96d2f5508e6885c3e0a91536f69
Python
nourandolat25/Python-Course
/Week 2/practice 2-B.py
UTF-8
1,610
3.703125
4
[]
no_license
# coding: utf-8 # In[ ]: print ("1.dinar converter system") print ("2.dolar converter system") print ("3.turkish lira converter system") choice = input("choose 1, 2 or 3:") if choice == "1": print ("1.dinar to lira converter") print("2.dinar to dolar converter") choice2 = input("choose 1 or 2:") ...
true
3f9f3d63c1824da6d2d1e44cb305efc6e7e47345
Python
Vanova/icu_rnn
/test.py
UTF-8
1,907
2.578125
3
[ "MIT" ]
permissive
import numpy as np import random import m2m_rnn as m2m # one example is one audio file seq_time_steps = 20 nb_examples = 401 // seq_time_steps feat_dim = 19 hidden_dim = 100 nb_clcs = 7 X = [] Y = [] for i in xrange(nb_examples): X.append(np.random.uniform(-np.sqrt(1./feat_dim), np.sqrt(1./feat_dim), (seq_time_st...
true
c6b8abc29c8996e575dff6ea1a0e31ecce47c8c6
Python
jeffclough/handy
/pylib/exiftool.py
UTF-8
4,288
2.953125
3
[]
no_license
#!/usr/bin/env python3 ''' This module provides a fairly clumsy Python interface to Phil Harvey's most excellent exiftool command. At the moment, it supports only the ability to read EXIF tags from a given file. When I need to do more with EXIF (maybe adding or updating GPS data), I'll add that capability then. Go to...
true
94b23d19a1c6cacde7d68bd66dc1c6c261d4f09c
Python
danalenvargas/project-euler-solutions
/009.py
UTF-8
178
3.359375
3
[]
no_license
def compute(): for a in range(1, 998): for b in range(1, 998-a): c = 1000 - a - b if(a**2 + b**2 == c**2): return a*b*c return False print(compute())
true
d48595d1f7e5e9f18d7bcdefff5e71aabc77e495
Python
estenssoros/sebflow
/sebflow/operators/python_operator.py
UTF-8
1,014
2.5625
3
[ "MIT" ]
permissive
from sebflow.exceptions import SebflowException from sebflow.models import BaseOperator from sebflow.state import State # from sebflow.utils.decorators import apply_defaults class PythonOperator(BaseOperator): """ Executes a python callable """ # @apply_defaults def __init__( self, ...
true
48ccf11408f554ebb86ceed13f00499125793f09
Python
c4rl0sFr3it4s/Python_Analise_De_Dados
/_estudoPython_solid/solid/manipulacao_string.py
UTF-8
3,094
4.21875
4
[ "Apache-2.0" ]
permissive
# comentario ctrl + /, ctrl + alt + r, auto identação, ctrl + shift + f10 frase = 'Oi, tudo bem?' ''' strings python trata a frase como se fosse uma lista, lista de letras. letra começa do indice 0, 1, em diante. ''' print(frase) print(frase[0], frase[1], frase[2], frase[3], frase[4], frase[5], frase[6], frase[...
true
b1d81941e9d340fc440d006201de223ce9e062d7
Python
WuhaoIclouder/LabviewMeasure
/labviewservice/startrs.py
UTF-8
11,042
2.75
3
[]
no_license
"""Start a server locate on a remote Linux machine. The remote Linux machine should be installed bash. First we try to connect the remote Linux host by SSH. And try telnet again if failed. If we succeed to login, we check if the package of server is existed. If not, we try scp or sftp or ftp get the package. And after ...
true
ebb2ee3824dbf7b0d70432512721dffaee5d3904
Python
eidonfiloi/criticalAI
/dataprovider/cifar.py
UTF-8
7,088
2.6875
3
[]
no_license
''' loads all the data from cifar into memory. some help from this insightful blog post: http://aidiary.hatenablog.com/entry/20151014/1444827123 assumes data is in cifar-10-batches-py, and cpkl'ed python version of data is downloaded/unzipped there. 0 - airplane 1 - automobile 2 - bird 3 - cat 4 - deer 5 - d...
true
e418a4eb59c778acf17936a28d01c86b3d1a5c32
Python
idealgupta/pyhon-basic
/form.py
UTF-8
191
3.421875
3
[]
no_license
mat =[ [1,2,3], [4,5,6], [7,8,9] ] print(mat) trans=[] for i in range(3): x=[] for row in mat: x.append(row[i]) trans.append(x) print(trans)
true
4d69689cb485ccc9d391b2c38d8660f9820dbef5
Python
devanand73/landing-zone
/unzip/aws-landing-zone-acct-password-policy/update_acct_password_policy.py
UTF-8
5,004
2.609375
3
[]
no_license
#!/usr/bin/python ############################################################################### # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # # # Licensed under the Apache License Version 2.0 (the "License...
true
934e7516c7d44790037ebb5d639210fa098b19d3
Python
c7w/BiliSearchCST
/Web/utils/Pagination.py
UTF-8
1,399
2.703125
3
[]
no_license
class Pagination: def __init__(self, src, baseUrl, **kwargs): self.src = src self.count = kwargs.get('count', 10) self.baseUrl = baseUrl self.length = kwargs.get('length', -1) if self.length == -1: self.length = len(src) def getMaxPage(self): return ...
true
d6564a6725a92dc50ffcd2b02f6906bc6bf27ced
Python
chrishavlin/tempidv
/yt_idv/cameras/base_camera.py
UTF-8
3,807
2.609375
3
[ "BSD-3-Clause" ]
permissive
import contextlib import numpy as np import traitlets import traittypes from OpenGL import GL from yt_idv.traitlets_support import YTPositionTrait, ndarray_ro, ndarray_shape class BaseCamera(traitlets.HasTraits): """Camera object used in the Interactive Data Visualization Parameters ---------- pos...
true
3ec35f7aad8694c5fce18d3681160a5e68a30fb8
Python
simpeg/discretize
/discretize/utils/interpolation_utils.py
UTF-8
10,882
3.078125
3
[ "MIT" ]
permissive
"""Utilities for creating averaging operators.""" import numpy as np import scipy.sparse as sp from discretize.utils.matrix_utils import mkvc, sub2ind from discretize.utils.code_utils import deprecate_function try: from discretize._extensions import interputils_cython as pyx _interp_point_1D = pyx._interp_poi...
true
c9e849fb8807c6b3ede7a57d29ecd7ba38ea69cc
Python
rossigiorgio/DIA_Project2020-2021
/PricingAdvertising/pricingEnviroment/Non_Stationary_Environment.py
UTF-8
655
2.78125
3
[]
permissive
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 1 14:07:39 2021 @author: amandaseger """ from Environment import Environment import numpy as np class Non_Stationary_Environment(Environment): def __init__(self, n_arms, probabilities, horizon): super().__init__(n_arms, probabilities)...
true
b3f5fae84e1319528c7d2a95d46ba089ecdacec9
Python
dmon6/coursera
/course_4_troubleshooting/week1/search_types.py
UTF-8
962
4.03125
4
[]
no_license
#!/usr/bin/env python3.7 def linear_search(list, key): """If key is in the list returns its position in the list, otherwise returns -1.""" for i, item in enumerate(list): if item == key: return i return -1 def binary_search(list, key): """Returns the position of key in the l...
true
b098efea86ba5eb4c002968a9146495230a07056
Python
dazm1710/matrizCaracol
/matrizCaracolSinNumpy.py
ISO-8859-2
579
3.3125
3
[]
no_license
at = [x.split() for x in open("matriz.txt","r").readlines()] def rotar(lista): if len(lista)>=2: return list(reversed(map(list, zip(*reversed(lista[::-1]))))) return lista def sepLista(lista): if lista==[]: return [] return (lista[0] + sepLista((rotar(lista[1:])))) print sepLista(at) ...
true
440388c8a184161ae57af8746809a0dd8ba717f8
Python
carlomarxdk/Face-Anonymization
/k_same/anonymizer.py
UTF-8
6,720
2.609375
3
[]
no_license
import numpy as np from math import sqrt import cv2 import os from sklearn.decomposition import IncrementalPCA from matplotlib import pyplot as plt PCA_N = 30 SCALER = 0.45 E = 8e-15 class Anonymizer: def __init__(self): self.M = None self.mean = None self.normalized_mean = None s...
true
313c7413ddcb98ac1e150579881e6e6859da92a5
Python
Ironman-007/WOSA
/Code/Python_client/client_pygatt.py
UTF-8
500
2.78125
3
[]
no_license
import pygatt from binascii import hexlify adapter = pygatt.GATTToolBackend() def handle_data(handle, value): """ handle -- integer, characteristic read handle the data was received on value -- bytearray, the data returned in the notification """ print("Received data: %s" % hexlify(value)) try: ...
true
cad71706688da5931f9933863876accedfbd2d74
Python
eternal-flame/topology
/Web service/server/edge.py
UTF-8
1,004
2.703125
3
[]
no_license
""" Provide functions to add new edge between two nodes, edit port status of two endpoint and delete a existing edge. """ from flask import request, Blueprint from db import connect import functions.edgeFunc as edgeFunc edge = Blueprint('edge', __name__) cursor = connect.cursor() @edge.route('/edit/', methods=['PO...
true
8a06f027f5f96fa02b887ae12b0fa7aa83d73630
Python
immasyanya/homeework
/урок 3/3.4exersize.py
UTF-8
536
3.765625
4
[]
no_license
def my_func_1(x,y): n = 1 if y == 0: return n else: while y < 0: n = n * x y += 1 return round(1 / n, 3) def my_func_2(x_1,y_1): return round(x_1 ** y_1, 3) print(my_func_1(int(input('Введите положительное число: ')), int(input('Введите отрицательное числ...
true
77e430cd3a452cccf14f1fa412a6b9c58e334b88
Python
helton886/store-flask-api
/resources/user.py
UTF-8
877
2.59375
3
[]
no_license
import sqlite3 from flask import request from flask_restful import Resource, reqparse from models.user import UserModel class UserRgister(Resource): parser = reqparse.RequestParser() parser.add_argument('username', type=str, required=True, ...
true
cfe06199079ff61c488e77a1e9aba9e55d78e2ac
Python
LinadVonapets/tasha-clicker-pygame
/clicker/main.py
UTF-8
7,054
3
3
[]
no_license
import pygame import random from colors import * pygame.init() # global variables WIDTH = 400 HEIGHT = 600 FPS = 30 count = 0 # initialization win = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("clicker_indev") pygame.display.set_icon(pygame.image.load('textures/lamp.png').convert...
true
40ecceb3d85dd84afffa368142f5569f8e17bc41
Python
linhdb-2149/topdup
/modules/crawlers/src/libs/docbao_crawler.py
UTF-8
2,791
2.640625
3
[]
no_license
from loguru import logger from libs.data import ArticleManager from libs.config import ConfigManager from libs.browser_crawler import BrowserWrapper from libs.postgresql_client import PostgresClient class Docbao_Crawler(): _crawl_newspaper = True def __init__(self, crawl_newspaper=True, export_to...
true
862e92575c573283ad84d571d73acc3745656e25
Python
vliegenthart/coner_feedback_analyser
/generate_rewards_overview.py
UTF-8
1,312
2.796875
3
[ "MIT" ]
permissive
# @author Daniel Vliegenthart # Generate overview JSON of rewards import json import time import os from config import ROOTPATH, viewer_pids, data_date from util_functions import read_json_file # ################### # # SETUP ARGS # # ################### # def main(): # ############################# # ...
true
777abeaa7a8d3909b690d00f8bf98d86cec00b0f
Python
she12306/stancode_projects
/stancode_projects/breakoutgraphics.py
UTF-8
10,920
3.296875
3
[ "MIT" ]
permissive
""" stanCode Breakout Project Adapted from Eric Roberts's Breakout by Sonja Johnson-Yu, Kylie Jue, Nick Bowman, and Jerry Liao Heather is so sleepy, but the city lights are too bright to sleep. Please help her to turn off all the lights so that she can have a good sleep. """ from campy.graphics.gwindow import GWindow...
true
1fa92dbbb44f0ce2d9f7edfcc405e10f00c39463
Python
NDesprez001/Range_and_formating_practice
/Range_and_format_practice.py
UTF-8
362
3.28125
3
[]
no_license
lst = [] for x in range(20): lst.append(x) html_lst = [] for x in lst: html_lst.append('<li><h1>' + str(x) + '</h1></li>') make_str = '' for x in html_lst: make_str = make_str + x x = '''<html> <head></head> <body> <ul> <li> <h1> {0} </h1> </li> </ul> </bod...
true
d9473830f9558e69550c0364881cd0d0ca772acf
Python
pankamo/17_2_KPU2DGP
/FlyingStateSlamGauge.py
UTF-8
3,383
2.671875
3
[]
no_license
from pico2d import * class FirstGauge : image = None Charging, Charged = 0,1 def __init__(self): if self.image == None : self.image = load_image('./Images/RocketSlamGauge.png') self.state = self.Charged self.frame = -1 self.x, self.y = 58, 447 def update...
true
b8fada02e8b67a5600dfb874d31746735901889d
Python
Pizzabakerz/codingsuperstar
/python-codes/codes/15.lambda_map_example/mapfun.py
UTF-8
189
3.484375
3
[]
no_license
def square(val): return val*val # use map to avoid this square(1) square(2) square(3) square(4) mytuple = (1,2,3,4) ans = map(square,mytuple) # map function print(set(ans))
true
c585b4e24dae52199004d4d1dd8bc24cfa77294b
Python
anilhimam17/SuperMarketManagement
/statistics.py
UTF-8
1,267
2.921875
3
[ "MIT" ]
permissive
import mysql.connector as sql import matplotlib.pyplot as pl from tkinter import * passwords_database = sql.connect(host = "localhost", user = "root", passwd = "anil@1234", database = "supermarket_passwords") product_database = sql.connect(host = "localhost", user = "root", passwd = "anil@1234", database = "product_ma...
true