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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1c8d3e7b5007911ccfb5a9d70ad97ce032cf161f | Python | pdpipe/pdpipe | /tests/col_generation/test_colbyframefunc.py | UTF-8 | 1,816 | 2.734375 | 3 | [
"MIT"
] | permissive | """Testing ApplyToRows pipeline stages."""
# flake8: noqa: E712
import pytest
import pandas as pd
from pdpipe import ColByFrameFunc
from pdpipe.exceptions import PipelineApplicationError
def _some_df():
return pd.DataFrame(
data=[[3, 3], [2, 4], [1, 5]], index=[1, 2, 3], columns=["A", "B"]
)
def ... | true |
1aa427aac5a1e077159281a24dea2827d966a9ad | Python | TheAwesomeWizard13597/15-112-Term-Project | /keyBindings.py | UTF-8 | 1,490 | 2.765625 | 3 | [] | no_license | from helpfulFunctions import *
def initKeyBindings(app):
app.keybindings = {'togglePause': 'Escape',
'toggleTestMode': '`',
'toggleInventory':'i',
'toggleCrafting':'x',
'toggleCharSelect':'c',
'moveUp... | true |
ae982d04a02891880ffd736195067baea32b3da4 | Python | huazuhao/policy_gradient_cartpole | /spy_many_discrete_actions/spy/reward_type_3/model_1_cpu/utils.py | UTF-8 | 1,843 | 3.09375 | 3 | [] | no_license | import numpy as np
import torch
from torch.nn.functional import log_softmax, softmax
from datetime import datetime
def get_discounted_rewards(rewards: np.array, gamma: float) -> np.array:
"""
Calculates the sequence of discounted rewards-to-go.
Args:
rewards: the sequenc... | true |
d9f25ea5ff9869bdf5c716a5807d844d57049759 | Python | samuellsaraiva/2-Semestre | /l07e06menu_critica.py | UTF-8 | 2,369 | 4.25 | 4 | [] | no_license | ''' - 5. Refaça o programa anterior, acrescente a função menu que não recebe nada e retorna
a opção escolhida pelo usuário. O programa vai coordenar todo o processamento, ou
seja, chama a função menu e depois chama uma das duas funções (soma ou subtrai).
- 6. Use estrutura de repetição dentro da função menu par... | true |
292935566905a70d6fd90a35049ed50f89346a5b | Python | atomdog/octopancake | /speechrecognition.py | UTF-8 | 1,709 | 2.703125 | 3 | [] | no_license | import speech_recognition as sr
import threading, time
import pyttsx3
r = sr.Recognizer()
engine = pyttsx3.init()
mic = sr.Microphone(device_index=0)
global audiolist
global textlist
textlist = []
audiolist = []
global word
global tts
tts = True
word = ''
def microphone_record():
try:
with mic as... | true |
7f0895ae45b93fa52a6e95a5786b998fa0b79774 | Python | serbanb17/movieRecommenderSystem | /mf.py | UTF-8 | 2,609 | 2.796875 | 3 | [] | no_license | import sys
import numpy as np
from copy import deepcopy
"""
GoodToKnow
R - matrix: rows = users, columns = movies
K - latent dimensions
alpha - learning rate
beta - regularization rate
gamma - learning acceleration rate (must be < 1; 1 means no acc)
iterations - max number of iterations
maxError - maximum ... | true |
53a448e57de9d4d92d8d1bc1648882803e499ffe | Python | gjakubik/distSys | /A5/TestPerf.py | UTF-8 | 2,961 | 2.796875 | 3 | [] | no_license | import sys
import time
from ClusterClient import ClusterClient, ClientError, ServerError
def testInsert(client):
numOps = 0
totTime = 0.0
overallStart = time.perf_counter()
title = "\nInserting a large amount of numbers..."
while time.perf_counter() - overallStart < 3:
st... | true |
12a7d83719f945ffebf503453fbb26903eb738e9 | Python | gmortuza/ctci-python | /5_bit_manipulations/2_frac_to_bin.py | UTF-8 | 366 | 3.515625 | 4 | [] | no_license | def fract_to_bin(fract):
fract_len = len(str(fract)) - 1
return_str = ""
for _ in range(32):
if fract <= 0:
return return_str
fract = round(fract * 2, fract_len)
if fract >= 1:
return_str += "1"
fract -= 1
else:
return_str += "0... | true |
8ab3008365f768d082b5b1863a06936031691734 | Python | GalaxyZpj/Python_Institutional | /Notes/Python with SQL/DeleteByID.py | UTF-8 | 389 | 2.671875 | 3 | [] | no_license | import pymysql as sql
try:
conn = sql.connect(host = 'localhost', port = 3306, user = 'root', password = '12345678', db = 'Practice')
cmd = conn.cursor()
id = input('Enter Product ID to be deleted: ')
q = f"delete from Product2 where ProductID = {id}"
cmd.execute(q)
print('Record Deleted.')
... | true |
d83c76a0ca2124974a108f0a3f3c29566cbdbe98 | Python | jeffreylean/rhbhackhaton | /server/predmarketvalue.py | UTF-8 | 1,759 | 2.84375 | 3 | [] | no_license | import csv
import os
import pandas as pd
from collections import defaultdict
import random as rd
def getPAIRS():
data = pd.read_csv("stockmarket.csv")
data=data.dropna(axis=1,how='all')
#print(data.head())
predpair = {}
itemhead = data.columns.values
companytype=['Commercial Service... | true |
5a88e576de3602c7fa7f208dc3f3bd4ac520e940 | Python | BCCS7alex/google | /google_sheeets_client.py | UTF-8 | 2,091 | 2.859375 | 3 | [
"MIT"
] | permissive | import gspread
from oauth2client.service_account import ServiceAccountCredentials
class GoogleSheetsClient:
"""
Gets data from Google Sheets. Specifically, the guild's command channels and the bot's custom responses.
"""
music_services_column = 5
def __init__(self):
print("Connecting to ... | true |
8305d682cd6688dd824e4dc340ad5e8efa2f33c9 | Python | dessn/sn-bhm | /dessn/framework/analytic_verification.py | UTF-8 | 1,706 | 2.96875 | 3 | [
"MIT"
] | permissive | import numpy as np
from scipy.integrate import simps
from scipy.stats import norm, skewnorm
import matplotlib.pyplot as plt
# Make true to test erf
# False to test skewnorm
if False:
pop_mu, pop_sigma = 20, 2
selection_mu, selection_sigma = 19, 3
mbs = np.linspace(5, 35, 10000)
pop_pdf = norm.pdf(mbs,... | true |
9ae476cfb8971c8d327847cb89a88e1d216edca7 | Python | irissooa/Algorithm-with-Python | /Baekjoon/3502_나머지.py | UTF-8 | 73 | 2.90625 | 3 | [] | no_license | li = set()
for i in range(10):
li.add(int(input())%42)
print(len(li)) | true |
2af6bb7002d63adbe315b8c3176fa4de9a6a0df5 | Python | arnavraina/Coding-Projects | /consoletest.py | UTF-8 | 740 | 2.859375 | 3 | [] | no_license |
import sys
def printOut(strOut):
print(strOut)
def printErr(strErr):
print(strErr,file=sys.stderr)
printOut("This will come as output")
printOut("This will come as output")
printOut("This will come as output")
printOut("This will come as output")
printErr("This is error statement")
printErr("This is error ... | true |
bfb56c02769b099e60534e27d7b19e66ab67da3c | Python | Srinivas-Voore/My-Python-Programs | /python Basics-2/5.slicing.py | UTF-8 | 459 | 3.796875 | 4 | [] | no_license | #slice(start,end-1,step);
'''
str1="ASTRING";
s1=slice(4);
s2=slice(1,5,2);
s3=slice(-1,-200,-2);
print(str1[s1]);
print(str1[s2]);
print(str1[s3]);
'''
#string[start:end-1:step]
str1="ASTRING";
print(str1[:3]);
print(str1[1:5:2]);
print(str1[-1:-200:-2]);
#reversing a string
print(str1[::-1... | true |
6558041879e5e566d770a43703113d0bed3c5b6e | Python | aakashmhankale/Leaflet_webmaps | /mapsfinal.py | UTF-8 | 379 | 2.75 | 3 | [] | no_license | import folium
import pandas
map=folium.Map(location=[40,-120],zoom_start=4)
df=pandas.read_csv("Volcanoes-USA.txt")
for lat,loc,name,elv in zip(df["LAT"],df["LON"],df["NAME"],df["ELEV"]):
map.simple_marker(location=[lat,loc],popup=name,marker_color="green" if elv in range(0,1000) else "orange" if elv in range(100... | true |
c92b1ddcc50360316454cb227b69e5b9f55418d3 | Python | cmathx/news_recommend | /code/chenan/news_read_time_UCF.py | UTF-8 | 7,530 | 3.078125 | 3 | [] | no_license | # -*- encoding: utf-8 -*-
'''
Created on 2014年5月30日
@author: Chenan
'''
import news_popular
import math
def read_set(filename):
'''
:param filename: dataset following the format: user_id, news_id, read_time, edit_time, title (, content)
:return:user_news_dict, type dict, user_id=>news_id=>read_time
... | true |
5538b116bf89c0bfb018bf140db769b5919bdfa6 | Python | Swarchal/rosalind_solutions | /sgra/sgra.py | UTF-8 | 932 | 3.03125 | 3 | [] | no_license | #! /usr/bin/env python3
import numpy as np
import itertools
from sys import argv
from data import fetch_mass_dict
mass_table = fetch_mass_dict()
def mass_lookup(mass_list, tol=1e-3):
"""
given a list of masses, this will return the first amino acid that
has a mass within tolerance, and the index of that ... | true |
85f28ab14e260f113a8f36b7b356426dfd779501 | Python | renjieliu/leetcode | /0001_0599/99.py | UTF-8 | 4,411 | 3.53125 | 4 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def recoverTree(self, root: 'Optional[TreeNode]') -> None: #O(N | N)
"""
Do not return anyth... | true |
5ac81ae52bf501f3ae02ab15b2799daa83daef04 | Python | jaydenxxx/Spider_proxy | /proxies_spiders/redis_client.py | UTF-8 | 1,129 | 2.53125 | 3 | [] | no_license | import redis
import json
import time
from CommenModel.TaskQueue import TaskQueue
import config
def get_redis_pool():
pool = redis.ConnectionPool(host=config.redis_config['address'], port=config.redis_config['port'], password=config.redis_config['password'], db=0)
r = redis.StrictRedis(connection_pool=pool)
... | true |
66f57f7339e53d08bb98a3e8434e73aa08f5bf79 | Python | thomaswhocares/Propaganda-Mobil-Server | /interpreter.py | UTF-8 | 1,265 | 2.984375 | 3 | [] | no_license | import RPi.GPIO as GPIO
class Interpreter:
def __init__(self):
global wheel_left, wheel_right
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT) # rechts
GPIO.setup(19, GPIO.OUT) # links
wheel_right = GPIO.PWM(21, 50) # rechts
wheel_right.start(0)
wheel_l... | true |
3a4582639ba7b709f074c8b6ec52376f65f39f3a | Python | Kawser-nerd/CLCDSA | /Source Codes/AtCoder/abc048/A/4927266.py | UTF-8 | 49 | 2.53125 | 3 | [] | no_license | A = list(input().split())
print('A'+A[1][0]+'C') | true |
9679c8f1220cc5ba03a2d3542df3716d616935f5 | Python | Sadtrxsh/Mathboi | /bot_fish.py | UTF-8 | 2,146 | 2.890625 | 3 | [] | no_license | from bot_base import ActivatableSimpleBot
from bot_util import *
import re
class FishBot(ActivatableSimpleBot):
P_FISH_DONE = re.compile(f"^You cast out your line and brought back ([0-9]*) ({P_SHOP_NAME}) {P_SHOP_ICON}!" + P_EOL)
P_FISH_DONE2 = re.compile(f"^You cast out your line and brought back one ({P_SHO... | true |
0416a1d48d6345b64bfd730a1262cb20a6507ee5 | Python | isabel-lombardi/workbook_python | /chap_3/ex-72.py | UTF-8 | 155 | 4.03125 | 4 | [] | no_license | # Is a String a Palindrome?
pal = ""
s = input("Enter the word: ")
for i in s:
pal = i + pal
if s == pal:
print("True")
else:
print("False") | true |
0e81886277e91b12bea5f5bb4917fb2d3af178f2 | Python | robotpy/robotpy-navx | /examples/rotate-to-angle/physics.py | UTF-8 | 2,011 | 2.875 | 3 | [
"MIT"
] | permissive | import wpilib.simulation
from pyfrc.physics.core import PhysicsInterface
from pyfrc.physics import drivetrains
import typing
if typing.TYPE_CHECKING:
from robot import MyRobot
class PhysicsEngine:
def __init__(self, physics_controller: PhysicsInterface, robot: "MyRobot"):
"""
:param physics... | true |
de47acc7ed42efe9d13435f88e0740cc0e6478b1 | Python | yp757078635/tom | /pytorch学习/05_批训练.py | UTF-8 | 599 | 2.75 | 3 | [] | no_license | import torch
import torch.utils.data as Data
BATCH_SIZE = 5
x = torch.linspace(1,10,10)
y = torch.linspace(10,1,10)
torch_dataset = Data.TensorDataset(x,y)
loader = Data.DataLoader(
dataset=torch_dataset,
batch_size=BATCH_SIZE,
shuffle=True, #是否打乱顺序
num_workers=0, #线程数量
)
#epoch 为迭代次数 step为每次迭代的batc... | true |
5aeff9b2aafc8718bd5c296aa2e407a2a6c740f7 | Python | champseo2017/pythonautomatetest | /Demo/list_clear01.py | UTF-8 | 748 | 3.71875 | 4 | [] | no_license | # เมธอดที่ใช้กับชนิดข้อมูล list []
# เมธอด clear () เป็นเมธอดที่ใช้สำหรับลบข้อมูลทั้งหมดออกจากลิสต์
# lst.clear() โดยที่ lst คือ ตัวแปรชนิดข้อมูลลิสต์ที่ต้องการลบข้อมูลทั้งหมด
# ตัวแปรที่มีข้อมูลแล้วเราสามารถเปลียนแปลงข้อมูลได้
books_lst = ["Python", "Java", "C", "C++", "C#", "Scala"]
books_lst.clear()
print("ลบข้อมูลท... | true |
7f4c4a6cf37c4287b3c24ebbe448fb0cafcfe25b | Python | thanhthanhthile/DAA_UIT_CS112 | /bruteforce/5_DauNgoac.py | UTF-8 | 413 | 2.828125 | 3 | [] | no_license | def backtracking(A, i, n, opened):
if opened == n:
print(A + (2 * n - i) * ')')
return
S = {'('}
if opened > 0:
S.add(')')
for x in S:
# Debug = tay chetmie moi ra duoc cai dieu kien nay do nhaaaa
if opened >= i - opened:
backtracking(A + x, i + 1, n, ... | true |
6321b4e7a473f1dba033b41c22819f8598e76b05 | Python | pd451/Machine-Learning | /ML/K_means/K_means.py | UTF-8 | 5,693 | 2.578125 | 3 | [] | no_license | from sklearn.datasets.samples_generator import make_blobs;
import matplotlib.pyplot as plt;
from sklearn.svm import SVC; # "Support Vector Classifier"
import numpy as np;
import random;
import seaborn as sns;
def initialization(X,K):
n = len(X);
S = random_subset(n,K);
return [X[i] for i in S];... | true |
1f130ec627c75e8afddb1c276379929ce418dc4e | Python | CarolinaGonzalezS/Clase9 | /practica6.py | UTF-8 | 304 | 3.609375 | 4 | [] | no_license | import turtle
n=int(input("ingrese el tamaño del cuadrado: "))
l=int(input("ingrese el numero de lados: "))
t=turtle.Pen()
def MiPoligono(tamaño, lados):
for x in range(1,lados+1):
t.forward(tamaño)
a=360/lados
t.left(a)
MiPoligono(n,l)
turtle.getscreen()._root.mainloop() | true |
5d50f86b7eae788537317ad708a7389c222c5afe | Python | dyohan9/ChangeCodeTFMMap | /DB.py | UTF-8 | 878 | 2.984375 | 3 | [] | no_license | import sqlite3
class DB:
def __init__(this):
this.Count = 1
this.ChangeCodeMap()
this.GetLastRow()
def ChangeCodeMap(this):
result = Cursor.execute("select Code from MapEditor").fetchall()
for i in result:
Cursor.execute("update MapEditor set Code = ? where ... | true |
dce4349e2e18a8947c038a4920cb19348fcc0bca | Python | castrapel/uber.py | /examples/ubercli.py | UTF-8 | 8,582 | 2.578125 | 3 | [
"MIT"
] | permissive | from __future__ import unicode_literals
from cmd import Cmd
import json
from os import path
import shlex
import signal
import time
from uber import UberClient, geolocate, ClientStatus, UberException
from uber.model_base import Model, StringField
import sys
def exempt_login(func):
"""
marks a command as login-... | true |
207fc8b6d6357a604a06da18bad0e71171bdd51a | Python | midi0/python | /CodingDojang/Unit 6. variable/6.1.py | UTF-8 | 257 | 3.71875 | 4 | [] | no_license | x = 10
y = 'hello world'
print(type(x))
print(type(y))
x,y,z = 10,20,30
print(x,y,z)
x = y = z = 10
print(x,y,z)
x,y = 10,20
x,y = y, x
print(x,y) #x, y로 20 10이 출력
x = 10
del x
# print(x) 컴파일 에러
x = None
print(x) | true |
ee5d9adbe94b0a4a25f3b92774a74657b69c7118 | Python | rtix/course_bot | /Models/Excel.py | UTF-8 | 5,599 | 2.8125 | 3 | [
"MIT"
] | permissive | import xlsxwriter
import openpyxl
import Database.CourseDB as CourseDB
import Database.UserDB as UserDB
import os.path
if not os.path.exists('ExcelData'):
os.makedirs('ExcelData')
class ExtensionException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return str('{0} could not ... | true |
25149a24ec93b87dcae260c02a7a397fa761a6ef | Python | geokala/steganexample | /process_bmp | UTF-8 | 6,984 | 3.140625 | 3 | [
"BSD-3-Clause"
] | permissive | #! /usr/bin/env python3
"""A steganography example using BMP (bitmap)."""
import argparse
from struct import unpack
import sys
class UnsupportedFormat(Exception):
"""Raised if we don't see the expected files structure."""
class TooMuchData(Exception):
"""Raised if too much data is passed for the image to st... | true |
5a21333984ed99bbb9f63c6fb4fe413af931241f | Python | arjun-panwar/PyPi-connectdb | /connectdb/mysql_db.py | UTF-8 | 6,484 | 3.265625 | 3 | [
"MIT"
] | permissive | import mysql.connector as connection #importing MYSQL connector
class sql:
'''
SQL class through with we can perform most of the SQL tasks using python
Parameters
----------
host: host URL of MySQL server
user: user name
passwd: password
db: database name- default empty string ("")... | true |
0fff5b9fb3bdbfe407e65824aa96ffe4731b5ea2 | Python | Therealchainman/LeetCode | /problems/find_longest_awesome_substring/solution.py | UTF-8 | 1,063 | 3.046875 | 3 | [] | no_license | class Solution:
def longestAwesome(self, S):
prefix={}
mask=0
prefix[mask]=-1
best=0
for i,c in enumerate(S):
x=int(c)
mask ^=(1<<x)
# If this state existed prior then that means we just canceled a bunch of numbers that appeared even number... | true |
237425955ac7a3bfedebe27fd66b6502efb5e748 | Python | team-4-csc-591-ase/hw | /tests/test_syms.py | UTF-8 | 315 | 2.515625 | 3 | [
"MIT"
] | permissive | # from src.query import div, mid
# from src.sym import Sym
# from src.update import adds
#
#
# def test_syms():
# """
# Args : None
# Returns: Bool
#
# """
# sym = adds(Sym(), ["a", "a", "a", "a", "b", "b", "c"])
# print(mid(sym), round(div(sym), 2))
# assert 1.38 == round(div(sym), 2)
| true |
287e244b50235b1095341b10a2c25855b996463a | Python | chaquo/chaquopy | /server/pypi/packages/sentencepiece/test/__init__.py | UTF-8 | 436 | 2.625 | 3 | [
"MIT"
] | permissive | from os.path import dirname
import unittest
class TestSentencePiece(unittest.TestCase):
# Based on https://github.com/google/sentencepiece/blob/v0.1.95/python/README.md
def test_basic(self):
import sentencepiece as spm
sp = spm.SentencePieceProcessor(model_file=f"{dirname(__file__)}/test_mode... | true |
e02d9837caa66ee597cadec401c233ab8d91bb99 | Python | Ze1598/Python_stuff | /examples/iterators.py | UTF-8 | 3,080 | 5.28125 | 5 | [] | no_license | # Examples of iter() and next() as well as their implementation in a class\
# with __iter__() and __next__()
# -----------------------------------------------------------
# Using iter() and next() to iterate over an object
# The object which we'll iterate over (the iterable)
iterable_obj = "abc"
# Create the iterato... | true |
c10cf2617eeb8f2bfe4eb77a4f686433a125a7b6 | Python | newdha/crawl-usage | /utils.py | UTF-8 | 1,594 | 3.125 | 3 | [] | no_license | '''
Created on 2018年6月28日
@author: dha
'''
import math
import jieba
def docs(w, D):
'''
计算词引用数
'''
c = 0
for d in D:
if w in d:
c = c + 1;
return c
def seg(content, stopwords):
'''
分词并去除停用词
'''
segs = jieba.cut(content)
segs = [w for w in list(segs)]... | true |
8d9846b9c0fa362f91d1ca983bc515c614a2988d | Python | 0racul/111 | /cases/test_search_and_compare.py | UTF-8 | 923 | 2.734375 | 3 | [] | no_license | from PO.StuffForMarket import MarketSearch as market_search
import pytest
from selenium import webdriver
class Test_1_Search:
baseUrl = "https://market.yandex.ru/"
text = "Веники"
def test_search_and_compare(self):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('... | true |
384805381d06ed0f61bb0a1554e4ff6e7f036d29 | Python | davnajork/maritime-whale | /src/dashboard.py | UTF-8 | 3,315 | 2.828125 | 3 | [
"MIT"
] | permissive | # Copyright 2020 The Maritime Whale Authors. All rights reserved.
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE.txt file.
#
# Generates season-to-date dashboard from DataFrame. Centralized view for
# statistics of interest.
import pandas as pd
def dashboard(df):
... | true |
d0ad9127f2ef493025350f3bd9e22889a989f93a | Python | xfause/VoiceGame | /player.py | UTF-8 | 868 | 2.9375 | 3 | [] | no_license | import math
import random
import cocos
class Player(cocos.sprite.Sprite):
def __init__(self):
super(Player, self).__init__('player.png')
self.can_jump = False
self.speed = 0
self.image_anchor = 0, 0
self.position = 100, 300
self.schedule(self.update)
def ju... | true |
eb102a7835eb02b8b338ec6d85be2c08599e3051 | Python | SSevenTwo/alieninvasion_game | /alien_invasion/ship.py | UTF-8 | 1,603 | 3.421875 | 3 | [] | no_license | import pygame
from pygame.sprite import Sprite
from settings import Settings
class Ship(Sprite):
def __init__(self,settings,screen):
"""Initialize screen and starting position of ship"""
super(Ship,self).__init__()
self.screen = screen
#load ship image and r... | true |
e7510caf3ce352ce257a8a577fd19e868509717e | Python | Ismagulov-K/turtle_example | /AmongUS.py | UTF-8 | 1,315 | 3.40625 | 3 | [] | no_license | import turtle
BODY_COLOR = 'red'
GLASS_COLOR = 'skyblue'
t = turtle.Turtle()
def body():
t.pensize(10)
t.fillcolor(BODY_COLOR)
t.begin_fill()
t.right(90)
t.forward(50)
t.right(180)
t.circle(40, -180)
t.right(180)
t.forward(200)
t.right(180)
t.circle(100, -180)
t.backward(20)
t.left(15)
t.circl... | true |
98708f9efaec3f7f29e4b42de18520aade32d8e5 | Python | rafaelmsartor/python-studies | /PythonAndBlockchain/assignments/assignment5.py | UTF-8 | 381 | 3.796875 | 4 | [] | no_license | #1) Import the random function and generate both a random number between 0 and 1 as well as a random number between 1 and 10.
import random
print(random.random())
print((random.random()*9) + 1)
#2) Use the datetime library together with the random number to generate a random, unique value.
import datetime
print(str(... | true |
3c56c1d985a1fe04b3f48fa3b4b63658791e657c | Python | kingalok/mydata | /python/test6.py | UTF-8 | 58 | 2.921875 | 3 | [] | no_license | a=[1,2,3]
print(a[0])
print(a[1])
print(a[2])
print(a[3])
| true |
861a9491d23a8718aada2144fd41a29c6c08aae3 | Python | HaraldLeitner/Enigma | /Enigma.Python/tests/UnitTest.py | UTF-8 | 8,731 | 3.140625 | 3 | [] | no_license | import os
import unittest
from BusinessLogic import BusinessLogic
from Enums import Mode
from Roll import Roll
from main import Program
class MyTestCase(unittest.TestCase):
def setUp(self):
self.trans_linear = bytearray(256) # here every char is mapped to itself
self.trans_linear_invert = bytear... | true |
70a2bd6f833688cb018cf925b2894d700a14f9dc | Python | fr0st61te/pyserv | /core/protocol.py | UTF-8 | 729 | 2.65625 | 3 | [] | no_license | # -*- coding: utf8 -*-
import abc
import asyncio
import socket
from core.log import Log
log = Log().get_logger()
class Protocol(asyncio.Protocol, metaclass=abc.ABCMeta):
def __init__(self):
self.transport = None
self.data = ''
@abc.abstractmethod
def connection_made(self, transport):
... | true |
4578412cd107e3337b8c92984722cb2b874b306e | Python | JoyceHe1998/Dependency-Based-Word-Embeddings | /word_frequency.py | UTF-8 | 252 | 2.671875 | 3 | [] | no_license | import pickle
pickle_counts = open('keywords_pickles/word_counts.pickle', 'rb')
word_counts = pickle.load(pickle_counts)
pickle_counts.close()
# print(word_counts)
a = {k: v for k, v in sorted(word_counts.items(), key=lambda item: item[1])}
print(a) | true |
043e43d7628600961079197a8e73efbf8fe13999 | Python | gatesn/TileDB-Py | /examples/libtiledb/tiledb_object_type.py | UTF-8 | 623 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
"""
Example shows how to get the type of a TileDB object (resource).
You need to run the following to make this work:
$ python tiledb_group_create.py
$ python tiledb_dense_create.py
$ python tiledb_kv.py
$ python tiledb_object_type.py
"""
import tiledb
def main():
ctx = tile... | true |
aa19368cea49ead5b3feb60d49b25a6fa790cc0a | Python | Komport/mypython3examples | /a_tutorials_for_beginners/GetPassexample.py | UTF-8 | 408 | 3.203125 | 3 | [] | no_license |
import getpass
try:
p = getpass.getpass(prompt='Enter Password: ', stream=None)
except Exception as error:
print('ERROR', error)
else:
print('Password entered:', p)
user = getpass.getuser()
while True:
pwd = getpass.getpass("User Name : %s" % user)
if pwd == 'abcd':
print("Welco... | true |
92245d224d4d2e4e253a8704761842be2f50a785 | Python | Ruchir-Verma/PythonPractice | /Tuples.py | UTF-8 | 456 | 4.03125 | 4 | [] | no_license | '''
Tuples are like lists , but it is immutable .
'''
x = (1,2,3)
print(x)
print(x[0])
#x[0] = 5 it will show error as tuple is immutable
print(len(x))
'''
Iteration in tuple is faster than list
'''
##################################################
''' Sets are the data types that returns only unique val... | true |
44b6dc4af850bff509685bffb0b8809a531750b0 | Python | JamesBrill/traffic-predictor | /traffic-predictor.py | UTF-8 | 3,605 | 3.203125 | 3 | [] | no_license | import csv
import time
import numpy as np
from sklearn.preprocessing import StandardScaler
def get_epoch_timestamp(timestamp):
if len(timestamp) != 19:
timestamp = timestamp[:-7]
return int(round(time.mktime(time.strptime(timestamp, "%Y-%m-%d %H:%M:%S"))));
def get_data_from_csv():
data = []
w... | true |
83ad22a10f4bb07b546157f177fb633d36ed4b14 | Python | tylerdonison/CSE111 | /students.py | UTF-8 | 1,661 | 3.625 | 4 | [] | no_license | import csv
def main():
I_NUMBER_INDEX = 0
NAME_INDEX = 1
students = read_dict("students.csv", I_NUMBER_INDEX)
user_input = input("Please enter an I-Number (xxxxxxxxx): ")
user_input = user_input.replace("-", "")
#print(user_input)
good_i_number = test_valid_number(use... | true |
e005d1c62251a6a2cc48dcf22e1447a99f99db80 | Python | mattkjames7/Arase | /Arase/HEP/ReadOmni.py | UTF-8 | 2,372 | 2.59375 | 3 | [
"MIT"
] | permissive | import numpy as np
from .ReadCDF import ReadCDF
from ..Tools.PSpecCls import PSpecCls
import DateTimeTools as TT
from ..Tools.ListDates import ListDates
def ReadOmni(Date):
'''
Reads the level 2 omniflux data product for a given date.
Inputs
======
Date : int
Integer date in the format yyyymmdd
If Date is a... | true |
5f0c53f167afb2abf7b8ff707ced1c3c5512ef4b | Python | FrederikBrezina/SProject | /ConcanateData.py | UTF-8 | 648 | 2.90625 | 3 | [] | no_license | import numpy as np
dataset = np.loadtxt("units_of_first_layer.txt", delimiter=" ")
X = dataset[:, 0:1]
Y = dataset[:, 1:2]
dataset = np.loadtxt("units_of_first_layer_from_100_to_390.txt", delimiter=" ")
X1 = dataset[:, 0:1]
Y1 = dataset[:, 1:2]
print(X)
dataset = np.loadtxt("units_of_first_layer_from_420_to_3000.txt", ... | true |
ac2c75df5bfeb14ab7d16732c4ce74425bef1eda | Python | s1len0eye/python_learning | /Chapter 11/employee.py | UTF-8 | 246 | 3.515625 | 4 | [] | no_license | class Employee():
def __init__(self, first, last, salary):
self.first_name = first
self.last_name = last
self.annual_salary = salary
def give_raise(self, amount=5000):
self.annual_salary += amount
| true |
7e61e7a35763584025b14cdaf18274021a4f58a6 | Python | chroblert/Python | /gradeSort/201501-201802CJ_xinerSort.py | UTF-8 | 6,495 | 2.75 | 3 | [] | no_license | #!/usr/bin/python
# _*_coding: utf-8 _*_
"""
created by Jerrybird
"""
import re
import chardet
import json
import sys
from openpyxl import Workbook
from openpyxl import load_workbook
reload(sys)
sys.setdefaultencoding('utf-8')
def htmlToJson(in_file_name,out_file_name='CJ.json'):
with open(in_file_name,'r') as f... | true |
c7cc3cb1e9483aa5e59a45d663f972654abc6d67 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_200/1955.py | UTF-8 | 1,763 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env python3
#coding:utf-8
#---------------------------------------------------------------------
import os
import sys
#---------------------------------------------------------------------
def isTidy(num):
buf = str(num)
if len(buf) == 1:
return True
for i in range(1, len(buf)):
i... | true |
665d23d8a34affc67e3da842e952785fd1cda50a | Python | DasBehemoth/OrdnerNr2 | /Class10/example 1.py | UTF-8 | 265 | 3.0625 | 3 | [] | no_license |
def main ():
print "Hi, this is main"
def print_greeting(name):
print "Hello " + name
if __name__=='__main__': # runde klammer ist ein call, eckig ist wenn idexes oder keys geht; __ = Dunder variables (name, file)
main()
print_greeting('oli')
| true |
a8f9822eb79e3f88cd677803b5f3b43cf7a330a6 | Python | joelhaasnoot/spoortkaarthopper-tools | /list_to_map.py | UTF-8 | 2,651 | 3.5 | 4 | [
"MIT"
] | permissive | """
Convert a list of to/from coordinates and a path to a map of each individual path and an overview
Requires pygmaps
"""
import csv
import sys
import pygmaps
class MapMaker:
output_dir = ""
def __init__(self, output):
self.output_dir = output
def make_map(self, a, b, point_a, point_b, path):
... | true |
a2dff6e9aa4a5fd7fe4574595c2c4ec1cdaf8b62 | Python | lwxted/contact_dynamics | /v1_xgboost_model/xgboost_model_label.py | UTF-8 | 921 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Basic xgboost model that attempts to predict values of acceleration
"""
import os
import xgboost as xgb
base_path = os.path.dirname(os.path.realpath(__file__))
print base_path
train_file = os.path.join(base_path, 'training_data', 'contact_mode_label.train')
test_fil... | true |
73932f84f542681ac69fac1a4cd82e6cd290bdb8 | Python | judejuma/python_dictionaries | /dictionary.py | UTF-8 | 328 | 3.796875 | 4 | [] | no_license | menu = {} # Empty dictionary
menu['Chicken Alfredo'] = 14.50 # Adding new key-value pair
print (menu['Chicken Alfredo'])
# Your code here: Add some dish-price pairs to menu!
menu['Guakamelo'] = 20.50
menu['Fried Tuna'] = 15.30
menu['Salmon'] = 20.10
print ("There are " + str(len(menu)) + " items on the menu.")
prin... | true |
e59f8c9aa3334d0652461ae5e93766ead5cb2cf7 | Python | mohamedfaresslim/easistrain | /easistrain/imgshow_bw.py | UTF-8 | 726 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python3
import pylab
import fabio
import numpy
import sys
### usage : python imgshow.py image_file.edf [max_int_value]
img = fabio.open(sys.argv[1])
pixels = img.data
maxpixels = numpy.amax(pixels)
minpixels = numpy.amin(pixels)
print(maxpixels, minpixels)
if numpy.size(sys.argv) == 4:
... | true |
05a70f4361b992665ffd398ce491ec04e5094393 | Python | guigzzz/Exercism | /grep/grep.py | UTF-8 | 1,301 | 3.3125 | 3 | [] | no_license |
def get_file_contents(file_name):
with open(file_name, 'r') as f:
return f.read().split('\n')
def parse_flags(flags):
return ('n' in flags,
'l' in flags,
'i' in flags,
'v' in flags,
'x' in flags)
def get_comparison_function(v, x, i):
if v:
... | true |
054944acb3b88176810301cb23a89b914daaeff3 | Python | thispassing/poker | /ad.py | UTF-8 | 525 | 3.96875 | 4 | [] | no_license | # importing datetime and defining current date
from datetime import datetime
today = datetime.now().strftime("%Y-%b-%d")
# making definition for new balance
def calculate(totalBalance):
chop = 600000
tax = 218543
newBalance = totalBalance - chop - tax
newBalance = "{:,}".format(newBalance)
return... | true |
e5bae77013defc827a4c52a2154349706eea310e | Python | wlyjk12345/opencvtest | /c1/Pixel Read and Write.py | UTF-8 | 568 | 2.75 | 3 | [] | no_license | import cv2 as cv
import numpy as np
src = cv.imread("E:\DSC00006.jpg")
cv.namedWindow("input", cv.WINDOW_NORMAL)
cv.imshow("input", src)
m3 = cv.resize(src , (200,200) ,interpolation=cv.INTER_CUBIC) #change size cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst
h, w, ch = m3.shape
print("h , w, ... | true |
2edf4c812fc7ecbaa61ff0c66e497791e1a6133e | Python | DavidZong/LEDPi | /ledon.py | UTF-8 | 293 | 2.796875 | 3 | [] | no_license | import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
print "Turning On"
while True:
try:
GPIO.output(11, True)
sleep(30)
print "Turning off"
GPIO.output(11, False)
sleep(30)
print "Turning On"
except KeyboardInterrupt
GPIO.cleanup() | true |
544ef6f623f75bb3b1acf44d74e24dd444de9b73 | Python | webclinic017/OptionProfitabilityHeatmap | /OptionProfitabilityHeatmap.py | UTF-8 | 5,013 | 2.90625 | 3 | [
"MIT"
] | permissive | import scipy.stats
import plotly.express as px
import plotly.graph_objects as go
import requests
import pandas
import time
API_KEY = "***INSERT YOUR TD AMERITRADE API KEY***"
UNDERLYING = "QQQ"
YEAR = "2021"
MONTH = "09"
DAY = "20"
DAYS_TO_EXP = "3"
OPTION_START,OPTION_END = 365,380
UNDERLYING_STAR... | true |
7dccab2a14c0e8eb8c50358f8f7369bf997cb159 | Python | Yashikab/GraduationThesis | /kikuchi_2class/main.py | UTF-8 | 5,612 | 3.078125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import pickle as pkl
# ユークリッド距離
def distance(a, b):
return np.linalg.norm(a-b)
# 線分abと線分acについて内積
def naiseki(a, b, c):
return np.dot(b-a, c-a)
# 線分abと線分acについて外積 / 使ってない
def gaiseki(a, b, c):
return np.cross(b-a, c-a)
# クラスaについて,点cを始点としてbを現在... | true |
ef091ef45ab766a003f2314dd1ffd1f5702872a4 | Python | eunjin917/Summer-Algorithm-Merge | /dongyeop/quiz2.py | UTF-8 | 133 | 2.515625 | 3 | [] | no_license |
#자연수 뒤집어 배열로 만들기
def solution(n):
answer =list(reversed(tuple(str(n))))
return list(map(int,answer)
| true |
5a5bb2e89cfa08f1017f6079c324f14e688ee293 | Python | tsonglew/learn-python | /Exercises/PyQueryTest/test.py | UTF-8 | 693 | 3.0625 | 3 | [] | no_license | #-*- coding: utf-8 -*-
# Four methods to initialize PyQuery
# 1. init with string
# from pyquery import PyQuery as pq
# doc = pq('<html></html>')
# 2. init with lxml.etree
# from lxml import etree
# doc = pq(etree.fromstring("<html></html>"))
# 3. init directly with URL
# from pyquery import PyQuery as pq
# doc = p... | true |
246c0091d8a227a5cbf5fb7d1fef6f2d72944c0c | Python | aryanxxvii/myAssistant | /home.py | UTF-8 | 5,935 | 2.875 | 3 | [] | no_license | import os
import time
import pickle
import datetime
import login
import search
import reminder
import notifications
import notes
import games
import user_notes
import my_calendar
"""
This is the actual interface for the user which uses all the modules needed.
The interface is based on a structured input... | true |
b047be46e4c9c1fda05070cca9f32db573f21dae | Python | juanauli/Inversion-Sequences-Consecutive-Patterns-of-Relations | /CONSEC_INEQ3.py | UTF-8 | 2,023 | 3.640625 | 4 | [] | no_license | # Finding and counting inversion sequences avoiding
# consecutive patterns of inequalities of length 3
# Uses the file consec_detect_ineq3.py and gen_inv_seq.py
import consec_detect_ineq3
import gen_inv_seq
# Counts the number of sequences in a collection that avoid
# a given pattern of inequalities of length 3.
# ... | true |
37407f29263eef61a10feb991a727ec2c23fc9e6 | Python | JuAnne/CarND-P2-Traffic-Sign-Classifier | /trafficSignClassifier_final.py | UTF-8 | 12,496 | 3.234375 | 3 | [] | no_license | # Input Hyperparameters from command line
# E.g. python trafficSignClassifier.py 6 16 120 84 >conv1_cfg1_out.txt
# E.g. python trafficSignClassifier.py 16 32 400 200 >conv1_cfg2_out.txt
"""
import sys
conv_depth1 = int(sys.argv[1]) #6 16
conv_depth2 = int(sys.argv[2]) #16 32
fc_depth1 = int(sys.argv[3]) #1... | true |
f60004961d505d8015f7d742dfa874824f139db1 | Python | IDemiurge/LeetCodePython | /algs/sum.py | UTF-8 | 279 | 2.9375 | 3 | [] | no_license | # https://leetcode.com/problems/two-sum/
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i, x in enumerate(nums):
for j in range(i + 1, len(nums)):
if x + nums[j] == target:
return i, j
| true |
3bc986981255473f8f16c414b47a4b7a9894f60d | Python | xuetingandyang/leetcode | /src/searchRangeInBST.py | UTF-8 | 1,446 | 4.0625 | 4 | [] | no_license | # Given a binary search tree and a range [k1, k2],
# return node values within a given range in ascending order.
# Input:{5},6,10
# Output:[]
# No number between 6 and 10
# Input:{20,8,22,4,12},10,22
# Output:[12,20,22]
# Explanation:
# 20
# / \
# 8 22
# / \
# 4 12
# it will be seri... | true |
1cc102fd8af21ce3f5e52be578022e2886e487a3 | Python | cclauss/PyGae | /Tasks/Loops/loop.py | UTF-8 | 307 | 3.03125 | 3 | [] | no_license | r=range(10)
print r
for i in r:
print i
i=0
while(i<len(r)):
print i
i=i+1
s=0
l=[1,2,3,4,5,1,2,3]
for i in l:
s=s+i
print s
i=0
s=0
while(i<len(l)):
s=s+l[i]
i=i+1
print s
i=-1
while(1):
i=i+1
if(i>5 and i<8):
continue
if(i>8):
break
print i
| true |
6af2d5e86fbe846319add449c40b30252605dd42 | Python | benjaminkoh1994/BXACK | /extract.py | UTF-8 | 1,407 | 2.53125 | 3 | [
"MIT"
] | permissive | class EXTRACTCMD:
def __init__(self, file1):
self.cmdhist = []
self.file = file1
def readFile(self):
with open(self.file) as fp:
for line in fp:
if "CMD:" in line:
newline = line.split("'")
if newline[1] ... | true |
15aafe10b92d09e35ff0b9e94ee4b49014c6a6c2 | Python | WikiWatershed/gwlf-e | /gwlfe/Input/WaterBudget/AvWithdrawal.py | UTF-8 | 638 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | from numpy import sum
from numpy import zeros
from gwlfe.Input.WaterBudget.Withdrawal import Withdrawal
from gwlfe.Input.WaterBudget.Withdrawal import Withdrawal_f
from gwlfe.Memoization import memoize
def AvWithdrawal(NYrs, StreamWithdrawal, GroundWithdrawal):
result = zeros(12)
withdrawal = Withdrawal(NYrs... | true |
f167d72addb970c07ab54d2383d0f332e9898ec5 | Python | BiggHeadd/Algorithm | /two_.py | UTF-8 | 1,225 | 3.25 | 3 | [] | no_license | # coding: utf8
"""
单链表定义如下:
class ListNode(object):
def __init__(self, val):
self.val = val
self.next = None
"""
import sys
class Solution(object):
def removeDuplicates(self, head):
"""
:type head: ListNode
"""
# 在这里编写代码
_ = int(sys.stdin.readline())
... | true |
bedb3fef115370edc37eb16534da087df0b318a0 | Python | applekey/MISC | /travel[Conflict].py | UTF-8 | 2,649 | 3.09375 | 3 | [] | no_license | #### travel question
import csv, sqlite3
##class to generate a testing dataset
class testing:
def generateDataSet(self):
#hotel_name,nightly_rate,promo_txt,deal_value,deal_type,start_date,end_date
str ='''Hotel Foobar,250,$50 off your stay 3 nights or more,-50,rebate_3plus,2016-03-01,2016-03-31 \n
... | true |
46f9bfe714294f7de45d18944529033334d85167 | Python | shockssoftware/financialpredictionlstm | /app.py | UTF-8 | 11,737 | 2.546875 | 3 | [] | no_license | from flask import Flask, render_template
import pandas as pd
import numpy as np
import plotly.express as px
import time
import requests
import plotly.graph_objects as go
# libraries
import warnings
warnings.filterwarnings('ignore')
import tensorflow as tf
from tensorflow.keras.preprocessing.sequence import TimeseriesGe... | true |
0dfcd99b6758975432495508aef87756194985e2 | Python | taupalosaurus/ipfg18-5 | /tests/question-5_5.py | UTF-8 | 1,900 | 2.90625 | 3 | [] | no_license | test = {
'name': 'question 5.5',
'points': 1,
'suites': [
{
'cases': [
{
'code': r"""
>>> type(isInt) == types.FunctionType
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> len(param) ... | true |
67f8405399dd75f50f999f6ec1b90ca28ba0ce79 | Python | meetmemathanram/python_programs | /divisible_or_not.py | UTF-8 | 220 | 3.953125 | 4 | [] | no_license | a = float(input('Enter the number a. '))
b = float(input('Enter the number b. '))
def div(a , b):
if(a % b == 0):
print("number is divisible")
else:
print("number is not divisible")
div(a , b) | true |
505725f24bddb00c8b84a9776629180fc4f08d9a | Python | VeysDev/channel-point-farmer | /screen_capt_git.py | UTF-8 | 10,165 | 2.59375 | 3 | [] | no_license | from PIL import ImageGrab
import numpy as np
from pynput.mouse import Button, Controller
import time, datetime, cv2, webbrowser
import tkinter as tk
import tkinter.font as font
from tkinter import colorchooser
# this part solves the problem with the windows 10's scaling feature
# by reducing the scaling to ... | true |
e872cfb860b1b5c13b6d080ab9d41fa1fccdbbbe | Python | arcelien/hawc-deep-learning | /image-gen/Vanilla DCGAN/data.py | UTF-8 | 1,879 | 2.546875 | 3 | [] | no_license | import torch
from torch.utils.data import Dataset, DataLoader
import torch.nn as nn
import torch.functional as F
import numpy as np
import os
# pytorch dataset for features generated from gamma data
class Dataset(Dataset):
@staticmethod
def load_to_dict(file, labels):
return {'x': np.load(file), 'y': n... | true |
247724f7b713ebe4013100f14cae5e26c6a03426 | Python | yingzwei/machineLearing | /test/Opctest.py | ISO-8859-1 | 1,234 | 2.78125 | 3 | [] | no_license | # OpenOPC and SQLite Python example
import sqlite3
import os
import time
import OpenOPC
dbfile=test.db
remotehost=testbox
opcserver=Matrikon.OPC.Simulation
tagname=Random.Int4
sampletime = 2
dbexist = os.path.exists(dbfile)
db = sqlite3.connect(dbfile)
cur = db.cursor()
# create table first time new databa... | true |
7577a4b4ac2c025f4af071057b05703b697628c2 | Python | avmi/streamalert | /tests/unit/streamalert/shared/test_rule.py | UTF-8 | 12,705 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | """
Copyright 2017-present Airbnb, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, sof... | true |
746f27f86952ab63e09defd9b8e1e4d54e752327 | Python | jjfPCSI1/py4phys | /lib/M_schema_de_verlet3D.py | UTF-8 | 8,337 | 3.375 | 3 | [] | no_license | # coding: utf8
# Sauf mention explicite du contraire par la suite, ce travail a été fait par
# Jean-Julien Fleck, professeur de physique/IPT en PCSI1 au lycée Kléber.
# Vous êtes libres de le réutiliser et de le modifier selon vos besoins.
"""
Programme permettant de visualiser l'effet de l'intégration par méth... | true |
4a59d182afe73af110f6983cc502484f01f7f721 | Python | nadhembenameur99/hashcode-tutorial | /local_search.py | UTF-8 | 2,499 | 2.78125 | 3 | [] | no_license | import numpy as np
import tqdm
import copy
import utils
def _score_element(solution, tags, idx, neighborhood):
total_score = 0
if neighborhood > 0:
total_score += utils.slide_score(tags, solution[neighborhood - 1], solution[idx])
if neighborhood + 1 < len(solution):
total_score += utils.s... | true |
7f650c8e3e9c1680218d0abb9d956180f2554c03 | Python | kmasaya/Nonoji | /tests.py | UTF-8 | 7,217 | 3.15625 | 3 | [] | no_license | #!/usr/bin/python3
import main
def parse_inline(parse_str):
return main.parse_inline(parse_str)
def parse_line(parse_str):
return main._test_parse(parse_str).replace('\n', '')
def parse_break(parse_str):
return main._test_break(parse_str).replace('\n', '')
def test_h():
for count in range(1, 7):
... | true |
41886177809162465e43628bef777dea5efb3a21 | Python | its-Kumar/Python.py | /3_Strings/maxOccurance.py | UTF-8 | 998 | 4.375 | 4 | [] | no_license | """Given a function which accept 3 argument. If occurrences of the
second argument in first argument is equal to the third argument
return True else False.
function max_occurrences(str1: str, str2: str, num: int) -> bool:
"""
def max_occurrences(str1: str, str2: str, num: int) -> bool:
count: int = 0
i: int ... | true |
dfbba46a5b1157048e5f31660f2de5ae5ff6f756 | Python | rawsashimi1604/Qns_Leetcode | /leetcode_py/3-sum-closest.py | UTF-8 | 731 | 3.21875 | 3 | [] | no_license | from typing import List
class Solution:
def threeSumClosest(self, nums: List[int], target: int) -> int:
nums.sort()
closest = float('inf')
for i in range(len(nums)):
leftPtr = i + 1
rightPtr = len(nums) - 1
while leftPtr < rightPtr:
sumV... | true |
f97c71783fd3edb86edba2e1e1b2d6e3ae260c08 | Python | trinhgliedt/Algo_Practice | /2021_05_26_fibonacci.py | UTF-8 | 573 | 4.25 | 4 | [] | no_license |
def fibonacci1(n, a=0, b=1):
if n == 0:
return a
if n == 1:
return b
return fibonacci(n-1, b, a+b)
def fibonacci2(n):
fib = [0]*n
if n == 0:
return 0
elif n < 3:
return 1
else:
fib[0], fib[1], fib[2] = 0, 1, 1
for i in range(3, n):
fib[i... | true |
d2dd2832be1f8f92f1a15972bddb9d2fa499d911 | Python | kuangzheng800/SLR_abstract_viewer | /SLR_screener3.py | UTF-8 | 9,516 | 3.21875 | 3 | [
"MIT"
] | permissive | import tkinter as tk
import tkinter.messagebox as messagebox
from tkinter import filedialog
import pandas as pd
class CustomText(tk.Text):
'''A text widget with a new method, highlight_pattern()
example:
text = CustomText()
text.tag_configure("red", foreground="#ff0000")
text.highlig... | true |
e9e6d56d130d8c79424f8aa7614b16ba989120bc | Python | joelegner/leglib | /leglib/engmath.py | UTF-8 | 1,393 | 3.828125 | 4 | [
"MIT"
] | permissive | """
Engineering math classes and functions
"""
import unitval
class EngVar:
"Engineering variable with a value that is a UnitVal."
def __init__(self, name, value):
assert isinstance(value, unitval.UnitVal)
self.name = name
self.value = value
def __str__(self):
return f"{... | true |
4c5e65ce9e3dd84b2ad940991cd6f48b42a666f5 | Python | RithvikChuppala/MedicalAssistant | /client/modules/PriaidDiagnosisClient.py | UTF-8 | 8,052 | 2.75 | 3 | [
"MIT"
] | permissive | #! /usr/bin/python3.4
# -*- coding: utf-8-*-
import requests
import hmac, hashlib
import base64
import json
from enum import Enum
Gender = Enum('Gender', 'Male Female')
SelectorStatus = Enum('SelectorStatus', 'Man Woman Boy Girl')
class DiagnosisClient:
'Client class for priaid diagnosis health se... | true |