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
e3a049946807aa9e85077660df141dc38d9fa431
Python
jcmayoral/SEE-Project
/code/parameter_optimization.py
UTF-8
3,023
2.984375
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sat Nov 5 11:23:37 2016 @author: jose """ import numpy as np from scipy.optimize import minimize def dF1(alphas, v, omega, v_hat, omega_hat, gamma_hat): k = (alphas[0] * v**2 + alphas[1] * omega**2) if k < 1e-100: k = 1e-100 d = -0.5 * (v**2 / k - ((v - v_h...
true
8debb0a6a56ac596b24b638bb7df78191441c200
Python
YuJuncen/auto_sign
/src/SignClient.py
UTF-8
4,547
2.546875
3
[]
no_license
from requests import post from json import dumps, loads from datetime import datetime as D from sys import exc_info from random import choice, random from asyncio import sleep, run from .Config import static_config as SConf from .TokenFactory import AbstractTokenFactory from .SignInfoServer import BaseSignInfoServer f...
true
dc2044eaaf53e4d71c1236278eaf9e7daf48b7f2
Python
buddiman/alda2020
/sheet07/cocktails/cocktail.py
UTF-8
3,720
3.609375
4
[]
no_license
''' Christopher Höllriegl, Marvin Schmitt Blatt 7 Aufgabe 1 ''' import json import re ignore = {'wasser', 'eiswürfel'} #Aufgabe a) # Read the recipes file and store the json object # Finally... forgot to set utf-8 flag with open('cocktails.json', encoding='utf-8') as data: recipes = json.load(data) def normal...
true
b6705614a45ec82b6afc5c2c8e65c579f796d689
Python
zlouity/adventofcode2020
/03/day3b.py
UTF-8
530
3.296875
3
[]
no_license
with open("day3.txt") as f: array = [] for line in f.readlines(): array.append(line.strip()) def tree_counter(_array): counter = 0 x =_array[0] y =_array[1] while y < len(array): if array[y][x] =="#": counter+=1 x = x+_array[0] x = x%len(array[y...
true
1d92a5987221cc2c03d21017397c616ded4f5012
Python
jehunseo/Algorithm
/Baekjoon/17256.py
UTF-8
125
2.953125
3
[]
no_license
a,b,c = [int(i) for i in input().split(' ')] d,e,f = [int(i) for i in input().split(' ')] print(f'{d - c} {e // b} {f - a}')
true
e2fca4ac93a0fae10da3f40b86dee279fbaf43d0
Python
DustyHatz/CS50projects
/pset6/hello.py
UTF-8
185
4.03125
4
[]
no_license
# This program takes in a users name and says hello to that person! from cs50 import get_int, get_float, get_string name = get_string("What is your name?\n") print("hello, " + name)
true
6dc2566580ad104129d96e9c9a3908537b91dfc8
Python
daniel-reich/ubiquitous-fiesta
/Y2AzE8m4n6RmqiSZh_21.py
UTF-8
67
3.109375
3
[]
no_license
def reverse_list(num): return [int(i) for i in str(num)][::-1]
true
a3243e966545b34a2327f7b603dbcc7413be7a3d
Python
qiudebo/13learn
/code/matplotlib/aqy/aqy_lines_bars3.py
UTF-8
1,499
2.859375
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'qiudebo' import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__': plt.rcdefaults() fig, ax = plt.subplots() labels = (u"硕士以上", u"本科", u"大专", u"高中-中专", u"初中", u"小学") x = (0.13, 0.22, 0.25, 0.18, 0.13, 0.10) ...
true
67c79a08997fc1040e4f2144e6c6c0e01c80a727
Python
Deepak-Vengatesan/Skillrack-Daily-Challenge-Sloution
/15-6-2021.py
UTF-8
601
3.21875
3
[]
no_license
R,C = map(int,input().split()) matrix = [list(map(int,input().split())) for row in range(R)] N= int(input()) for row in range(0,R): for col in range(0,C): if N-col-1>=0 and N+col < C: print(matrix[row][N-col-1]+matrix[row][N+col],end=" ") elif N-col-1 >= 0: print(matrix[row]...
true
365291e3b1f3a03ffd5062d6ee48fd51dbd234e7
Python
WangXin93/tianchi-fashionai-challenge
/TRAIN/view_data.py
UTF-8
4,453
2.53125
3
[]
no_license
import torch from torchvision import datasets, models, transforms from torch.utils.data import Dataset, DataLoader import pandas as pd import os from PIL import Image import matplotlib.pyplot as plt import torchvision import numpy as np # import Augmentor class FashionAttrsDataset(Dataset): """Fashion Attributes ...
true
1b89b330bac9ecb13eddafb52899601f10ccd5e8
Python
jhli973/Projects
/filehandling/ReadFileFromSubfolder.py
UTF-8
1,678
3.453125
3
[]
no_license
''' Senario: Imagine we have houdreds of customer specific folders which hold package files. Our mission is to check if two specific packages were created for each clients This program is to find the specified files from any folder and return a ordered dictionary of the foldername(ClientName):filename ''' #Part one...
true
744c093b1d6613503f03a4b4277c6803fc144ae9
Python
jaysurn/Leetcode_dailies
/Add_Two_Num.py
UTF-8
3,020
4.53125
5
[]
no_license
# Goal : Return the sum of 2 postive integers stored as reverse linked lists # Given : 2 linked lists of ints stored in reverse ( ex. 123 stored as 3->2->1 in list ) # Assumption : Lists' int value does not begin with 0 class Node: # Class definition for creating a Linkedlist def __init__( self , ...
true
7876e99a9af36d7e57ba6fef6f8822595a3c48c2
Python
me450722457/python_test
/test.py
UTF-8
345
3.09375
3
[]
no_license
#!/usr/bin/env python3 account = 'admin' password = '123456' user_account = input(str('Please input your account\n')) user_password = input(str('Please input your password\n')) if user_account == account: if user_password == password: print('success') else: print('password error') else: pr...
true
d3ca57ef154ba5e774a9d152c4a5fabedb3cd951
Python
SamVyazemsky/otus
/PythonQA/Lesson16/perser_access_log.py
UTF-8
437
2.78125
3
[]
no_license
import re from collections import Counter import json def read_log(filename): with open(filename) as f: log = f.read() ip_list = re.findall(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', log) return ip_list def count_ip(ip_list): count = Counter(ip_list) return count if __name__ == '_...
true
5aa7119e2387fe2d6d28a0ee62bf50386556a1d6
Python
henrytan0705/DS-A
/interview questions/twoSum.py
UTF-8
1,010
4.09375
4
[]
no_license
# O(n log n) Time| O(1) Space def twoNumberSum(array, targetSum): # sort array in order array.sort() # track left and right elements with indexes left_idx = 0 right_idx = len(array) - 1 while left_idx != right_idx: left = array[left_idx] right = array[right_idx] # check if sum is equal to targetSu...
true
2f1b38ce8b3c1d2da522091bfa301516739ebd92
Python
anurag1212/Search-Algorithms
/Search Algos/DFS/dfs.py
UTF-8
1,286
2.765625
3
[]
no_license
words = [] #newList=[] for line in open('i2.txt'): words.extend(line.split()) algo=words[0] start=words[1] goal=words[2] live_lines=int(words[3]) ll=live_lines*3 graph1={} #print words def fill_graph(): for v in range(4,ll+4,3): if(graph1.has_key(words[v])==False): graph1[words[v]]=[words[v+1]] elif(graph1...
true
fb02f39486aafa860bf8df6c2976cc8db45d0c2c
Python
Serge45/MSVCAutoBuilder
/msbuilder.py
UTF-8
2,436
2.515625
3
[]
no_license
# -*- coding: utf-8 -*- import os, subprocess class Msbuilder: def __init__(self, \ sln_path = r".\\", \ prj_name = "", \ build_config = r"Release", \ devenv_path = ""): self.possible_msbuild_path = [] self.msbuild_path = None ...
true
77be83e2bc743cca9ecb8ecb7ba7e3a861f69d0b
Python
Flavio58it/Supervised-Product-Similarity
/test_model.py
UTF-8
1,299
2.828125
3
[]
no_license
import numpy as np from src.model import siamese_network from src.common import Common # ## Manual Testing ############################################################### # Converts titles into embeddings arrays and allow the model to make a prediction # ################################################################...
true
81f4d65a3fefd7bdf5236b0eafea4a1a467dd563
Python
razmikarm/structures_in_python
/stack.py
UTF-8
1,116
3.609375
4
[]
no_license
from __future__ import annotations class Node: def __init__(self, value): self.__next = None self.__value = value @property def value(self): return self.__value @value.setter def value(self, value): self.__value = value @property def next(self): ...
true
e085c8bffb7023ac6a6356cbc059dc3ec3630050
Python
nizanshami/software_projet
/hw1/kmeans.py
UTF-8
4,213
3.578125
4
[]
no_license
""" Kmeans implementation in Python Software Project ex. 1 Amit Elyasi 316291434 Nizan Shemi 206962912 """ import sys def Kmeans(k, max_iter=200): data_points = read_data() if not good_input(data_points, k): return centroids = data_points[:k] for i in range(max_iter):...
true
5b8db511d50e8f2b37bc2ede8a107f534394e9eb
Python
zhjohn925/test_python
/TeachKidsPython/p00Spiral1.py
UTF-8
539
4.09375
4
[]
no_license
import turtle # https://docs.python.org/3.3/library/turtle.html?highlight=turtle t1 = turtle.Turtle() # or use alias turtle.Pen() t2 = turtle.Turtle() t1.pencolor('blue') t1.penup() t1.setpos(100, 100) t1.pendown() t2.pencolor('pink') for x in range(30): t1.forward(x) # move forward x pixels #t1.left(90)...
true
499c334aaaf704c08661536b80f3bb9bfe23147e
Python
davidbrough1/TSP_Algorithms
/plot_points.py
UTF-8
1,814
2.640625
3
[ "MIT" ]
permissive
# This file contains code used to generate plots from the trace and # solution plots from __future__ import division import numpy as np import matplotlib.pyplot as plt import csv from os import listdir from os.path import isfile, join import sys mypath = "/home/davinciwin/Algos/Amish_data" output_path = "/home/davi...
true
520c09ef12ec0f5b6b81d720df46e0aebeab07b5
Python
sek788432/Electricity-Forecasting-DSAI-HW-2021
/code/prophet.py
UTF-8
846
2.859375
3
[]
no_license
from fbprophet import Prophet from matplotlib import pyplot as plt from neuralprophet import NeuralProphet def prophet(data): m = Prophet(interval_width=0.95, daily_seasonality=True) m.fit(data) future = m.make_future_dataframe(periods=7, freq='D') forecast = m.predict(future) forecast.tai...
true
441a52daeda41951a059a786e4183bd3b99f0d30
Python
szazyczny/MIS3640
/Session04/quadratic.py
UTF-8
888
3.921875
4
[]
no_license
#Define a function quadratic(a, b, c) to solve a quadratic equation: ax^2+bx+c=0 #Discriminant: b^2−4ac def quadratic(a, b, c): ''' return the two roots of a quadratic equation. ''' d = (b ** 2 - 4 * a * c) ** 0.5 #use discriminant, 0.5 is exponent to get square root x = (-b + d) / (2 * a) #solvi...
true
18c0c2ccc40270968df3517afaa6157b26919846
Python
gharib85/toqito
/toqito/state_opt/unambiguous_state_exclusion.py
UTF-8
3,444
3.671875
4
[ "MIT" ]
permissive
"""Unambiguous state exclusion.""" from typing import List import cvxpy import numpy as np from .state_helper import __is_states_valid, __is_probs_valid def unambiguous_state_exclusion( states: List[np.ndarray], probs: List[float] = None ) -> float: r""" Compute probability of unambiguous state exclusio...
true
fc5b4e10560be66e6173735da674dbb6cacc5615
Python
MaxConstruct/ClimateSample
/analysis/netcdf_util.py
UTF-8
3,195
2.71875
3
[]
no_license
# Import libraries and set configuration # os used for path and directory management import os # xarray, is the most important library, used for manipulate netCDF Dataset operation from pathlib import Path import xarray as xr import numpy as np # matplotlib for plotting Dataset. cartopy for various map projection f...
true
7227c471e01b92533fd45d035fd81bd5d6e98def
Python
Leir-Cruz/ED
/questionario_grafo/q4.py
UTF-8
867
3.375
3
[]
no_license
class Vertex: def __init__(self, key): self.key = key self.neighboors = {} def addNeighboor(self, vertex): self.neighboors[vertex.key] = Vertex(vertex) class Graph: def __init__(self): self.vertList = {} def addVertex(self, key): newVextex = Vertex(key...
true
95a9e6a79e7db1e075d77eb7d51ee305d7809b46
Python
WANGLU2/WANGLU_CP1404practicals
/prac_03/convert_temps.py
UTF-8
369
3.875
4
[]
no_license
def main(): out_file = open("temps_output.txt", "w") in_file = open("temps_input.txt", "r") for line in in_file: Fahrenheit = float(line) print(convert_fahrenheit_to_celsius(Fahrenheit), file=out_file) in_file.close() def convert_fahrenheit_to_celsius(Fahrenheit): celsius = 5 ...
true
543bcc4c448c10a3f0e0faca19b41bbec3dd24b6
Python
abhi8893/tensorflow-developer-certificate-deeplearning-ai
/04-sequences-time-series-and-prediction/course-notebooks/utils.py
UTF-8
778
3.4375
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt def plot_series(time, series, format="-", start=0, end=None, label=None): plt.plot(time[start:end], series[start:end], format, label=label) plt.xlabel("Time") plt.ylabel("Value") plt.grid(True) def trend(time, slope=0): return slope * time def s...
true
e3542802a904bc9fa329e32e486080492921d731
Python
WeichselRiver/database
/sqlalchemy_test.py
UTF-8
560
3.125
3
[]
no_license
from sqlalchemy import create_engine db_string = "postgresql://postgres:<pwd>@localhost:5432/postgres" db = create_engine(db_string) # Create db.execute("CREATE TABLE IF NOT EXISTS films (title text, director text, year text)") db.execute("INSERT INTO films (title, director, year) VALUES ('Doctor Strange', 'Scott...
true
af50b4006e89d70cff91a58eeac7669638e152c5
Python
sanxml/Conveyor-belt-grabbing-device
/code/main.py
UTF-8
2,073
2.515625
3
[]
no_license
import cv2 as cv import numpy as np import serial import time from binascii import unhexlify from crcmod import mkCrcFun import picture_process import control camera=cv.VideoCapture(2) ROI_rect = (150,0,640-150,480) lower_green = np.array([35, 45, 0]) upper_green = np.array([100, 255, 255]) # control.coordinate_wr...
true
e8afe0c71f21cc2be8d1b7b146c8b99e33c9c0b8
Python
Michael-Python/w3_weekend_game_v3
/w3_homework_v3/app/models/player.py
UTF-8
117
2.84375
3
[]
no_license
class Player: def __init__(self, player, choice): self.player = player self.choice = choice
true
c3886224ef132f059eb058f7398e32663cd7af81
Python
mohammedlutf/cg
/1.py
UTF-8
784
3.671875
4
[]
no_license
import csv print("the most specific hypothesis is :[000000]") a=[] print("the given training dataset \n") with open('ws.csv','r') as csvfile: reader=csv.reader(csvfile) for row in reader: a.append(row) print(row) num_attributes=len(a[0])-1 print("the initial value of hypothesis:\n") hypothesis = ['0']*num_attr...
true
291a64696ae8595db81eac3fb012874f9b913f08
Python
tebeco/MyDemos
/Python/Demos/NumPyDemos/4/4-7.py
UTF-8
274
2.796875
3
[]
no_license
#!/usr/bin/python #-*-coding:utf-8-*- import numpy as np student = np.dtype([('name','S20'), ('age', 'i1'), ('marks', 'f4')]) print student print '###################################' a = np.array([('abc', 21, 50),('xyz', 18, 75)], dtype = student) print a
true
b92dc0b13cc7b327f3bbefc891e6be7aec456956
Python
Bazzzzzinga/Credit-Risk-Assessment
/Implementations/2.KNN/knn.py
UTF-8
1,274
2.828125
3
[]
no_license
import os,csv,math import numpy as np from sklearn.metrics import classification_report #Reading Data csv_file_object = csv.reader(open('csvdataset.csv', 'rb')) data=[] for row in csv_file_object: data.append(row) data=np.array(data) data=data[2::] x=data[:,1:24] y=data[:,24:25] x=x[:,:].astype(np.float64) x=(x-np.m...
true
50a93efcf6e1ef6c5b453ed2b35424f0e3dc5d70
Python
Ciprianivan2015/2020_PYHTON_SORTING
/PY_numpy_sorting_20200403.py
UTF-8
1,955
3.078125
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Fri Apr 3 19:14:47 2020 @author: Cipriandan 1. define list of sample size 2. for each element in the list_1: create random.normal() 3. for each element in the list_1 4. for each element in the list_of_sorting_algorithms 5. t0 = time.time() 6. sort( s...
true
e3d2fb72b04aa45fb993fc76ce6c660febf6180e
Python
john-Lyrics/John
/fibonachi.py
UTF-8
183
3.171875
3
[]
no_license
def fib_rec(n): if n<= 1 : return n else : return fib_rec(n-1) + fib_rec(n-2) print(fib_rec(10)) print(list(map(fib_rec, range(1,11))))
true
511157a8663341e503408a2a3b88e8809413d8cf
Python
zurk/lookout-sdk-ml
/lookout/core/tests/test_metrics.py
UTF-8
6,267
2.828125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
import threading import unittest import requests from lookout.core.metrics import ConfidentCounter, PreciseFloat, record_event class MetricReader: def __init__(self, port, addr="localhost"): self.__is_running = False self.__port = port self.__addr = addr self.__metrics = {} ...
true
90e9692d11ad2658f2681164d53440f21fcfcc09
Python
harry671003/coursera-algorithmic-toolbox
/week-2/euclidean-gcd.py
UTF-8
563
3.734375
4
[]
no_license
def gcd(n1, n2): # Swap numbers in case n1 < n2 if n1 < n2: temp = n1 n1 = n2 n2 = temp print("n1: %d | n2: %d" % (n1, n2)) if n2 == 0: return n1 return gcd(n2, n1 % n2) def main(): token = input('Enter 2 number: ') (n1, n2) = token...
true
2ac640d2a8cd666eae373aebeb4a2a7e81133dba
Python
andreatrejod/TC101
/wsq10.py
UTF-8
1,035
4.21875
4
[]
no_license
import statistics # Este módulo permite calcular operaciones estadísticas como las que necesitamos en este programa. lista = [float(input("Please give me the first number: ")), float(input("Please give me the second number: ")), float(input("Please give me the third number: ")), float(input("Please give me the four...
true
397292fc6b253c856b13dda39e3531a87fac3da4
Python
Stargrazer82301/CAAPR
/CAAPR/CAAPR_AstroMagic/PTS/pts/magic/analysis/stars.py
UTF-8
5,138
2.765625
3
[ "GPL-1.0-or-later", "AGPL-3.0-only", "AGPL-3.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-philippe-de-muyter", "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** ##...
true
00317e414b485fd1f926a3681824e30046f76bd3
Python
rootUJ99/py-programs
/left_right_sum_difference.py
UTF-8
681
3.859375
4
[]
no_license
''' array = [1,2,4,5,1] Find min difference of left and right sum of the array e.g. LS - RS 1 - 12 => 11 3 - 10 => 7 7 - 6 => 1 12 - 1 => 11 ''' def min_diff(sum, index, arr): try: print(sum) if len(arr) > 1: #if index > 0: divider = len(arr) // index le...
true
7482732b8e3c8e7d646fa81754f0458594d827cf
Python
MatteoLacki/logerman
/logerman/json_ops.py
UTF-8
362
2.984375
3
[]
no_license
import json from pathlib import Path class PathlibFriendlyEncoder(json.JSONEncoder): """This helps to store the paths.""" def default(self, z): if isinstance(z, Path): return str(z.expanduser().resolve()) else: return super().default(z) def dump2json(obj): return j...
true
8360c745043095b3aee6168b863ac046c6b1184d
Python
Sumitsahu896/My_LeetCode_Solutions
/fibonacci-number/fibonacci-number.py
UTF-8
238
3.4375
3
[]
no_license
class Solution: def __init__(self): self.dict = {0:0, 1:1} def fib(self, n: int) -> int: if n not in self.dict: self.dict[n] = self.fib(n - 1) + self.fib(n - 2) return self.dict[n]
true
7daa2b63b32f1509dcb3ab8c78c9633fe98bafdc
Python
yopy0817/course-python
/day08/03def_return.py
UTF-8
719
4.25
4
[]
no_license
# 함수의 반환 return #매개 변수로 전달 받은 2개의 값의 합을 반환하는 함수. def add(a, b) : return a + b result = add(10, 20) print("10과 20의 합:", result) #매개변수 까지의 합을 반환하는 함수. def calSum(a) : sum = 0 a = 1 while a <= 10 : sum += a a = a + 1 return sum result = calSum(10) print("1부터 10까지 합:", result) #리스트의...
true
4a2ca9f868a836715206e4e9db32bd178aad31de
Python
mcf-rocha/pyDEA
/pyDEA/core/gui_modules/custom_canvas_gui.py
UTF-8
435
2.765625
3
[ "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
''' This module contains StyledCanvas class. ''' from tkinter import Canvas from pyDEA.core.utils.dea_utils import bg_color class StyledCanvas(Canvas): ''' Implements Canvas object with a custom background colour. Args: parent (Tk object): parent of this widget. ''' def __init__(sel...
true
ab60e1f5e4e2cffff6e5cad57e486b710ebf4bae
Python
yoshioH/readaloud-workout
/chunks/__init__.py
UTF-8
592
2.671875
3
[]
no_license
# coding: utf-8 from enum import Enum from abc import ABC from abc import abstractmethod from dataclasses import dataclass class ChunkType(Enum): READ_ALOUD = 0 QUESTION = 1 ANSWER = 2 @dataclass(frozen=True) class Chunk: type: ChunkType text: str class ChunkResource(ABC): @abstractm...
true
c6bfcc85d8e36d70b081308d416b0e9c873e1dd4
Python
VagishM6/JPG_to_PNG_Converter
/JPGtoPNGConverter.py
UTF-8
559
3.1875
3
[]
no_license
import sys import os from PIL import Image, ImageFilter # grab the first and second args from the user image_folder = sys.argv[1] output_folder = sys.argv[2] # check if (new) folder exist/ if not create it if not os.path.exists(output_folder): os.makedirs(output_folder) # loop through the directory, then conver...
true
c483144e38c7a9f48f751c0316d3ae1cd248f009
Python
danierubr/Exercicios-resolvidos
/URI/1548.py
UTF-8
299
3.6875
4
[]
no_license
quant = int(input()) for v in range(quant): alunos = int(input()) fila = list(map(int, input().split())) filaordenada = sorted(fila, reverse=True) cont = 0 for ind in range(0, len(fila)): if fila[ind] == filaordenada[ind]: cont += 1 print(cont)
true
4cae91584955eb167a0db4f3f2f6e4a5534470e3
Python
lusiux/aoc2020
/11/main.py
UTF-8
5,453
3.5625
4
[ "MIT" ]
permissive
import sys sys.path.append('./') import Helper import copy input_for_testing = """L.LL.LL.LL LLLLLLL.LL L.L.L..L.. LLLL.LL.LL L.LL.LL.LL L.LLLLL.LL ..L.L..... LLLLLLLLLL L.LLLLLL.L L.LLLLL.LL """ class Seatmap(): def __init__(self, lines): self._read_input(lines) def _read_input(self, lines): ...
true
0b92001b2e32f67b798c7c7f0f1cf7de4f3ace44
Python
ZheHanLiang/UAGA_reconstruct
/UAGA/model.py
UTF-8
2,454
3.234375
3
[]
no_license
########################################################################## # @File: model.py # @Author: Zhehan Liang # @Date: 1/10/2020 # @Intro: GAN的模型函数,其中Discriminator是鉴别器,mapping是生成器 ########################################################################## import time import torch from torch import nn # from .ut...
true
0a6cd3ac5c88cde947ddd6b7a4715d4d12b82d36
Python
MichalRybecky/Informatika
/ulohy/20.1.py
UTF-8
965
2.953125
3
[]
no_license
import tkinter c = tkinter.Canvas(height=200, width=1000, bg='black') c.pack() with open('stanice.txt', 'r') as file: data = [x.strip() for x in file.readlines()] def main(): global current, stanice c.delete('all') for stanica in stanice: c.create_text(stanica[1], 100, anchor='w', text=stanic...
true
e99c7b6e9c5e8b8562e72467d7877dc5255594c0
Python
ispastlibrary/Titan
/2015/AST1/vezbovni/anja/treci.py
UTF-8
69
2.875
3
[]
no_license
S=0 for i in range(101): S+=i print("konacno resenje je: ", S)
true
dcbe681f2dae5ee7c917f79691e2cd33b70940d2
Python
VigneshKarthigeyan/DS
/Linked_List/flat_multi_level_ll.py
UTF-8
970
3.578125
4
[]
no_license
#Flatten a multilevel ll class Node: def __init__(self,val): self.data=val self.next=None self.child=None def printlist(head): while head: print(head.data,end=' ') head=head.next def flat(head): tail=head while tail.next: tail=tail.next ...
true
c81a5d5e79032cd7baf9a46d2979a58d34001413
Python
dansgithubuser/pdf-explorer
/pdf/_objects.py
UTF-8
2,955
2.921875
3
[]
no_license
''' This file makes page and section references to ISO 32000-1:2008. Objects are documented in section 7.3 of ISO 32000-1:2008. ''' import re import pprint import zlib class Name: escape_regex = re.compile('#([0-9a-fA-F]{2})') def __init__(self, literal): self.value = Name.escape_regex.sub(lambda m:...
true
f17160c31a9a3eac744b6b549ba49231afed5d7a
Python
batbeerman/hellogit
/qu2.py
UTF-8
131
3.1875
3
[]
no_license
test_tup = 32,454,56,32,1,9,76 print('Max element of tuple is :',max(test_tup)) print('Min element of tuple is :',min(test_tup))
true
e531d0b14eae818c79ff7770b49416d77c5ed4c1
Python
widelec9/codewars
/kata/python/5kyu/tongues.py
UTF-8
347
2.90625
3
[]
no_license
def tongues(code): v = 'aiyeou' c = 'bkxznhdcwgpvjqtsrlmf' out = '' for i, ch in enumerate(code): if ch.isalpha(): ch = v[(v.index(ch.lower()) + 3) % len(v)] if ch.lower() in v else c[(c.index(ch.lower()) + 10) % len(c)] ch = ch.upper() if code[i].isupper() else ch ...
true
b6ec1b528c3614b4a9e8cce5e0292d15dc77ec98
Python
sp5/c-exercises
/sort/testsort.py
UTF-8
157
3.140625
3
[]
no_license
import sys prev = 0 for line in sys.stdin: cur = int(line) if cur < prev: print("EVIL SORT VERY BAD") sys.exit(0) prev = cur
true
8177a65fddd055c711e994c0725fb27077ca1812
Python
peterpeng1993/learngit
/script/python/pygame入门9.py
UTF-8
1,867
3.1875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Thu Mar 29 20:26:31 2018 @author: asus """ import sys,pygame from random import choice class MyBallClass(pygame.sprite.Sprite): def __init__(self,image_file,location,speed): pygame.sprite.Sprite.__init__(self) self.image=pygame.image.load(image_fi...
true
0a33a5d574c1d8b6d889f75a4a2f3f001eb35af9
Python
swarren/advent-of-code-2020
/python/day20.py
UTF-8
1,601
2.859375
3
[]
no_license
#!/usr/bin/env python3 import functools import operator with open("../input/day20.txt") as f: data = f.read().splitlines() def s2i(s): v = 0 for c in s: v <<= 1 v |= ((c == '#') and 1 or 0) return v tiles = {} tile = None ln = 0 ts = 0 ls = 0 rs = 0 for l in data: ln += 1 #pr...
true
f667647fe7156078432a23743802c0d629413ad6
Python
rajui67/learnpython
/python_code_exaples/collections/sets/union.py
UTF-8
1,026
4.09375
4
[]
no_license
set1 = {1, 2, 3} set2 = {1, 5} print(set1 | set2) print(set1.union(set2)) print(set2 | set1) print(set2.union(set1)) # up until this point set1 and set2 remain unchanged. The operators and function return a new set print(set1, set2) set1 = {1,1,2,2,3} set2 = {1,5} # |= a shortcout operator. Essentially, set1 |= set2 ...
true
c47fc129c20863be802047f9abfef0fc4b38bf8d
Python
shilpakancharla/machine-learning-tutorials
/data_scraping/bing.py
UTF-8
1,723
2.6875
3
[ "MIT" ]
permissive
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sun Jun 24 10:45:31 2018 @author: shilpakancharla """ import urllib,urllib2 import re from bs4 import BeautifulSoup from datetime import datetime def bing_grab(query): t1 = datetime.now() address = "http://www.bing.com/search?q=%s" % (urllib...
true
3a4efe163811aeb7c30ddf1e4e8bdde05cccdd1e
Python
weidler/RLaSpa
/src/gym_custom_tasks/envs/simplePathing.py
UTF-8
4,772
2.671875
3
[ "MIT" ]
permissive
import copy import numpy import numpy as np import gym import torch from gym import error, spaces, utils from gym.utils import seeding import platform if 'rwth' in platform.uname().node.lower(): import matplotlib matplotlib.use('Agg') # Force matplotlib to not use any Xwindows backend. import matplotlib.pyplot...
true
7970f33425d471802dcc3751601fc0eb6cdb3925
Python
srinitude/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
UTF-8
1,806
3.65625
4
[]
no_license
#!/usr/bin/python3 """Matrix Divided Module""" def check_for_ints_and_floats(matrix): """Bad input""" bad_input = "matrix must be a matrix (list of lists) of integers/floats" flat_list = [i for sublist in matrix for i in sublist] for i in flat_list: if type(i) is not int and type(i) is not flo...
true
fddfca3ddbb7e04ea6895479a101537f0fd5b1c8
Python
Ich1goSan/LeetcodeSolutions
/removeNthFromEnd.py
UTF-8
508
3.125
3
[ "MIT" ]
permissive
class ListNode: def __init__(self, x): self.val = x self.next = None def removeNthFromEnd(self, head, n): if not head: return None if not head.next and n == 1: return None r = [] current = head while current: r.append(current) current = current.ne...
true
19b8735515f2dabddbd703545e944a816289245a
Python
Addikins/CIS164
/Unit12/CSVread.txt
UTF-8
130
2.59375
3
[]
no_license
import csv csv_file = open('cochise.csv') csv_reader = csv.reader(csv_file) csv_contents = list(csv_reader) print(csv_contents)
true
e912546e6bed4325be0adcd54f5761135f97867b
Python
sweec/leetcode-python
/src/NextPermutation.py
UTF-8
785
2.984375
3
[]
no_license
class Solution: # @param num, a list of integer # @return a list of integer def nextPermutation(self, num): l = len(num) for i in range(l-2, -1, -1): if num[i] < num[i+1]: index = l-1 for j in range(i+2, l): if num[j] <...
true
37e10f39d8819bdd38e13ffe90a7b7bcd6306f40
Python
antman9914/CitiChatbot
/Aiml模板翻译/TranslateXml.py
UTF-8
4,961
2.703125
3
[]
no_license
#作者:肖劲宇 李蕴琦 #用途:对aiml模板进行翻译 #时间:2019.7.3 from bs4 import BeautifulSoup import requests import string import time import hashlib import json import os import random #百度翻译api的url,以及appid和密钥 api_url = "http://api.fanyi.baidu.com/api/trans/vip/translate" my_appid = '20151113000005349' cyber = 'osubCEzlGjzvw8q...
true
aaea7fe7acc39c1c517311540de8d1fa44cc94c3
Python
onehours/python-crawler
/xiaoshuo-quanshuwang.com/get_book.py
UTF-8
1,447
2.84375
3
[]
no_license
import requests import time from lxml import etree from get_headers import getheaders import sys if len(sys.argv) == 1: url = 'http://www.quanshuwang.com/book/174/174135' else: url = sys.argv[1] if not url.startswith('http'): print('请输入有效的url') sys.exit(1) def get_obj(url): # head...
true
279c4ba720b08aee015799dcc4db84177a828a4e
Python
mandub/project_2
/convolution.py
UTF-8
2,660
3.421875
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt def convolve(g, h): """ Convolves g with h, returns valid portion :param g: image :param h: filter :return: result of convolution, shape=( max( len(g), len(h) ), max( len(g[0]), len(h[0]) ) ) result of convolution, shape=( max( len(g), len(h)...
true
4f85b028c59999f4017254ba2d4f5e4c5fa308c4
Python
ealehman/mpi
/mandelbrot/mandelbrot_masterslave.py
UTF-8
2,016
2.859375
3
[]
no_license
import numpy as np import matplotlib.pyplot as plt from mpi4py import MPI from P4_serial import * def slave(comm): jobs = True while jobs: status = MPI.Status() y = comm.recv(source=0, tag = MPI.ANY_TAG, status = status) #, status=status) tag = status.Get_tag() if tag ...
true
54c0bd639845218533276a39cac3615371227147
Python
dantepsychedelico/sufproject
/socketServer/router.py
UTF-8
2,038
2.65625
3
[]
no_license
import json, time from Users import users from mongoCtrl import mongoCtrl as mctrl class router: def __init__(self, socket): """ every online user have one router object and used 'Ctrl' method to control request and response """ self.socket = socket self.uid = None self.__route = ...
true
a0af15dfdd0fbd612a46b33e14408c4b257a88b2
Python
AaruranLog/Analogies
/analogies/utils/word_entry.py
UTF-8
326
2.796875
3
[ "MIT" ]
permissive
""" Forms to capture text """ from flask_wtf import FlaskForm from wtforms import StringField, SubmitField from wtforms.validators import DataRequired class SimpleWordEntry(FlaskForm): """Simplest form to capture text""" text = StringField('Text: ', validators=[DataRequired]) submit = SubmitField('Sub...
true
25c85237687f297ded228521719eed1d72715d5b
Python
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_2/rchen8/revenge_of_the_pancakes.py
UTF-8
376
2.953125
3
[]
no_license
file = open('revenge_of_the_pancakes.txt', 'r') output = open('revenge_of_the_pancakes_out.txt', 'w') t = int(file.readline()) for i in xrange(0, t): s = file.readline() count = 0 for j in xrange(0, len(s) - 2): if s[j] != s[j + 1]: count += 1 if s[-2] == '-': count += 1 output.write('Case #' + str(i + 1) ...
true
1a45f311253331631bb052de98bdb1f6e00118ab
Python
vstarman/python_codes
/19day/02.jing_dong.py
UTF-8
1,556
3.03125
3
[]
no_license
from pymysql import * class JD(object): def __init__(self): # 创建数据库对象 和 数据库操作对象 self.qd_liu = connect( host='localhost', port=3306, database='jd_market', user='root', password='mysql', charset='utf8') self.cursor = sel...
true
291fb6c3d36dc89483af428cf73c99c1888f105c
Python
Aggraxis/killer-bot
/utilities.py
UTF-8
1,138
3.65625
4
[ "MIT" ]
permissive
import csv from random import randint def listFiller(fileName): with open (fileName) as csvfile: reader = csv.DictReader(csvfile) return (list(reader)) def compose_response(random_target): # random_target is a dictionary, and the key names like # 'CONTRACT_NUMBER' come from ...
true
0eff68e3d52c755f6cedf473296a21905f03c92f
Python
Ogiwara-CostlierRain464/scikit-learning
/play.py
UTF-8
185
3.734375
4
[]
no_license
for i in range(1, 101): if i % 15 == 0: print("WizzWuzz") elif i % 3 == 0: print("Wizz") elif i % 5 == 0: print("Wuzz") else: print(i)
true
6fe2f20c583da091aa3bfd85562d65ab8762105c
Python
aig-upf/automated-programming-framework
/domains/other/blocks/gen-problem.py
UTF-8
1,175
2.53125
3
[]
no_license
#! /usr/bin/env python import sys,time,random #**************************************# # MAIN #**************************************# try: nblocks = int(sys.argv[1]) except: print "Usage:" print sys.argv[0] + " <nblocks>" sys.exit(-1) str_problem="" str_problem=str_problem + "(define (problem p"+str(nblo...
true
71de6ed5f999d4ec597a8ff5cf4f8a841b70766c
Python
rmorales87atx/cosc1336_fall12
/lab01/tip_tax_total.py
UTF-8
961
4.34375
4
[]
no_license
# COSC 1336 Lab 1 Problem 1 # Robert Morales # # Test Case: # The bill amount is $100.00. The tip is $15.00, tax is $7.00, # total is $122.00. # # First probem is that input is not being correctly converted. # Using 'float()' fixes this problem. # # Second problem is in the summation of the total; the bill # total is b...
true
6899d0950bea82651195cdea9c2c737af548730a
Python
park8989/python_example
/initial_code/dateExpressChange.py
UTF-8
636
3.890625
4
[]
no_license
#! python3 # 日付表示方法を変える import datetime today1= datetime.date.today() today2= "{0:%Y:%m:%d}".format(today1) today3= "{0:%Y.%m.%d}".format(today1) today4= "{0:%Y年%m月%d日}".format(today1) today5= "{0:%Y년%m월%d일}".format(today1) print(today1) print(today2) print(today3) print(today4) print(today5) #曜日を付け加える p = today1.w...
true
522536cd6e41e5af96eeec8119ede510758b5034
Python
nocproject/noc
/core/clickhouse/fields.py
UTF-8
10,912
2.59375
3
[ "BSD-3-Clause" ]
permissive
# ---------------------------------------------------------------------- # ClickHouse field types # ---------------------------------------------------------------------- # Copyright (C) 2007-2020 The NOC Project # See LICENSE for details # ---------------------------------------------------------------------- # Pytho...
true
0cdfd467f31e9f092a60f613b7a4a636ce06790f
Python
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/80_10.py
UTF-8
2,301
3.734375
4
[]
no_license
Python | Rear stray character String split Sometimes, while working with Python Strings, we can have problem in which we need to split a string. But sometimes, we can have a case in which we have after splitting a blank space at rear end of list. This is usually not desired. Lets discussed ways in which this ...
true
28cc67917715f6c9ede4590b4c3962532693bf83
Python
andrenasx/FEUP-MNUM
/Segundo Teste/2016T2/4.py
UTF-8
250
3.140625
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Mon Dec 9 21:16:39 2019 @author: fmna """ def dyx(x,y): return -0.25*(y-42) def euler(T,t,tf,h): while(t<tf): T+=h*dyx(t,T) t+=h return T #euler(10,5,5+2*0.4,0.4)
true
6707e782bcb42b5bc6a72cd8282efdc575e2c2c7
Python
dcarrillo11/PHaDA
/features.py
UTF-8
2,011
3.0625
3
[]
no_license
#PHaDA: features v1.0 #Daniel Carrillo Martin import os import shutil from datetime import datetime from subprocess import Popen,PIPE,call from time import sleep from Bio import SeqIO def directorer(filequery,filesubject): """filequery: query fasta file filesubject: subject fasta file This functi...
true
ae189caa08994b60d3490b83a17a690699c69f1e
Python
fedetft/tdmh
/experiments/scripts/old/extract_graph.py
UTF-8
704
2.859375
3
[]
no_license
#!/usr/bin/python import re import sys from graphviz import Graph dot = Graph(name='Topology') dot.graph_attr['rankdir'] = 'LR' nodes = [] fname = (sys.argv[1][0: sys.argv[1].rindex(".")] if sys.argv[1].index(".") > 0 else sys.argv[1]) + '.pdf' with open(sys.argv[1], 'r') as fin: line = fin.readline() while ...
true
75d596a1db2dc721cf6706059b6743a10f3827c7
Python
fherrmannsdoerfer/masterArbeit
/scriptsForPictures/compareSkellamVariance.py
UTF-8
2,686
2.828125
3
[]
no_license
import numpy as np import matplotlib.pyplot as plot def doSkellam(data): diffs=data[1:]-data[:-1] meandiff = (diffs[0]-diffs[-1])/np.float(data.shape[0]) sig2 = np.sum((meandiff-diffs)**2)/(data.shape[0]-1) return (meandiff+sig2)/2. listvarvar = [] listvarskellam = [] listmeanskellam = [] listmeanvar=...
true
7655e51aa224f544226172a1c4c7be0f85fdd6ec
Python
paramita2302/algorithms
/iv/Strings/Palindrome.py
UTF-8
839
3.859375
4
[ "MIT" ]
permissive
class Palindrome(): # @param A : string # @return an integer def isPalindrome(self, A): n = len(A) if len(A) < 2: return 1 i = 0 j = n -1 while i < j: if (A[i]).isalnum() and (A[j]).isalnum(): print((A[i]).lower()) ...
true
fac34e0cbc83b5acaebbbb2346201622afbef9b3
Python
wulinlw/leetcode_cn
/leetcode-vscode/92.反转链表-ii.py
UTF-8
2,076
3.828125
4
[]
no_license
# # @lc app=leetcode.cn id=92 lang=python3 # # [92] 反转链表 II # # https://leetcode-cn.com/problems/reverse-linked-list-ii/description/ # # algorithms # Medium (49.23%) # Likes: 314 # Dislikes: 0 # Total Accepted: 38.3K # Total Submissions: 77.5K # Testcase Example: '[1,2,3,4,5]\n2\n4' # # 反转从位置 m 到 n 的链表。请使用一趟扫描完成...
true
b99f0f7eb61850c527bc566cb41233ba9a114e11
Python
SWHarrison/CS-2.1-Trees-Sorting
/Code/tree_project/B_plus_tree.py
UTF-8
11,251
3.796875
4
[]
no_license
class B_plus_tree_node: def __init__(self, is_leaf = True): self.keys = [] self.children = [] self.is_leaf = is_leaf self.next_leaf = None # currently unused and non-functional def add_node(self, key, new_node): for i in range(len(self.keys)): if key <...
true
b08f4fc892d2727a77ca5945e1e017bcd59c1ac4
Python
Orbedi/Daily-coding-problem
/Daily_coding_problem_2.py
UTF-8
1,519
4.59375
5
[]
no_license
""" Problem: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the...
true
765fbb9f14447f829cdba2fc8a957a1512507a02
Python
chrismabdo/airport-python
/apps/weather.py
UTF-8
191
3.03125
3
[]
no_license
import random class Weather: def __init__(self): self.conditions = ["sunny", "overcast", "stormy"] def weather_check(self): return random.choice(self.conditions)
true
5b5ad3ea5ad60085ceec65e5999aa5c98cf58fd8
Python
brennan6/DSCI551
/project_final/mysqlRanksConnector.py
UTF-8
868
2.640625
3
[]
no_license
from mysql.connector import Error import mysql.connector import json cnx = mysql.connector.connect(host = 'project-dsci551-ranks.c8u9e3pxnupz.us-east-1.rds.amazonaws.com', user = 'mbrennan6', password = 'songdsci551', database = 'songRanks') def pull_down_ranks(): """ (2) Pull down all...
true
07fa944369a136a34c5d1b9b20b56821eed2da03
Python
mylesmcleroy/planar-data-classifier
/planar_data_classifier.py
UTF-8
12,295
3.59375
4
[]
no_license
# coding: utf-8 # Planar data classification with one hidden layer # Packages # - [numpy](www.numpy.org) is the fundamental package for scientific computing with Python. # - [sklearn](http://scikit-learn.org/stable/) provides simple and efficient tools for data mining and data analysis. # - [matplotlib](http://mat...
true
cf29797e76a030296d6e52e6cf545063b6b3bf60
Python
liuhanyu200/pygame
/8/8-9.py
UTF-8
174
2.859375
3
[ "BSD-3-Clause" ]
permissive
# coding:utf-8 def show_magicians(magicians): for magician in magicians: print(magician) show_magicians(['gekongquwu', 'kongshoutaobailang', 'dianjujinghun'])
true
031ed4581c78c49b3b3552a76ab014529852c95e
Python
Bassmann/deepsecurity
/python/computer-status.py
UTF-8
7,268
2.625
3
[]
no_license
import json import os import sys import warnings import deepsecurity as api from deepsecurity.rest import ApiException from datetime import datetime def format_for_csv(line_item): """Converts a list into a string of comma-separated values, ending with a newline character. :param line_item: The list of lists t...
true
584bc2883fc95f60403141f029fab7a1b61ace20
Python
etmitchell/MTTime
/MTTime.py
UTF-8
2,004
3.28125
3
[]
no_license
from datetime import datetime import time import Tkinter def DateTimeInMagic(MEDITECH): MEDITECH = float(long(MEDITECH)) MTTime = MEDITECH if time.daylight == 1: #Add the difference between UTC Daylight Savings and MEDITECH time (320734800 seconds) MTTime += 320731200 else: #Add...
true
a92c4d44866769a62a10908e3a1aaa0ae6fdb0c8
Python
shikha735/Programs
/Competitive Programming/IB_Strings_Reverse_String.py
UTF-8
422
3.75
4
[]
no_license
# https://www.interviewbit.com/problems/reverse-the-string/ ''' Given an input string, reverse the string word by word. Example: Given s = "the sky is blue", return "blue is sky the". ''' class Solution: # @param A : string # @return string def reverseWords(self, A): li = A.split() li.re...
true
0c855755ae66b018c20a0d7a2b57769e63a5f89f
Python
roquesrolando/holberton-system_engineering-devops
/0x15-api/3-dictionary_of_list_of_dictionaries.py
UTF-8
713
2.6875
3
[]
no_license
#!/usr/bin/python3 """Gather data from API""" import json import requests import sys if __name__ == "__main__": info = {} site = 'https://jsonplaceholder.typicode.com/' user = requests.get(site + 'users').json() for x in user: ID = x.get('id') dos = requests.get(site + 'todos?userId={}...
true
1979b6d72815c967bf012d65effed314ceafdf31
Python
dm-alexi/acmp
/0001_0100/0031/0031.py
UTF-8
352
3.09375
3
[]
no_license
def derange(n): return 1 if n == 0 else 0 if n == 1 else n * derange(n - 1) + (-1)**n def c(n, k): a = b = 1 while n > k: a *= n b *= n - k n -= 1 return a // b with open("input.txt", "r") as f, open("output.txt", "w") as q: n, k = map(int, f.readline().split()) q.write...
true
4a80871374293318b3ecc2737f15a675731c4bc3
Python
iamshivamgoswami/Random-DSA-Questions
/task scheduler.py
UTF-8
746
2.859375
3
[]
no_license
import collections class Solution: def leastInterval(self, tasks: List[str], k: int) -> int: s = "".join(tasks) c = collections.Counter(s) stack = sorted(c.items(), key=lambda x: x[1]) char, count = stack.pop() lst = [[char] for i in range(count)] while stack and sta...
true