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
0974611cbb376d4f54f9c7a099a6a1aba2c64b67
Borghese-Gladiator/discord-word-wolf-bot
/app/utils.py
UTF-8
1,468
3.65625
4
[]
no_license
import random def load_word_pairs(path): ''' @return list of word pairs Load word pair tuple list from TXT file ''' word_pairs = [] with open(path) as f: content = f.readlines() for line in content: line = line.strip() # remove whitespace characters two_word_tuple = ...
true
79772493cb23d900078b84a978aa20ccdeb8ebc5
TravelTimN/ci-milestone05-fsfw
/project/stats/views.py
UTF-8
3,878
2.578125
3
[]
no_license
from django.shortcuts import render from django.utils import timezone from datetime import timedelta from accounts.models import Profile from tickets.models import Ticket def get_all_stats(request): """ Filter all necessary objects to render Statistics using Chart.js """ # convert time/day into unix epoch ti...
true
e0660b35a01d01cf00d431cbee6603fac16ed891
gabriellaec/desoft-analise-exercicios
/backup/user_207/ch23_2020_03_09_14_21_02_639072.py
UTF-8
318
3.640625
4
[]
no_license
velocidade_carro = int(input ('Qual era a velocidade do veículo, em Km/H (formato XYZ) ')) def multa (velocidade_carro): y = 5 * (velocidade_carro - 80) return y if velocidade_carro > 80: print ("Você foi multado em {0:.2f} reais" .format(multa(velocidade_carro))) else: print ('Não foi multado')
true
70cee84de3fc84a09d03407979e12c9829c53070
JoarSkalse/bias-AI
/bias_level.py
UTF-8
3,437
2.609375
3
[]
no_license
import pandas as pd import numpy as np import itertools import random ##################################################################################################### #### Assessing the level of bias based on the causal model described in other submitted material #### ####################################...
true
6565828f24204ae6a7e7bdda357ff82016b625b4
s20309-pj/asd
/merge/mergeSort.py
UTF-8
1,813
3.71875
4
[]
no_license
import timeit import random random_array = [] sorted_array = [] reverse_sorted_array = [] def fill_random_array(): return [random.randint(1, 50000) for _ in range(50000)] def fill_sorted_array(): for i in range(0, 50000): sorted_array.append(i) def fill_reverse_sorted_array(): for i in range(...
true
3103ed3aaef933b8784e0f87b8834ce8b15bbe91
arverma/100DaysOfCode
/Day_44/demo.py
UTF-8
297
2.96875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Fri Jan 4 18:43:31 2019 @author: amanranjan """ def rec(p, count): if(p==1): count += 1 elif(p==2): return 0 for i in range(4): print(i, count) rec(p+1, count) count = 1 rec(0, count)
true
4ead74b39bbcdb34cb6275a2bfe19517e98d3810
kuralayenes/PythonUygulama
/Uygulama7.py
UTF-8
319
4.03125
4
[]
no_license
print("Girilen pozitif bir tamsayının,iki sayının kareleri toplamı şeklinde \n yazılıp yazılmayacağını veren program !") sayi1 = int(input("Bir sayi giriniz: ")) for i in range(1,sayi1,1): for j in range (1,sayi1,1): topla = i**2+j**2 if(sayi1 == topla): print(i,j,sayi1)
true
ba38fbad554e762ebf143fe48cf7e2a35dd33475
arasharchor/SDA2
/autoencoder/new.py
UTF-8
1,038
2.640625
3
[]
no_license
import theano from theano import tensor as T import numpy x = T.matrix('x') w = T.matrix('w') t = T.matrix('t') y = T.dot(w, x) error = ((t - y)**2).sum()# + 0.005 * (w ** 2).sum() gradient = T.grad(error, [w]) f = theano.function([w, x, t], error) f_prime = theano.function([w, x, t], gradient) learning_rate = f...
true
8e4d5b4d68912f07179520465d0c96c4304e597f
Suykum/100DaysOfCode_Python
/flask_expl/hello.py
UTF-8
813
3.390625
3
[]
no_license
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return '<h1 style="text_align: center">Hellooooo!</h1> ' \ '<p>This is a paragraph.<p>' \ '<img src="https://media.giphy.com/media/6RuhlzSdhIAqk/giphy.gif">' def make_bold(function): def wrapper(): ...
true
481dca51945bceaf2130a51c405874863399ea9c
krishg-11/FakeNews
/DataFormatting/dataToJson.py
UTF-8
810
3.015625
3
[]
no_license
import json import os data = {"text":{}, "label":{}} count = 0 for filename in os.listdir("../fake"): with open("../fake/" + filename, encoding='utf8') as fakeFile: print(filename, "added to data") text = fakeFile.read().strip().replace("\n", " ") data["text"][str(count)] = text d...
true
4b43c0716c9e21c392e0087bcf1283c6b6bfe9fa
Singlea-lyh/LeetCode
/Python/54.spiral-matrix.py
UTF-8
2,911
3.703125
4
[]
no_license
# # @lc app=leetcode id=54 lang=python3 # # [54] Spiral Matrix # # https://leetcode.com/problems/spiral-matrix/description/ # # algorithms # Medium (32.98%) # Likes: 2227 # Dislikes: 557 # Total Accepted: 358.9K # Total Submissions: 1.1M # Testcase Example: '[[1,2,3],[4,5,6],[7,8,9]]' # # Given a matrix of m x n...
true
18fac3bd8078138dbdad88cce27c31cf091728d2
MedicaicloudLink/Rosetta
/main/source/scripts/PyRosetta/public/surface_docking/post_processing/PhiPsi.py
UTF-8
13,124
2.671875
3
[]
no_license
#!/usr/bin/env python from string import strip, split from sys import argv, exit from math import sqrt, pi, acos, cos, sin #from numpy import zeros, arange class ATOMinfo: """ Reduce a pdb atom or hetatm line to a set of objects describing that atom """ def __init__(self, PDB): """ ...
true
2f2834847a7b5cf0d88c3a8a4c6c5cc6ade164ad
Meier-Link/LPIC_irc_bot
/src/update_db.py
UTF-8
3,644
2.703125
3
[ "Unlicense" ]
permissive
#!/usr/bin/env python2 # -*- coding: utf-8 -*- # Copyright 2010 Jérémie Balagna-Ranin <jeremie.balagna@autistici.org> # update_db.py # A new way to update sqlite DB from lpi.txt file # # This is free and unencumbered software released into the public domain. # See LICENCE file for more information # # # Some importa...
true
c4b0c3244bceb6fbd28e55ca2fd0ea2d309c0fdd
thejayhaykid/Python
/COS120/testPlanet.py
UTF-8
605
3.625
4
[ "MIT" ]
permissive
import planetClass def createSomePlanets(): aPlanet=planetClass.Planet("Zorks",2000,30000,100000,5) bPlanet=planetClass.Planet("Zapps",1000,20000,200000,17) print(aPlanet.getName() + " has a radius of " + str(aPlanet.getRadius())) planetList=[aPlanet,bPlanet] for planet in planetList: print...
true
4baa814f808120da3dabe5f285ad252b4b55b790
daniel-bogdoll/unknown_objects_roads
/mseg_semantic/mseg-api/tests/test_scannet_splits.py
UTF-8
2,089
2.703125
3
[ "CC-BY-4.0", "MIT" ]
permissive
#!/usr/bin/python3 from collections import defaultdict from pathlib import Path import pdb from mseg.utils.txt_utils import ( read_txt_file, generate_all_img_label_pair_relative_fpaths, ) """ Ensures that train/val/test splits are correct. """ # Make the paths absolute, resolving any symlinks. _TEST_DIR = P...
true
72ce7b1f42bc1e70eb9b526ca62bca21845ebd31
allenxzy/Data-and-Structures-and-Alogrithms
/python_data/Chapter 9/R/R-9.4.py
UTF-8
559
3.078125
3
[]
no_license
#-*-coding: utf-8 -*- """ An airport is developing a computer simulation of air-traffic control that handles events such as landings and takeoffs. Each event has a time stamp that denotes the time when the event will occur. The simulation program needs to efficiently perform the following two fundamental operations: •...
true
b66226c1b9fac60dbf915755cd254eca0b0015f1
PIvanov94/SoftUni-Software-Engineering
/PB-Python April 2020 Part 2/Walking.py
UTF-8
421
4
4
[]
no_license
count_steps = 0 while count_steps < 10000: command = input() if command == "Going home": steps_to_home = int(input()) count_steps += steps_to_home break else: walked_steps = int(command) count_steps += walked_steps if count_steps >= 10000: p...
true
99a3b2ef2d42da1943c8b72605c62042e513a5a6
cole-k/turksort
/turksort.py
UTF-8
8,989
2.671875
3
[]
no_license
import csv import time import boto3 import random from pprint import pprint from xml.dom.minidom import parseString # How long to wait between polling for a response from mturk wait_time = 5 # Whether to print debug messages debug = False # Duration workers have to complete the task assignment_duration = 300 # Duratio...
true
cb744dc90b674765666521e644585ea818c47d62
savadev/LeetCode-28
/1-two-sum/two-sum.python3.py
UTF-8
345
2.90625
3
[]
no_license
class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i,x in enumerate(nums): if target - x in nums: i2 = nums.index(target - x) if i2 != i: ...
true
6911488851f05d5bc3b9e6e612579f09cef63811
wangzelin007/first_project
/Users/suidx/Desktop/python/excercise_20171115/0013_20171127.py
UTF-8
1,053
2.859375
3
[]
no_license
# -*- coding: utf-8 -*- import urllib,urllib2 import re #头信息 header={'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:44.0) Gecko/20100101 Firefox/44.0'} def get_img_url(page_url):#得到页面所有图片的链接 request=urllib2.Request(page_url) #生成request对象 reference=urllib2.urlopen(request) #获取页面对象 page=referenc...
true
b60fed36ee73932b98d6e84649a7e121c735877f
sebranly/code-snippets
/0002-the-perfect-city.py
UTF-8
1,320
3.765625
4
[ "MIT" ]
permissive
def isInt(number): return (number % 1 == 0) def diffWithUpperInt(number): if (isInt(number)): return 0 return number // 1 + 1 - number def diffWithLowerInt(number): if (isInt(number)): return 0 return number - number // 1 def getShortestPath(departure, destination): min_distan...
true
03de3cef67084ab001e0f22fd94ddce7b30b0287
Yungbluth/Euler
/48.py
UTF-8
372
3.84375
4
[]
no_license
""" Matthew Yungbluth Project Euler Problem 48 The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. """ import time def main(): start = time.time() finalsum = 0 for i in range(1, 1001): finalsum += i**i ...
true
aa612b5f2a65ca8c38dbfff6c133fc27d6cf6edb
nshantha/VFH_and_Astar
/scripts/astar.py
UTF-8
4,509
2.6875
3
[]
no_license
#!/usr/bin/env python3 #!/usr/bin/env python import numpy as np import math # Provided map from map.txt map1 = [[0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,...
true
4b571b309c672334c89f5fbcb1a53fafcb6ac7cb
achsooistdas/Python-For-Offensive-PenTest
/Module 4/Client/Python-Code/HijackClipboard.py
UTF-8
758
3.453125
3
[]
no_license
# Download Link https://pypi.python.org/pypi/pyperclip/1.5.11 import pyperclip import time # we create a list which will store the clipboard content list = [] # infifnite loop to continously check the clipboard while True: if pyperclip.paste() != 'None': # if the clipboard content is not...
true
17ed970bcae1a684b4008080b5fe303ae8ca42b1
WouterVdd/Learning_Python
/Numbers-Find_PI_to_the_Nth_Digit/main.py
UTF-8
455
4.15625
4
[]
no_license
# Find PI to the Nth Digit - Enter a number and have the program generate PI up to that many decimal places. # Keep a limit to how far the program will go. from math import pi while True: number = input("Until what digit do you want to know PI? ") number = int(float(number)) if number < 100: resul...
true
29c98c2f10ed618339920526dbbda23535227cb0
ReDI-School/redi-python-intro
/theory/Lesson5-Files/code/file_read_whole.py
UTF-8
152
3.0625
3
[ "MIT" ]
permissive
# Lesson5: reading all the file at once # source: code/file_read_whole.py f = open('file_for_reading.txt', 'r') text = f.read() print(text) f.close()
true
8a3bb66783c0cd74f8f55106774c3d09b774511d
bsimps01/Avengers
/superhero.py
UTF-8
9,014
3.625
4
[]
no_license
#SuperHeroTeamDueler import random class Ability: #Creates the ability of the charcater def __init__(self, name, attack_strength): self.name = name self.max_damage = attack_strength def attack(self): random_value = random.randint(0, self.max_damage) return random_v...
true
f9520f290bdffb3165d4b0195c4bc6cd9ce21d82
torgeirtrex/Python
/questionprogram/question.py
UTF-8
2,295
3.65625
4
[]
no_license
#!/usr/bin/env python3 import json import time import os def ask_one_question(question): print("\n" + question) choice = input("Enter Your Choice [a/b/c/d]: ") while(True): if choice.lower() in ['a', 'b', 'c', 'd']: return choice else: print("Invalid choi...
true
fcb632580bb123b92143874cc31217836f516719
wxd11/HelloPython
/input_print.py
UTF-8
248
3.453125
3
[]
no_license
#!/usr/bin/env python # -*- coding: utf-8 -*- print 'Hello Python'; print 'test', 'space', 'space'; print 300; print 100+200*3/2; print ('hello word'); name=raw_input('please enter your name:'); print name; age=input('年龄: ') print (age)
true
40cafe3b068ca1bf08f6b7687490e2209db4b69e
andy-ifeanyi/andie-flask-restful-api
/resources/students.py
UTF-8
2,234
2.703125
3
[]
no_license
from flask_restful import Resource, reqparse from flask_jwt import JWT, jwt_required from models.students_models import StudentModel class Student(Resource): parser = reqparse.RequestParser() # parser.add_argument('name', type=str, required=True, # help='This field cannot be left bla...
true
118c5a167c86d975989dd4e02984d9da80078948
logantaggart/ForexConversion
/test.py
UTF-8
488
3.15625
3
[]
no_license
from flask import flask from unittest import TestCase from app import app def currency_checker(start, new, ammount): """Check that currency conversion is working properly""" newamount = str(round(c.convert(start, new, amount),2)) return newamount assert currency_checker(USD, USD, 1) == 1 assert currency_...
true
0fcfb0c474c76ce32baf147a22b14737cfebf1d5
ewjoachim/pyxbox
/game.py
UTF-8
1,119
3.265625
3
[ "WTFPL", "LicenseRef-scancode-unknown-license-reference" ]
permissive
import pygame class Game(object): """ Base game set : an inifinite loop This is to be inherited, with the methods prepare, loop and cleanup overridden """ def __init__(self, fps=50): self.clock = pygame.time.Clock() self.fps = fps pygame.init() def prepare(self): ...
true
b3cf3922c0e9803990bfbc3a9c73e14c5c923135
aleeeesf/PCTR
/Campus/Python/Codigos_Python/multiprocessing_pipes.py
UTF-8
1,278
3.796875
4
[]
no_license
import multiprocessing #tarea para el proceso 1; se escriben en el pipe numeros #del 1 al 10 def create_items(pipe): output_pipe, _ = pipe for item in range(10): output_pipe.send(item) output_pipe.close() #tarea para el proceso 2; se leen los datos del pipe, #se elevan al cuadrado, y se vuelven ...
true
2762bd5acaab424df9ce4a5524c91fe94bb8ddf9
codio-packs/tkinter-widgets
/canvasscroll.py
UTF-8
4,467
2.828125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
from tkinter import * from infrastructure import DemoWindow, demo_path import tkinter.messagebox as messagebox SCROLLAREA_HEIGHT=1024 SCROLLAREA_WIDTH=1280 ROW_NUM=10 COLUMN_NUM=16 ROW_PAD=30 COLUMN_PAD=30 BOX_HEIGHT=(SCROLLAREA_HEIGHT/COLUMN_NUM) - COLUMN_PAD BOX_WIDTH =(SCROLLAREA_WIDTH/ROW_NUM) - ROW_PAD CURRE...
true
c30224e680d4b4f24b2ff1190fbeb19a24bb0140
paulara/Poo1
/POOfinal/ejers/ejer3.py
UTF-8
210
3.09375
3
[]
no_license
import math class Punto(object): x=0 y=0 x2='' y2='' def distancia(self): return math.sqrt(self.x2**2+self.y2**2) def muestra_punto(self): print(self.x2,self.y2)
true
76b3e05b93178b7f4479a6756e63a388860f17c5
captain-pool/FC_FeedForward_SGD
/Test.py
UTF-8
902
2.796875
3
[ "MIT" ]
permissive
#! /usr/bin/python3 ''' Program to Differentiate between Even and Odd numbers of 30 bit ''' from FC_SGD import Network import numpy as np from _pickle import load from _pickle import dump def bits(i): assert len(bin(i))<=32 l=list(bin(i).split('b')[1]) return np.array(list(map(int,([0]*(30-len(l)))+l))) d...
true
5b581f93a59cbbebe0402b39f67aea3c819e59d7
ziqinXU/Leetcode
/Medium_Python/921_Minimum_add_to_make_Parentheses_valid.py
UTF-8
385
3.296875
3
[]
no_license
#栈的思想,LIFO class Solution: def minAddToMakeValid(self, S: str) -> int: stack=[] for i in range(len(S)): if S[i]==')': if len(stack)>=1 and stack[-1]=='(': stack.pop() else: stack.append(S[i]) else: ...
true
186c496a8217162aaff63906e89bf74daa1d2855
rwid-python/about-python
/geometry/oop_triangle.py
UTF-8
391
3.375
3
[]
no_license
from geometry.inheritance_geometry import Geometry class Triangle(Geometry): def __init__(self, base, high): self.base = base self.high = high def info(self): return f'Calc Area of Triangle with base {self.base} and high {self.high}' def get_area(self): return self.base *...
true
42a2479910026f420b112045eb573be29c420ff5
ageraldo1/Python-bootcamp
/list_comprehension/examples.py
UTF-8
2,469
4.125
4
[]
no_license
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # example 1 # loop way my_list = [] for n in nums: my_list.append(n) print (my_list) # using list comprehension my_list = [n for n in nums] # | | # | |_____________ for loop # |_______________ returing # print (my_list) # example 2 # square a n...
true
42fbb1f7a377cc3c9b3e11f27b6a14fcccfa3226
dkb4rb/hodor
/level_3/level3.py
UTF-8
3,840
2.5625
3
[]
no_license
#!/usr/bin/python3 #coding: utf-8 # level1.py # Juan Duque <3428@holbertonschool.com> """ Import libraries """ from bs4 import BeautifulSoup from numpy.core.arrayprint import printoptions import requests import sys import os import pytesseract import time from pwn import * # def def_handler(sig, frame): # sys.exit(0)...
true
66aef5d3b39316f4fd584ff6026bab8476e5f29b
dwagon/pydominion
/dominion/cards/Card_Warehouse.py
UTF-8
1,855
2.734375
3
[]
no_license
#!/usr/bin/env python import unittest from dominion import Game, Card, Piles import dominion.Card as Card ############################################################################### class Card_Warehouse(Card.Card): def __init__(self): Card.Card.__init__(self) self.cardtype = Card.CardType.ACT...
true
ba021a724261b5bbf9ca48b299113705ef811f3c
aziule/kindle-to-anki
/src/anki.py
UTF-8
1,297
2.8125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
import genanki import hashlib import math from datetime import datetime def create_model(): return genanki.Model( int(datetime.utcnow().timestamp()), 'kindle-to-anki model', fields=[ {'name': 'Question'}, {'name': 'Answer'}, ], templates=[{ ...
true
6dee1ff22f2b0c7b78d1f64ec3ca38adf50fdac1
ekisu/qwer
/qwer/repositories/command.py
UTF-8
1,237
2.765625
3
[]
no_license
from qwer.domain.entities.command import Command from typing import List, Optional from sqlalchemy import select from sqlalchemy.orm import Session class CommandRepository: session: Session def __init__(self, session: Session): self.session = session def find_command_by_guild_id_and_name( ...
true
1476a508824fefcc3b7b95e3a93acb1f9b4996ef
BaoCaiH/Daily_Coding_Problem
/Python/2019_05_13_Problem_118_Square_And_Sort.py
UTF-8
534
3.90625
4
[]
no_license
#!/usr/bin/env python # coding: utf-8 """2019 May 13th - Daily_Coding_Problem #118.""" # <markdown> # ## 2019 May 13th - Daily_Coding_Problem #118 # # Problem: Given a sorted list of integers, square the elements # and give the output in sorted order. # # For example, given [-9, -2, 0, 2, 3], return [0, 4, 4, 9, 81]. ...
true
7176244dff8f77bc8512f5fdffdc8bb02f44352c
miguepoloc/guajira
/Pruebas/pruebarecibir.py
UTF-8
881
2.84375
3
[]
no_license
# -*- coding: utf-8 -*- #Importamos la librería serial import serial #Importamos la librería de tiempo import time import paho.mqtt.publish as publish print("Abriendo puerto serie") serie = serial.Serial('/dev/ttyS0', 38400) serie.close() serie.open() serie.write("AT") time.sleep(1) print("#escribiendo =1") serie.write...
true
61c11039d5f4c5f17ea83bebfb95212130a9b519
nmiranda98/enigma
/enigmaCipher.py
UTF-8
4,685
3.3125
3
[]
no_license
#Hi! This program replicates the Enigma cipher from Nazi Germany during #World War II. The rotors, reflectors, and plugboard settings are authentic #and the output is given according to cryptographic conventions. #Rotors I = ['EKMFLGDQVZNTOWYHXUSPAIBRCJ', 'Q', 0, 0] II = ['AJDKSIRUXBLHWTMCQGZNPYFVOE', 'E', 0, 0]...
true
d0e25f51d0b515cd8736467b6cab33c057a39001
smolczi/Portfolio
/NBA Web Scraping/NBA Web Scraping.py
UTF-8
1,964
2.90625
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Mon Mar 18 13:43:51 2019 @author: osanchez """ from urllib.request import urlopen from bs4 import BeautifulSoup import pandas as pd import numpy as np # Basic NBA Stats year = 2019 url = "https://www.basketball-reference.com/leagues/NBA_{}_per_game.html".format(year) # this i...
true
723c9cd866fe2d59c45bb2cc13d5bc320ffd0d74
chinmayk1613/LawPilots_Task_Ping_Machine
/src/requester.py
UTF-8
1,539
3.421875
3
[]
no_license
try: import requests import time except Exception as exe: print("Exception Occured {}".format(exe)) # All header file declaration SERVICE_ENDPOINT = 'http://localhost:5000/' ROUTE_ENDPOINT = "{}status/".format(SERVICE_ENDPOINT) '''above two lines define the service that needs to be called to get machine...
true
2cbae69c86d787244ae73b39049dedbbd09b9bc1
sjhhh3/Leetcode
/Leecode/leetcode21.py
UTF-8
1,412
3.78125
4
[]
no_license
class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def mergeTwoLists(self, l1, l2): if not l1 and not l2: return None node = guard_node = ListNode(0) while l1 and l2: if l1.val <= l2.val: ...
true
22cc925a1e54cb8e6d51a42b657775bc1a8db3bc
dovgyfu/gyfuPython
/read_discrete_files.py
UTF-8
2,080
2.609375
3
[]
no_license
# -*- coding: utf-8 -*- import csv import re from datetime import datetime import pandas as pd import os fname = r'y:\discrete_analysis.csv' def read_dir_to_csv(fname): wrfname = open (fname, 'w') wr = csv.writer(wrfname, lineterminator='\n') header = ["1", "2", "3", "4", "5", "6", "7", "8"...
true
d66aee51ca230e828ec7f68b6dbf298cc19e49d5
RAdamMartin/CodeJam
/2017/Qualification/A/code.py
UTF-8
603
2.96875
3
[]
no_license
import sys sys.path.append('../../../cjLib') from cjUtils import * def solver(s, k): moves = 0 while len(s) >= k: try: #Get the first backwards pancake idx = s.index('-') except ValueError: #Nothing backwords so done return moves s = s[idx:] #move on as ...
true
1be6a049189765a73a13f1661469d1c76fe5d116
wenqiang0517/PythonWholeStack
/day11/02 补充的知识点(global,nonlocal).py
UTF-8
1,748
4.375
4
[]
no_license
# 默认参数的陷阱 # 陷阱只针对于默认参数是可变的数据类型 """ def func(name, alist=[]): alist.append(name) return alist ret1 = func('alex') print(ret1, id(ret1)) # ['alex'] 140241017331136 ret2 = func('lwq') print(ret2, id(ret2)) # ['alex', 'lwq'] 140241017331136 """ # 如果你的默认参数指向的是可变的数据类型,那么你无论调用多少次这个默认参数,都是同一个 # def func(a...
true
89effe961e7e8c4f845a66696f3814f21422fb76
daring-board/py-practice
/pipeline/interface.py
UTF-8
932
3
3
[]
no_license
import cmd import sys import os import os.path class TextInterface(cmd.Cmd): """ Text-based Interface for Pipeline """ def __init__(self, keep_going, filename): super().__init__(completekey = 'tab') self.keep_going = keep_going self.path = filename self.prompt = 'Pipline>' ...
true
a9ccbb570dcb6011775b154eb931a35fd42366b1
karthickrajas/Data-Mining-and-Decision-Models
/Data Mining Assignment/Map-Reduce-KMeans/k-Means MapReduce/kMeans_FinalClustering.py
UTF-8
870
2.84375
3
[]
no_license
#!/usr/bin/env python from operator import itemgetter #from collections import defaultdict from defdict import * import sys # this program performs the final cluster and creates files for each cluster def main(args): point2centroid = defaultdict(list) point2centroid = args datapoint = '' centroidpoint='' iter = 0 for c...
true
e0655ae2b52d4f5e5456f4fdc3b40a17a846769c
joanna-janos/torchfunc
/tests/hooks/registrators_test.py
UTF-8
960
2.59375
3
[ "MIT" ]
permissive
import pathlib import shutil import tempfile import torch import pytest import torchfunc @pytest.fixture def registrator(): class Hook: def __init__(self): self.counter = 0 def __call__(self, *_): self.counter += 1 def __int__(self): return self.coun...
true
97bc453be2457f9f152e5eba378271ee93cd2b52
PengchongLiu/Algorithms
/w7_course_schedule.py
UTF-8
2,458
3.578125
4
[]
no_license
# LeetCode 207. https://leetcode.com/problems/course-schedule/ # A good reference: https://leetcode.com/problems/course-schedule/discuss/441722/Python-99-time-and-100-space.-Collection-of-solutions-with-explanation class Solution(): def canFinish(self, numCourses, prerequisites): # DFS to detect cycles ...
true
313611e4dbbe0b826821460570efd1f5e0f74cbd
Gab0/japonicus
/promoterz/supplement/phenotypicDivergence.py
UTF-8
975
2.515625
3
[ "MIT" ]
permissive
#!/bin/python from deap import tools from . .import parameterOperations import random def checkPhenotypicDivergence(constructPhenotype, indA, indB): cmp = [indA, indB] cmp = [constructPhenotype(x) for x in cmp] cmp = [parameterOperations.flattenParameters(x) for x in cmp] score = 0 for w in cmp[0]...
true
2f9bbe18ef999df77c8d9469ac508e0d987965a3
abhiaswale/Python
/type_list.py
UTF-8
217
2.96875
3
[]
no_license
l1=[1,2,'abhi',[1,2]] def chck(list1): count=0 for i in range(len(list1)): if type(list1)==type(list1[i]): count += 1 return count print(chck(l1)) # print(type(l1[1])==type(l1[2]))
true
ef1fd7938bcf0cee938cd2ca9f9d92c063e7fe93
armenhak59/ArmenHakobyan
/Home4/STOOLS.py
UTF-8
217
2.90625
3
[]
no_license
hasak_ = input('մուտքագրեք հասակները ').split() for i in range(len(hasak_)): hasak_[i] = int(hasak_[i]) max_ = max(hasak_) stools = [max_ - hasak_[i] for i in range(len(hasak_)) ] print(stools)
true
12c28d6342ab44c4fda4a3cde95463bbf9c7d71c
alexshakouri/ECS171_Final
/LogisticRegression_SagaSolver_Ishita.py
UTF-8
1,070
2.84375
3
[]
no_license
import numpy as np from sklearn import linear_model from time import time import os from sklearn.metrics import accuracy_score from sklearn.metrics import mean_absolute_error os.chdir('/Users/ishitasharma/Desktop/ECS171-Project') trainData = np.load('ecs171train.npy') parsed_trainData = np.zeros([50000, 771]) for ...
true
04a60b3ba6be1ffc7928160c7f7d88ee7a614e2c
bonczol/AEM
/main.py
UTF-8
1,873
2.734375
3
[]
no_license
import utilites as ut import numpy as np import evolutionary_algorithm as alg import greedy_algorithms as ga import time import global_convex def test(algorithm, instance, distances): n = 10 solutions = [] times = [] ls_counts = [] results = np.zeros(n, dtype="int64") for i in range(n): start = time.perf_coun...
true
d89bc5893f60e8d1abde499878b7d69e0dd5e78d
Pineappluh/AoC-2020
/18/18-1.py
UTF-8
1,153
3.546875
4
[]
no_license
import fileinput def solve_expression(expression): stack = [] index = -1 for char in expression: if char.isnumeric(): stack.append(int(char)) else: stack.append(char) index += 1 while True: if index >= 2 and isinstance(stack[index], in...
true
89526ba8c5b8c2f4c99c98be25d62d786ad031fa
zarubind/geekbrains
/lesson_1.py
UTF-8
4,323
4.09375
4
[]
no_license
# 1. Поработайте с переменными, создайте несколько, выведите на экран, # запросите у пользователя несколько чисел и строк и сохраните в переменные, # выведите на экран. a = 10 b = 2 print(a/b) a = int(input('Введите число: ')) b = input('Введите строку: ') print(f'Число: {a}\nСтрока: {b}') # 2. Пользователь ...
true
9250da2220ca557927e281a55b47166fcf2558bb
falloutdurham/specaugment
/specaugment.py
UTF-8
2,244
3.09375
3
[]
no_license
import torch import random class FrequencyMask(object): """ Implements frequency masking transform from SpecAugment paper (https://arxiv.org/abs/1904.08779) Example: >>> transforms.Compose([ >>> transforms.ToTensor(), >>> FrequencyMask(max_width=10, use_mean=False), ...
true
c0b7b523f0a7f1eb2b7bf1008a375a5d09c2a452
st3v3nmw/hash-tables
/tests.py
UTF-8
1,926
3.25
3
[ "MIT" ]
permissive
import unittest from hashtable import HashTable from random import randint, random import binascii class TestHashTableMethods(unittest.TestCase): def test_empty_table(self): table = HashTable() self.assertEqual(str(table), '{}') self.assertEqual(len(table), 0) self.assertEqual(table...
true
6db7b15b6a0efd2fd8136de629212e6cb4429abc
fredrikhl/which-module
/whichmodule.py
UTF-8
7,794
2.796875
3
[]
no_license
#!/usr/bin/env python # encoding: utf-8 """ Look up and return file location of a module. """ from __future__ import unicode_literals, print_function, absolute_import import argparse import fnmatch import imp import importlib import inspect import os import re import sys __version__ = '1.3.1' def iter_dict(d): ...
true
ac2b6562dc06baae4b8c45b27b5951cbec157cd5
shmyhero/waverider
/wrapi/context.py
UTF-8
2,042
2.65625
3
[]
no_license
import datetime import pytz from ibbasic.api import API from wrapi.strategy_config import StrategyConfig class Context(object): def __init__(self): self.strategy_name = None self.terminate_p = False @property def portfolio(self): return API().get_portfolio_info() def display...
true
ba384d6c646f1b394b7d9b7fe628cb2f36d4546d
egr400/FSP
/hw1/Homework1.py
UTF-8
1,262
3.84375
4
[]
no_license
#Part 1 #1. print("The print function is treated as a statement in python" " 2 and it is treated as a method is python 3") #2. x = [0,1,2,3,4,5,6] print(x[2]) #3 y = [] n = [-1] for n in x[::-1]: y.append(n) print (y) #4 z = x[1:2] + x[3:4] + x[5:6] print (z) #5 x = 99 if (x > 0):...
true
affab59bf11e060785f87c2a053c94dcc50bca68
nurmister/MachineLearning-ActivityDetection
/RunOrWalk/nb_author_id.py
UTF-8
3,672
3.015625
3
[]
no_license
#!/usr/bin/python import numpy as np import pandas as pd import scipy as sc def preprocesses(): df=pd.read_csv('../input/dataset.csv', na_values = "?") df.dropna(inplace=True) df.index = np.arange(1, len(df)+1) df.corr() df1=df.drop(['date','time','username','wrist'],axis=1) df1 ##### impo...
true
b152c88a63579f7a57c0a302279d4d72845c4987
Xparky/python-practical
/geometry.py
UTF-8
96
3.328125
3
[]
no_license
import math def circleArea(r): return math.pi*r*r def squareArea(x): return x**2
true
b402c711db812ee98a481530b92d6c34d4620649
salman1993/BuboQA
/entity_linking/entity_linking.py
UTF-8
5,734
2.640625
3
[]
no_license
import os import pickle from collections import defaultdict from tqdm import tqdm from argparse import ArgumentParser from fuzzywuzzy import fuzz from nltk.corpus import stopwords from util import clean_uri, processed_text, www2fb inverted_index = defaultdict(list) stopword = set(stopwords.words('english')) def get...
true
b52600e6b54b16e8bbc2d06b889e11837c4d2555
THUDM/GIAAD
/neutrino/labelconvert.py
UTF-8
320
2.703125
3
[]
no_license
_labels = [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] label_idx = {} idx_lable = {} idx = 0 for l in _labels: label_idx[l] = idx idx_lable[idx] = l idx += 1 def get_label_idx(label): return label_idx[label] def get_idx_label(idx): return idx_lable[idx]
true
f13d0ef4384f8a360186731a0e9c6f6254c66be1
wesselb/gpcm
/gpcm/util.py
UTF-8
8,043
2.609375
3
[ "MIT" ]
permissive
from collections import namedtuple from varz import Vars, minimise_l_bfgs_b import jax import lab as B import numpy as np from plum import Dispatcher from stheno import Normal from scipy.signal import hilbert __all__ = [ "min_phase", "summarise_samples", "estimate_psd", "invert_perm", "closest_psd...
true
1157c4111b9a8380f845f7589fd957997d4b6360
mishranurag/HSPFTools
/WDMOutputToDataFrame.py
UTF-8
740
3
3
[ "MIT" ]
permissive
'''This is an example script that finds all the DSN from a WDM file and uses the first DSN to extract the data and plot it. It can easily be modified to loop through all the datasets.''' from wdmtoolbox import wdmtoolbox as wdm import pandas as pd files_path='C:\BASINS45\modelout\Test' wdmfile= os.path.join(files_pat...
true
7f45eabb794c1d6e9c4e2ea68011ec027451639e
keolis-metropole-orleans/ITxPT
/IHM/ClientNTP.py
UTF-8
2,155
2.890625
3
[ "MIT" ]
permissive
import ntplib import time import sys import logging import socket def get_network_time(ntp_server): """ Fonction pour récupérer l'heure à partir d'un server NTP Nom fonction: get_network_time() Paramètre: server, un server NTP Return: une date sous la forme : 'Jour Mois NumJour Heure:Min:S...
true
ed41c77a59ed89daa0c2d98fdc31fec5e5d16408
yangh-zzf-itcast/Python_heima_Study
/02多任务-多进程-多线程/09-多线程共享全局变量-资源竞争的问题.py
UTF-8
1,126
3.4375
3
[]
no_license
import threading import time # 线程获取CPU时间片来执行 # 多线程共享全局变量会有一个问题:同时对一个变量进行操作时,发生资源竞争 # 通过线程同步来解决,原子性/原子操作 # 同步就是协同步调,按预定的先后次序 # 互斥锁 # 定义一个全局变量 g_num = 0 # 主线程和子线程之间是共享全局变量的 def test1(num): global g_num for i in range(num): g_num += 1 print("------------in test1 g_num = %d -----------" % g_num...
true
a2038012b8665bd0b44e4cf6a38e5cd680f7e354
KZVK3/MSc-Project
/data/filter_msa.py
UTF-8
179
2.515625
3
[]
no_license
import json msa_evals = json.loads(open('data/msa_evals.json','r').read()) print(len(msa_evals)) msa_evals = {k:v for k, v in msa_evals.items() if v<1e-10} print(msa_evals)
true
5661b6b6070c956e80e597dba0d6a8cd41251d12
patriciobaez/algoritmos1
/ejercicios/ejercicio8.py
UTF-8
693
4.625
5
[]
no_license
''' Crear un programa que permita ingresar un número entero positivo(N) y otro número también entero positivo (M). Luego calcular las tablas de multiplicación desde N a M Asumir que M siempre va ser mayor a N. Ejemplo: Entrada del programa: N = 2 M = 10 Salida del programa: 2 x 2 = 4 2 x 3 = 6 . . . 2 x 10 = 20 ...
true
a0c9577cd98a60834e3926902c07be589dfadaa0
pdhummel/practice
/techie_delight/quicksort.py
UTF-8
1,030
3.46875
3
[]
no_license
#!/usr/bin/python import sys def main(): arr = [9, -3, 5, 2, 6, 8, -6, 1, 3] print arr sorted_arr = split_and_sort(arr) print sorted_arr def split_and_sort(arr): sorted_arr = [] if len(arr) > 2: pivot = arr[len(arr)-1] left = [] right = [] for i...
true
539d6ecfb9e44288a81ffd1bb33d6c21c9ad3ed3
text007/learngit
/14.函数/2.函数调用.py
UTF-8
121
2.8125
3
[]
no_license
# 函数调用 def h2(strs): # 定义一个黄函数 print(strs) return h2('调用函数') h2('调用函数')
true
59582b023c44b65b3ab654bedde0d6b3a84ff521
mirek190/x86-android-5.0
/external/lldb/test/terminal/TestSTTYBeforeAndAfter.py
UTF-8
4,162
3.03125
3
[ "NCSA" ]
permissive
""" Test that 'stty -a' displays the same output before and after running the lldb command. """ import os import unittest2 import lldb import pexpect from lldbtest import * class CommandLineCompletionTestCase(TestBase): mydir = os.path.join("functionalities", "completion") @classmethod def classCleanup(...
true
ddbfa82897c48c3717f4e29a311327f858033b32
jonathankao97/coronavirus_county
/wiki_scraper.py
UTF-8
1,214
2.921875
3
[]
no_license
from bs4 import BeautifulSoup import requests import json r = requests.get("https://en.wikipedia.org/wiki/List_of_U.S._municipalities_in_multiple_counties") soup = BeautifulSoup(r.content, 'lxml') table_list = soup.find_all('table', class_='wikitable') with open('dict.json', 'r') as file: dict = json.loads(file....
true
8955f11cd8ee75cc2602bdd68290bf64135fb9f4
ryfeus/lambda-packs
/Pdf_docx_pptx_xlsx_epub_png/source/reportlab/pdfgen/pdfgeom.py
UTF-8
2,988
3.0625
3
[ "MIT" ]
permissive
#Copyright ReportLab Europe Ltd. 2000-2017 #see license.txt for license details #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/pdfgen/pdfgeom.py __version__='3.3.0' __doc__=""" This module includes any mathematical methods needed for PIDDLE. It should have no dependencies beyon...
true
94386796a24621ae84df69ffcfb9b2b66809db50
GAJENDIRAN25/GUVI
/vowels.py
UTF-8
145
3.21875
3
[]
no_license
ch= input() if (ch.isalpha()): if ch in 'a,e,i,o,u,A,E,I,O,U': print('Vowel') else: print('Consonant') else: print('invalid')
true
de2bacd3bf8c3c329aef7611510617a374fa1f97
xpsurgery/customer-base
/python/customer_base_test.py
UTF-8
1,258
2.90625
3
[ "MIT" ]
permissive
import unittest from customer_base import CustomerBase from customer import Customer class CustomerBaseTest(unittest.TestCase): def setUp(self): self.alice = Customer("Alice", "Rossi", 10000) self.bob = Customer("Bob", "Rossi", 20000) self.charlie = Customer("Charlie", "Bianchi", 30000) ...
true
38c52558e73cefe49fec660b20d3f07d983367e1
nemu626/PyRadib
/helpermodule.py
UTF-8
182
3.40625
3
[]
no_license
def confirm(questionstr): print questionstr + "(Y/N)" str = raw_input() if str == "Y" or str == "y" or str == "yes": return True else: return False
true
c375258ad813b0bcb175c47324167456f12df165
susunini/leetcode
/LintCode_Sort_Letters_by_Case.py
UTF-8
443
3.796875
4
[]
no_license
class Solution: def sortLetters(self, chars): """ @param chars: The letters array you should sort. """ p1 = 0; p2 = len(chars)-1 while p1 < p2: if chars[p1].islower(): p1 += 1 continue if chars[p2].isupper(): ...
true
211875757b6f0e9d9bc53368c402eceb932266f9
AdityaShenoy/Data_Structures_and_Algorithms
/archive/dynamic_programming/fibonacci_numbers/memoization.py
UTF-8
207
2.890625
3
[]
no_license
def fibo(n): return fibo_memo(n, dict()) def fibo_memo(n, dp): if n in dp: return dp[n] if n in [0, 1]: dp[n] = n else: dp[n] = fibo_memo(n - 1, dp) + fibo_memo(n - 2, dp) return dp[n]
true
d40da3a44f0f7a7c81fd127e9a61aafbd3785d74
815382636/codebase
/leetcode/Solution56.py
UTF-8
599
3.21875
3
[]
no_license
from typing import List class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals, index = sorted(intervals), 1 while index < len(intervals): if intervals[index - 1][1] >= intervals[index][0]: intervals[index - 1][1] = max(intervals[index...
true
de58944fef7fabe934fda78853d91dfdc2af0d26
ottersome/dashTerm
/scraping/scraper.py
UTF-8
1,523
2.859375
3
[]
no_license
#!/usr/bin/env python3 from bs4 import BeautifulSoup import urllib.request,urllib.error, urllib.parse import time from random import randint import json import logging class Scraper: def scrapeNews(quers): time.sleep(randint(0,1)) a = (('hl','en'),('q',quers),('tbm','nws')) final_url = ...
true
6ce18ceb8c247183c70aa7e19ed0defaf103d8b4
chenxy3791/leetcode
/basic-algo/basic-algo/removeNthFromEnd.py
UTF-8
2,998
4.125
4
[]
no_license
""" Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. Follow up: Could you do this in one pass? """ # D...
true
c3c3297489445390249d1a5a4dfde56e4528112b
VinitaNarayanamurthi/Python_course_assignments
/Lab_7_LinkedLists/potato.py
UTF-8
925
3.640625
4
[]
no_license
import sys from dlnode import DoublyLinkedNode from dlList import DoublyLinkedList print('Welcome to the Hot Potato Game!') print('Reading from: players.txt') print('Using random number generator seed: ', sys.argv[2]) file_name = sys.argv[1] infile = open(file_name, "r") items = infile.readlines() n = len(items) i...
true
766a83ebfdf140c3d606f4f18cb44df868ddfa96
devejs/Algorithm
/SWEA/swea_1220_python.py
UTF-8
811
3.71875
4
[]
no_license
""" 1220. Magnetic 210126 Solution 1. 전치행렬 구함 2. for문으로 1,2 값만 빼냄 3. 1의 값은 스택에 담고 2일때 count++ """ for tc_num in range(10): rec_len = int(input()) arr = [[] for _ in range(rec_len)] N = "1" S = "2" for i in range(rec_len): for index, num in enumerate(input().split()): arr[index]....
true
7da2f052f3ccacb536e11c795392937e63c71954
bchang1213/python_fundamentals
/assignment1.py
UTF-8
783
4.1875
4
[]
no_license
#Find and Replace # words = "It's thanksgiving day. It's my birthday,too!" # replace = words.find("day") # print replace # new = words.replace("day", "month") # print new #Min and Max # x = [2,54,-2,7,12,98] # minimum = min(x) # print "The minimum value of the given list is" , minimum # maximum = max(x) # print "T...
true
d8b8cc5e3a3df56714fff7f0de499fb809339535
szzheng/CSE150
/Assignment 3/solutions/p4_ac3.py
UTF-8
1,852
2.640625
3
[]
no_license
# -*- coding: utf-8 -*- from collections import deque from assignment3 import Variable, Variables, Constraint, Constraints, BinaryCSP from p1_is_complete import is_complete from p2_is_consistent import is_consistent def ac3(csp, arcs=None): """Executes the AC3 or the MAC (p.218 of the textbook) algorithms. If the ...
true
da49665c9753eebd52e92c42fa3c44eda9784bb2
vvakrilov/python_basics
/02. Conditional Statements/01. Lab/06. Area of Figures.py
UTF-8
497
3.734375
4
[]
no_license
import math input_type = input() if input_type == "square": input_a = float(input()) print(f'{(input_a * input_a):.3f}') elif input_type == "rectangle": input_a = float(input()) input_b = float(input()) print(f'{input_a * input_b:.3f}') elif input_type == "circle": input_a = float(input()) ...
true
945f2df9e5dc0972303c1ca95d636eeed22826ec
DiegoEmilio01/Advanced-Programming
/Proyects/Activities/AC03/decodificador.py
UTF-8
1,093
3.140625
3
[]
no_license
from itertools import chain def decodificar(string): # dict_1 = {"a": "0", "r": "1", "q": "2", "u": "3", "e": "4", "t": "5", "i": "6", "p": "7", "o": "8", "s": "9"} # dict_2 = {"0": "a", "1": "r", "2": "q", "3": "u", "4": "e", "5": "t", "6": "i", "7": "p", "8": "o", "9": "s"} # string = [dict_1[letra] if ...
true
a5d5827fdef04d7d627ba584d0f41e25ea4a14db
agankur21/Algorithm
/LeetCode/Anagrams.py
UTF-8
506
3.515625
4
[]
no_license
def add_str( anagram_dict, str): sorted_str = "".join(sorted(str)) if sorted_str in anagram_dict: anagram_dict[sorted_str].append(str) else: anagram_dict[sorted_str] = [str] def groupAnagrams(strs): """ :type strs: List[str] :rtype: List[List[str]] """ anagram_dict = {}...
true
045a802e03a69ccb664a6dd39ae735f5ec5639d5
GoogleCloudPlatform/PerfKitBenchmarker
/tools/demos/process_histogram_samples.py
UTF-8
1,320
2.859375
3
[ "Classpath-exception-2.0", "BSD-3-Clause", "AGPL-3.0-only", "MIT", "GPL-2.0-only", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
#!/usr/bin/env python2.7 """Transform PKB json output into a csv format.""" from __future__ import print_function import collections import json import re import sys def main(): if len(sys.argv) != 4: print('usage: %s samples_file.json metric_name data_label' % sys.argv[0]) sys.exit(1) latency_histogra...
true
5b8107ffdb503a1f8d24432d86b9b5d3804af303
btrevizan/poa_expenses
/src/pydata.py
UTF-8
20,227
2.71875
3
[]
no_license
from .inverted import Inverted from .pybin import StructFile from .helper import to_str, to_parts from datetime import date from .btree import BTree class Registry(): """Represent a registry in database.""" def __init__(self, table, fmt, pk): self.__pk = pk @classmethod def get_strct(cls): ...
true