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
ebfff51cfa9f4ca5d1291cd2335eb27ece88d565
k-hikell/vsc_test
/hello.py
UTF-8
686
4
4
[]
no_license
# test file print("hello kitty") var_file = "index.html" with open(var_file) as file_in: contents = file_in.readlines() print("contents:") print(contents) print("\nwe printed the index.html file contents") #simple dictionary months = { 1: "January", 2: "February", 3: "March", 4: "April" } pr...
true
f859ca8eddc0773e32cdc6c6a19257a0fc9b2db5
Avyuktaj/pythonworks
/1 Print_sum_of__odd__numbers_using_range_and_loop w7.py
UTF-8
1,393
4.375
4
[]
no_license
#This Program is a sample program #Modellling for loop # using range function # What is range ? #range() generates the integer numbers between the given start integer to the stop integer, i.e., It returns a range object. # Using for loop, we can iterate over a sequence of numbers produced by the range() function # rang...
true
551de805114fb51777b1999e2d437a0d812ab86a
daniel-reich/ubiquitous-fiesta
/xjC7TM77RbrT6PhQ2_7.py
UTF-8
163
3.015625
3
[]
no_license
def switches(n): seq = ['0', '1'] for _ in range(n-1): seq = ['0' + i for i in seq] + ['1' + i for i in seq[::-1]] return seq.index('1' * n)
true
b6e95dc92ed37c42824ac266344d90480595f034
renshengqiang/PythonLearn
/control_flow.py
UTF-8
237
3.625
4
[]
no_license
a = 3 if a == 2: print("a=2") elif a == 3: print("a=3") else: print("a=", a) while a<10: print("a=", a) a=a+1 else: print("while loop is over") i = 10 for i in range(10, 15): if i == 14: break else: print("for loop is over")
true
bad16d0dbdf4ee3f5099517f337b7ccba49e562f
ryuz/jelly
/projects/ultra96v2/ultra96v2_udmabuf_sample/app/led_sample.py
UTF-8
556
2.625
3
[ "MIT" ]
permissive
import numpy as np import mmap import os import time def main(): # uio mmap uio_name = '/dev/uio4' uio_file = os.open(uio_name, os.O_RDWR | os.O_SYNC) uio_mmap = mmap.mmap(uio_file, 0x100000, mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE, offset=0) mem_array = np.frombuffer(uio_mmap, np.uint64,...
true
54fdec166f2eee05fc082981cf1bdc7dd74f4c8e
ThrallOtaku/python3Test
/base/day8/mystr/8字符串的格式化强化.py
UTF-8
849
4.09375
4
[]
no_license
#用于套路字符串,填充 #%c字符,%d整数,%s字符串,%f浮点数 %e指数 print("pass is %c --------" %('X')) print("何丰成有%d个女神" %(10)) #格式化严格对应,可能会出现异常 print("何丰成女神的名字=%s---" %("凤姐")) print("何丰成为女神花了%f元"%(123456.78321321)) print("何丰成为女神花了%.2f元"%(123456.78321321)) print("何丰成为女神花了%e元"%(123456.78321321)) print("何丰成为女神花了%.2e元"%(123456.78321321)) #10代表宽...
true
e0077c40e7a0bdaaed78d5757cfc0468fbb07e3c
leetuckert10/CrashCourse
/chapter_6/exercise_6-3.py
UTF-8
865
4.78125
5
[]
no_license
# Glossary # Using five words learned in the book as keys, create a dictionary of the # words and their meanings. glossary = { 'list': 'a data structure that stores a list of items of any data type', 'dictionary': 'a data structure that stores data using a set of key/value pairs', 'print': 'a function use f...
true
79aa0c84487e8d99eabbe252e186dc5c329cd2b7
mingruimingrui/E2EGraphSage
/e2e_graphsage/bin/import_from_tsv.py
UTF-8
12,101
2.578125
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Importing of graph data from tsv files """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os import random import argparse import snap import h5py import num...
true
2ace7d21bcd02a3fe6ecdedbc92a8fb29e90d773
mlaxn/Educational-Projects
/Python/Assignment#3/stack.py
UTF-8
4,811
3.28125
3
[]
no_license
import pandas as pd import time # Data Object for keeping track of streaks class Streak: def __init__(self, start, end, min_val, playerID): self.l = start # start index self.r = end # ending index self.v = min_val # minimum value self.playerID = playerID # the player id de...
true
51b37a5620b54ce34fd3ebd5ab66476500b41fab
nikitamahoviya/iarm
/iarm/arm_instructions/directives.py
UTF-8
6,812
3.015625
3
[ "MIT" ]
permissive
import iarm.exceptions from ._meta import _Meta import warnings import inspect class Directives(_Meta): """ Directives, unline instructions, perform their action immediately """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.equates = {} self.direc...
true
360503209ac363ebc0ba6cadf11a952758498a66
woshixiaomimei/cs61a-2021
/lab01/what_if.py
UTF-8
930
3.796875
4
[]
no_license
def ab(c, d): ''' >>>ab(10,20) 10 foo ''' if c > 5: print(c) elif c > 7: print(d) print('foo') >>> ab(10, 20) def bake(cake, make): ''' >>> bake(0,29) 1 29 29 >>>bake(1, "mashed potatoes") mashed potatoes 'mashed pot...
true
c39d4e9125f40e3af1ead21bb42b2a38a262eb14
NewenLai/Num_Romanos
/romanclass.py
UTF-8
6,995
3.703125
4
[]
no_license
class RomanNumber(): simbolos = { "unidades": ["","I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"], "decenas": ["", "X", "XX", "XXX", "LX", "L", "LX", "LXX", "LXXX", "XC"], "centenas": ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"], "millares": ["", "M", "MM", "MMM"] } ...
true
5bd633fea141f3eb62899a4a81c5c9c8888d487c
bamessenger/WebScrapy_DOC
/src/main/python/WebScrapy_DOC/filewriter.py
UTF-8
1,973
3.21875
3
[]
no_license
from openpyxl import Workbook, load_workbook class WriteFile: def __init__(self): self.wb = Workbook() self.existingDict = {} def currExcel2Dict(self, currMaster): # load workbook self.wb = load_workbook(currMaster) # select workbook sheet = self.wb.active ...
true
0b1f4fc1bd917d1b43372e10880b1867ae417224
iamTanTanTan/python_programming
/032把数组排成最小的数.py
UTF-8
775
4.3125
4
[]
no_license
''' 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。 例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。 ''' from functools import cmp_to_key class Solution: def build_minimum_number(self, numbers): if not numbers or len(numbers) <= 0: return '' numbers = [str(i) for i in numbers] ...
true
b721492ed0553a138affd2b546be84559589fd7b
bugengine/BugEngine
/mak/libs/glrp/parse/parser.py
UTF-8
11,198
2.6875
3
[ "BSD-3-Clause" ]
permissive
from .production import Production from .grammar import Grammar from ..lex import Token from be_typing import TYPE_CHECKING, TypeVar from abc import abstractmethod import os import re import hashlib import zlib import base64 try: import cPickle as pickle except ImportError: import pickle # type: ignore LOAD_O...
true
81e7025b5d675be296bca078a4261283ab126ac5
HenryDaiCode/PEulermusings
/Problem 053.py
UTF-8
267
3.359375
3
[]
no_license
from math import factorial def comb(n, r): return factorial(n) // (factorial(r) * factorial(n - r)) overMillion = 0 for n in range(101): for r in range(n + 1): if comb(n, r) > 1000000: overMillion += 1 print(overMillion)
true
9cef2b423e008397a2f7834b80f1ceda5bca9e44
lalprasad/Ud-Project3-Submission
/automatedtesting/selenium/selenium-tests.py
UTF-8
2,571
3.078125
3
[]
no_license
#!/usr/bin/env python from selenium import webdriver from selenium.webdriver.chrome.options import Options as ChromeOptions import datetime # Create the timestamp def date (): return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # Start the browser and login with standard_user def login (user, password): ...
true
b6310296ea423e3e217c379a797b087325b804d0
Palkess/discordbot3.4
/main.py
UTF-8
3,445
2.609375
3
[ "MIT" ]
permissive
import discord import json import threading import os import asyncio import xmltodict client = discord.Client() audioplayer = None @client.event @asyncio.coroutine def on_message(message): # Current solution to updating commands during runtime f = open("commands.json", "r") jsonData = f.rea...
true
1ac67af8e501b502437eaca4a2c4f9e04099d08d
rdenadai/ia870p3
/ia870/iaaddm.py
UTF-8
339
2.71875
3
[ "BSD-2-Clause" ]
permissive
# -*- encoding: utf-8 -*- # Module iaaddm import numpy as np def iaaddm(f1, f2): from ia870.ialimits import ialimits if type(f2) is np.array: assert f1.dtype == f2.dtype, 'Cannot have different datatypes:' k1,k2 = ialimits(f1) y = np.clip(f1.astype(np.int64)+f2, k1, k2) y = y.astype(f1.dt...
true
f0dfdbf4c883809c0e95239a0010e7c0c8a460dd
saigoutham235/python
/sc.py
UTF-8
52
2.671875
3
[]
no_license
a=input().split() print(len("".join(x for x in a)))
true
8bfebda4eded430abe0c62b60d006d496c64c29d
alpharender/SFIAProject1
/tests/test_app.py
UTF-8
2,699
2.703125
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
#!/usr/bin/python3 import unittest from flask_testing import TestCase from flask import url_for from application import app, db from application.models import Parent, Player class TestBase(TestCase): def create_app(self): app.config.update(SQLALCHEMY_DATABASE_URI="sqlite:///") app.config['SECRET_...
true
aee0343377b7163cf6e4f5e30b7beeb36ab10cd5
michael-bailey/python-p2p-messaging
/interface/login_window.py
UTF-8
4,138
2.828125
3
[]
no_license
#Date: 11/08/2019 #Time: 20:00 #Imports import tkinter import tkinter as tk from tkinter import ttk class Login_Frame(tk.Tk): def __init__(self, *args, **kwargs): super.__init__(self, *args, **kwargs) self.iconbitmap(self, default="") self.wm_title(self, "Login") #tk.Tk.overridered...
true
75320e750f4e1ee1c17a8913930088ecc76d1d49
lingfromSh/liquidpy
/liquid/tags/tag_else.py
UTF-8
1,176
2.96875
3
[ "Apache-2.0" ]
permissive
"""Else tag in following situations ```liquid // in if {% if ... %} ... [{% elsif ... %}] ... {% else %} ... {% endif %} // in case / when {% case x %} {% when ... %} ... {% when ... %} ... {% else %} ... {% endcase %} // in for {% for ... %} ... {% else %} ... {% endfor %} ``` """ from .manag...
true
04730a8295b70d7c3ff135cc4321eeaf1385cf62
a652895216/example_of_qianduan
/pachong/pa7.py
UTF-8
590
2.6875
3
[]
no_license
from urllib import request,error if __name__ == '__main__': url='http://www.baidu.com' try: #用try万一出问题崩溃 req = request.Request(url) rsp = request.urlopen(req) html = rsp.read().decode() print(html) except error.HTTPError as e: print("Httperror:{0}".format(e.reason)...
true
98acc3ff6cb371209841fdc638328339c1205f0a
zpyao1996/leetcode
/random pick with weight.py
UTF-8
610
3.578125
4
[]
no_license
import random from bisect import bisect class Solution(object): def __init__(self, w): """ :type w: List[int] """ self.sum_list = [] c_sum = 0 for weight in w: c_sum += weight self.sum_list.append(c_sum) self.total_weight = self.sum_...
true
9878dad313480ecfe69f2d47231f2b3a71d9f1f5
amanjainIIITB/RBAC
/src/RBAC.py
UTF-8
6,604
2.515625
3
[]
no_license
from CONSTANT_MESSAGE import message from prettytable import PrettyTable import sys import json # Opening JSON file with open('src/config.json') as json_file: config = json.load(json_file) class RoleBaseAccessControl: def loginUser(self, userID): try: if userID in config['USER']: ...
true
acdf383b6b31f4fb19151e2bac65178cc25afa4e
edt-yxz-zzd/python3_src
/seed/algo/bucket_sort/classify.py
UTF-8
1,247
3.25
3
[]
no_license
__all__ = ''' classify '''.split() def classify(alphabet_size, iterable, key , *, output = None, return_output=False): ''':: UInt -> [a] -> (a->UInt) -> [[a]] input: alphabet_size :: UInt iterable :: Iter a key :: a -> UInt[0..alphabet_size-1] output :: None | [[a]]{alphabet_size....
true
87a9b57f87164caeb8e3293258bca30d18a58bfb
snuderl/Project-euler
/prob81.py
UTF-8
477
2.984375
3
[]
no_license
with open("matrix.txt") as f: matrix = [[int(x) for x in line.strip().split(",")] for line in f.readlines()] size = 80 def v2(): minimals = [[0] * (size ) for x in range(size)] for x in range(0, size): for y in range(0, size): if x > 0: s0 = minimals[x - 1][y] m = s0 if y > 0: s1 = minimals[...
true
adde802146d98612b2efded9793f157e8093ed51
DenisPecherin/Lab-2-
/1.py
UTF-8
1,915
3.71875
4
[]
no_license
import timeit # Сравните время вычисления 35-го числа Фибоначчи при помощи формулы Бине, # итерационной формулы, метода «разделяй и властвуй», метода нисходящего динамического программирования, # метода восходящего динамического программирования. # Формула Бине code_to_test1 = """ from pervoe_zadanie1 import f1 """ p...
true
1b54733b367e081c4e6b95987d951bf930e17f71
david-alexander-white/dagster
/examples/dagster_examples/bay_bikes/resources.py
UTF-8
4,394
2.78125
3
[ "Apache-2.0" ]
permissive
import json import os import shutil from abc import ABCMeta, abstractmethod from google.cloud import storage from six import with_metaclass from dagster import Field, List, String, resource, seven class AbstractFileTransporter(with_metaclass(ABCMeta)): """ This is a class that moves data between your filesy...
true
7b28490f796ab88058b0a1bd193f0717a79c569d
dezhili/My_learnings
/tensorflow_note/tensorflow手册/tensorflow_note.py
UTF-8
6,624
4.0625
4
[]
no_license
# Introduction: ''' Tensorflow : graph : 使用图来表示计算任务 Session: 在被称之为会话的上下文(context)中执行图, 为了进行计算,图必须在会话里被启动。 会话将图的 op 分发到诸如CPU GPU之类的设备,同时提供执行op的方法。 tensor: 使用tensor 表示数据, 每个Tensor是一个类型化的多维数组,numpy ndarray对象 图像集 表示为一个四维浮点数数组,这四个维度分别是[batch, height, width, channels] Variable : 通过变量 维护状态 op: Tensorflow 是一...
true
9e2e39c90889e46fe87b60a6a8e3dbe5c62da1b3
asdf2014/algorithm
/Codes/stardrewer/3_longest-substring-without-repeating-characters/solve.py
UTF-8
1,004
3.28125
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Author : Star @Email : zsdzzydos@gmail.com @Time : 2019年09月09日 13:48 @Desc : 无重复字符的最长子串 """ class Solution(object): def lengthOfLongestSubstring(self, s): """ 68 ms, 7.5 MB 滑动窗口解法 :type s: str :rtype: int "...
true
ba7b99e3f2c1c511b1ad2576f368f7e6db818ba0
lilyandcy/python3
/leetcode/classMagicDictionary.py
UTF-8
955
3.75
4
[]
no_license
class MagicDictionary: def __init__(self): """ Initialize your data structure here. """ def buildDict(self, dict: List[str]) -> None: """ Build a dictionary through a list of words """ self.dict = dict def search(self, word: str) -> bool: ...
true
7ec7500fb906e4f3061b8d210669c8ac0e528866
Shahidraza-Shaikh/FaceRecognitionWithPython
/Live_FaceRecognition.py
UTF-8
2,203
3.484375
3
[]
no_license
# Python Program to Detect the Face of Human with openCV & Frontal Face cascade xml File # ---- Input taken is Either a Path of a Recorded Video OR Accessing a WebCam ---- # Importing openCV Module import cv2 # Accessing the frontalface cascade xml file with cv2 face_cascade = cv2.CascadeClassifier('haarcas...
true
5d7a2e9c984cd39696f4e82edd55efc3dcdd8077
AndersHR/useless_roomba---Project-in-TFY4190-Instrumentation
/useless_roomba.py
UTF-8
3,132
2.890625
3
[]
no_license
import RPi.GPIO as GPIO import random import time as time from distance_sensor import DistanceSensor from servomotor import ServoMotor from dcmotor import DCMotor class Roomba: def __init__(self, MotorE, MotorA, MotorB, servo_pin, trigger, echo,green,yellow,red,distance_timer): GPIO.setwarnings(F...
true
5119dd6711f4741a154545fa801d46e850ee42ce
Celesta1998/Homework3
/Калькулятор.py
UTF-8
894
3.859375
4
[]
no_license
print('Выберите знак!') while True: a = input("Знак(+,-,*,/): ") if a == '0': break if a in ('+','-','*','/'): b = float(input("b=")) c = float(input("c=")) if a == '+': print('Ваша сумма прибавления =',"%.2f" %(b+c)) elif a == '-': ...
true
32f48527785de74f24f287bd505830276d65675c
lalo1898developer/Java_level1_Bot
/main.py
UTF-8
2,549
2.9375
3
[]
no_license
# >> Imports necesarios import telebot import os from Utils.Keyboards import get_main_keyboard,get_clear_keyboard from Services.Java import Java from Services.JokeAPI import JokeAPI from Services.UnplashAPI import UnplashAPI # << # >> Inicializar bot API_TOKEN = os.getenv('TOKEN_TELEBOT') bot = telebot.TeleBot(API_TOK...
true
cd1f4cd2beacf8586ec25d7116c2aab2eb529534
Karthik1000/Information_Retrieval_project
/crawl/mcheck.py
UTF-8
4,780
2.5625
3
[]
no_license
from bson import ObjectId from pymongo import MongoClient import re import itertools #client = MongoClient() client = MongoClient('localhost', 27017) mydatabase = client['urldata'] urls = mydatabase.urls def splitfun(u): common = ["is", "the", "a", "an", "and", "or", "have", "of", "for", "was", "this", "that", ...
true
1fd6b8aaba6e3c40b92857658f09b79ce152e718
EnochMeng/exercise_library
/atm/core/main.py
UTF-8
3,004
2.796875
3
[]
no_license
##main program import collections from core import logger from core import auth from core import transaction from core import account user_data={ 'account_id':None, 'is_authentiacted':False, 'account_data':None} transaction_logger=logger.logger('transaction') access_logger=logger.logger('access') def r...
true
bfbcb5d86005d4842a593263f3de6e4b451455e0
lamsoa729/chi_pet
/tests/test_chi_node.py
UTF-8
1,963
2.734375
3
[ "MIT" ]
permissive
#!/usr/bin/env python """@package docstring File: test_chi_node.py Author: Adam Lamson Email: adam.lamson@colorado.edu Description: """ from pathlib import Path from shutil import rmtree import pytest import yaml from chi_pet.chi_node import ChiNode MOCK_YAML_DICT = {"mock_param.yaml": {"param": 1}} def clean_mock...
true
94a781fa961bf5472192d628b4fa37c6f7959a0a
mvarshne0/traccar
/GetDevicesData.py
UTF-8
1,557
3.140625
3
[]
no_license
#Python script to get the devices data from traccar portal. # How many devices are online in a group? # How many devices are offline in a group? # How many devices are Unknown in a group? import csv import requests import json import uuid if __name__ == "__main__": URL = '' userName = '' ...
true
873ef1dfb04dc67b9f327a0cd2bc45ec0d935183
HonkeeChan/curl_video_address
/test/thread_test.py
UTF-8
1,171
3.171875
3
[]
no_license
#coding=utf-8 import threading from time import ctime,sleep def music(func,func1): print func print func1 for i in range(2): print "I was listening to %s. %s" %(func, i) sleep(1) def move(func): for i in range(3): print "I was at the %s! %s" %(func, i) sleep(5) def ne...
true
c4bb402afa23837ac8d1525c30927a13ee2ad501
sv91/Morpho-Organizer
/test.py
UTF-8
143
2.796875
3
[]
no_license
from parse import * a = parse("Point({p}) = {x},{y},{z},{s}","Point(0) = -9.23706e-16,2.84217e-16,4.44089e-17,7.4685") print(a) print(a['x'])
true
657000344278588e5dcbf590c22590ebf47b9a7a
krockfr/hexapode_pi
/client.py
UTF-8
733
3.046875
3
[]
no_license
#!/usr/bin/env python # coding: utf-8 import socket hote = "127.0.0.1" port = 12801 connexion_avec_serveur = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connexion_avec_serveur.connect((hote, port)) print("Connexion établie avec le serveur sur le port {}".format(port)) msg_a_envoyer = b"" while msg_a_envoyer !...
true
744576b7ac97b52302b595d73b05165e04b1cafd
mcodt1702/nyc1
/crash_course/pizza.py
UTF-8
484
3.828125
4
[]
no_license
pizzas = ['peperoni', 'margarita', 'cuatro stragioni', 'hawaian', "meat lover's"] print(pizzas) for pizza in pizzas: print(f'I love {pizza} pizza ') print('\nI love all the pizzas you can make!!!') print(f'the first three items of the list are {pizzas[0:3]}') print(f'The last three items are{pizzas[-3:]}') frien...
true
351307565cb15de720fa959a61e19e0c47545406
iancwwong/Text-Based-Adventure-Game
/src/Agent.py
UTF-8
10,003
3.515625
4
[]
no_license
#!/usr/bin/python # ------------------------------------------------------- # agent.py # Agent for Text-Based Adventure Game # COMP3411 Artificial Intelligence # UNSW Session 1, 2016 # Written by: Ian Wong and Jason Ng # Date: 26/04/2016 # ------------------------------------------------------- # The agent for ...
true
30afc78d5d70fe11c424317dbf3bbe7337ef39f6
absbin/genreator-test
/davin_reddy/generators/generators_fibonacci.py
UTF-8
206
3.140625
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Thu Dec 28 20:35:18 2017 @author: ABSBIN """ def fib(): a,b=0,1 while True: yield a a,b=b,a+b for f in fib() : if f<50: print(f)
true
ce44b142d46f241d4d7128c6cdd31e381b1d6f6a
ethansudman/Research
/Research/KarateClub.py
UTF-8
373
2.953125
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sat Jun 26 17:04:07 2021 @author: Ethan_000 """ import networkx as nx G = nx.karate_club_graph() comms = list(nx.algorithms.community.girvan_newman(G)) kclique = list(nx.algorithms.community.kclique.k_clique_communities(G, 4)) print(comms) print('Length:') print(len(comms))...
true
7ce553f6805e8c8b813a9ebdf0393622654d16ca
TheComet/wavesim
/experiments/2d-wavesim/Simulation.py
UTF-8
7,710
2.890625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
import numpy as np import math import colorsys import pygame from scipy.fftpack import dct from Updateable import Updateable def idct(arr): return dct(arr, type=3) / (2 * len(arr)) def dct2(arr): return dct(dct(arr, axis=0), axis=1) def idct2(arr): along_x = dct(arr, type=3, axis=0) / (2 * arr.shape[0])...
true
2ea2fdd0583d30c1eba398780fc6292bc6c08495
li-ang/sublime-markdown-popups
/st3/mdpopups/coloraide/util.py
UTF-8
8,793
2.578125
3
[ "MIT" ]
permissive
"""Utilities.""" import decimal import math import numbers import re import warnings from functools import wraps RE_FLOAT_TRIM = re.compile(r'^(?P<keep>-?\d+)(?P<trash>\.0+|(?P<keep2>\.\d*[1-9])0+)$') NaN = float('nan') INF = float('inf') ACHROMATIC_THRESHOLD = 0.0005 DEF_PREC = 5 DEF_FIT_TOLERANCE = 0.000075 DEF_ALPH...
true
46fb948dc07c15eea29a4b22b9440515b6d7fcb7
JamesWo/Algorithms
/linkedList/kthlast/kthlast.py
UTF-8
453
3.859375
4
[]
no_license
# returns kth last element from linked list import sys sys.path.append('..') from linkedList import * def kth(node, k): length = 0 curr = node while curr: length += 1 curr = curr.next while length > k: length -= 1 node = node.next return node l = createLinkedList(...
true
d2664983429cd1a65a75175c5bdf579f51b8b62a
andycasey/ges-wg15-homogenisation
/homogenisation/rules/groups.py
UTF-8
17,522
2.5625
3
[]
no_license
# coding: utf-8 """ Rules for updating groups of duplicate stars in Gaia-ESO WG data sets. """ from __future__ import division, print_function __author__ = "Andy Casey <arc@ast.cam.ac.uk>" __all__ = ["DeleteDuplicateRowsRule", "UpdateDuplicateRowsRule"] # Standard library import json import logging import re import...
true
a8ad281f8ffab36d132c8d20a0d1d795b46e336e
yuty2009/eeg-python
/common/regularizer.py
UTF-8
2,978
3.125
3
[]
no_license
# -*- coding: utf-8 -*- # # reference: https://towardsdatascience.com/different-types-of-regularization-on-neuronal-network-with-pytorch-a9d6faf4793e import numpy as np from abc import ABCMeta, abstractmethod class Regularizer(object): __metaclass__ = ABCMeta @abstractmethod def add_param(self, param): ...
true
0c9236e7da66f1c9a18be41ea898f4c948b56fe2
sachinolickan/Basics
/palianslice.py
UTF-8
125
3.5625
4
[]
no_license
str=input("enter the word:") if (str[::-1]==str[0: ]): print("word is paliandrome") else: print("not a paliandrome")
true
73a3a2bb6f3d8e72da4c1cfb09997eab4a27e6fb
annarob/testing
/christopher's programming/sunrisemath.py
UTF-8
138
2.796875
3
[]
no_license
print('welcome to sunrise math lab') print('type plus, minus, times, divide, or fractions') plus = ('1 + 1, 2 + 1, 4 + 3, 5 + 6, 7 + 9.')
true
92d447f4d22e03a1197777cfb89c5b6e73b8f8b3
mstfakdgn/full-python
/Archive/test.py
UTF-8
12,900
2.84375
3
[]
no_license
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*- import warnings from sksurv.metrics import cumulative_dynamic_auc warnings.filterwarnings("ignore") import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.metrics import roc_auc_score, roc_curve, confusion_matrix, classification_report from ...
true
8fbef21bf4dabd1db1682695f45a6acc05f8d6b7
rinshu2510/Data-Science
/pandas_series.py
UTF-8
443
3.25
3
[]
no_license
import numpy as np import pandas as pd labels = ['a','b','c'] my_data = [10,20,30] arr = np.array(my_data) d = {'a':10 , 'b':20 , 'c':30} # print(pd.Series(data=my_data)) # OR print(pd.Series(my_data)) print(pd.Series(my_data,labels)) print(d) print(pd.Series(d)) ser1 = pd.Series([1,2,3,4],['India','USA','UK','France...
true
27e9950c0bec64224f56ccad639a66522f31791e
Salcon77/Python-Basics
/Flow Control/While Loop.py
UTF-8
703
4.6875
5
[]
no_license
#WHILE LOOPS # The while loop in Python is used to iterate over a block of code as long as the test expression (condition) is true. # In while loop, test expression is checked first. The body of the loop is entered only if the # test_expression evaluates to True. After one iteration, the test expression is checked agai...
true
1beb95c43f8aab1c54e6e0d0ca136de40a7ee575
hcxie20/pdf_converter
/converter.py
UTF-8
881
2.6875
3
[]
no_license
import os from pdf2image import convert_from_path # Store Pdf with convert_from_path function def is_pdf(file_name, file_path): return os.path.isfile(os.path.join(file_path, file_name)) and file_name[-4:] == ".pdf" pdf_dir = "/Users/xiehaochen/Desktop/hospital/第二医院" pdf_names = [file_name for file_n...
true
00ae762819475d4f99f5cbadae2131a88ea6865b
Bluegreen55/first
/dotprod.py
UTF-8
1,264
4.59375
5
[]
no_license
## TODO: Fill in the dotproduct() function to calculate the ## dot product of two vectors. ## ## Here are the inputs and outputs of the dotproduct() function: ## INPUTS: vector, vector ## OUTPUT: dot product of the two vectors ## ## ## The dot product involves mutliplying the vectors element ## by element and ...
true
d60bc88c92b515feb5c8df81f3b4b0e27c810121
maiihegazy/Test-Project---Car-Controlled-by-a-Web-Application
/car_movement.py
UTF-8
1,558
2.921875
3
[]
no_license
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) enL = 6 enR = 12 mL_a = 27 mL_b = 22 mR_a = 23 mR_b = 24 speed = 100 GPIO.setup(enL , GPIO.OUT) #Enable A GPIO.setup(enR , GPIO.OUT) #Enable B GPIO.setup(mL_a , GPIO.OUT) #out1 GPIO.setup(mL_b , GPIO.OUT) #out2 GPIO.setup(mR_a , GPIO.OUT) #out3 GPIO.setup(mR_b , GPIO.OU...
true
fa9ec4227038bc7303d53e14c9fa32a73f4c8263
Okinas/Epitech-first-year
/Maths/105torus_2019/newton.py
UTF-8
440
3.171875
3
[]
no_license
import math from function import function from function import derivative def newton(args, x0, n): if derivative(args, x0) == 0: exit(84) x = x0 - (function(args, x0) / derivative(args, x0)) if x < 0 or x > 1: exit(84) if round(x, args['n']) != round(x0, args['n']): print("x = {...
true
9f1686dffb527ae6b4ba6fd95a81c0fe1c5dc6b6
aaronepv/PR01-project-python
/pass.py
UTF-8
1,221
3.8125
4
[]
no_license
import random as rd digit1=["abcdefghijklmnopqrstuvwxyz","0123456789","ABCDEFGHIJKLMNOPQRSTUVWXYZ","@#%$&*-_"] def f_usuario(): user=input("Please intruduce your user name ") return user def f_len(): print("Please choose the length of your password") number_len =int(0) while number_len < 4 o...
true
719454944d95f4a19e9f25bb1bc74f8e96f56894
kunal01996/pybasics
/gkg/pp/ch8.py
UTF-8
911
4.21875
4
[]
no_license
# Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), # compare them, print out a message of congratulations to the winner, and ask if the # players want to start a new game) # # Remember the rules: # # Rock beats scissors # Scissors beats paper # Paper beats rock import ...
true
df4b282b3e261016d47ba774b2b36ec6b31c2888
joeylitalien/project-euler
/p32.py
UTF-8
513
3.796875
4
[]
no_license
#!/usr/bin/python import time def is_pandigital(n, s = 9): n = str(n) return len(n) == s and not '1234567890'[:s].strip(n) def pandigital(): p = set() for i in range(2,100): start = 1234 if i > 9: start = 123 for j in range(start, 10000/i+1): if is_pandigital(str(i) +...
true
7c77c64567afd59ca3a73dbd9721514dbfe1a62c
Ann-Hubskaya/1st
/5th lesson/hw_11_C.py
UTF-8
420
3.78125
4
[]
no_license
h = int(input('Please enter height: ')) for i in range(h): for j in range(h*2): if ( h//2 >= i > 0 and h + i > j > h - i - 1 or j == h - i - 1 and i <= h//2 or i >= h//2 and i == j or i > h//2 and j == h*2 - 1 - i - 1 and j > h*2 - h - 1 ...
true
712eabb773bb1a1b997b1f745110570bf8ea7d95
thuspatrick/PYTHON-EXERCICES
/exercices/morefizzbuzz.py
UTF-8
933
3.984375
4
[]
no_license
# Nettoyer la console avant le demarrage du programme # import os os.system('clear') ####################################################### ################## # counting FIZZBUZZ # ################# num = 1 fizzes = 0 buzzes = 0 fizzbuzzes = 0 fizval = [] buzval = [] fizbuzval = [] while num <= 1000: if ((num % 3)...
true
81b82698808e8d4563a239652089f9622aafbd73
innovator-zero/CS420_ML_Project
/augmentation.py
UTF-8
2,856
2.796875
3
[]
no_license
import os import glob import numpy as np from keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img, array_to_img def augmentation(path_aug='data_aug/'): if not os.path.exists(path_aug): os.mkdir(path_aug) if not os.path.exists(path_aug + 'tmp'): os.mkdir(path_aug + 'tmp'...
true
c705f05358ed845959304773c7b189f140a53e5a
sadsadperson/The-Wanderer----VERSION-2.0
/stuff/shop.py
UTF-8
2,121
3.5625
4
[]
no_license
import util from colorama import Fore, Style import database def shop(player): while True: util.clear() print(Fore.GREEN + "GOLD: " + str(player['gold']) + ' | LIFE: ' + str(player['life'])) shop_list = [ ['[1]', 'Sword', '10 Gold'], ['[2]', 'Shield', '10 Gold'], ['[3]', 'Bow', '10 Gold'], ['[4]',...
true
a28b58adc825634f27a68d58bf51ab83700817b7
mberkanbicer/Very-Unfriendly-Train
/Code/SwarmHandler.py
UTF-8
27,804
2.5625
3
[]
no_license
#region Imports from enum import Enum import copy as cp import numpy as np import os import random as rn import sys import time as tm sys.path.append(os.path.abspath(".")) fro...
true
5df2b41f4f5575d29f65d78a89c54dd27ebafdca
jenkspt/CarND-MiniFlow
/5_forward_propagation_solution/nn.py
UTF-8
1,184
3.90625
4
[ "MIT" ]
permissive
""" This script builds and runs a graph with miniflow. There is no need to change anything to solve this quiz! However, feel free to play with the network! Can you also build a network that solves the equation below? (x + y) + y """ from miniflow import * x, y = Input(), Input() f = Add(x, y) feed_dict = {x: 10,...
true
06b149b6766030a377728eaa7a762e4582377940
crazykuma/leetcode
/python3/0198.py
UTF-8
563
3.078125
3
[]
no_license
from typing import List class Solution: def rob(self, nums: List[int]) -> int: # 当前位置的最大值=max(上一个位置的值,上两个位置的值+当前这个位置的值) if not nums: return 0 if len(nums) < 3: return max(nums) dp = [0]*(len(nums)+1) dp[0] = 0 dp[1] = nums[0] for i in...
true
dd77877898f0a1214396525957fc6788b08c65cf
sarbor/infin
/infin/validator.py
UTF-8
1,351
3.40625
3
[]
no_license
import json from typing import Any, Iterable import jsonschema class Validator: def __init__(self, schema_filename: str) -> None: """A class for validating whether given JSON data conforms to a given schema Args: schema_filename (str): path of file containing json schema """ ...
true
69840cce9691bdb69323ef69b2db17a454c31530
deshmukh-saurabh/Image-Brightness-Detection-using-Deep-Learning
/src/model.py
UTF-8
1,554
2.765625
3
[]
no_license
# imports import pickle import numpy as np from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation, Flatten from keras.layers.convolutional import Conv2D, MaxPooling2D from keras.utils import np_utils # load the data from pickle pickle_in=open("../pickled_data/X.pickle", "...
true
08102802eccbd2bbd5f744cd1a3e3b8f96c2ae42
Liudzz/LeetcodeEveryday
/1/125.验证回文串.py
UTF-8
723
3.921875
4
[]
no_license
class Solution: def isPalindrome(s: str) -> bool: l = len(s) i,j = 0,l-1 def checkalaph(chr): if (ord(chr) in range(ord('a'),ord('z')+1)) or (ord(chr) in range(ord('A'),ord('Z')+1)): return False else: return True while(i<j): ...
true
026b92058f1590eb416680d650af69e2237a38b1
huhudaya/leetcode-
/LeetCode/344. 反转字符串.py
UTF-8
816
4.1875
4
[]
no_license
# 344. 反转字符串.py ''' 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 char[] 的形式给出。 不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。 你可以假设数组中的所有字符都是 ASCII 码表中的可打印字符。 示例 1: 输入:["h","e","l","l","o"] 输出:["o","l","l","e","h"] 示例 2: 输入:["H","a","n","n","a","h"] 输出:["h","a","n","n","a","H"] 链接:https://leetcode-cn.com/problems/reverse-...
true
20bfd5306e483591d3c33ac43b5a1fd0efdfb963
ty-porter/Reddit-ID-Checker
/words.py
UTF-8
250
2.6875
3
[]
no_license
import json class Words: __WORD_PATH = 'english-words/words_dictionary.json' @classmethod def load_dictionary(cls): with open(Words.__WORD_PATH, 'r') as file: dictionary = json.load(file) return dictionary
true
1f9a7926c761bea22440ec5e789999a6eedd375c
deepdrivepl/CTMC-v1-solution
/MOT/yolo2MOT/yolo2MOT.py
UTF-8
1,196
2.671875
3
[]
no_license
import argparse import os import json from glob import glob from txt2MOT import txt2mot from json2MOT import json2mot if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--input', type=str, required=True) parser.add_argument('--out_dir', type=str, required=True) parser...
true
d1d4c243dc9a4fe64912a7c6b1f5c10f86b714f6
Omega094/lc_practice
/goodyhandy/ImplementQueueUsingStack.py
UTF-8
1,016
3.765625
4
[]
no_license
class Queue(object): def __init__(self): """ initialize your data structure here. """ self.stackForPush = [] self.stackForPop = [] def push(self, x): """ :type x: int :rtype: nothing """ self.stackForPush.append(x) return ...
true
601e93c9c08921109f9296fe054db861fb7e2604
777acauleytosi/python
/avg2.py
UTF-8
487
4.28125
4
[]
no_license
# avg2.py # A program to average three scores # by: Macauley Tosi def main(): print("This program averages three scores you give.") x = eval(input("Enter your first score from 1 to 100 ")) y = eval(input("Enter your second score from 1 to 100 ")) z = eval(input("Enter your thrid score from 1 to...
true
1b4e1813b710278b25fbba4ac489284255d7ee7f
Arvaesri/Python_OS
/bash/random_exit.py
UTF-8
131
2.953125
3
[]
no_license
#!C:\PythonAqui\python import sys import random value = random.randint(0,3) print("Returning Exit: " + str(value)) sys.exit(value)
true
97670ca80a4da4387e74160bab81bef0934e84c0
3vikram/Application-Security-Fix
/XSS_URI.py
UTF-8
2,283
2.890625
3
[]
no_license
import requests import json import ast def xss_test(**url_params): file = input("Enter the xss payloads containing file to test: ") uri = input("Enter the uri to test: ") uri_parameters = input("Enter the uri parameter to test: ") req_headers = ast.literal_eval(input("Enter the headers to be sent with ...
true
2395d413503d2e069cc03f9c027623e458ca0960
RainFZY/LeetCode-Practice
/494.目标和.py
UTF-8
856
3.46875
3
[]
no_license
# # @lc app=leetcode.cn id=494 lang=python3 # # [494] 目标和 # # @lc code=start # minus + plus = target # minus + plus + (-minus + plus)= target + (-minus + plus) # 2plus = target + sum # plus = (target + sum)/2 # --> goal: find some numbers in nums with sum (target + sum)/2 # 转换成0-1背包问题 class Solution: def findTarg...
true
d562ff6bbc4b4bee861484065f531e34a3569801
nao1412/Competitive_Programing_Codes
/Atcoder_contests/ABC/141C.py
UTF-8
232
3
3
[]
no_license
n, k, q = map(int,input().split()) a = [] for i in range(q): b = int(input()) a.append(b) pnt = [0] * n for x in a: pnt[x-1] += 1 for j in range(n): if pnt[j] > q-k: print('Yes') else: print('No')
true
04132783faaf627c227c32217b7a2dfe82d417e8
msmbuilder/vde
/vde/vde.py
UTF-8
12,784
2.515625
3
[ "MIT" ]
permissive
# Author: Carlos Xavier Hernandez <cxh@stanford.edu> # Contributors: Muneeb Sultan <msultan@stanford.edu> # Hannah Wayment-Steele <h.wayment-steele@stanford.edu> # Brooke Husic <brookehusic@gmail.com>, # Copyright (c) 2017, Stanford University and the Authors # All rights reserved. import n...
true
01e5a4c5f4d63756970cb6d97592f0f8341d0536
brenj/solutions
/hacker-rank/python/data-types/lists.py
UTF-8
380
3.546875
4
[]
no_license
# Loops Challenge """ You have to initialize your list L = [] and follow the N commands given in N lines. """ lines = int(raw_input()) list_ = [] for _ in range(0, lines): line = raw_input().split() command = line.pop(0) arguments = map(int, line) if line else [] if command == 'print': print ...
true
2774395e2d3967dd3d0036e8825ff96b1a3f49f6
arunpandian7/skywatch-ai
/skywatchai/utils.py
UTF-8
956
2.9375
3
[]
no_license
import numpy as np import cv2 import pathlib def preprocess_image(img, target_size): processed_img = cv2.resize(img, target_size) processed_img = np.expand_dims(processed_img, axis=0) processed_img = processed_img / 255 return processed_img def getEuclideanDistance(a, b): euclidean_distance = a -...
true
19d9f27c21bcd4a128f17c4bb600e76b9635b0bf
anectto/basicpythonprogramming
/ch05-numbers-in-python/4-work-with-numbers.py
UTF-8
383
4.59375
5
[]
no_license
# 5.4 - Work With Numbers # Solutions to Review Exercises # Exercise 1 num = float(input("Enter a number to be rounded to two decimal places: ")) print(f"{round(num, 2)}") # Exercise 2 num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) print( f"The difference between {num1} and...
true
228677771fe209dd8ff0186e9d1703a0aa0b6a61
VioletWnk/VirtualSchoolApp
/virtual_school.py
UTF-8
967
2.71875
3
[]
no_license
from menu import Menu from school_service import SchoolService from student_service import StudentService class VirtualSchool: def __init__(self): self.menu = Menu() self.school_service = SchoolService() self.student_service = StudentService() def start(self): while True: ...
true
cd4c0b257eaad5ee0ad88c4f86e70e58a02db1ec
sd86519529/YzBgdMmtSysTestProject
/common/ftp_connect.py
UTF-8
1,366
2.640625
3
[]
no_license
import ftplib import os from common.config_manager import ConfigManager class FtpConnect(object): def __init__(self): obj = ConfigManager.get_ini_obj() self.username = obj.get('ftp_config', 'username') self.password = obj.get('ftp_config', 'password') self.host = obj.get('ftp_confi...
true
c1cf45c29d8e2a509096fe6fd5e2697444dc8973
GaelVaroquaux/nipy
/nipy/utils/compat3.py
UTF-8
356
2.71875
3
[ "BSD-3-Clause" ]
permissive
""" Routines for Python 3 compatibility These are in addition to the nibabel.py3k routines. """ import sys if sys.version_info[0] >= 3: def to_str(s): """ Convert `s` to string, decoding as latin1 if `s` is bytes """ if isinstance(s, bytes): return s.decode('latin1') r...
true
b13ce7da1e0eb143f05cd40211d546f566a5ff74
Sleeither1234/t10-HUATAY.CHUNGA
/huatay/submenu_CLI7.py
UTF-8
2,857
3.375
3
[]
no_license
def f_constante(): def ver_grafica(): print("##########################") print("# | F.constante #") print("# ___|________ #") print("#______|_______ #") print("# | #") print("##########################") def forma(...
true
12cbbd36c89e2be0f58f977fd6cdf38072b830e2
mc-lovin-mlem/concept-embeddings-and-ilp
/sources/model/finetuning/model_loaders/mobilenetv2.py
UTF-8
1,606
2.625
3
[ "MIT" ]
permissive
"""Loader of modified MobileNetV2 for finetuning on picasso dataset.""" from typing import Sequence, Dict import torch from torchvision.models import MobileNetV2, mobilenet_v2 from ..defaults import NUM_CLASSES MOBILENETV2_FINETUNE_LAYERS: Sequence[str] = ( 'features.17', 'features.18', 'classifier', ) ...
true
82647e7af930551abecb6f94721c613cc77a2c52
maciej-ros/python
/Hadoop/bigrams/mapper.py
UTF-8
493
3.09375
3
[]
no_license
#!/usr/bin/env python3 """mapper.py""" import sys bigrams = [] for line in sys.stdin: line = line.replace(",","") line = line.replace("-","") line = line.replace("?","") line = line.replace(".","") line = line.replace(";","") line = line.strip() words = line.split() for word in words:...
true
50cfbc58820d8b6fd34efa93e3b227d7d5b7d775
CapArken20/ab_TLAT_API
/app.py
UTF-8
1,939
2.578125
3
[]
no_license
from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_marshmallow import Marshmallow import os app = Flask(__name__) basedir = os.path.abspath(os.path.dirname(__file__)) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'app.sqlite') db = SQLAlchemy(ap...
true
9a0a5da806f9361b36fbdd6dcde894868be9a315
karolinelende/mars-rover-kl
/mars-rover.py
UTF-8
4,361
3.890625
4
[]
no_license
# -------------- Functions --------------- # def move_one(init_pos,instruction): """Calculate the updated the position of a robot based on an initial position and one instruction. :param init_pos: initial position in the form [x, y, orientation] :type init_pos: list of int, int, str :param in...
true
c46c97eb0b41400810bffce3372c4f9d951dca55
camcaswell/Cellomata
/speedtest.py
UTF-8
1,930
2.90625
3
[]
no_license
import cmap as cm import update_functions as ufuns import initial_states as inits import moviepy.editor from itertools import repeat from types import GeneratorType import numpy as np from time import time def main(): SEED = 8 STATES = 3 FRAME_DELAY = .05 CELL_SIZE = 10 GENERATIONS = 250 COL...
true
8119776a90d5335ff0bfedeb80fe827047bded8d
ndhcuong/pxu2021python
/vong-lap-for.py
UTF-8
249
3.671875
4
[]
no_license
a = [('Hung', 18), ('Tuan', 20), ('Quang', 21)] print("Kieu lap thu nhat") for item in a: print(item) print('-----------------') print('Kieu lap thu 2') for idx, (name, age) in enumerate(a): print(name, '--', age) print('-----------------')
true
1e1248dfa44e8dc92da91c6422d6a4d3846ae90c
bolof2000/Rest-API-Automation-In-Python
/Automation/automation_code/build/lib/ssqaapitest/src/helpers/products_helper.py
UTF-8
1,564
2.71875
3
[]
no_license
from ssqaapitest.src.utilities.requestsUtility import RequestsUtility import logging as logger class ProductsHelper(object): def __init__(self): self.requests_utility = RequestsUtility() def get_product_by_id(self, product_id): return self.requests_utility.get(f"products/{product_id}") ...
true
de42973513ffd09c2a87695e3807cca195d71fdb
nicolagennaro/Computational_Physics_Lab
/lecture2/exercise/read_random.py
UTF-8
472
3.140625
3
[]
no_license
#!/usr/bin/env python3 import sys import numpy as np print("hello") if( len(sys.argv) != 2 ): print("USAGE: " + sys.argv[0] + " file_name") sys.exit(1) with open(sys.argv[1], 'r') as f: v = [] lines = f.readlines() for i in range(len(lines)): v.append(float(lines[i])) print("r...
true