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 |
|---|---|---|---|---|---|---|---|---|---|---|
bbf37f7401fc36b2a004ad7846ea13d80830b089 | thejakenixon/advent | /20/02/p2.py | UTF-8 | 1,273 | 4.0625 | 4 | [] | no_license | data = open("data.txt", "r") # Open data.txt
dataArray = data.read().splitlines() # Put each line into an array
validpwds = 0 # Start with no valid passwords
for x in dataArray: # For loop for every value in the array
x = x.replace(":","",1) ... | true |
c3aea2c1fb6b3042cea0a671a0fcf3813dec5273 | miaozaiye/PythonLearning | /miaozaiye/1103gcd.py | UTF-8 | 246 | 3.734375 | 4 | [
"MIT"
] | permissive | #学习递归思路寻找最大公约数
'''
gcd(p,q) = gcd(q,p%q)
'''
import sys
a = int(sys.argv[1])
b = int(sys.argv[2])
(p,q) = (a,b) if a>b else (b,a)
def gcd(p,q):
if p%q == 0:
return q
return gcd(q,p%q)
print(gcd(p,q)) | true |
8bb2801927c0e7f4c53833f76c68a09f227084c3 | lysky/self_modules | /seq_process.py | UTF-8 | 2,355 | 2.703125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 11 16:07:16 2012
class of fasta
@author: corin li
"""
def rev_comp(seq_str):
#用来取反补
transTable={"A":"T","T":"A","C":"G","G":"C","N":"N","n":"N"}
rev_str=seq_str[::-1]
comp_list=[]
for i in rev_str:
comp_list.append(transTable[i])
return "".join(... | true |
2b7ddf621f784cf2c4608d86b219262d40198750 | silviafrigatto/python-exercicios | /e046_ContagemRegressiva.py | UTF-8 | 271 | 3.765625 | 4 | [] | no_license | # Faça um programa que mostre na tela uma contagem regressiva para o estouro
# de fogos de artifício, indo de 10 até 0, com uma pausa de 1 segundo entre eles.
from time import sleep
for cont in range (10, 0, -1):
print(cont)
sleep(1)
print("Feliz Ano Novo!") | true |
5d8b1f39e1b1f6bceb02268c1a93a880d130eeea | IshaqNiloy/is-divisible-by-eleven | /multipleOfEleven.py | UTF-8 | 568 | 4.125 | 4 | [] | no_license |
def isDivisible(num):
sumOfEvenDigits = 0
sumOfOddDigits = 0
txt1 = " is a multiple of 11."
txt2 = " is not a multiple of 11."
for index in range(len(num)):
if (index % 2) is 0:
sumOfEvenDigits += int(num[index])
else:
sumOfOddDigits += int(num[index])
... | true |
1895017b9496fc327ae56695c538b630afddf63f | tleonhardt/CodingPlayground | /python/swig/fibonacci/test_swig.py | UTF-8 | 1,331 | 3.625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python
""" Python wrapper to time the SWIG wrapper for computing the nth fibonacci number
in a non-recursive fashion and compare it to the pure Python implementation.
"""
import fibonacci
import fib_python
if __name__ == '__main__':
import sys
import timeit
n = 20
try:
n = int(s... | true |
a5132541e8a7553ee68f27d0b3f25e697100799c | LasterSmithKim/Python-Base | /网络爬虫/爬虫练习/3、IP地址爬虫/ipCrawler.py | UTF-8 | 816 | 2.84375 | 3 | [] | no_license | import urllib.request
import ssl
import re
def getHtmlStr(url):
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 "\
"(KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
}
req = urllib.request.Request(url,headers=headers)
con... | true |
8ed933d75ed2c248a602576d79a02d604e99143e | olga2288/lpthw | /cars.py | UTF-8 | 570 | 3.765625 | 4 | [] | no_license | class Car(object):
"""Car class"""
def __init__(self, make = "", year = 0, miliage = 0, colour = ""):
self.make = make
self.year = year
self.miliage = miliage
self.colour = colour
def drive(self, km):
self.miliage += km
def repaint(self, new_colour):
sel... | true |
4a395a59bcea47678215df308a235e8d10622a80 | wtrnash/LeetCode | /python/167两数之和 II - 输入有序数组/167两数之和 II - 输入有序数组.py | UTF-8 | 923 | 3.78125 | 4 | [] | no_license | """
给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。
函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。
说明:
返回的下标值(index1 和 index2)不是从零开始的。
你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。
示例:
输入: numbers = [2, 7, 11, 15], target = 9
输出: [1,2]
解释: 2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。
"""
# 解答:双指针法
class Solution:
def twoSum(s... | true |
13b2f74640d40cf850209326a37d5b6229dbfeff | pks369/selenium-py | /navigationalcommand_03.py | UTF-8 | 1,044 | 3.203125 | 3 | [] | no_license | '''
Redirect one url to another url like Forward & Backward
Thread.sleep() in java:
time.sleep(): It does not wait for the complete duration of time. In case it finds the element before the
duration specified, it moves on to the next line of code execution, thereby reducing the time
of... | true |
d02164834c45739bc9f83d0cbf10fa44650c006e | Benny7/Tools | /OutputDirFile.py | UTF-8 | 1,683 | 2.65625 | 3 | [] | no_license | #!/usr/bin/python
# coding=utf-8
#Copyright:
#File: OutputFileName.py
#Author: Benny Huang
#Email: harvyson@gmail.com
#Date: 2014-1-3
#Description:
import os
def ListFileToTxt(dir, file, wildcard, recursion, preStr):
exts = wildcard.split(" ")
for root, subdirs, files... | true |
c9c4bb9252f6d63e1536088dae2d585ac430c605 | fabricio24530/ListaPythonBrasil | /EstruturaDeRepeticao03.py | UTF-8 | 1,300 | 4.1875 | 4 | [] | no_license | '''
Faça um programa que leia e valide as seguintes informações:
Nome: maior que 3 caracteres;
Idade: entre 0 e 150;
Salário: maior que zero;
Sexo: 'f' ou 'm';
Estado Civil: 's', 'c', 'v', 'd';
'''
nome = input('Informe seu nome: ').strip().lower()
idade = int(input('Informe sua idade: '))
salario = float(input('Infor... | true |
89208264bc943fda0447a5c382aeae4c4600a012 | MScracker/code_interview | /解方程-resolve_function.py | UTF-8 | 331 | 2.96875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @since : 2020-03-03 20:46
# @author : wongleon
from scipy.optimize import fsolve
def pmix(x):
return x
def paera(x, y):
return x**2 - y**2
def findIntersection(fun1, fun2, x0):
return [fsolve(lambda x:fun1(x)-fun2(x, y), x0) for y in range(1, 10)]
print findIntersection(pmix... | true |
d186b0fb7afd6171c0babc7df79c9fce0a07fbb4 | durena30/Tarea3S.O | /Tarea3_KGranados_DUrena_IMontero_HGonzales/Archivo.py | UTF-8 | 702 | 3.125 | 3 | [] | no_license | import msvcrt as ms
class Archivo:
def __init__(self):
self.Nombre=""
self.Texto=""
self.Direccion=""
def Editar(self, texto):
finish=False
print(texto)
while not finish:
if ms.kbhit() :
print("\033[2J\033[1;1f")
if ord(... | true |
9b57761f8b747bdd6295fffbafcc78294c4790d8 | xukangjune/Leetcode | /solved/264. 丑数II.py | UTF-8 | 725 | 3.9375 | 4 | [] | no_license | """
这题是找出第n个丑数,我的方法用到了集合,并在集合与数组之间转化,比较慢
最好的方法应用到了数学知识。
"""
class Solution(object):
n = 1690
listSet = {1}
index = 0
while n != 1:
ret = sorted(list(listSet))[index]
new = {ret * 2, ret * 3, ret * 5}
listSet |= new
index += 1
n -= 1
listSet.add(1)
ret = so... | true |
65823001bec9a9fc0cff96859fc284fae088c72a | Timurdov/python_lessons | /pr_8/cgi-bin/_wall.py | UTF-8 | 3,431 | 3 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import random
import time
class Wall:
USERS = 'cgi-bin/users.json'
WALL = 'cgi-bin/wall.json'
COOKIES = 'cgi-bin/cookies.json'
def __init__(self):
"""Створюємо початкові файли, якщо вони не створені"""
try:
... | true |
79bf20ca580e4c95c05a62312df5229247766a27 | devjuneja/Network-Traffic-Analyzer | /ssh.py | UTF-8 | 1,151 | 2.515625 | 3 | [] | no_license | from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from paramiko.ssh_exception import SSHException
from netmiko.ssh_exception import AuthenticationException
def check_ssh(ip):
ios = {
'device_type': 'cisco_ios',
'ip': ip,
'username': 'dev... | true |
566cf796e027eaf17fb60648b0c9ef3186d85334 | RWC18/Python | /Homework/Homework2_ex1.py | UTF-8 | 206 | 3.765625 | 4 | [] | no_license | list1 = [3, 6, True, True, -1, 'abc', (1, 2), [2, 3], 6]
print("List1 =",list1)
for i in range(len(list1)):
if type(list1[i]) == tuple:
print("ID of first Tuple", i)
break
print("List1[i] =",list1[i]) | true |
2768976c1d3c3f6ee5b46969e134cbc841e7ce3d | mjwestcott/projecteuler | /python/problem68.py | UTF-8 | 2,098 | 3.828125 | 4 | [
"MIT"
] | permissive | """
problem68.py
https://projecteuler.net/problem=68
What is the maximum 16-digit string for a 'magic' 5-gon ring?
"""
from itertools import chain
flatten = chain.from_iterable
def five_gon_rings(n):
"""Return list of solutions to the 'magic' 5-gon ring problem, each line
summing to n. The empty list will b... | true |
5434759690a68bd12d15f56b218b739f03c3d2a2 | Carb-X/Exercise | /decorator_0.py | UTF-8 | 437 | 3.203125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import functools
import time
# print function running time
def metric(fn):
@functools.wraps(fn)
def wrapper(*args, **kw):
start = time.time()
f = fn(*args, **kw)
end = time.time()
print('%s executed in %s ms' % (fn.__name__, end - start))
... | true |
bc64f94f5be5bb61be8a05f42598c54a2890154e | Reba001/Practica2s1_201314817 | /Estructuras/Lista.py | UTF-8 | 2,655 | 3.296875 | 3 | [] | no_license | import Nodo
cn = Nodo
#Clase listaSimple
class Lista(object):
def __init__(self):
self.__primero = None
self.__ultimo = None
self.__tamanio = 0
def getVacio(self):
if self.__primero == None:
return True
def setNodoInicio(self, elemento) :
nuevo = cn.Nodo(elemento)
if self.getVacio() == True:... | true |
8d1bdbd1b857294a0c0ae7c499db59c1a7aa35fa | eduardostalinho/project_euler | /src/euler2/test_euler2.py | UTF-8 | 525 | 3.453125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import unittest
import euler2
class TestFibonacci(unittest.TestCase):
def test_fibonacci_breaks_on_400000(self):
fib = euler2.fibonacci()
self.assertTrue(fib[-1] < 4000000 )
self.assertTrue(fib[-1] + fib[-2] > 4000000)
class TestSumOfEvens(unittest.TestCase):
... | true |
c423f345e764e3c2b9f718e7332c44423fe6d3a6 | spacetime314/python3_ios | /extraPackages/matplotlib-3.0.2/examples/images_contours_and_fields/contourf_hatching.py | UTF-8 | 1,844 | 3.453125 | 3 | [
"BSD-3-Clause"
] | permissive | """
=================
Contourf Hatching
=================
Demo filled contour plots with hatched patterns.
"""
import matplotlib.pyplot as plt
import numpy as np
# invent some numbers, turning the x and y arrays into simple
# 2d arrays, which make combining them together easier.
x = np.linspace(-3, 5, 150).reshape(1,... | true |
0b707d6df96105b301f66f516c0f08dbcf1640ff | therealbappi/Pitta-Goda | /src/block.py | UTF-8 | 410 | 3.015625 | 3 | [] | no_license | import pygame
from pygame.locals import *
class Block(pygame.sprite.Sprite):
def __init__(self, game, pos):
pygame.sprite.Sprite.__init__(self)
self.game = game
self.game.solids.add(self)
self.image = pygame.Surface([25,25])
self.image.fill((255,0,15))
self.rect = ... | true |
56f68308bd6d908d375d5d67342c9175c8ad5851 | dengyings/biji | /AID/object.py | UTF-8 | 3,408 | 2.671875 | 3 | [] | no_license | import os
import sys
import warnings
import numpy as np
import cv2 as cv
import hmmlearn.hmm as hl
def show_image(title, image):
cv.imshow(title, image)
def search_objects(directory):
if not os.path.isdir(directory):
raise IOError(
"The director '" + directory + "' doesn't... | true |
604f8c5bca19dcde160287839fdb7af8174dbccf | carlemil/ProjectEuler | /completed/euler0081.py | UTF-8 | 1,241 | 3.5 | 4 | [] | no_license | ##In the 5 by 5 matrix below, the minimal path sum from the top left to the
##bottom right, by only moving to the right and down, is indicated in red and
##is equal to 2427.
##
##131 673 234 103 18
##201 96 342 965 150
##630 803 746 422 111
##537 699 497 121 956
##805 732 524 37 331
##
##Find the minimal pat... | true |
3c33aa93d1ff174156acdc87991535efb2efada3 | Aiden-Wei/humanoid_walking_gait | /source/walking/robot_linear_interpolation_walking.py | UTF-8 | 6,287 | 2.53125 | 3 | [] | no_license | from time import sleep
from .template_for_robot_interpolation_walking import TemplateForRobotInterpolationWalking
class RobotLinearInterpolationWalking(TemplateForRobotInterpolationWalking):
DEBUG = False
def _take_steps(self, is_swing_leg_left, initial_position, lift_up_front_position, lift_up_front_forwar... | true |
a7c0bacdef5e62ffabfb1ea431a58beab6c05a16 | Eoin-McMahon/termToDo | /main.py | UTF-8 | 1,005 | 2.75 | 3 | [] | no_license | from termcolor import colored
from tabulate import tabulate
from utils import Utils
from table import Table
import os
class termToDo(object):
def __init__(self, items, done, table_headers):
self.items = items
self.table_headers = table_headers
self.done = done
self.utils = Util... | true |
ca696c26a25d067277343896db693f75c4b2a94d | KNG-Scherezade/Comp-472-Board-Game-AI | /data.py | UTF-8 | 2,052 | 3.0625 | 3 | [] | no_license | import numpy as np
# numpy array where index 0 is white and index 1 is red
# index [n][0] is color
# index [n][1] is moved pieces
# index [n][2] is placed pieces
p1_ascii = 119
p2_ascii = 114
player_data = np.array([[p1_ascii, 0, 0], [p2_ascii, 0, 0]])
board = np.empty((10, 12), np.int8)
empty_ascii = 43
board.fill(... | true |
7b2028bcbb88011197ab81d2f364f5cd30234769 | sengatang/TCrawler | /crawler/scrapy/sample/spiders/news.py | UTF-8 | 1,195 | 2.546875 | 3 | [] | no_license | #coding:utf-8
import scrapy
from scrapy.selector import Selector
from qqnews.items import QqnewsItem
from scrapy_redis.spiders import RedisCrawlSpider
import re
class newsSpider(RedisCrawlSpider):
print('here')
redis_key = 'newsSpider:start_urls' #redis 设置
print(redis_key)
# start_urls = ['http://news.... | true |
1303a245fb025d64baa9d85f28474eb35e0c79ea | vkaurmaj/MapQuest-Python | /mapquest_ui.py | UTF-8 | 3,630 | 3.4375 | 3 | [] | no_license | # mapquest_ui.py
# This module is responsible for tying together
# the user input, the API module and the output
# module through various functions.
import mapquest_api
import mapquest_op
def _num_of_inputs() -> int:
# Gets the number of address the user wants to navigate to
# and returns and integer v... | true |
2137f0de8519605c20dfeb996f4492cd82bf7669 | EnricoHuber/Rubbish | /Palindromi.py | UTF-8 | 1,001 | 4.28125 | 4 | [] | no_license | def reverse(stringToBeReversed):
"""
reverse a string
:param stringToBeReversed:
:return: output
"""
output = ""
for c in stringToBeReversed:
output = c + output
return output.lower()
def is_palindrom(string_in):
"""
Find if a word is palindrom
:param... | true |
a1caed12a665155d82c0e2eb1e78c945cc7cd11e | Anu9808/tathastu_week_of_code | /day3/program2.py | UTF-8 | 541 | 3.828125 | 4 | [] | no_license | from itertools import permutations
#METHOD 1 (WITH THE HELP OF ITERTOOLS MODULE)
def find_all_permutations(string):
for i in permutations(string):
print(''.join(i))
# driven code
string = input("Enter the string ")
find_all_permutations(string)
#METHOD 2 (WITHOUT USING ANY MODULE)
def permutations(l)... | true |
3c76223f75b2f794ea80974e332f9aae75c0952f | tiagolira13/moscowdjango | /apps/vacancies/parsers.py | UTF-8 | 3,734 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | # coding: utf-8
import re
import arrow
from arrow.locales import RussianLocale, EnglishLocale
from dateutil.tz import tzoffset
from django.utils.timezone import make_naive
import requests
import xmltodict
from apps.vacancies.models import Vacancy
class VacancySync:
def __init__(self, parsers=None):
sel... | true |
f4b1b78ad3c6abb7df25e877271228825b70f157 | derek-mallon/265 | /assignment2/knight.py | UTF-8 | 3,292 | 3.84375 | 4 | [] | no_license | #!/usr/bin/python
import random
import sys
#Class Definitions
#Pos class to hold a position on the board or the dimension of the board (used to make handling moves easier).
class Pos:
#Constructed with the x and y values.
def __init__(self,x,y):
self.x = x
self.y = y
return
def __st... | true |
876707c612bbeb3e3b79a1355fa3c09c49d0e1fd | mark-griffin/binja-debugger-scripts | /get_debuggee_value.py | UTF-8 | 6,746 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# By mechanicalnull, for funsies
"""
Get a register or memory value from the debuggee at a given address.
Envisioned use case: Compare register/memory values across inputs.
This is only a basic implementation but can easily be extended.
Written for well-behaved targets on little-endian system... | true |
5390b51cbc23c38e7b38fbf486551ddea5027917 | flyingleafe/dqnroute | /src/dqnroute/messages.py | UTF-8 | 12,375 | 2.6875 | 3 | [] | no_license | from functools import total_ordering
from copy import deepcopy
from typing import Tuple
from .utils import AgentId, InterfaceId
##
# Elementary datatypes
#
class WorldEvent:
"""
Utility class, which allows access to arbitrary attrs defined
at object creation. Base class for `Message` and `Action`.
""... | true |
27db379c14bb8aa2ffe14c60b0eb24e16a6c6153 | soskok1488/poe-currency-flip-planner | /src/backends/poetrade.py | UTF-8 | 2,033 | 2.671875 | 3 | [] | no_license | import concurrent.futures
import requests
from bs4 import BeautifulSoup
from src.assets import ItemList
def name():
return "poetrade"
def fetch_offers(league, currency_pairs, item_list: ItemList, limit=10):
"""
Fetches trading offers for a specific league and a pair of currencies from
poe.trade and... | true |
a8e22c4a133c24217a94861ad76b09e202c096ef | wwwwodddd/Zukunft | /leetcode/numbers-with-repeated-digits.py | UTF-8 | 550 | 2.671875 | 3 | [] | no_license | class Solution:
def numDupDigitsAtMostN(self, n: int) -> int:
z = n
n += 1
a = []
while n:
a.append(n % 10)
n //= 10
v = set()
c = 9
for i in range(1, len(a)):
z -= c
c *= 10 - i
for i in range(len(a))[::... | true |
764614ae79eb6e92265cc5f1bca3814ef9344245 | entrekid/daily_algorithm | /2020/0411/5397.py | UTF-8 | 613 | 3.25 | 3 | [] | no_license | import sys
input = sys.stdin.readline
from collections import deque
test_case = int(input())
def check(string):
cursor1 = deque()
cursor2 = deque()
for word in string:
if word == "<":
if cursor1:
cursor2.appendleft(cursor1.pop())
elif word == ">":
if ... | true |
a729b6c7ec56d0b7254e77b82dfff556b2797d81 | chenyidao110/python | /day007/Fibonacci.py | UTF-8 | 114 | 3.640625 | 4 | [] | no_license | """
斐波拉契数列
"""
a,b = 1,1
print(a,b,end=' ')
for _ in range(18):
a,b = b,a+b
print(b,end=' ') | true |
ea3b9efece7f337ac4760fad29e073d0612b0d75 | hoanghm/Face-Detector | /explore_images.py | UTF-8 | 2,100 | 2.796875 | 3 | [] | no_license | import pandas as pd
import os
import matplotlib.pyplot as plt
import numpy as np
import cv2
link_dataset = 'C:/Users/hoang/Downloads/CelebA'
image_folder = link_dataset + '/' + 'img_align_celeba/img_align_celeba'
os.chdir(link_dataset)
attribs_df = pd.read_csv('list_attr_celeba.csv')
def show_img(id):
img = cv2... | true |
5845930c54c0a9605b8a440bf1c470c9df669855 | RenYchh/interface_excel_pro | /Action/get_rely.py | UTF-8 | 3,359 | 2.625 | 3 | [] | no_license | from Config.Public_data import *
class GetRelyValue(object):
# 用于获取接口的依赖数据
def __init__(self):
pass
@classmethod
def get(cls,requestData,relyData):
#需要获取的数据可能来自上一个接口的请求参数,也可能来自响应body
if not requestData or not relyData:
return
reData = requestData.copy()
... | true |
3afaf8a8d1168c2e9fec3a73760a71f85dfc5410 | ArtyomKaltovich/Phylo | /hw1/task2/ete.py | UTF-8 | 1,074 | 2.765625 | 3 | [] | no_license | import os
import random
import sys
from ete3 import Tree, TreeStyle, TextFace
from utils import save_data_to_file
INPUT_DATA_FILE = r"data/data.txt"
NUMBER = 30
def read_prunned_data():
if not os.path.exists(INPUT_DATA_FILE):
save_data_to_file(INPUT_DATA_FILE)
t = Tree(INPUT_DATA_FILE, format=1)
... | true |
856d4bb1a3853bb040d953dec5ee1990ef04989f | sunsharing-note/python | /python_notes/day6/file1.py | UTF-8 | 739 | 2.953125 | 3 | [] | no_license | #! /usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : file1.py
@Time : 2018/12/19 20:05:59
@Author : chow
@Version : 1.0
@Contact : test@app.com
@License : (C)Copyright 2017-2018, Liugroup-NLPR-CASIA
@Desc : None
'''
# here put the import lib
'''
r只可读,
w只可写 #先清空,再写
r+ 读写模式 w+ 写读模式 a+ 追加... | true |
8f2d8d0a5a1726a2ab184136770824d93e6c0dea | JainManjari/ML_And_DataScience | /Data_Science_and_Machine_Learning/Getting_Familiar_with_ML_Libraries/Data_Visualization/Surface and Contour Plots.py | UTF-8 | 885 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#Used in ML, DL and Reinforcement Learning
# In[22]:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# In[23]:
a=np.array([0,1,2])
b=np.array([4,5,6,7])
a,b=np.meshgrid(a,b)
print(a)
print(b)
# In[29]:
fig = plt.f... | true |
07523625d297317c5ee40bdf173e374153d0ee53 | yaejinpark/machinelearning | /W1D4-5/CalculateLoss.py | UTF-8 | 524 | 2.859375 | 3 | [] | no_license | x = [1, 2, 3]
y = [5, 1, 3]
#y = x
m1 = 1
b1 = 0
#y = 0.5x + 1
m2 = 0.5
b2 = 1
y_predicted1 = [xval*m1 for xval in x]
y_predicted2 = [xval*m2+b2 for xval in x]
total_loss1 = 0
subsq = 0
ydiff = [yi - ypi for yi,ypi in zip(y,y_predicted1)]
for sub in ydiff:
subsq = sub*sub
total_loss1 += subsq
print(total_loss... | true |
a14de50d32dd2c56d3cf4d8f05d0ea2d3730c273 | lazypig-jan/Lan | /lan/commands/make.py | UTF-8 | 1,914 | 2.53125 | 3 | [] | no_license | import os
from jinja2 import Template
from lan import Yaml, Utils, Log
from lan.commands.it.apis_tpl_code import get_apis_code_tpl
class Make(object):
def __init__(self, path='./'):
# 获取当前执行命令目录
self.project_path = path
# yaml init
self.yaml_apis = Yaml(self.project_path + '/config... | true |
5e20a7bce1c0cbb24b657ae731bb864cd9c9c1db | Lucasbertilima/PythonPro | /Aula36 17-01/Dao/dao_backend.py | UTF-8 | 1,452 | 2.53125 | 3 | [] | no_license | import MySQLdb
from Model.backend import BackEnd
class DaoBackEnd:
conexao = MySQLdb.connect(host = '127.0.0.1',
database = 'PadawanHBSIS',
user = 'root')
cursor = conexao.cursor()
def listar_todos(self):
comando_sql = f"SELECT * FROM BAC... | true |
04a57b2ff8266953345d587a9da660b09b4a7fd3 | maurisg/python-for-everybody | /Chapter 10/exercise_02.py | UTF-8 | 1,406 | 4.09375 | 4 | [] | no_license | my_dictionary = {} # Creates an empty dictionary
my_list = [] # Creates an empty list
file = input("Enter file name: ")
try:
file = open(file)
except FileNotFoundError:
print("File cannot be opened:", file)
exit()
for line i... | true |
10a6085f93a0c3e8537e55a0a71afbb2927a0371 | vminakov/system-monitor | /src/model/memorychart.py | UTF-8 | 1,079 | 2.53125 | 3 | [] | no_license |
import psutil, random
from PySide import QtCore
from wsw.model import QAbstractItemModel, QTimer
class MemoryChart(QAbstractItemModel):
def __init__(self, memType, parent=None):
super(MemoryChart, self).__init__(parent)
self._type = 'virt' if memType == 'virt' else 'swap'
# fetch initial... | true |
13bf56c37ccd96de3f0913f92c1ac27ee7f68052 | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_1/lvwrence/sheep.py | UTF-8 | 814 | 3.78125 | 4 | [] | no_license | import sys
def sheep(n):
if n == 0:
return "INSOMNIA"
digits = set(range(0, 10))
current_number = n
while digits:
string_version_of_current_number = str(current_number)
digits_to_remove = map(int, list(string_version_of_current_number))
digits = digits.difference(digits... | true |
2a66fbe95f58a35107bb26e73ba23e3f5f74b24c | topDreamer/nlp-journey | /tutorials/06.transformers_tutorial/02.question_answer.py | UTF-8 | 2,441 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | # coding=utf-8
# created by msgi on 2020/4/10 10:15 上午
import torch
from transformers import BertForQuestionAnswering
from transformers import BertTokenizer
model = BertForQuestionAnswering.from_pretrained('bert-large-uncased-whole-word-masking-finetuned-squad')
tokenizer = BertTokenizer.from_pretrained('bert-large-u... | true |
07ee4b30ed7c39f4c53c7b134be4dd24197cf3f8 | redcrix/puzzle_text | /app.py | UTF-8 | 1,300 | 2.59375 | 3 | [] | no_license | import cv2
import numpy as np
import csv
# reading the image
image = cv2.imread("puzzlev4.jpg")
edged = cv2.Canny(image, 10, 250)
#cv2.imshow("Edges", edged)
#cv2.waitKey(0)
# applying closing function
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (7, 7))
closed = cv2.morphologyEx(edged, cv2.MORPH_CLOSE, kernel... | true |
82bb7749bae3f08ebb2d0d9e8a63b44f7cb5d533 | JackAbel/testPython | /PythonDebugDemo/chapter-11-function.py | UTF-8 | 4,831 | 3.421875 | 3 | [] | no_license | # /usr/bin/env python
# -*- coding:utf-8 -*-
from random import randint as ri
def bar():
return 'abc', [(4-6j), 12], 'Guido'
# 如果函数返回多个对象,Python把他们聚集成一个元组返回
# 当显式的返回None,没有显示的返回对象时,便返回一个none
from operator import add, sub
from random import randint, choice
ops = {'+': add, '-': sub}
MAXTRIES = 2
def doprob():
... | true |
357fbb3431c0d2c74c8f82d3ff80d3b8a6b1d65b | ControlEverythingCommunity/A1332 | /Python/A1332.py | UTF-8 | 884 | 3.15625 | 3 | [] | no_license | # Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
# A1332
# This code is designed to work with the A1332_I2CS I2C Mini Module available from ControlEverything.com.
# https://www.controleverything.com/content/Hall-Effect?sku=A... | true |
ae31e73aba86370c9405dd53ea6b9a43a78e92de | Crone1/College-Python | /Year One - Semester One/Week Seven/non-empty-1.py | UTF-8 | 126 | 2.671875 | 3 | [] | no_license | #! /usr /bin/env python
total = 0
i = 0
while i < len(a):
if a[i] != '':
total = total + 1
i = i + 1
print total
| true |
668315172f41f074dcdc9df2124ab5c145d3422e | musainiramlee/Projects | /Car Game.py | UTF-8 | 691 | 3.59375 | 4 | [] | no_license | started = False
while True:
command = input().lower()
if command == 'start':
if started:
print('Car has already started')
else:
started = True
print("Vroom...vroom! Car is ready. Let's go!")
elif command == 'stop':
if not started:
print... | true |
81628c4d608712b40dcba1dafa04474cdfc8bf7c | khanmaster/eng_57_opp | /python_name_&_main.py | UTF-8 | 683 | 3.859375 | 4 | [] | no_license | # what is __name__ & __main__ in python and why we need it
# what is the benefit of __name__ and __main__ when importing
# They are part of python execution/interpreter engine and set these variables before running any other code within a file/function/method
# Let's dive straight in as it's the easiest way to under... | true |
327ff4197fe8f897216c41e64efd0cbc2f4df2a3 | blue995/stair-lighting | /stair_lighting/config/stair_settings.py | UTF-8 | 1,750 | 2.859375 | 3 | [] | no_license | import json
import logging
from pathlib import Path
logger = logging.getLogger()
class StairSettingsEntry:
def __init__(self, *args, **kwargs):
self.number = -1 if not ('number' in kwargs) else kwargs['number']
self.gpio = -1 if not ('gpio' in kwargs) else kwargs['gpio']
class StairSettings:
... | true |
f39cc944fc9ddd7502b54ccfe3af9b0bbb2a8405 | SDoc/py-sdoc | /sdoc/sdoc1/data_type/StringDataType.py | UTF-8 | 3,015 | 3.296875 | 3 | [
"MIT"
] | permissive | from sdoc.sdoc1.data_type.DataType import DataType
class StringDataType(DataType):
"""
Class for string data types.
"""
# ------------------------------------------------------------------------------------------------------------------
def __init__(self, value: str):
"""
Object c... | true |
7715e5ae23246bdbd234c13db737873e43b629f4 | Yu-Igarashi-aiiit/SelfStudying | /atcoder/abc/abc141.py | UTF-8 | 950 | 3.15625 | 3 | [] | no_license | #a
s = input()
li = ["Sunny","Cloudy","Rainy"]
if(s==li[0]):
print(li[1])
elif(s==li[1]):
print(li[2])
elif(s==li[2]):
print(li[0])
#b
s = list(input())
flg=0
for i in range(1,len(s)+1):
if(i%2!=0):
if s[i-1] not in ["R","U","D"]:
flg=1
elif(i%2==0):
if s[i-1] not in [... | true |
3bd9457c271619e0d7c3238a100c4d5973b80662 | has2k1/plotnine | /plotnine/geoms/geom_bar.py | UTF-8 | 1,373 | 2.59375 | 3 | [
"MIT"
] | permissive | from __future__ import annotations
import typing
from ..doctools import document
from ..utils import resolution
from .geom_rect import geom_rect
if typing.TYPE_CHECKING:
import pandas as pd
@document
class geom_bar(geom_rect):
"""
Bar plot
{usage}
Parameters
----------
{common_paramet... | true |
ddbdbce3a3a8d301d64857e33841d62e1217f580 | lethanhday/hieuhien.vn | /script.module.framework/lib/api/data.py | UTF-8 | 3,220 | 2.640625 | 3 | [] | no_license | import zipfile
import cStringIO as StringIO
import gzip
import hashlib
import binascii
import json
import simplejson
import api
import sys
# from lxml import etree, html, objectify
# from lxml.html import soupparser
# from bs4 import UnicodeDammit
class ZipArchive(object):
def __init__(self, data=None):
self.... | true |
88fff45921e83351ac2aa3ad97ea49a31ae0fb97 | Stanels42/python-data-structures-and-algorithms | /challenges/ArrayShift/test_array_shift.py | UTF-8 | 1,664 | 3.734375 | 4 | [
"MIT"
] | permissive | import pytest
from array_shift import insert_shift_array, remove_center
################
# Insert Shift #
################
# Test Even List
def test_one():
actual = insert_shift_array([1,2,4,5], 3)
expected = [1,2,3,4,5]
assert actual == expected
# Test Odd List
def test_two():
actual = insert_shift_array([... | true |
7363a1ab2c59a4b98d19088f6aec5686e9ee8ee1 | madisonmay/Decorative | /decorative/tests/test_debug.py | UTF-8 | 503 | 3.15625 | 3 | [] | no_license | import sys
import unittest
from StringIO import StringIO
from decorative import debug
@debug
def f(a, b):
return a + b
class DebugTestCase(unittest.TestCase):
def test_debug(self):
saved_stdout = sys.stdout
try:
fake_stdout = StringIO()
sys.stdout = fake_st... | true |
a2e1e2c5b9322c6c1b55b67a364bfc6ee5ea0d36 | Wald-K/design_patterns | /facade.py | UTF-8 | 557 | 3.328125 | 3 | [] | no_license | class Element1:
def metoda(self):
print("Metoda klasy Element1")
class Element2:
def metoda(self):
print("Metoda klasy Element2")
class Element3:
def metoda(self):
print("Metoda klasy Element3")
class Facade:
def __init__(self):
self.element = []
self.el... | true |
ba0ef70eea16849cb975427787b2108fe58a21cc | nitronoid/PokemonTCG | /GameHub/Cards/SM/SUM/135.py | UTF-8 | 1,388 | 2.984375 | 3 | [] | no_license | import poke as p
def pokeFilter(card):
return card.cardType() == p.CARD.POKEMON
def discardFilter(card):
return True
# checks if the amount of cards in your hand is bigger than 2 and deck is not empty
# return true if yes else return false
def canPlay(h):
return h.numCards(p.PLAYER.SELF,p.PILE.HAND) > 2... | true |
973bd3f153b4d4ddc6b7807c8a21b0a9def9f3a3 | DainDwarf/AdventOfCode | /2017/Day22/day22.py | UTF-8 | 4,289 | 3.546875 | 4 | [] | no_license | #!/usr/bin/python3
from __future__ import print_function
def turnRight(d):
if d=='up':
return 'right'
elif d=='right':
return 'down'
elif d=='down':
return 'left'
elif d=='left':
return 'up'
def turnLeft(d):
if d=='up':
return 'left'
elif d=='left':
... | true |
3e745ca208a40f45e82435dbe1f1c60c50717711 | jikaufman/testbank | /scrape.py | UTF-8 | 5,065 | 2.875 | 3 | [] | no_license | import os
import sys
import requests
from lxml import html
if __name__ == "__main__":
# login details, handled by bash script
username = sys.argv[1]
password = sys.argv[2]
# necessary urls
login_url = 'https://upe.seas.ucla.edu/auth/login'
testbank_url = 'https://upe.seas.ucla.edu/testban... | true |
ac803d215a2cc2dbf193e3a7cf10d90193410935 | hackingmath/AdventOfCode2020 | /day15.py | UTF-8 | 1,128 | 3.296875 | 3 | [] | no_license | # Advent of Code 2020 Day 8
# https://adventofcode.com/2020/day/8
import time
#from random import randint
from itertools import combinations
starting_time = time.time()
nums = [0,3,1,6,7,5]
numdict = dict()
def find_last(arr,n,testing):
"""Returns difference of indexes of n in arr"""
if arr.co... | true |
94d46d414e622fb9853f212015587df76b5f7420 | athletejuan/TIL | /Algorithm/BOJ/16768.py | UTF-8 | 1,325 | 2.75 | 3 | [] | no_license | N,K = map(int, input().split())
MY = [list(input()) for _ in range(N)]
flag = True
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
def connect(x,y,c):
stack, temp = [[x,y]], [[x,y]]
check = 1
while stack:
x,y = stack.pop()
visited[x][y] = 1
for i in range(4):
nx, ny = x + dx[i], ... | true |
14fa93a701fee59fe2becb4627b6d416e67eeeab | astoeff/Programming-101-Python-2020 | /week06/WEDNESDAY/book_generator.py | UTF-8 | 1,231 | 3.65625 | 4 | [] | no_license | import random
def generate_book(title, chapters_count, words_count):
with open('book.txt', 'w') as f:
f.write(title + '\n\n')
for chapter_number in range(chapters_count):
with open('book.txt', 'a') as f:
f.write('# Chapter ' + str(chapter_number + 1) + '\n')
words = ope... | true |
ca6ebe556b378a9006bf879bf217c96a76b238ec | atreyu595/Australian-Bush-Fire-Analysis | /Forest Fire Predictor/model.py | UTF-8 | 1,421 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 15 17:58:40 2021
@author: Atrey
"""
#import necessary libraries for data wrangling
import pandas as pd
#Import model saver
import pickle
#import machine learning libraries and modules
from sklearn.model_selection import train_test_split
from sklearn.m... | true |
7f323c61aa08c9147dcc9f51467f494a3569fea6 | Pyk017/Python | /Interesting_Codes/combinations.py | UTF-8 | 1,108 | 2.546875 | 3 | [] | no_license | <<<<<<< HEAD
import itertools
n, a, b = list(map(int, input("Enter N, A and B :- ").split()))
l = list(dict(zip(itertools.count(a), range(b - a + 1))))
flag = False
new_l = []
j = 0
for i in range (2, n // min(l) + 1):
it = list(itertools.combinations_with_replacement(l, i))
for j in it:
if sum... | true |
b742dd1f50451c17a1a38abca887be6512e5d258 | ChoppingBroccoli/Testing | /Items_Brought.py | UTF-8 | 978 | 4.09375 | 4 | [] | no_license | allGuests = {'Alice': {'apples': 5, 'pretzels': 12},
'Bob': {'ham sandwiches': 3, 'apples': 2},
'Carol': {'cups': 3, 'apple pies': 1}}
def totalBrought(guests, item):
numBrought = 0
for k, v in guests.items():
numBrought = numBrought + v.get(item, 0)
return numBrought
pri... | true |
1a39345d2951242ee6af42d332d743958e638979 | ABenxj/leetcode | /54 spiralOrder.py | UTF-8 | 872 | 3.25 | 3 | [] | no_license | #!/usr/bin/env pyhton
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021 , Inc. All Rights Reserved
#
"""
Authors: jufei
Date: 2021/4/19 11:10 AM
"""
from typing import List
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
"""
递归的思想, 每次遍历最外圈,剩下的递归就好,注意边界条件; 另一种思路,按照螺旋规则... | true |
9cf3cb32104c2223af531d432986d7ce3ebe12de | thepharmproject/set_of_scripts | /single_web.py | UTF-8 | 1,727 | 2.890625 | 3 | [] | no_license | ''' This python file implements a text parser for any website '''
''' LIBRARIES IMPORTED '''
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.support import ... | true |
6e8167786d7028f5e9dcd36197442718a83024e1 | FLoosli/CP_GAN | /Input_and_Utils.py | UTF-8 | 13,387 | 2.765625 | 3 | [] | no_license | import skimage.io
import numpy as np
import skimage
from skimage.transform import resize
from matplotlib import pyplot as plt
from pycocotools.coco import COCO
from scipy import ndimage
# Directory to which the images are saved to
SAVE_DIRECTORY = '../Examples_Results'
EVAL_DIRECTORY = '../Evaluation'
# Dataset path... | true |
c49e1ed8df0b99a7fcf552c22433651d986e631d | Mikisepic/SpaceApps | /air_quality_visualisation_demo.py | UTF-8 | 3,172 | 3.03125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# coding: utf-8
# In[225]:
import pandas as pd
import folium
# In[226]:
def get_aod_data_by_time_and_region(selected_year, selected_month, selected_day, selected_region):
if selected_region == "Los Angeles, USA":
aodData = pd.read_csv("air quality losAngeles.csv", sep=";")
... | true |
5faaef98966012f31ac1e1e720907f5fd5b0d3f6 | fengjiachen/leetcode | /300_349/334_Increasing_Triplet_Subsequence.py | UTF-8 | 527 | 3.234375 | 3 | [] | no_license | import sys
class Solution:
def increasingTriplet(self, nums: [int]) -> bool:
if len(nums) < 3:
return False
small = nums[0]
mid = sys.maxsize
for i in range(1, len(nums)):
if nums[i] > mid:
return True
elif nums[i] <= small:
... | true |
5765ac083f088a6058eac28a4affe2de9872954d | LyricLy/python-snippets | /harmonic_series.py | UTF-8 | 1,076 | 3.546875 | 4 | [
"CC0-1.0"
] | permissive | #!/usr/bin/env python3
# encoding: utf-8
#
# harmonic_series.py
#
# Benjamin Mintz, 2017
#
# Public Domain
import unittest
def harmonic_series(n):
"""not tail-call recursive"""
if n == 1:
return 1
else:
return 1/n + harmonic_series(n - 1)
def harmonic_series_tcr(n):
"""tail-call recursive"""
def a... | true |
975d5bf15e6980f1b52044a90056b0fd344b8990 | cclark94/automata | /aut/baseAut.py | UTF-8 | 6,918 | 3.140625 | 3 | [] | no_license | from PIL import Image
import random, string, sys
class BaseAut:
def __init__(self, width, height):
self.width = width
self.height = height
# Stores the list of filters that have been applied
# to the automaton
self.filters = list()
def __str__(self):
... | true |
6d67ae8dbe0bbea8fbc42dec01641f15d2d3173b | fstakem/Lexly | /Lexly/Token.py | UTF-8 | 863 | 2.578125 | 3 | [] | no_license | # ------------------------------------------------------
#
# Token.py
# By: Fred Stakem
# Created: 7.8.13
#
# ------------------------------------------------------
# Libs
# None
# User defined
from Utilities import *
from Stream import Stream
from Corely import Jsonable
# Main
class Token(Jsonable):
... | true |
387e5e3ce7cd66a2e1aed63182081271e7bdb216 | dualfame/yzu_python | /case09.py | UTF-8 | 154 | 3.40625 | 3 | [] | no_license | # BMI
h = float(input("身高"))
w = float(input("體重"))
BMI = w / (h/100)**2
print(BMI)
print("身高= %s 體重= %s BMI= %.2f" % (h, w, BMI)) | true |
e62058dabb054f819dd0db16ac0695a057e9e75f | PhilippeJanssens/3D_houses-1 | /utils/api.py | UTF-8 | 3,239 | 3.15625 | 3 | [
"BSD-3-Clause"
] | permissive | #importing requests library to get the request from the API
import requests
from Typing import List, Dict
class API:
"""
Class API is where we request the details of the address from the API
It contains two functions namely:
:get_details function where we check if the address is in the API and get the ... | true |
3d19d7065ea05a001d8a8d538916da4575a2f777 | socek/cashcat | /backend/code/cashcat/bill/patcher.py | UTF-8 | 1,959 | 2.9375 | 3 | [] | no_license | class BillPatcher(object):
_bill_keys = ["place", "billed_at"]
_item_keys = ["name", "quantity", "value", "group_uid"]
def __init__(self, old_object, new_object):
self.old_object = old_object
self.new_object = new_object
self.new_object.billed_at = self.new_object.billed_at.isoforma... | true |
a36cc02ca26f89a6e240c8a525adfafbd784d4f7 | AndyKANG98/Drop-MOOC-Prediction | /main.py | UTF-8 | 5,189 | 3.21875 | 3 | [] | no_license | import pandas as pd
import time
import numpy as np
from preprocess import Preprocessor
# Scikit Learn Libraries
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import VotingClassifier
from sklearn import metrics
# XGBoost Library
from xgboost... | true |
75cfb799d711a70e5e501a9564812236709ca594 | d3rky/django-rql | /dj_rql/grammar.py | UTF-8 | 2,010 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | #
# Copyright © 2020 Ingram Micro Inc. All rights reserved.
#
# flake8: noqa
"""
RQL EBNF LALR(1) compatible grammar for standard Lark lexer.
Notes:
- rules are lowercase. They only consist of values, other rules and terminals.
- TERMINALS are uppercase. They only consist of values and other terminals.
"""
... | true |
2c56fff5765c1f66bb34f6979958ab06eba26688 | dogac00/Pandas | /select-rows-based-on-columns.py | UTF-8 | 250 | 3.5625 | 4 | [] | no_license | import pandas as pd
# import the libray
d = {'foo': [100,101,102], '^bar': [200,201,202]}
# create the dictionary
df = pd.DataFrame(d)
# pass the dictionary to the pandas dataframe
df.loc[df.foo == 101]
# the the row where foo is equal to 101
| true |
4b37db9a1d963581e369888ec39d4b22be97a42c | PaulAYoung/nlp2014_kaggle | /tfidf_class.py | UTF-8 | 3,255 | 2.828125 | 3 | [] | no_license |
# coding: utf-8
# In[7]:
import math
import cPickle as pickle
import nltk
from testing_util import sample_sets
# In[2]:
def get_idfs(samples, termer):
sample_terms = [list(set(termer(s[1]))) for s in samples]
nsamps = len(samples)
idf = {}
for term in [t for s in sample_terms for t in s]:
... | true |
0903f48a303c25ef2e29bff3f35e07f4b29cafb7 | gleiss/rapid | /examples/arrays/str_cpy.spec | UTF-8 | 691 | 3.03125 | 3 | [] | no_license | func main()
{
Int[] a;
const Int[] b;
const Int length;
Int i = 0;
while(i < length && b[i] != 0)
{
a[i] = b[i];
i = i + 1;
}
}
(conjecture
(forall ((pos Int))
(=>
(and
(<= 0 length)
(<= 0 pos)
(< pos (i main_end))
)
(= (a main_end pos) (b pos) )
)
)
)
(conjecture
(forall ((pos... | true |
0fe78b3efa957ecd05357dac2af774dda1f778ba | zhaocheng1996/pyproject | /algorithm_test/link/revese_neighbor.py | UTF-8 | 1,087 | 4.3125 | 4 | [] | no_license | '''
把链表相邻元素翻转,给定链表 1->2->3->4->5->6->7
翻转后链表变为 2 1 4 3 6 5 7
就地逆序
'''
class LNode():
def __init__(self,x=None):
self.data = x
self.next = None
def reverseNear(head):
cur = head.next
pre = head
next = None
while cur != None and cur.next != None:
next = cur.next.next#next这个时候... | true |
a23d20b32a8ec38af1db2283a39350160e901d2a | sh999/search | /parse.py | UTF-8 | 977 | 2.5625 | 3 | [] | no_license | '''
parse.py
Parse for pagerank
'''
import json
import pickle
from pprint import pprint
pages = {}
counter = 0
path = "sitegraph-engr-9pm-7000.json"
with open(path) as inputfile:
for line in inputfile:
line = json.loads(line)
site = line['url']
# Treat http and https as the same
if site[4:5] == "s":
site ... | true |
29dfd7e1f533c96dc462058a4594c3c8e9e8635a | glample/Gutenberg | /gutenberg/common/typesafe.py | UTF-8 | 4,928 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | """Utility functions to deal with type-safety."""
import types
def namedtuple(clsname, field_info): # pylint: disable=R0912
"""Factory that creates a type with a given name and fields.
This is essentially a version of collections.namedtuple that enforces the
types of its arguments.
Arguments:
... | true |
eb8163a13bf9d9c8355ac3bb2be52698879e20f2 | freonL/MARK5826_MovieBot | /data/data_prep.py | UTF-8 | 1,275 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | import pandas as pd
import ast
# read dataset
# movies_metadata_sample is faster to preprocess
# movies_metadata has bigger record but slower to preprocess
metadata = pd.read_csv('data/movies_metadata_sample.csv', low_memory=False)
# metadata = pd.read_csv('data/movies_metadata.csv', low_memory=False)
# we drop som... | true |
38673b70490dc6b59215c04581ce5d8acb80ae5e | AbhiGowdaIndia/Mechine-Learning | /Naive Bayes/NaiveBayes-Example-3.py | UTF-8 | 1,044 | 3.140625 | 3 | [] | no_license | import pandas
import numpy
from sklearn import datasets
from sklearn.metrics import classification_report,confusion_matrix,accuracy_score
from sklearn.naive_bayes import GaussianNB
# Loading dataset from csv
dataset=pd.read_csv("SocialNetworkAds.csv")
# extracting independent variables
X = dataset.iloc[:,[2... | true |
7be6e362e2538ced082a2a29b85f551661dc9b78 | jjvilm/osrmacro | /herbCleaner.py | UTF-8 | 7,119 | 2.59375 | 3 | [] | no_license | #!/usr/bin/python3
import cv2 #to find template
import numpy as np #needed by cv2
from random import seed, randint, choice, triangular, random#get random time
from time import sleep #for sleep
from os import getcwd
from modules import osr # to open bank at Castle Wars
import Herbdat
#Finds an image from the given temp... | true |
9e072a842c1fbebbd08aa028d6f954b5d582d8aa | VladislavSpassov/HackBulgariaTasks | /Week02/Stations.py | UTF-8 | 731 | 3.234375 | 3 | [] | no_license | import pdb
#pdb.set_trace()
def gas_stations(distance, tank_size, stations):
result = []
for index in range(len(stations)):
if(index == len(stations) - 2):
if(distance - stations[index]> tank_size):
result.append(stations[index + 1])
break
if(index ==... | true |
d325cccf98ef233599059a6b226abc1ad7aa99e8 | suqin/Practice | /Suduku/SudukuResolv.py | UTF-8 | 1,390 | 3.1875 | 3 | [] | no_license | Suduku = []
Suduku +=[[7,4,0,0,8,0,0,1,6]]
Suduku +=[[9,0,0,0,3,5,0,0,4]]
Suduku +=[[0,0,0,7,0,0,0,0,0]]
Suduku +=[[0,7,0,0,0,9,5,0,0]]
Suduku +=[[6,1,0,0,5,0,0,8,7]]
Suduku +=[[0,0,2,6,0,0,0,4,0]]
Suduku +=[[0,0,0,0,0,4,0,0,0]]
Suduku +=[[3,0,0,5,6,0,0,0,2]]
Suduku +=[[5,6,0,0,1,0,0,3,9]]
Value = [0,1,2,3,4,5,6,7,8,... | true |