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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fd8d35816b91b3f7caa6ebf38b9ed7f7a48fdf91 | Python | nickto/covid-latvia | /scripts/clean.py | UTF-8 | 1,768 | 3 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import pandas as pd
import yaml
from openpyxl import load_workbook
def clean(resource_configs):
filepath = resource_configs["raw"]["path"]
metadata = yaml.safe_load(open(filepath + ".meta.yaml", "r"))
if resource_configs["raw"]["format"] == "csv":
print(f"Reading CSV from {f... | true |
c56f37752005bdb6051bbf1a27a09cd8de0d64ed | Python | Aryan-Satpathy/SWARMTaskRound2021 | /code.py | UTF-8 | 17,305 | 2.578125 | 3 | [] | no_license | import sys
from api import *
from time import sleep
import numpy as np
import random as rnd
import cv2
import math
####### YOUR CODE FROM HERE #######################
CommsFilePath = r'Status.txt'
BlackFilePath = r'Gone.txt'
stringFormat = 'i : Status jj : len\n'
# Index helper :012345678901234567890123
whil... | true |
38d6b2b0993172a4681fb0d9ca4d298a4182e2db | Python | shan18/Solutions-to-Machine-Learning-by-Andrew-Ng | /KMeans_and_PCA/PCA/pca_script.py | UTF-8 | 1,513 | 3.015625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from scipy.io import loadmat
from KMeans_and_PCA.PCA.RunPCA import pca
from KMeans_and_PCA.PCA.ProjectData import project_data
from KMeans_and_PCA.PCA.RecoverData import recover_data
# ----------------------- Load data ------------------------------------
data = lo... | true |
dc0ff5efcbff9257d6644789c0f0058d2961aa9a | Python | RyanKung/magic-parameter | /magic_parameter/parameter_declaration.py | UTF-8 | 2,766 | 2.703125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from __future__ import (
division, absolute_import, print_function, unicode_literals,
)
from builtins import * # noqa
from future.builtins.disabled import * # noqa
from collections import namedtuple, Iterable
from magic_parameter.type_declaration import type_decl_factory
... | true |
400350b86e6724b7e36b32c75336f1e9d775addb | Python | ramanmishra/Code-Chef-Solutions | /Beginner/Coins_And_Triangle.py | UTF-8 | 170 | 3.609375 | 4 | [] | no_license | t = int(input())
def sum_n(n):
return n * (n + 1) // 2
for i in range(t):
n = int(input())
h = 0
while sum_n(h) <= n:
h += 1
print(h - 1) | true |
33d200c928756f57f336003c3352e6b04f7989a4 | Python | RobertNimmo26/quizBuddy | /population_script.py | UTF-8 | 11,815 | 2.796875 | 3 | [] | no_license | import os
import random
os.environ.setdefault('DJANGO_SETTINGS_MODULE','quiz_buddy.settings')
import django
django.setup()
from django.utils import timezone
from quiz.models import Character,User,Class, Quiz, Question, Option, QuizTaker
from quiz.managers import CustomUserManager
def populate():
#CREATE USERS AND... | true |
be406ef455dff038f483f17eee5373e567bd0751 | Python | 1109israel/AprendiendoGit | /margarita/palindromo.py | UTF-8 | 282 | 3.71875 | 4 | [] | no_license | palabra=input() #Pedir al usuario una frase
nva_palabra=palabra.lower()
palabra2=nva_palabra.replace(' ','')
reversa=palabra2[::-1]
if reversa == palabra2:
print('La frase que ingresaste SÍ es un palíndromo.')
else:
print('La frase que ingresaste NO es un palíndromo.')
| true |
d8b5d7b58768ff357637e98615789972ab11f9a4 | Python | lixiang2017/leetcode | /explore/2020/november/Longest_Substring_with_At_Least_K_Repeating_Characters.1.py | UTF-8 | 997 | 3.34375 | 3 | [] | no_license | '''
Brute Force
Time: O(26 * n^2) = O(n^2)
Space: O(1)
Success
Details
Runtime: 9240 ms, faster than 5.30% of Python online submissions for Longest Substring with At Least K Repeating Characters.
Memory Usage: 14.1 MB, less than 9.93% of Python online submissions for Longest Substring with At Least K Repeating Charact... | true |
34747b1c2333c7eeb9bf71b44d16e40a869573fb | Python | xu20160924/leetcode | /leetcodepython/app/leetcode/61.py | UTF-8 | 874 | 3.140625 | 3 | [] | no_license | from app.algorithm.Entity import ListNode
class Solution(object):
def rotateRight(self, head: 'ListNode', k: 'int') -> 'ListNode':
if not head:
return None
if not head.next:
return head
old_tail = head
n = 1
while old_tail.next:
old_tail... | true |
8a0f8e21abf97f7f077fb89caf36bf63cc06f923 | Python | wancongji/python-learning | /lesson/7/practice4.py | UTF-8 | 198 | 4.09375 | 4 | [] | no_license | n = int(input("Please input a number: "))
for i in range(2,n):
if n%i == 0:
print(i)
print("The number is SUSHU.")
break
else:
print("The number is not SUSHU.")
| true |
9b6eddf6c38ce9bb9485e35880943b54879fb0d4 | Python | cwarje/AWSBotoLab | /p1.py | UTF-8 | 940 | 2.625 | 3 | [] | no_license | import boto3
import sys
def main(tag, toggle):
client = boto3.client('ec2')
response = client.describe_instances(
Filters=[
{
'Name': 'tag:Tag',
'Values': [
tag,
]
},
]
)
responseInstanceId = response["Reservations"][0]["Instances"... | true |
bd6b3644afc104e7ba772eedf48f6077f38cdacf | Python | ThomasQuer/FIUBA_ALGO_TP2_G5_2020 | /chatbot_training.py | UTF-8 | 1,381 | 2.53125 | 3 | [] | no_license | import os
from chatterbot import ChatBot
from chatterbot import comparisons
from chatterbot import response_selection
from chatterbot import filters
from chatterbot.trainers import ListTrainer
chat = ChatBot(
'Crux',
read_only=True,
logic_adapters=[
{
'import_path': "chatterbot.logic... | true |
2727c6b20db3b13dbe46561dc47374f5af0c8ffd | Python | harneyp2/bikemap | /bike_scraper/averages.py | UTF-8 | 3,801 | 3.140625 | 3 | [] | no_license | import sqlite3
import datetime
class averager(object):
def getHourAverage(self, cur, id, day):
'''THe function takes in as parameters a cursor to a database, the day of the week to be queried and the station id and returns the average
available bikes available in the station for an hourly basis'''
... | true |
a658887f69d044aa0d909f9358784ec36e218d22 | Python | Aasthaengg/IBMdataset | /Python_codes/p03565/s344958162.py | UTF-8 | 341 | 2.984375 | 3 | [] | no_license | S = input()
Sa = S.replace("?", "a")
T = input()
nt = len(T)
ans = list()
for i in range(len(S) - nt + 1):
X = S[i: i + nt]
for x, t in zip(X, T):
if x == "?":
continue
if x != t:
break
else:
ans.append(Sa[:i] + T + Sa[i + nt:])
ans.sort()
print(ans[0] if ans ... | true |
607bb63d853b7df667e7dc67ae932eecfb6ced2e | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_97/1736.py | UTF-8 | 869 | 2.8125 | 3 | [] | no_license | #!/usr/bin/python
import sys
T=input()
for nin in range(T):
line=sys.stdin.readline()
n1=int(line.split(" ")[0])
n2=int(line.split(" ")[1][:-1])
length=len(str(n1))
count=0
if(n1>=n2):
count=0
sys.stdout.write("Case #"+str(nin+1)+": "+str(count)+"\n")
continue
for x... | true |
e496f800367f4b43a72e03aed8fcd6d35fd0f61b | Python | DanielSantin1/Phyton-1--semestre | /exercicio 9.py | UTF-8 | 404 | 3.640625 | 4 | [] | no_license | #FUAQ calculao consumo de combustível em uma viagem em um carro
#que faz media de 12km/L. Ler o tempo da viagem e a velocidade
#média. Calcule a distância utilizando a fórmula:
#D=V*T e o cosumo = D/12
T=float(input("tempo de viagem: "))
V=float(input("Velocidade média: "))
D=V*T
print('Foram {:.2f}'.format(D), 'Km D... | true |
9e4c1a2dddf57290dc103957c2837f13c94d2e77 | Python | aravind-sundaresan/python-snippets | /Interview_Questions/first_nonrepeated_char.py | UTF-8 | 449 | 4.25 | 4 | [] | no_license | # Question: print the first non repeated character from a string
def non_repeated_character(test_string):
char_count = {}
for character in test_string:
if character in char_count.keys():
char_count[character] += 1
else:
char_count[character] = 1
for key in char_count:
if char_count[key] == 1:
retu... | true |
6139eb89d4550565ac5fa60de60b025afe27147e | Python | helensanni/pihat | /hat_random_pixels.py | UTF-8 | 400 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env python
# this script will display random pixels with random colors on the Pi HAT
from sense_hat import SenseHat
import time
import random
sense = SenseHat()
# assign a random integer between 0 and 7 to a variable named x
x = random.randint(0, 7)
y = random.randint(0, 7)
print("the random number is"), x, ... | true |
30c18de1a90068260bb23cb6aaa63a5ef20484df | Python | happyxuwork/data-preprocess | /src/getImageFromDataSet/passive.py | UTF-8 | 182 | 2.609375 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
'''
@author: xuqiang
'''
def sayHello():
print("i am xuqiang")
def main():
print("i am main function")
if __name__ == "__main__":
sayHello() | true |
a546ded46effdcafe15c4ae278c22cfe67ab33c5 | Python | 2efPer/Siamese-LSTM | /src/utils.py | UTF-8 | 2,692 | 2.765625 | 3 | [] | no_license |
from tensorflow.python.keras import backend as K
from tensorflow.python.keras.layers import Layer
from tensorflow.python.keras.preprocessing.sequence import pad_sequences
import gensim
import numpy as np
import itertools
def make_w2v_embeddings(df, embedding_dim=20):
vocabs = {}
vocabs_cnt = 0
vocabs_not_... | true |
2ec68a20043e0f73cd531c9e3c5e461c14e9e36c | Python | romeorizzi/cms_algo2020 | /for2_std/sol/soluzione_fast_py.py | UTF-8 | 236 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- codingxs: utf-8 -*-
# Soluzione di for2_std
# Romeo Rizzi, last: 2020-04-01
N=int(input())
idx=list(range(1,N+1)) # creo lista [1,2,...,N]
for k in range(1,N+1):
print(' '.join(map(str, [k*x for x in idx])))
| true |
2bfb4cf46117150164810e5c02ae98785c50f059 | Python | Greenwicher/Competitive-Programming | /LeetCode/63.py | UTF-8 | 831 | 2.828125 | 3 | [] | no_license | # Version 1, Dynamic Programming, O(m*n) time complexity, O(m*n) space complexity
class Solution(object):
def uniquePathsWithObstacles(self, obstacleGrid):
"""
:type obstacleGrid: List[List[int]]
:rtype: int
"""
m, n = len(obstacleGrid), len(obstacleGrid[0])
dp = [[0]... | true |
2c0bfa0afa8384fa53fe93a4eac9ba7e4f1efd0d | Python | Himanshu372/what-s_cooking_kaggle_dataset | /weighted_approach.py | UTF-8 | 3,930 | 3.109375 | 3 | [] | no_license |
import json
import pandas as pd
from pandas.io.json import json_normalize
from urllib import request
from bs4 import BeautifulSoup
import re
import datetime
import pandas as pd
def read_json(path):
'''
Reads json file from path and converts it into pandas dataframe
:param path:
:return dataframe:
... | true |
18ab1a87de3dce17aab226234a985affdc26b211 | Python | mt3141/regex-replacer | /main.py | UTF-8 | 10,674 | 2.84375 | 3 | [] | no_license | # 122520200014 010620210228
# ==============================================================================
# main script
# ------------------------------------------------------------------------------
# get options and arguments from command line
# get backup from files if specified in options
# find all match reg... | true |
94e688f901a9570c29e13601371f6787e3acb2cb | Python | ricardoaraujo/boku-engine | /random_client.py | UTF-8 | 1,401 | 3.203125 | 3 | [
"Unlicense"
] | permissive | import urllib.request
import sys
import random
import time
if len(sys.argv)==1:
print("Voce deve especificar o numero do jogador (1 ou 2)\n\nExemplo: ./random_client.py 1")
quit()
# Alterar se utilizar outro host
host = "http://localhost:8080"
player = int(sys.argv[1])
# Reinicia o tabuleiro
resp = urlli... | true |
e19bfde8b4c36ea305720b188444c1c727d4ed97 | Python | tenpaMk2/myrogue | /npcai.py | UTF-8 | 6,974 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
__author__ = 'tenpaMk2'
import logging
import logging.config
logging.config.fileConfig("config/logging.conf")
from abc import ABCMeta, abstractmethod
import warnings
import model
import astar
import shadowcasting
import position
class STATE(object):
stop = 0
wa... | true |
f3148a0d7a12279035255c0412ed4b751b6fc84a | Python | af-orozcog/python4everybody | /UsingPythonToAccesData/socket1.py | UTF-8 | 427 | 3 | 3 | [] | no_license | #python program to examine the http response to a get request
import socket
mysocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
mysocket.connect(('data.pr4e.org',80))
getRequest = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n".encode()
mysocket.send(getRequest)
while True:
data = mysocket.r... | true |
00f8fb41df1e5f7a87247fb02c5ff2b09bcbfcb7 | Python | tiagomenegaz/frac-turtle | /runner.py | UTF-8 | 1,457 | 3.3125 | 3 | [
"MIT"
] | permissive | from turtle import Turtle, colormode
from random import randint
import sys
def randColor():
return randint(0,255)
def drawTriangle(t,dist):
t.fillcolor(randColor(),randColor(),randColor())
t.down()
t.setheading(0)
t.begin_fill()
t.forward(dist)
t.left(120)
t.forward(dist)
... | true |
7f97672e9989079ecf723aad9f71c57952440e35 | Python | josephcardillo/lpthw | /ex15.py | UTF-8 | 795 | 3.96875 | 4 | [] | no_license | # imports argv module from sys
from sys import argv
# the two argv arguments
script, filename = argv
# Using only input instead of argv
# filename = input("Enter the filename: ")
# Opens the filename you gave when executing the script
txt = open(filename)
# prints a line
print(f"Here's your file {filename}:")
# Th... | true |
fc831f350cfe5cac647ba130d31510dd30d9a2bd | Python | prempshaw/automatic-attendance-using-face-recognition | /img_recog_name_confidnce.py | UTF-8 | 803 | 2.546875 | 3 | [] | no_license |
from urllib2 import Request, urlopen
values = """
{
"image": "http://35.154.49.223/image/ankit/ankit_enroll2.jpg",
"gallery_name": "MyGallery"
}
"""
headers = {
'Content-Type': 'application/json',
'app_id': 'fe2b1d88',
'app_key': '622354d3f6cbcfde77192f290ef6e293'
}
request = Request('https://api.k... | true |
36abc0001d5210ff814d0e68a1c298a8c4dda3a8 | Python | huangshu91/gamebuilders_f14 | /hud.py | UTF-8 | 2,356 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Shuheng Huang'
import pygame
from constants import *
class hud():
def __init__(self, level, parent):
self.FONT = pygame.font.SysFont('Calibri', 25, False, False)
self.parent = parent
self.level = level
self.s... | true |
9b0fbf75bcd54dc279197f29619cc14fd2779e47 | Python | beeverycreative/Filaments | /tools/bee2cura.py | UTF-8 | 4,984 | 2.734375 | 3 | [] | no_license | #!/usr/bin/python2
# -*- coding: utf-8 -*-
import os
import sys
import glob
import re
import argparse
import xml.etree.ElementTree as ET
"""bee2cura.py: This script attempts to generate ini files to be used in Cura
from the XML files that are located in the folder this script is located in.
The resulting ini files w... | true |
472e1c5b0b0f394d1d3a4a4e4143ad55030a6632 | Python | sweetherb100/python | /interviewBit/Strings/01_StrStr.py | UTF-8 | 1,448 | 4.3125 | 4 | [] | no_license | '''
Another question which belongs to the category of questions which are intentionally stated vaguely.
Expectation is that you will ask for correct clarification or you will state your assumptions before you start coding.
Implement strStr().
strstr - locate a substring ( needle ) in a string ( haystack ).
Try not... | true |
ff7a79dd377db9608d820faa6def653ecb955108 | Python | choiasher/problem-solving | /greedy7_scale.py | UTF-8 | 1,548 | 4.0625 | 4 | [] | no_license | '''
(1)
어떤 임의의 수열 A={a1... an}에서 이 수들을 가지고 구간합 [1, S]까지의 수들을
모두 표현할 수 있다고 가정할 때, 이 수열에 S+1를 추가하면
수열 끝에 S+1이 추가된 수열 A(after)={a1. an, S+1}은
추가되지 않은 수열 A(before)={a1.. an}이 구간 [1, S]까지 표현이 가능하니까
1.. S까지 각각 S+1을 더한 [S+2, 2S+1]를 추가로 표현할 수 있게됨
따라서 [1, 2S+1]까지 수들을 누락없이 모두 표현이 가능해진다.
(2)
그러면 이 수열A에 S+2를 추가할 경우를 살펴보면
수열끝에 ... | true |
80db105c4a4946d9234564668f1bf0328c73f271 | Python | dymnz/ShitHappened | /email_sender.py | UTF-8 | 885 | 2.828125 | 3 | [] | no_license | import smtplib
from util import *
class EmailSender:
_user = 'user'
_password = 'password'
_stmp_url = 'smtp.gmail.com'
_stmp_port = 465
def __init__(self, user, password, stmpURL, stmpPort):
self._user = user
self._password = password
self._stmp_url = stmpURL
self._stmp_port = stmpPort
# https://stac... | true |
f68b82f018d4e2d9d8a7a8a2b47e248e92bc513a | Python | cuimin07/LeetCode-test | /109.二叉搜索树中的众数.py | UTF-8 | 1,690 | 3.734375 | 4 | [] | no_license | '''
给定一个有相同值的二叉搜索树(BST),找出 BST 中的所有众数(出现频率最高的元素)。
假定 BST 有如下定义:
结点左子树中所含结点的值小于等于当前结点的值
结点右子树中所含结点的值大于等于当前结点的值
左子树和右子树都是二叉搜索树
例如:
给定 BST [1,null,2,2],
1
\
2
/
2
返回[2].
提示:如果众数超过1个,不需考虑输出顺序
进阶:你可以不使用额外的空间吗?(假设由递归产生的隐式调用栈的开销不被计算在内)
'''
#答:【使用额外空间的中序遍历】
# Definition for a binary tree node.
# class T... | true |
e10a0cce80a2950c7df8207c3e7244a4db84661d | Python | jiasir803/character | /future_work/get_genres_representation_of_gender.py | UTF-8 | 6,234 | 2.96875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# This script is designed to apply a particular model of
# gender to characters in a particular span of time,
# and record the predicted probabilities.
# It summarizes and records the predicted probabilities
# both at the author level and at the "story" (document)
# level. In this dataset, some... | true |
debb7cef4e413fd3abd650b56361501cdfe987de | Python | kiayria/epam-python-hw | /homework02/task04/function_cache/function_cache.py | UTF-8 | 614 | 3.796875 | 4 | [] | no_license | """
Write a function that accepts another function as an argument. Then it
should return such a function, so the every call to initial one
should be cached.
def func(a, b):
return (a ** b) ** 2
cache_func = cache(func)
some = 100, 200
val_1 = cache_func(*some)
val_2 = cache_func(*some)
assert val_1 is val_2
"""
imp... | true |
bfb7e0e4417bf5c776ef64dcf7677f8ff20c4b7f | Python | AndrewKalil/private | /Holberton_projects/copy_holby_challenge/champ.py | UTF-8 | 8,510 | 2.796875 | 3 | [] | no_license | #!/usr/bin/python3
""""""
from base import Base
import json
import random
class Champ(Base):
T_dmg_done = 0
T_dmg_taken = 0
T_dmg = 0
CRIT = 0
reset = 0
energy = 200
energy_reset = energy
def __init__(
self, name, race, gender, element=None, id=None, weapon="", armor="", champ_... | true |
64eb7baba8d175e4d4deac617d8f46c786cdbe57 | Python | salmanmohebi/DetPoisson_Python | /funLtoK.py | UTF-8 | 995 | 3.25 | 3 | [
"MIT"
] | permissive | # K=funLtoK(L)
# The function funLtoK(L) converts a (non-singular) kernel L matrix into a (normalized)
# kernel K matrix. The L matrix has to be semi-positive definite.
import numpy as np #NumPy package for arrays, random number generation, etc
def funLtoK(L):
eigenValuesL,eigenVectLK=np.linalg.eig(L); #eigen d... | true |
b292a9dc6083659217f708569ea8e17115efdcb9 | Python | skyblue3350/marksheet-reader | /scripts/cli.py | UTF-8 | 8,718 | 3.046875 | 3 | [] | no_license | import argparse
import csv
from pathlib import Path
import cv2
import numpy as np
from PIL import Image
def open_dir(path):
p = Path(path)
if not p.exists():
raise argparse.ArgumentTypeError("not exists : {}".format(p))
if not p.is_dir():
raise argparse.ArgumentTypeError... | true |
22070f5b6fdfe797d378433f0b7e1c68daa007cd | Python | codeAligned/Leet-Code | /src/P-160-Intersection-of-Two-Linked-Lists.py | UTF-8 | 1,276 | 3.625 | 4 | [] | no_license | '''
P-160 - Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two
singly linked lists begins. For example, the following two linked
lists: begin to intersect at node c1. Notes:If the two linked lists
have no intersection at all, returnnull.The linked lists must retain
their... | true |
6073f734d95c4dfc0ae3017b72626247991baf88 | Python | hcxxn/case_pyspark | /global/analyze.py | UTF-8 | 3,228 | 3.140625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from pyspark import SparkConf, SparkContext
from pyspark.sql import SparkSession
from pyspark.ml.feature import StringIndexer, IndexToString
from pyspark.ml import Pipeline
import pandas as pd
import matplotlib.pyplot as plt
import mpl_toolkits.basemap
conf = SparkConf().setMaster("local").s... | true |
a43788999e31e0bd6e0e58e33eb9f4044eedc67f | Python | piyushkumar344/sabre | /pythonWithNode/face_recog.py | UTF-8 | 1,369 | 3.09375 | 3 | [
"MIT"
] | permissive | import face_recognition
import cv2
import sys
# Open the input movie file
input_video = cv2.VideoCapture(sys.argv[1])
length = int(input_video.get(cv2.CAP_PROP_FRAME_COUNT))
# Load some sample pictures and learn how to recognize them.
curr_image = face_recognition.load_image_file(sys.argv[2])
curr_face_encoding = fac... | true |
0708871fff9f89a1f288dc6696fa0e5a93d3527b | Python | luchesii/LogisticMap | /RNN/ESN/generator.py | UTF-8 | 364 | 2.78125 | 3 | [] | no_license | import numpy as np
import random
r = 4
x0=0.1
n=10000 #número de dados no dataset
file = open('esn_data10000_x0.1_r4.csv','w+')
for i in range(200):
x1=x0*r*(1-x0)
x0=x1
x=[]
for i in range(n*10):
x1=x0*r*(1-x0)
x0=x1
x.append(x1)
x=np.asarray(x)
for i in range(n):
file.write('{}'.format... | true |
a1c78c30ffcc3a42d575a6fc80bea500d164f418 | Python | wangtao090620/LeetCode | /wangtao/leetcode/0107.py | UTF-8 | 1,170 | 3.609375 | 4 | [] | no_license | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# @Author : wangtao
# @Contact : wangtao090620@gmail.com
# @Time : 2020-02-15 09:41
"""
给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)
例如:
给定二叉树 [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
返回其自底向上的层次遍历为:
[
[15,7],
[9,20... | true |
1c6281ba681b145b1eaf70555327681b080eed1f | Python | johndurde14/Python_Learn | /《Python编程从入门到实践》/10-文件和异常/eg_remember_me.py | UTF-8 | 755 | 3.578125 | 4 | [] | no_license | #coding = uft-8
import json
class RememberMe(object):
def __init__(self):
self.filePath = 'username.json'
def areYouThere(self, file):
try:
with open(file) as f_obj:
username = json.load(f_obj)
except FileNotFoundError:
username =... | true |
c9cd540e63d42760f186f9cd0a889e0b5eef21d0 | Python | dewiballard/ProjectEuler | /Problem07.py | UTF-8 | 884 | 3.984375 | 4 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 16 20:42:29 2019
@author: dewiballard
"""
# Problem 7
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see
# that the 6th prime is 13. What is the 10 001st prime number?
i = 0
count = 0
def isprime(n):
# make sure n is a p... | true |
7f232902dbebbd0f3aa6324c5ed1b1e41d97cbaa | Python | komony/sync-teams | /sync-teams.py | UTF-8 | 4,657 | 2.875 | 3 | [] | no_license | import sys, requests, json
# global vars
ROLE_MAINTAINER = "maintainer"
ROLE_MEMBER = "member"
GITHUB_API = "https://api.github.com"
def get_org(full_team):
return (full_team.split("/")[0])
def get_team(full_team):
return (full_team.split("/")[1])
def get_team_id(full_team, auth_token):
r = requests.get... | true |
e0a192d2833546db99ab4a4b39a3f4a51dc87916 | Python | clifftseng/stock_python | /StockPicking/StockPicking_10.py | UTF-8 | 1,832 | 2.921875 | 3 | [] | no_license | from haohaninfo import MarketInfo
from haohaninfo import GOrder
# 取公司配息資訊 (資訊代碼,股票標的)
Data = MarketInfo.GetMarketInfo('3006','All')
ProdList = sorted(set([ i[1] for i in Data ]))
for Prod in ProdList:
# 該商品資料
Data1 = [ i for i in Data if i[1] == Prod ]
# 該商品近10年資料
Data2 = Data1[-10:]
# 該商品近10年的現金股... | true |
748e3d97e97f60d05335e26200312895087d8739 | Python | scott2b/webtools | /webtools/search.py | UTF-8 | 2,281 | 2.71875 | 3 | [
"MIT"
] | permissive | import datetime
import requests
import time
class BingWebPage(dict):
"""
No real attempt is made to stylize or format the full snippet or full rich
caption (below). These are primarily useful for preliminary inspection of
web page content, not so much for e.g. user interface display
"""
def g... | true |
4eda9e19865c07f0951961e916ab759eb9f00358 | Python | florinbordeanu/bookstore | /rent/models.py | UTF-8 | 974 | 2.8125 | 3 | [] | no_license | from django.db import models
from accounts.models import User
from store.models import Product
class RentBook(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
book = models.ForeignKey(Product, on_delete=models.CASCADE)
first_name = models.CharField(max_length=50)
last_name = mod... | true |
9bca1d7686eb8166ce8ebf1322d3b588703cf43d | Python | caerulius/RTAOC | /cae/seven/part2.py | UTF-8 | 1,530 | 2.734375 | 3 | [] | no_license | import itertools
from subprocess import Popen, PIPE
import os
import sys
highest_signal = 0
def translateOutput(output):
print(output) #for some reason this line makes this work
return int(output.decode("utf-8").replace("\r", "").replace("\n", ""))
def nextIndex(index):
if index == 4:
return 0
... | true |
01c9444e82f3e1f0192a0a4c86f0af44a58ee4ca | Python | B1rch/aoc-2020 | /2018/3/3.py | UTF-8 | 1,410 | 3.125 | 3 | [] | no_license | import itertools as it
import more_itertools as mi
import numpy as np
import fileinput, math
from collections import defaultdict
def gridPrint(grid):
for line in grid:
s = " ".join([str(x) for x in line])
print(f'{s}\n')
data = defaultdict(dict)
for line in fileinput.input():
id,_,coords,size = str(line)... | true |
baa1a4b97a671a46ff97180f110b4c0a3e74ad7c | Python | Daimy0u/PyPracticeDump | /PlatformerPhysics.py | UTF-8 | 1,704 | 3.25 | 3 | [] | no_license | import pygame
import time
pygame.init()
print("Created by Daimy0u - 2018")
def sleep(s):
time.sleep(s)
screenWidth = 500
screenHeight = 500
gamewin = pygame.display.set_mode((screenWidth,screenHeight))
pygame.display.set_caption("Platformer Test")
x = 40
y = 460
width = 40
height = 40
xvel = 10
... | true |
8d9148605137ecfa94719b3896bb58a4334d443e | Python | majaszymajda/Internet_Rzeczy | /lista3/apka4.py | UTF-8 | 467 | 2.65625 | 3 | [] | no_license | import base
def zwroc_dane(czas):
for i in range(1, 97):
czas_z_danych = f'{str(czas[0]).rjust(2, "0")}:{str(czas[1]).rjust(2, "0")}'
if czas_z_danych == dane[i][0]:
return {"Time": dane[i][0], "Peoples": dane[i][1]}
if __name__ == '__main__':
# base.wyslij_dane(zwroc_dane,'ilos... | true |
77184010dd4a05f000a8394c19b64b478d15b17d | Python | linkinpark213/leetcode-practice | /pysrc/987.py | UTF-8 | 1,121 | 3.46875 | 3 | [] | no_license | from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def verticalTraversal(self, root: TreeNode) -> List[List[int]]:
d = {}
queue = [(root, 0, 0)]
while len(queue) > 0:
node,... | true |
1b52ee2e203564339241470a1b107ac3b49db12e | Python | zbh123/hobby | /人脸识别/1、Logistic_Regression/lr_test.py | UTF-8 | 2,762 | 3.421875 | 3 | [] | no_license | # coding:UTF-8
import numpy as np
def sig(x):
'''
Sigmod函数,把模拟结果映射成一个概率
:param x:(mat) feature * w
:return: sigmoid(x)(mat):Sigmoid值
'''
return 1.0 / (1 + np.exp(-x))
def error_rate(h, label):
'''
计算损失函数值
:param h: (mat)预测值
:param label: (mat)实际值
:return: err/m(float)
... | true |
734d748e519c23b61db3c2a231adddf181c8ebf1 | Python | jk96491/Aircombat | /AircombatPython/UnityTesting/Class/Actor.py | UTF-8 | 740 | 2.625 | 3 | [] | no_license | import tensorflow as tf
class Actor:
def __init__(self, name, state_size, action_size):
with tf.variable_scope(name):
self.state = tf.placeholder(tf.float32, [None, state_size])
self.fc1 = tf.layers.dense(self.state, 128, activation=tf.nn.relu, kernel_regularizer=tf.contrib.... | true |
c88140470655f57646a529e4fafcfaee6c2060c7 | Python | susebing/HJ108 | /pass/HJ55 挑7.py | UTF-8 | 632 | 3.796875 | 4 | [] | no_license | # coding=utf-8
"""
题目描述
输出7有关数字的个数,包括7的倍数,还有包含7的数字(如17,27,37...70,71,72,73...)的个数(一组测试用例里可能有多组数据,请注意处理)
输入描述:
一个正整数N。(N不大于30000)
输出描述:
不大于N的与7有关的数字个数,例如输入20,与7有关的数字包括7,14,17.
示例1
输入
复制
20
输出
复制
3
"""
def ff(n):
s = 0
for i in range(1, n + 1):
if '7' in str(i) or i % 7 == 0:
s += 1
r... | true |
e8d438b34121b8ae6ecc7611a0fdd3222a666554 | Python | fujiten/Nand2Tetris | /projects/06/parser.py | UTF-8 | 4,384 | 2.75 | 3 | [] | no_license | import re
import sys
filename = sys.argv[1]
def write_file(binary):
file = open(f'{filename}.hack','a')
file.write(f'{binary}\n')
file.close()
def create_dest_binary(dest):
if dest is None:
return "000"
elif dest == 'M':
return "001"
elif dest == 'D':
return "010"
... | true |
ada239fa5f188d3d3e5e8ce85f46088892f54ab4 | Python | wildansupernova/Nthing-Problem-Solver | /src/Main.py | UTF-8 | 4,231 | 3.6875 | 4 | [] | no_license | from Board import Board
from PawnElement import PawnElement
from typing import List
from HillClimbing import HillClimbing
from SimulatedAnnealing import SimulatedAnnealing
from GeneticAlgorithm import GeneticAlgorithm
import copy
import sys
def makingInput(listOfPawn: List[PawnElement]):
filename = input(">> Pleas... | true |
0aad883aac2a27bbaa4f76f9c21a9c80a9f0c330 | Python | K-State-Computational-Core/example-10-releases-python-denea-clark | /src/guess/Main.py | UTF-8 | 1,121 | 3.1875 | 3 | [
"MIT"
] | permissive | """Main class for guessing game.
Author: Russell Feldhausen russfeld@ksu.edu
Version: 0.1
"""
import random
from src.guess.GuessingGame import GuessingGame
from src.guess.Renderer import Renderer
from typing import List
class Main:
"""Main class for guessing game."""
@staticmethod
def main(args: List[s... | true |
8c7ea1f86f1ea116a92eb79da598f8f863956b51 | Python | starstorms9/Insight-CS-Practicals | /toxic_class/Tyler_Habowski_Toxic_v1.py | UTF-8 | 7,749 | 2.546875 | 3 | [] | no_license | """
Created on Mon Mar 2 14:46:02 2020
"""
#%% Imports
import numpy as np
import os
import time
import json
import pandas as pd
import random
import inspect
import pickle
from tqdm import tqdm
import tensorflow as tf
import matplotlib.pyplot as plt
from collections import *
import tensorflow as tf
import spacy
fro... | true |
832039df03f64eb3c4094e4848e8c04956da2cc9 | Python | inaheaven/Tutorials_Python_Basics | /Day1/exercise3.py | UTF-8 | 1,593 | 3.40625 | 3 | [] | no_license | money = 2000
card = 1
if money >= 3000 or card >= 1:
print('taxi')
else:
print('walk')
var = 100
if(var == 100):
print("check 100")
if(var == 200):
print("check 200")
else:
print("check200 failed")
count = 0
while(count<9):
print('count is', count)
count = count+1
print("exit")
var = 1
w... | true |
320083a37fe63d59d9c36d28f3cc66e4b72c79c0 | Python | YY-in/PyQt | /src/Event.py | UTF-8 | 1,019 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2021/8/17 12:53 下午
# @Author : infinity-penguin
# @File : Event.py
from PyQt5.Qt import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('事件机制')
self.resize(600, 450)
self.move(300, 300)
class Btn(Q... | true |
626262876dd0c66a46b6767e029b69bab474e797 | Python | mapetranick/python_work | /MichaelPetranick_Assignment_3_1.py | UTF-8 | 701 | 4.59375 | 5 | [] | no_license | # CIS 240 Introduction to Programming
# Assignment 2.2
# Calculate the cost of installing fiber optic cable at a cost of .87 per ft for a company.
print("Hello!")
print("What is the name of your company?")
name = input()
print("The cost of fiber optic cable per foot is 87 cents.")
print("How much fiber optic cable ... | true |
96627fbebec40ff5c466eb48707b1ca71c8e8d3d | Python | amoghrajesh/Coding | /Non Leetcode Solutions/draw.py | UTF-8 | 333 | 3.328125 | 3 | [] | no_license | t=int(input())
for i in range(t):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ma=max(a)
a[a.index(ma)]=0
sa=sum(a)
mb=max(b)
b[b.index(mb)]=0
sb=sum(b)
if(sa>sb):
print("Bob")
elif(sb>sa):
print("Alice")
else:
p... | true |
0f5898d9a0fc7ec8fda1b75b1c1c7dbb9d9ff344 | Python | rxwx/impacket | /examples/sniffer.py | UTF-8 | 2,302 | 2.703125 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"Apache-1.1",
"MIT"
] | permissive | #!/usr/bin/env python
# Impacket - Collection of Python classes for working with network protocols.
#
# SECUREAUTH LABS. Copyright (C) 2018 SecureAuth Corporation. All rights reserved.
#
# This software is provided under a slightly modified version
# of the Apache Software License. See the accompanying LICENSE file
# f... | true |
e9135e6f315bbdbaf689a7a7048117b5213d4f3c | Python | poulter7/lastfm-history | /lastfm_parse.py | UTF-8 | 2,398 | 2.984375 | 3 | [] | no_license | from __future__ import division
import pygame, urllib2, json, pprint,time
from random import randint, random
from datetime import datetime, timedelta
from urllib2 import urlopen
from colorsys import hsv_to_rgb
# setup some useful stuff for display
pygame.init()
SECONDS_IN_A_DAY = 86400
time_height = 1000
time_width = ... | true |
34b842371737288383c8003404cac5e3cc31332d | Python | t0m/codeeval | /python-challenges/50_string_substitution.py | UTF-8 | 1,550 | 3.0625 | 3 | [] | no_license | from itertools import izip
import sys
class StringPiece():
def __init__(self, value, scannable=True):
self.value = value
self.scannable = scannable
def scan(string, scan_list):
string_pieces = []
string = StringPiece(string)
string_pieces.append(string)
for scan in scan_list:
piece_idx = 0... | true |
11ab6f75ded63d6ff86c0f9f9359fe070ebc1049 | Python | Shadofisher/Micropython_STM32F746Discovery | /MicropythonScripts/STM7/__main.py | UTF-8 | 1,603 | 2.53125 | 3 | [] | no_license | # main.py -- put your code here!
# main.py -- put your code here!
# main.py -- put your code here!
from pyb import Pin,LCD,I2C,ExtInt
i2c=I2C(3,I2C.MASTER);
#tp_int=Pin(Pin.board.LCD_INT,Pin.IN);
t_pressed = 0;
def drawText(text,x,y,colour):
a = len(text)
for n in range(a):
lcd.text(te... | true |
6e6084c76ff6b47e2c89445af66eb073c4e1eb38 | Python | vleseg/zmsavings | /zmsavings/utils/converter.py | UTF-8 | 822 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | from datetime import datetime
# Third-party imports
from money import Money
class Converter(object):
def __init__(self, model_field_name, convert_method):
self.model_field_name = model_field_name
self._convert = convert_method
def __call__(self, value):
return self._convert(value)
... | true |
b14b66637cec6ba8c953b5e1ee8c657ee48544ea | Python | Ursuline/dssp14 | /tweet_processor.py | UTF-8 | 19,812 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 26 21:42:54 2020
tweet_processor.py
@author: charles meegnin
"""
import os
import requests
import string
import re
import emoji
from nltk.stem.snowball import FrenchStemmer
from langdetect import detect
from langdetect import DetectorFactory
from... | true |
a8f08f996786849f5fe30ae5a5e79754dcaa4db1 | Python | RadiObad/atm | /Forums/models.py | UTF-8 | 487 | 3.5 | 4 | [] | no_license | class Member():
"""This class provides a way to store member name and age"""
def __init__(self, name, age):
self.id = 0
self.name = name
self.age = age
def __str__(self):
return '{} has {} years'.format(self.name, self.age)
class Post():
"""This class provides a way to store post title and content"""
de... | true |
3ec55027dee9fbfcab74655844ab03e3fde49e49 | Python | prade7970/PirplePython | /If-statement-assignment.py | UTF-8 | 478 | 4.1875 | 4 | [] | no_license | """
Assignment 3 - If Statement
"""
# function works well with only numbers
def Compare(n1,n2,n3):
if n1==n2 or n2==n3:
return True
elif n1!=n2 or n2!=n3:
return False
#Function works with String aswell
def CompareAll(n1,n2,n3):
if int(n1)== int(n2) or int(n2)==int(n3):
return Tr... | true |
23aec7c62f91307c2f5526b754c878624c94beba | Python | akr19/calcbackend | /src/calculator.py | UTF-8 | 2,665 | 2.8125 | 3 | [] | no_license | from flask import Flask, jsonify, make_response, url_for
from flask_httpauth import HTTPBasicAuth
from sqlalchemy import *
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger... | true |
2d9266d7498df7664739921dbf2e29442f7b8035 | Python | alexalpz/DressMeBot | /test.py | UTF-8 | 4,206 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python
print('hello world')
'''
import nltk
import random
import string
import re, string, unicodedata
from nltk.corpus import wordnet as wn
from nltk.stem.wordnet import WordNetLemmatizer
import wikipedia as wk
from collections import defaultdict
import warnings
warnings.filterwarnin... | true |
c3a074cf93ebcd9d4f5388a9b8ddd977dde002ae | Python | rene84/cfn-python-lint | /src/cfnlint/rules/templates/Base.py | UTF-8 | 1,160 | 2.765625 | 3 | [
"MIT-0"
] | permissive | """
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from cfnlint.rules import CloudFormationLintRule
from cfnlint.rules import RuleMatch
class Base(CloudFormationLintRule):
"""Check Base Template Settings"""
id = 'E1001'
shortdesc = 'Basic CloudFormati... | true |
98cbdf0649c70ab9241710cb97aae185a061a841 | Python | zhoufwind/py_dictContacts03 | /m_search.py | UTF-8 | 2,513 | 3.0625 | 3 | [] | no_license | import os,sys
from prettytable import PrettyTable
import itertools
def f_preSearch(contacts):
#print "This is precise search!", contacts.keys()
while True:
Psearch = raw_input("Search Name: ").strip().lower()
if len(Psearch) == 0: continue
if Psearch == 'q': break
if contacts.has_key(Psearch): # output acco... | true |
9915340935f485603f9e708ee500b29a8d402f3e | Python | antocuni/pytabletop | /pytt/tools.py | UTF-8 | 1,817 | 2.828125 | 3 | [
"MIT"
] | permissive | from kivy.event import EventDispatcher
from pytt.fogofwar import Tool, RevealRectangle
def bounding_rect(pos1, pos2):
if pos1 is None or pos2 is None:
# this should never happen, but better to return a dummy value than to
# crash
print 'wrong position :(', pos1, pos2
return (0, 0), ... | true |
3eded4c13ea623870b08f0c635fc35c0c2ca225c | Python | fikery/ArticleSpider | /ArticleSpider/tools/crawl_xici_ip.py | UTF-8 | 3,173 | 2.734375 | 3 | [] | no_license | import re
import requests
from scrapy.selector import Selector
import pymysql
conn=pymysql.connect(host='127.0.0.1',user='root',passwd='mysqlpassword',db='articlcspider',charset='utf8')
cursor=conn.cursor()
def crawl_ips():
#爬取西刺代理IP
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10... | true |
c05ab7a716aab0b920f66c51382abcc30db7bca7 | Python | ahuber950/Euler | /pe004/pe004.py | UTF-8 | 592 | 4.125 | 4 | [] | no_license | # Problem 4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
def mod4(digits):
if type(digits) != int or digits < 1:
raise ValueError("The va... | true |
09ca6f1a0ccfcfd70b05d489a04f4ccbaf8024fd | Python | arjunbista/assignment | /Valid.py | UTF-8 | 1,683 | 3.59375 | 4 | [] | no_license | '''import sys
name=input("Enter your Name: ")
for x in range(1,4):
if name.isalpha()==True and len(name)>=4 or " " in name:
pass
break
else:
print("Invalid name")
name = input('enter name again')
else:
sys.exit("Please follow next Time")
age=input("Enter your Age: ")
for y in... | true |
6665ca6a973d65c186b314b543a1ed8a25ab580c | Python | axtrace/alisa_sq_color_func | /guess.py | UTF-8 | 5,939 | 3.484375 | 3 | [] | no_license | import random
def while_or_black(text):
whites = ('белый', 'белая', 'белые', 'белое', 'белого')
blacks = (
'черный', 'черная', 'черное', 'черные', 'чёрн', 'черного', 'черн')
for c in whites:
if c in text:
return 'WHITE'
for c in blacks:
if c in text:
ret... | true |
603ca9e3c1b50f264b96b648794cd5ea2f5c7576 | Python | shinan0/python2 | /约瑟夫环问题.py | UTF-8 | 1,574 | 4 | 4 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
def move(players,step):
#移动step前的元素到列表末尾
#将如何step的元素从列表中删除
num = step - 1
while num > 0:
tmp = players.pop(0)
players.append(tmp)
num = num - 1
return players #根据step做了元素的移动
def play(players,step,alive):
"""
模拟约瑟夫问题... | true |
1dd0b9f494a09bc60d8e841405c4436bda8f7b7a | Python | natc79/MENAJobData | /step1_download/src/create_databases.py | UTF-8 | 7,880 | 2.875 | 3 | [
"MIT"
] | permissive | """
This code creates key databases for various data that is being downloaded.
Author: Natalie Chun
Created: November 22, 2018
"""
import sqlite3
def update_table(tablename,newtablequery,insertstatement):
"""Update table"""
conn = sqlite3.connect("egyptOLX.db")
c = conn.cursor()
query ='''PR... | true |
a9f47126e318efddba8b8c9ae55af3467e701e98 | Python | ValentunSergeev/FinTechFinal | /constants.py | UTF-8 | 2,129 | 2.703125 | 3 | [] | no_license | from emoji import emojize
labels = {1: 'Акции', 2: 'Блокировка карты', 3: 'Вам звонили', 4: 'Вклад', 5: 'Действующий кредит',
6: 'Денежные переводы', 7: 'Задолженность', 8: 'Интернет банк', 9: 'Карты', 10: 'Кредит',
11: 'Кредитные карты', 12: 'Курс доллара', 13: 'Курс евро', 14: 'Курсы валют', 15: ... | true |
3008cda72a7d6faf50f5a191068445ee419e1dd7 | Python | JudahDoupe/MachineLearning | /NeuralNet/NetworkOptimizer.py | UTF-8 | 3,612 | 3.03125 | 3 | [] | no_license | from NeuralNet.NeuralNetwork import *
import operator
import matplotlib.patches as mpatches
from NeuralNet.NormalizedData import *
class NetworkOptimizer:
def __init__(self, fileName, fileDelimter=',', debug=False):
self.data = NormalizedData(fileName, fileDelimiter)
self.numDataSets = len(self.da... | true |
8516113dff141c2142a37483ddc3f23dfbfedc22 | Python | vaishali59/CrackingTheCodingInterview | /Sorting_Searching/Peak_Valleys_mysol.py | UTF-8 | 816 | 3.265625 | 3 | [] | no_license | def peakValleys(arr):
up = False
down = False
for k in range(len(arr)-1):
if not up and not down:
if arr[k]>arr[k+1]:
up = not up
elif arr[k]<arr[k+1]:
down = not down
else:
return -1
elif down:
... | true |
25c8c5a3d31ce42582fccd31c530b59df7128f53 | Python | NainAcero/mineria | /informe01.py | UTF-8 | 2,114 | 3.078125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 11 13:35:50 2021
@author: NAIN
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.svm import SVR
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, f1_score, confusion_matrix, accur... | true |
b4837888f4b4d09a6829d58782d75df8c757148b | Python | zhangjiatao/Confidence-Knowledge-Graph | /2-PCRA.py | UTF-8 | 7,643 | 2.640625 | 3 | [] | no_license | '''
Step 2: Calculate the PCRA confidence of each triples
'''
import os,sys
import math
import random
import time
in_path = './2-data_with_neg/'
# 构建全局容器
ok = {} # ok['h'+'t'][r] = 1
a ={} # a[h][r][t] = 1 # 用于存储dataset三元组
relation2id = {}
id2relation = {}
relation_num = 0
h_e_p = {} # h_e_p['e1'+'e2'][rel_path] ... | true |
ec25b487ccd92e281d8f7d31df4e4fe9cf707c0e | Python | thiagorabelo/pycout | /ostream/ostream.py | UTF-8 | 1,774 | 3.265625 | 3 | [
"MIT"
] | permissive |
"""
Módulo que contém uma classe que simula a classe padrão ostream do C++
"""
import numbers
from sys import stdout
from typing import Union, Callable, IO, Text, Any
from .base_ostream import PrecicionManip, FillManipulator
class OStream(PrecicionManip, FillManipulator): # pylint: disable=useless-object-inherita... | true |
25b3de8decb6d3557f6c86e8991a1790cbe1af0d | Python | Paskal-Dash/university | /3.2/Коваленко/3/K-1(O).py | UTF-8 | 332 | 2.921875 | 3 | [] | no_license | n = int(input())
files = dict((lambda x: (x[0], x[1:]))(input().split()) for _ in range(n))
delta = {'execute': 'X', 'read': 'R', 'write': 'W'}
for i in range(int(input())):
obj = input().split()
if any(delta[obj[0]] == file1 for file1 in files[obj[1]]):
print('OK')
else:
print('Acce... | true |
2e9e5552f8642959165315f911f0929ed416833c | Python | SirLegolot/SSP | /Python/hw2_starter/photometry rectangle (Jason1984 KB).py | UTF-8 | 2,277 | 2.9375 | 3 | [] | no_license | from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import math
from astropy.io import fits
myim = fits.getdata("Average1.fit") # jason1984kb
##plt.imshow(myim, vmin=myim.mean(), vmax=2*myim.mean())
##plt.gray()
##plt.show()
##starx = input("What is your star x coordinate?"... | true |
5af41bfd1ff9920dbf4f09d97371b719355d247e | Python | devos50/fake-tribler-api | /FakeTriblerAPI/utils/read_torrent_file.py | UTF-8 | 292 | 2.984375 | 3 | [] | no_license | str = ""
with open("data/random_torrents.dat") as random_torrent_files:
content = random_torrent_files.readlines()
for random_torrent in content:
torrent_parts = random_torrent.split("\t")
print torrent_parts[0]
str = str + torrent_parts[0] + ", "
print str
| true |
cf2a7b4b3f77a5e15c95ee0c3a374af5b7a26c98 | Python | oshadmon/StreamingSQL | /db.py | UTF-8 | 2,155 | 3.25 | 3 | [
"MIT"
] | permissive | """
Create connection to the database, and execute SQL commands
"""
from StreamingSQL.fonts import Colors, Formats
import pymysql
import warnings
warnings.filterwarnings("ignore")
def create_connection(host='localhost', port=3306, user='root', password='', db='test')->pymysql.cursors.Cursor:
"""
Create a conn... | true |
71c75f3c6c56d529cbfabec0e8bb4e1cdcad1ecb | Python | Jorewang/LeetCode_Solutions | /5. Longest Palindromic Substring.py | UTF-8 | 808 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | class Solution(object):
def longestPalindrome(self, s):
pass
def manacher(self, s):
li = []
for char in s:
li.append('#')
li.append(char)
li.append('#')
print(li)
length = len(li)
res = [0]*length
mx, id = -1, -1
fo... | true |
b4270dcb3683a682090bc98844f5d4ce00f438be | Python | Sauvikk/practice_questions | /Level4/LinkedLists/Remove Nth Node from List End.py | UTF-8 | 1,186 | 4.09375 | 4 | [] | no_license | # Given a linked list, remove the nth node from the end of list and return its head.
#
# For example,
# Given linked list: 1->2->3->4->5, and n = 2.
# After removing the second node from the end, the linked list becomes 1->2->3->5.
#
# Note:
# * If n is greater than the size of the list, remove the first node of the l... | true |
69a19ea4a5362422c2dbe42f29c62098a055adb4 | Python | GuillaumeOj/Mergify-Technical-Test | /tests/test_finder.py | UTF-8 | 1,358 | 3.125 | 3 | [] | no_license | from warehouse.finder import Finder
from warehouse.box import Box
class MockBox:
def __init__(self, box_id):
self.box_id = list(box_id)
class TestFinder:
def test_compare_boxes_with_one_different_character_in_same_position(
self, monkeypatch
):
monkeypatch.setattr("warehouse.box.... | true |