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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
efbf189790a57044aa8404d86e8e71adb44f941b | Python | CitrineInformatics/refkit | /reference.py | UTF-8 | 4,645 | 3.015625 | 3 | [
"MIT"
] | permissive | """
Functions for determining information about a referenced work.
"""
from refkit.lookup import arxiv
from refkit.lookup import crossref
from refkit.metadata import Metadata
from refkit.util.doi import extract
def getMetadata(input, autoSaveMinimum = crossref.defAutoSaveMinimum, autoSaveMaximum = crossref.defAu... | true |
1e818cb231313b0d1172854c5f794f6b7f322f0d | Python | haokiet97/sort_1m_integer | /random_1m.py | UTF-8 | 223 | 2.921875 | 3 | [] | no_license | import random
import struct
with open('numbers.dat','wb') as output:
for i in xrange(1000000):
u = random.randint(-(2**31), 2**31-1) # number
b = struct.pack('i', u) # bytes
output.write(b)
| true |
31edc769a050baef20d324497202bbeaf0f9d967 | Python | ITianerU/algorithm | /leetcode/24_两两交换链表中的节点/python.py | UTF-8 | 764 | 3.953125 | 4 | [] | no_license | """
给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。
示例:
给定 1->2->3->4, 你应该返回 2->1->4->3.
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/swap-nodes-in-pairs
"""
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
# 递归
... | true |
7b293899463814cb8d2db127ae1707ff7240af0c | Python | officelabotera/RasPi_Saibaiman | /soil_monitor/monitorsoil.py | UTF-8 | 1,479 | 2.5625 | 3 | [] | no_license | #/usr/bin/python
import sys
import sqlite3
from webiopi.devices.analog.mcp3x0x import MCP3204
from datetime import datetime as dt
CURRENT_DIR="/home/pi/Tera/work/soil_monitor/"
DB_DIR=os.path.dirname(os.path.abspath(__file__)) + '/database/data.db'
class SoilMonitor(object):
def __init__(self):
self.id=None
... | true |
ffe321ce2512aa4c6d05c89049bdde7e40ed6e79 | Python | leorrib/texas_holdem_poker | /tests/validators/test_flush_validator.py | UTF-8 | 1,783 | 3.4375 | 3 | [] | no_license | import unittest
from poker.card import Card
from poker.validators import FlushValidator
class FlushValidatorTest(unittest.TestCase):
def setUp(self):
self.three_of_clubs = Card(rank = "3", suit = "Clubs")
self.five_of_clubs = Card(rank = "5", suit = "Clubs")
self.six_of_clubs = Card(rank =... | true |
774bdf9e875ad091a86b46136b5950ec9f9d3e02 | Python | kontheocharis/advent-of-code-2020 | /day-03/part2.py | UTF-8 | 377 | 3.328125 | 3 | [] | no_license | from math import prod
tree_map = [x.strip() for x in open('input.txt')]
def calc_trees(right, down):
count = 0
for y in range(0, len(tree_map), down):
if tree_map[y][int(right * y / down) % len(tree_map[0])] == '#':
count += 1
return count
slopes = [(1, 1), (3, 1), (5, 1), (7, 1), (1,... | true |
0c6c360e46226966efac71c826ab3f078a6fe23d | Python | davidedr/Ng-s-Neural-Networks-and-Deep-Learning | /src/image_manipulation/tensorflow_basics.py | UTF-8 | 6,012 | 3.28125 | 3 | [] | no_license | '''
Created on 02 set 2017
@author: davide
'''
import numpy as np
x = np.linspace(-3.0, 3.0, 100)
print(len(x))
print(type(x))
print(x.dtype)
print(x.shape)
print(x)
print()
print('USING TENSOR FLOW')
print()
import tensorflow as tf
print('Get default graph...')
g = tf.get_default_graph()
print... | true |
2a2ef4e02fb17369e1fcf6fb391f8411a87604dc | Python | grilo/complic | /complic/licenses/evidence.py | UTF-8 | 3,650 | 2.703125 | 3 | [
"BSD-2-Clause",
"AGPL-1.0-only",
"WTFPL"
] | permissive | #!/usr/bin/env python
import logging
import json
import copy
import datetime
class Report(object):
def __init__(self, name, compat_checkers=[]):
self.name = name
self.compat_checkers = compat_checkers
self.licenses = {}
self.dependencies = {}
def add_compat(self, compat):
... | true |
461f33b850175b5c36a0f015a9e47d1241b6f05e | Python | dverdejo/Package-transport | /packageTransport.py | UTF-8 | 660 | 3.15625 | 3 | [] | no_license | peso = 41.5
transporte = 300
# Envío terrestre
if peso <= 2:
precio = peso * 1.5 + transporte
elif (peso > 2) and (peso <= 6):
precio = peso * 3 + transporte
elif (peso > 6) and (peso <= 10):
precio = peso * 4 + transporte
else:
precio = peso * 4.75 + transporte
print("El envío terrestre cuesta $", pr... | true |
e4e46a45ff654c3cc9e81cc7e61d2e0ac854afee | Python | c-yan/atcoder | /arc/arc021/arc021b.py | UTF-8 | 183 | 2.953125 | 3 | [
"MIT"
] | permissive | L, *B = map(int, open(0).read().split())
A = [0] * L
for i in range(L - 1):
A[i + 1] = A[i] ^ B[i]
if B[L - 1] != A[L - 1] ^ A[0]:
print(-1)
exit()
print(*A, sep='\n')
| true |
022f476385acfbbeebe898b859490cb093ff5ff4 | Python | jzarnett/ece459 | /lectures/live-coding/L24/hash-and-reduce.py | UTF-8 | 396 | 3.234375 | 3 | [] | no_license | from hashlib import md5
from sys import argv
def reduce(digest):
reduced = ""
for c in digest:
if c.isdigit():
reduced = reduced + c
if len(reduced) == 7:
return reduced
plaintext=argv[1]
md5_digest = md5(plaintext.encode()).hexdigest()
reduced = reduce(md5_digest)
print ("Plaintext: ", p... | true |
9843520c1c76fd1eb434cfc050fd48bffca80660 | Python | catoror/masglobal_handsontest | /masglobal/employees_api/Services/Employee.py | UTF-8 | 582 | 3.078125 | 3 | [] | no_license | import abc
class Employee(abc.ABC):
def __init__(self, employee_id, name, contract_type_name, role_id,
role_name, role_description, hourly_salary, monthly_salary):
self.employee_id = employee_id
self.name = name
self.contract_type_name = contract_type_name
self.role... | true |
61b7a202c27cb0d9bc2b73b926c780b32c9bc1cd | Python | leandrop25/Saman-Caribbean | /Leandro Perestrelo - Saman Caribbean/VentaCrucero.py | UTF-8 | 2,298 | 3.171875 | 3 | [] | no_license | from Cliente import Cliente
from Venta import Venta
class VentaCrucero(Venta):
def __init__(self, habitaciones):
super().__init__([], 0.0, 0.0, 0.0)
self.habitaciones = habitaciones
self.iva = 0
self.items = []
def calcular_descuento(self, doc_identidad, discapacidad, habita... | true |
665d352d3c6376f4bdfbe7834f7d9d38e1c37554 | Python | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/hamming/7d777c8b1a134a1ca2a2ef4546f05a0a.py | UTF-8 | 352 | 3.5625 | 4 | [] | no_license | def hamming(A, B):
#Create a counter for the hams that happen
hamCount = 0
#Find which one is longer string
if len(A) > len(B):
j = len(B)
difference = len(A) - len(B)
else:
j = len(A)
difference = len(B) - len(A)
for i in range(0, j):
if A[i] != B[i]:
hamCount += 1
hamCount = hamCoun... | true |
0a74aa61a82ec28c96b36ee1624324cc08bbb4e8 | Python | FullSave/gamejam | /gamejam/scoreboard.py | UTF-8 | 4,339 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file is part of FullSave Gamejam.
Copyrights 2018 by Fullsave
"""
import pyxel
import random
from pyxel.ui.constants import FONT_WIDTH, FONT_HEIGHT
from .server import Server, RAM, CPU
from .rack import Rack
from .misc import SpriteSheet
TXT_COLOR = 7
TXT_SPACE... | true |
26be804408336eadba7347b1479ab399988561c4 | Python | GEEZEEBE/mountain-skyscraper_project | /data_scrap/skyscrapers/get_coord.py | UTF-8 | 893 | 3.53125 | 4 | [] | no_license | # 모듈 불러오기
import os
import re
def get_coord(building_name):
"""
설명 : 빌딩의 좌표를 읽어와 리턴함
building_name : 빌딩 이름
"""
# 파일 읽기
strfile = os.path.realpath(__file__)
strfile = os.path.join(os.path.dirname(strfile), "list.txt")
f = open(strfile, encoding='utf8')
lines = f.readline... | true |
cac4538c9a45db60d58298e7bfcfb564cce38069 | Python | danieljeswin/RLAlgos | /DQN/lib/dqn_model.py | UTF-8 | 6,385 | 2.671875 | 3 | [] | no_license | import torch
import torch.nn as nn
import numpy as np
import torch.autograd as autograd
import torch.nn.functional as F
class NoisyLinearFunction(autograd.Function):
@staticmethod
def forward(ctx, input, weight, bias, sigma_weight, sigma_bias, epsilon_input, epsilon_output):
output_features, input... | true |
ab556de2fcb6f5d0b22bbb99c99c146711348c2f | Python | diegodh1/spataro_pedido | /modulos/Cliente.py | UTF-8 | 15,084 | 2.890625 | 3 | [] | no_license | class Cliente:
def __init__(self, conn):
self.conn = conn
"""Este metodo se encarga de crear un nuevo cliente en la BD
Arguments:
id_cliente {Integer} -- la cedula o nit de la entidad o persona
id_tipo_doc {char(50)} -- el tipo de documento (cedula, cedula extra... | true |
e79db0e732e18462f784df838fbc1998dbe85563 | Python | MovinTarg/car | /car.py | UTF-8 | 870 | 3.796875 | 4 | [] | no_license | class car(object):
def __init__(self, price, speed, fuel, mileage):
self.price = price
self.speed = speed
self.fuel = fuel
self.mileage = mileage
if self.price > 10000:
self.tax = '15%'
else:
self.tax = '12%'
def display_all(self):
... | true |
637ce2f8dbe712bfd85cc23c1bd5fa1610beafa6 | Python | phongphung/Profile_team_small_portal | /other_tool/get_logo_from_url.py | UTF-8 | 3,724 | 2.625 | 3 | [] | no_license | __author__ = 'sunary'
import pandas as pd
import subprocess
from utils import my_helper, my_text
import os
from os.path import isfile, join
from PIL import Image
import time
class GetLogo():
def __init__(self):
self.logger = my_helper.init_logger(self.__class__.__name__)
self.file_dest_path = N... | true |
6ead43d1d1232c5f239808d9720e0ea96eb9f903 | Python | BigRLab/webpy-vue | /excel.py | UTF-8 | 1,565 | 2.6875 | 3 | [] | no_license | #coding=utf-8
import xlwt
import xlrd
# 导出excel
def writeExcel(json_data, file_name):
wb = xlwt.Workbook()
# 添加一个表
ws = wb.add_sheet('test')
# 3个参数分别为行号,列号,和内容
# 需要注意的是行号和列号都是从0开始的
ws.write(0, 0, '登记日期')
ws.write(0, 1, '模号')
ws.write(0, 2, '钳工')
ws.write(0, 3, '零件名称')
ws.write... | true |
528e9166d5891c6424db6ca026cf94f69f56ec4b | Python | saitrinath/final_year_project_v2 | /python/relay/relay.py | UTF-8 | 503 | 2.5625 | 3 | [] | no_license | import RPi.GPIO as g
import time
import os
a = os.environ['relay_a']
b = os.environ['relay_b']
c = os.environ['relay_c']
d = os.environ['relay_d']
g.setmode(g.BCM)
g.setup(a,g.OUT)
g.setup(b,g.OUT)
g.setup(c,g.OUT)
g.setup(d,g.OUT)
g.output(a,g.HIGH)
g.output(b,g.HIGH)
g.output(c,g.HIGH)
g.output(d,g.HIGH)
def tur... | true |
7ac7513dea9c0f7fb4cc329bb5e119c116e68b38 | Python | bruyss/Project-Euler | /39_integertriangles.py | UTF-8 | 710 | 3.890625 | 4 | [] | no_license | #! python3
# If p is the perimeter of a right angle triangle with integral length sides,
# {a,b,c}, there are exactly three solutions for p = 120.
#
# {20,48,52}, {24,45,51}, {30,40,50}
#
# For which value of p ≤ 1000, is the number of solutions maximised?
n_max = 1000
res_max = 0
res_n = 0
for n in range(1, n_max + ... | true |
30c87aee9351f7f26f66e22f218af76fff1dc752 | Python | UpraAnalisis/Herramientas_Optimizadas | /SCRIPTS_ANALISIS/Script_Add_Join_Cursor/JoinCursor_Multiple_v5_x64_feature.py | UTF-8 | 4,173 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# --------------------------------------------------------------------
# JoinCursor_Multiple_v3_x64_feature.py
# Fecha de creacion: 2017-11-15 08:59:08.00000
# Author: Carlos Mario Cano Campillo
# Email: carlos.cano@upra.gov.co / kanocampillo@gmail.com
# Propietario: Unidad de Planificación Rur... | true |
90e54c07efee5913ed88ae0fca5d12609451060b | Python | gemathus/bait | /bait/core/entities/base_entity.py | UTF-8 | 242 | 2.6875 | 3 | [] | no_license | from datetime import datetime
class BaseEntity:
def __init__(self,id):
self.id = id
self.created_at = datetime.now()
self.updated_at = datetime.now()
def __str__(self):
return "{}".format(self.__dict__) | true |
e980331f24e419ba57b3b5052cbbb2ddf7339fb1 | Python | fajrconnect/AnkoA | /app/bitrate.py | UTF-8 | 1,589 | 2.53125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
#
#------------------ AnKoA -----------------------#
# Made with love by grm34 (FRIPOUILLEJACK) #
# ........fripouillejack@gmail.com ....... #
# Greetz: thibs, Rockweb, c0da, Hydrog3n, Speedy76 #
#--------------------------------------------------#
from style... | true |
b85bedb05c576d679c1cf3ccc66d9264721180cc | Python | asherboy1/huhu-selenium | /Xpath.py | UTF-8 | 3,015 | 3.765625 | 4 | [] | no_license | # XPath (XML Path Language) 是由国际标准化组织W3C指定的,用来在 XML 和 HTML 文档中选择节点的语言。
# 目前主流浏览器 (chrome、firefox,edge,safari) 都支持XPath语法,xpath有 1 和 2 两个版本,目前浏览器支持的是 xpath 1的语法。
# 有些场景 用 css 选择web 元素 很麻烦,而xpath 却比较方便。
# 另外 Xpath 还有其他领域会使用到,比如 爬虫框架 Scrapy, 手机App框架 Appium。
"""
xpath 语法中,整个HTML文档根节点用’/‘表示,如果我们想选择的是根节点下面的html节点,则可以在搜索框... | true |
bf6b601d0fbba85951c186b66c6fe523065976bb | Python | hemilioaraujo/URI_online_judge | /1 iniciante/2709.py | UTF-8 | 83 | 3.203125 | 3 | [] | no_license | quantidade_moedas = int(input())
for i in range(quantidade_moedas):
print('a') | true |
0182877998ed38622118f0d4308c47fad73d15d0 | Python | cosmia/pythonProject | /myList.py | UTF-8 | 3,968 | 3.71875 | 4 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
class MyListError(Exception):
'''Wyjatek dla klasy MyList.'''
def __init__(self, mes):
'''Konstruktor, argumentem tresc przy rzucaniu wyjatku.'''
self.value = mes
def __str__(self):
'''Podaje tresc wyjatku.'''
return self.value
clas... | true |
f2a437f46e2c7598fb9eabdc06b8c08d910a5212 | Python | angelm1974/KURS_PYTHONA_GR3 | /Dzien1_i_2/slownik.py | UTF-8 | 107 | 2.765625 | 3 | [
"MIT"
] | permissive | person = {
"name" : "Jan",
"last_name" : "Nowak",
"age" : None
}
lista=person.keys()
print(person["age"]) | true |
6d36f64952caa52fc610f8f5ac410a6554be1780 | Python | anurgbht/deep_learning | /C22_TensorfFow_DeepLearning_V1.py | UTF-8 | 13,311 | 3.3125 | 3 | [] | no_license | import math
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.python.framework import ops
def random_mini_batches(X, Y, minibatch_size, seed):
n_x, m = X.shape
m2, n_y = Y.shape
idx = np.random.randint(m, size=minibatch_size)
# It will generate random ... | true |
a2d91dbf2d51b2b726d649254ed111ddbb0ce6fb | Python | o7500game/klose911.github.io | /src/python/src/pythonic/iterator/iterator.py | UTF-8 | 258 | 3.53125 | 4 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python
# -*- coding:utf-8 -*-
#Filename: iterator.py
colors = [ 'red', 'green', 'blue', 'yellow' ]
for i in range(len(colors)):
print (colors[i])
# >>> red
# green
# blue
# yellow
for color in colors:
print(color)
| true |
79c778d578625f94035751e7b17283c19870a72f | Python | valychbreak/Custom-LoL-Launcher | /settings_manager.py | UTF-8 | 1,741 | 2.796875 | 3 | [] | no_license | import yaml
from Settings import Settings
def get_login(settings_dict):
return settings_dict['install']['login-remember-me']
def get_globals(settings_dict):
return settings_dict['install']['globals']
class SettingsManager:
def __init__(self, settings_file_path) -> None:
self.settings_file_pat... | true |
122c1193429493b117bbff6513e6fbc5cae506a7 | Python | techgopal/TensorFlow_Exam | /sentiment_analysis_with_vector_layer_5/train.py | UTF-8 | 2,783 | 2.796875 | 3 | [] | no_license | import tensorflow as tf
from sentiment_analysis_with_vector_layer_5 import data_processing, model
import matplotlib.pyplot as plt
import re
import string
def get_standardize(input_data):
lower_case = tf.strings.lower(input_data)
cleaned_data = tf.strings.regex_replace(lower_case, '<br />', '')
regex_data ... | true |
31e5edcd8f274cd840f0f2a55faf0ad897649830 | Python | Zacharium/NoahKit | /applied_ai/text/hugging_face/__init__.py | UTF-8 | 3,858 | 2.8125 | 3 | [] | no_license | import transformers
import torch
from transformers import pipeline
'''
learning material : https://www.cnblogs.com/dongxiong/p/12763923.html
api : https://huggingface.co/transformers/
'''
'model importation'
# 1. automatic download :
# model = transformers.BertModel.from_pretrained('model-name') # network-hungry
# 2... | true |
d9bae90a2ffea99f169bfa26b407b32c3294986f | Python | UW-ParksidePhysics/Rizzo-Paul | /VPython - 02/2.2_two_balls_bounce_12.py | UTF-8 | 1,387 | 3.09375 | 3 | [] | no_license | import vpython as vp
initial_position_1 = vp.vector(-10, 12, 1)
initial_velocity_1 = vp.vector(10, -12, -2)
ball_1 = vp.sphere(pos=initial_position_1, radius=0.5, color=vp.color.cyan, make_trail=True)
initial_position_2 = vp.vector(-10, -5, -1)
initial_velocity_2 = vp.vector(14, 5, 2)
ball_2 = vp.sphere(pos=i... | true |
98df8e6a7e1121751ad54510f5f21ab3789e3b1c | Python | 5-digits/interview-techdev-guide | /Company Specific Interview Questions/Google/Solutions/Python/google_find_odds.py | UTF-8 | 247 | 3.015625 | 3 | [
"MIT"
] | permissive | t=int(input())
while t!=0:
n=int(input())
l=list(map(int,input().split()))
l.sort()
s=list(set(l))
for i in range(0,len(s)):
if l.count(s[i])%2!=0:
print(s[i],end=" ")
print()
t=t-1
| true |
20d0ad446fad4ad3ad5320b1390e6e84d0c81278 | Python | julien-roumagnac/Stikom_Data_Scrawling | /PRESSRELEASE_EXTRACTOR.py | UTF-8 | 3,768 | 2.53125 | 3 | [] | no_license | # coding: utf-8
from bs4 import BeautifulSoup
from sqlalchemy import create_engine
import pandas
import numpy as np
import requests
import hashlib
import time
from datetime import datetime
def pressrelease_extract(startdate,enddate):
#connnexion to the DB
#newsletter_db = create_engine('postgres://admin:admin... | true |
745b150abeb6a06b9cd3c68028afd0bb81e4398e | Python | paulweyers1/SunePython | /Pythonassesment/Previous versions/Assesment v2.py | UTF-8 | 1,303 | 3.171875 | 3 | [] | no_license | from tkinter import *
from tkinter import ttk
root = Tk()
root.title("Test")
price_list = [
["BLT",3.80],
["Ham salad sandwich",4.50],
["veggie Sandwich",4.50],
["Chicken panini",4.80],
["Hawaiian panini",4.50],
["Breakfast burrito",4.80],
["Nachos",3.50],
["Wedges",3.00]... | true |
5131891b7931322bfdb352211247b83cb2b965a3 | Python | AthenaWisdom/standalone_scorer | /source/task_runner/task_status_store/types.py | UTF-8 | 782 | 3.28125 | 3 | [] | no_license | class TaskKey(object):
def __init__(self, execution_id, task_ordinal, job_id):
"""
@type job_id: C{str}
@type execution_id: C{str}
@type task_ordinal: C{int}
"""
self.__job_id = job_id
self.__task_ordinal = task_ordinal
self.__execution_id = execution_... | true |
bd14fd3a369864bc1199f1ea83451963ffc64703 | Python | ToLoveToFeel/LeetCode | /Python/_0037_Sudoku_Solver/Solution.py | UTF-8 | 2,126 | 3.265625 | 3 | [] | no_license | # coding=utf-8
# Date: 2021/5/22 10:19
from typing import List
# 执行用时:132 ms, 在所有 Python3 提交中击败了69.98%的用户
# 内存消耗:15.1 MB, 在所有 Python3 提交中击败了47.61%的用户
class Solution:
def solveSudoku(self, board: List[List[str]]) -> None:
"""
Do not return anything, modify board in-place instead.
"""
... | true |
0c145213ba464f2e38b706cff24d73626a5e0d91 | Python | daijing2510/aaa | /test/005.py | UTF-8 | 337 | 3.5625 | 4 | [] | no_license | '''
Created on 2015-11-18
@author: jingdai
'''
def squares(n):
res=[]
for i in range(n):res.append(i**2)
return res
for x in squares(5):print x,':',
print '\n'
for x in [n**2 for n in range(5)]:
print x,':',
print '\n'
for x in map((lambda x:x**2),range(5)):
print x... | true |
f1f543e1eba21a2db25dba8ee7e1e924bd9cd013 | Python | momotofu/grab-citations-for-wikipedia-pages | /main.py | UTF-8 | 2,727 | 3.453125 | 3 | [] | no_license | #!/usr/bin/env python
"""
The goals of this webcrawler application are as follows:
1. Fetch citation formats for each link supplied in a text file.
2. Neatly print citation formats and corresponding links (from supplied
text file) to a markdown file.
Helper request functions can be found in utils.py
"""
from utils im... | true |
058e6c6a69782e9e81d9f12aa668c6d5d9a95541 | Python | ricardobarroslourenco/dxread | /examples/yearaverage.py | UTF-8 | 2,333 | 2.828125 | 3 | [] | no_license | #NOTE: This one downloads from the ISCCP database!
#I don't recommend running this but it's a good template
# for scripts that need to download data
import datetime
import time
import pydxread
import numpy as np
import gzip
import os
import pyqtgraph as pg
from examples.pos2Grid import pos2Grid
#I guess just download ... | true |
3640360fea1c9ba59000fdecc47f2fb8379e182f | Python | DeanHe/Practice | /LeetCodePython/ModifyGraphEdgeWeights.py | UTF-8 | 4,958 | 3.859375 | 4 | [] | no_license | """
You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, wi] indicates that there is an edge between nodes ai and bi with weight wi.
Some edges have a weight of -1 (wi = -1), while others have a positive weight (wi > 0).
... | true |
51112848b009d275208abfd7c99b7edfefbe73b3 | Python | mhrous/MY_TASK_GIT | /vvv/utils/file.py | UTF-8 | 322 | 3 | 3 | [] | no_license | from os import listdir, unlink
from os.path import isfile, join
def get_file(path):
return [
f"{path}\\{file_name}"
for file_name in listdir(path)
if isfile(join(path, file_name))
]
def set_file_empty(path):
files = get_file(path)
for f in files:
unlink(join('.\\', f)... | true |
3292c3f66f89191dc970fabb431d09629ca7152b | Python | EllaHayashi/Recursive_Descent_Parser | /ourTree.py | UTF-8 | 1,063 | 3.59375 | 4 | [] | no_license | class TreeNode:
def __init__(self, key, val, left = None, right = None, parent = None):
self.key = key
self.val = val
self.left = left
self.right = right
self.parent = parent
def hasLeftChild(self):
return self.left
def hasRightChild(self):
return self.right
def isLeftChild(self):
return self.par... | true |
fe8e247a1b0aee97714baf5a3e2f9b6834d266df | Python | teodoradra/Artificial-Intelligence | /Labs/Laborator - 1/Solution/sudoku.py | UTF-8 | 2,529 | 3.203125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 25 15:29:32 2020
@author: Teo
"""
from collections import Counter
import random
import numpy as np
import math
import itertools
import random
def sudoku_ok(line):
return sum(line) == sum(set(line))
def check_sums(grid):
bad_rows = [row for row in grid if not ... | true |
38decf03e62446234fe7429fd83181cee15efcfa | Python | joyma804/CS130R-Final-Project-A-and-J | /CS130R-Final-Project-A-and-J-main 2/util_csv_file.py | UTF-8 | 1,913 | 3.484375 | 3 | [] | no_license | import csv
def get_list_by_file(data_file_name):
data_list = []
with open(data_file_name, 'r') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
data_list = list(csv_reader)
#remove empty lenders if exist.
data_list = remove_empty_item_from_list(data_list... | true |
8e062c1dc6350cb0026afef33d7d681e2166ed8a | Python | sloaneluckiewicz/CSCE204 | /CSCE204/exercises/feb23/forest.py | UTF-8 | 1,212 | 3.53125 | 4 | [] | no_license | import turtle
turtle.setup(575,575)
pen = turtle.Turtle()
pen.speed(0)
pen.pensize(2)
pen.hideturtle()
turtle.bgcolor("midnightblue")
gridSize = int(turtle.numinput("Size", "Enter size: ", 5,1,10))
widthPadding = turtle.window_width()/gridSize
padding = widthPadding * .1
width = widthPadding * .8
leafRadius = width ... | true |
fdd048a2002ab5654120ad825c9eb6b38177a71d | Python | AcecomFCUNI/Topicos-IA | /Despliegue-de-modelos/Streamlit/Transferencia-estilo/neural_style/main.py | UTF-8 | 994 | 2.78125 | 3 | [] | no_license | # python3 -m venv venv
# . venv/bin/activate
# pip install streamlit
# pip install torch torchvision
# streamlit run main.py
import streamlit as st
from PIL import Image
import style
st.title('Transferencia de estilo con Pytorch')
img = st.sidebar.selectbox(
'Selecciona una imagen',
('amber.jpg... | true |
ea71349fce7046ede7bb794ebadaa8e6eb876b01 | Python | enkore/i3pystatus | /i3pystatus/openstack_vms.py | UTF-8 | 2,278 | 2.78125 | 3 | [
"MIT"
] | permissive | from i3pystatus import IntervalModule
# requires python-novaclient
from novaclient import client
import webbrowser
class Openstack_vms(IntervalModule):
"""
Displays the number of VMs in an openstack cluster in ACTIVE and
non-ACTIVE states.
Requires: python-novaclient
"""
settings = (
... | true |
b47a60a3dc2c5fd2fc9d07128018c28fbaf83feb | Python | zdrever/WordSearchSolver | /ocrAPI.py | UTF-8 | 2,148 | 2.765625 | 3 | [] | no_license | import requests
def text_array_from_image(imagefile):
print("Get array text")
writefile = "array.txt"
key = '6085b04c132cb3bf1b3cfd998e901d6e' # GET KEY
POSTURL = 'http://api.newocr.com/v1/upload?key=' + key #GET API KEY BEFORE RUNNING
multipartdata = {"name":"file", "filename":imagefile, "Content... | true |
5de0cfc63e26d888e133b68446703fef888158f5 | Python | a-poor/ThinkBayes | /bayes/Dirichlet.py | UTF-8 | 2,525 | 3.5 | 4 | [] | no_license | import numpy as np
from .PMF import PMF
from .Beta import Beta
class Dirichlet(object):
"""Represents a Dirichlet distribution.
See http://en.wikipedia.org/wiki/Dirichlet_distribution
"""
def __init__(self, n, conc=1, name=''):
"""Initializes a Dirichlet distribution.
n: number of d... | true |
1bac8a72f41157706edbcaaa9dc1ab92842723b6 | Python | AprilSpring/PythonCode | /NormalFunc/codecs.py | UTF-8 | 700 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 8 13:13:08 2018
@author: User
"""
#%% codecs 读入文件
#打开文件
#file = open(input_file_name,'rb')
#相比较于open(), codecs.open()在读入文件时会避免一些编码问题,建议使用
import codecs
input_file_name = 'D:\temp\input.txt'
out_file_name = 'D:\temp\out.txt'
#读入文件
inputfile = code... | true |
e3e3f22825d969ba0079e12f9cd374efa494fdc9 | Python | SoonPoong-Hong/TensorFlow-Tutorials | /keras/test/matplotlib_test.py | UTF-8 | 142 | 2.53125 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
def plot2():
plt.plot([1,3,2,4])
plt.ylabel('Intensity')
plt.show()
plot2()
| true |
4998463973f3033dd0ee52459608dd3eb1013761 | Python | 4x1md/de5000_lcr_py | /src/de5000_reader.py | UTF-8 | 755 | 2.578125 | 3 | [
"MIT"
] | permissive | '''
Created on Sep 15, 2017
@author: 4x1md
'''
from de5000 import DE5000
import sys
import time
import datetime
from serial import SerialException
PORT = "/dev/ttyUSB0"
SLEEP_TIME = 1.0
if __name__ == '__main__':
print "Starting DE-5000 monitor..."
try:
if len(sys.argv) > 1:
port = ... | true |
af9595add3316f58dd476a127e71653635baaabc | Python | koteswaracse/Pycharm-Prac | /Time.py | UTF-8 | 438 | 3.609375 | 4 | [] | no_license | #!/usr/bin/python
import time; # This is required to include time module.
import calendar;
ticks = time.time()
print ("Number of ticks since 12:00am, January 1, 1970:", ticks)
localtime = time.localtime(time.time())
print ("1Local current time :", localtime)
localtime = time.asctime( time.localtime(time.time()) )
p... | true |
ed3c26b3562e0c35bf448344f1961d0ed0ec18d1 | Python | Dylan-Dotti/Emerald-Auto-Trainer | /auto_trainer/gui/pokemon_files/pokemon_learn_moves_component.py | UTF-8 | 2,345 | 2.828125 | 3 | [] | no_license | import tkinter as tk
import tkinter.ttk as ttk
import auto_trainer.services.pokemon_moves_data_service as pmds
from auto_trainer.gui.multistage_frame import MultiStageFrame
from auto_trainer.gui.pokemon_files.pokemon_sprite_component import PokemonSpriteComponent
class PokemonLearnMovesComponent(MultiStageFrame):
... | true |
547e1a5adea4068669fb737af0530224753e1a17 | Python | Dan-Yoo/LanguageClassifier | /classify.py | UTF-8 | 4,046 | 3.03125 | 3 | [] | no_license | import unigram
import bigram
import math
inputFilePath = "./input.txt"
outputFilePath = "./outputs/out"
outputFileCount = 1
unigrams = {
'en': unigram.load('./models/unigramEN.txt'),
'fr': unigram.load('./models/unigramFR.txt'),
'ot': unigram.load('./models/unigramDC.txt')
}
bigrams = {
'en': bigram.lo... | true |
18d59364e200ee582ab157fb320a2959b0fb5772 | Python | tgsergeant/150Hexagons | /pysrc/probability.py | UTF-8 | 2,485 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import datetime
__author__ = 'tim'
import csv
import json
import os
INPUTFOLDER = "../input/"
OUTFOLDER = "../static/data/"
def main():
infiles = os.listdir(INPUTFOLDER)
datahistory = []
geoinfo = []
for fname in infiles:
if fname.startswith("data-"):
# Get date from filename
... | true |
8d84ef81f74d1068bf761b49a74909924c8d6e6a | Python | elijah-micho/ScheduleApp | /gui.py | UTF-8 | 1,192 | 2.984375 | 3 | [] | no_license | from tkinter import *
class Application():
def __init__(self, master):
master.title("ScheduleApp")
master.configure(background="#80bfff")
self.title = Label(text="ScheduleApp", bg="#80bfff")
self.title.grid(row=0)
self.labelUsername = Label(master, text="Username:")
... | true |
54e91616aa08ad9fc4aa3e1be28c0edfe22e17e4 | Python | mustafabozkaya/tutorials | /decision_tree_learning/decision_tree_classificaiton.py | UTF-8 | 2,061 | 3.53125 | 4 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | # Commented out IPython magic to ensure Python compatibility.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import tree
# %matplotlib inline
"""**Read Iris Dataset**"""
data = pd.read_csv('Iris.csv')
data
data.shape
"""**Define Colunms**"""
col_names... | true |
995fc13250eb0961c8ac936a16276e8b49867b84 | Python | thusser/spexxy | /tests/grid/test_values.py | UTF-8 | 438 | 2.96875 | 3 | [
"MIT"
] | permissive | import numpy as np
class TestValues(object):
def test_axis_values(self, number_grid):
assert np.array_equal(number_grid.axis_values(0), [0, 1, 2, 3, 4])
assert np.array_equal(number_grid.axis_values(1), [0, 1, 2, 3])
def test_call(self, number_grid):
assert 1 == number_grid((0, 0))
... | true |
482d95f3ea177f0b74b27840cceb8cb0ea81eb92 | Python | rjfitzg/Python3030 | /Homework/HW8/HW8_Riley_Fitzgibbons_Ex2.py | UTF-8 | 755 | 3.59375 | 4 | [
"MIT"
] | permissive | '''
Homework8 Exercixe 2
Riley Fitzgibbons
Decrypt a PDF using a dictionary attack
'''
def decryptPDF(pdfRead):
import time
# Load dictionary
dic = open(dictName, 'r')
# Start timer
start = time.time()
# Begin attack
for line in dic:
for word in line.split():
print(word)
if (pdfRead.decrypt(word) > 0... | true |
ae8a0f795f102105b66ba4deb31e1cbdb6a7439e | Python | Will1998/DT2119-Speech-and-Speaker-Recognition | /Lab2/lab2_proto.py | UTF-8 | 6,361 | 3.359375 | 3 | [] | no_license | import numpy as np
from tools2 import *
def concatTwoHMMs(hmm1, hmm2):
""" Concatenates 2 HMM models
Args:
hmm1, hmm2: two dictionaries with the following keys:
name: phonetic or word symbol corresponding to the model
startprob: M+1 array with priori probability of state
... | true |
2bb788a080dfb48e4bdbb941606012dace44db4e | Python | Jore93/Elementary-coding | /mielipiteiden_jakaja.py | UTF-8 | 911 | 2.984375 | 3 | [] | no_license | #-*- coding: UTF-8 -*-
mielipide1 = raw_input("Syötä ensimmäinen mielipide: ")
lkm_mielipide1 = float(raw_input("Syötä ensimmäisen mielipiteen kannatusluku: "))
mielipide2 = raw_input("Syötä toinen mielipide: ")
lkm_mielipide2 = float(raw_input("Syötä toisen mielipiteen kannatusluku:"))
print " "
print "Tulokset (%):... | true |
b811558c364a9bf621dc011aa441a83665dbff43 | Python | chriskuech/wavelab | /pitchanalysis.py | UTF-8 | 5,153 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
pitchanalysis.py
--
Christopher Kuech
cjkuech@gmail.com
--
Requires:
Python 2.7
Instructions:
python pitchanalysis.py [wav-file-name]
"""
import matplotlib
from math import log
matplotlib.use("TkAgg")
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.fig... | true |
4434376512232f9336daae376796aa1590c9639d | Python | bayan79/CacheRequest | /cached_request.py | UTF-8 | 2,603 | 2.703125 | 3 | [
"MIT"
] | permissive | import hashlib
import json
import logging
import dbm
from typing import Any
import requests
FILE_NAME = 'cache.db'
logger = logging.getLogger('CachedRequest')
# ============= STORAGE ==================
class Storage:
def __init__(self, file: str):
self.file = file
def set(self, key, value):
... | true |
586e70c8400c0a2eef5039a519b4c5a084e958b5 | Python | hretrita/MScDissertation | /weighted_vote.py | UTF-8 | 1,986 | 2.625 | 3 | [] | no_license | # WEIGHTED AVERAGE
import numpy as np
import pandas as pd
# Import files
ABCpred = pd.read_csv('./dev_files/ABCpred_parsed.csv')
LBtope = pd.read_csv('./dev_files/LBtope_parsed.csv')
iBCE_EL = pd.read_csv('./dev_files/iBCE_EL_parsed.csv')
Bepipred2 = pd.read_csv('./dev_files/Bepipred2_parsed.csv')
# Make a list of f... | true |
b850d55ef9b7a0123983ab22172d8d5f1b812702 | Python | hasanhuz/English_Emo_project | /benchmark_models/bow_means.py | UTF-8 | 1,222 | 2.953125 | 3 | [] | no_license | import numpy as np
class MeanEmbeddingVectorizer(object):
"Res: https://github.com/nadbordrozd/blog_stuff/blob/master/classification_w2v/benchmarking.ipynb"
def __init__(self, word2vec):
self.word2vec = word2vec
self.dim = len(word2vec.itervalues().next())
def fit(self, X, y):
... | true |
63828cbcf1766bbdc4582d8c7191d01c84e8b14c | Python | Xan1912/thesisdrei | /cnet_capture.py | UTF-8 | 3,615 | 2.875 | 3 | [] | no_license | import requests
import nltk
import time
from pathlib import Path
import csv
limitLeft = 119 # Although in theory some other code could be hitting the API, start with a presumption that we have all 500.
# from Stack Overflow
def request_rate_limited(request_function):
def limit_rate(*args, **kwargs):
glob... | true |
19feeba3f7503f24c615d1d950f0ecdcce2af70f | Python | Dumerion/eMarket | /back-end/createDb.py | UTF-8 | 1,288 | 2.96875 | 3 | [] | no_license | # for encrypting password
from werkzeug.security import generate_password_hash, check_password_hash
# for creating unique user id
import uuid
from api import app
from api import db
from api import User
# creating default admin user >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
def signup_admin():
# let's inicizlize db
db... | true |
09c28862c57eebd3fdf06a421290723a2ffbf6a8 | Python | cenalulu/python_euler_solver | /061/solution.py | UTF-8 | 4,748 | 3.671875 | 4 | [] | no_license | #! encoding: utf8
from itertools import count
from profile_decorate import profile
"""
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:
Triangle P3,n=n(n+1)/2 1, 3, 6, 10, 15, ...
Square P4,n=n2 1, 4, 9... | true |
c7546ba53dd962f6874476f2b0e69f2566a01594 | Python | fitrialif/Licence-Plate-Recognition | /LicencePlateRecognition/PlateRecognition.py | UTF-8 | 2,032 | 3.265625 | 3 | [] | no_license | import functions
class PlateRecognition(object):
def __init__(self):
pass
def find_plate(self,img):
"""
This method looks for a licence plate in a image.
It returns the cropped licence plate if it finds it.
"""
pass
def recognize_digits(self,img_plate... | true |
7c4c904bcbc62204b0d22b76cc40c31bb0e5d0c5 | Python | benjds/InvestorsSimulation | /Lib/Investor.py | UTF-8 | 10,420 | 3.265625 | 3 | [] | no_license | import random
from Lib import Bond
from Lib import Stock
import pandas as pd
####################################
# Investor Class #
####################################
#@Aim: Represent different type of investors
#@Initialize_date: 17-02-2017
#@Updates: - [23-02-2017] : Create the function in... | true |
a3f96eeaeeaa388afe469cc97d1f8d0f623ec81e | Python | ATFL/HETEKGUI | /src/dev4/ML.py | UTF-8 | 1,610 | 2.828125 | 3 | [] | no_license | import os
import sys
from pathlib import Path
import pickle5 as pickle
import pandas as pd
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
app = QApplication(sys.argv)
class ML:
def __init__(self, file):
super(ML, self).__init__()
sel... | true |
83c435c355c3e9c9f1059b74ff4fa8e9d6894a40 | Python | deslay1/Machine-Learning | /datasets.py | UTF-8 | 1,708 | 2.8125 | 3 | [] | no_license | from sklearn import datasets
from sklearn.model_selection import train_test_split
import MNIST
import numpy as np
def sklearn_digits(normalized=True, shuffle=True):
digits = datasets.load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, train_size=0.7, random_state=0, s... | true |
765183c2f996993ecf59d535add7918255a3a269 | Python | liuyuzhou/python3.7sourcecode | /chapter18/movie_top.py | UTF-8 | 4,288 | 2.921875 | 3 | [] | no_license | #! /usr/bin/python3
# -*- coding:UTF-8 -*-
from urllib import request
import re
class MovieTop(object):
def __init__(self):
self.start = 0
self.param= '&filter='
self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64)'}
self.movie_list = []
self.file_path ... | true |
7d0199e210450b8f6bce9a7d9088948fff97ed07 | Python | ViorelCodreanu/nt-06-python | /memory-savers-and-modularity/my_module.py | UTF-8 | 158 | 3.15625 | 3 | [] | no_license | print('name of my_module.py:', __name__)
def my_sum(a, b):
return a + b
my_list = [1, 2, 3]
if __name__ == '__main__':
print('my_list', my_list)
| true |
87fec60b7f1e488cc9155bd6a9f894cb78324138 | Python | daniel-reich/ubiquitous-fiesta | /hY6BMxxEYycT83GPs_4.py | UTF-8 | 304 | 2.671875 | 3 | [] | no_license |
def multiply_by_11(n):
n = '0' + n
ans = n[-1]
carry = 0
for pos in range(len(n)-2, -1, -1):
box = n[pos:pos+2]
s = int(box[0]) + int(box[1]) + carry
ans = str(s % 10) + ans
carry = s // 10
if carry > 0:
ans = str(carry) + ans
return ans
| true |
3b5b312f3f7d0295faf614baf2679723c2327caf | Python | CVan19/data-structure-and-algorithm | /图论/bfs_KM.py | UTF-8 | 3,291 | 3.171875 | 3 | [] | no_license | '''
#definition
N = max(left_num, right_num)
weight: N*N权重矩阵
left_match, right_match #左边的点匹配的右边点;右边的点匹配的左边点
left_ver, right_ver
slack
left_vis, right_vis
head, tail #队列头部与尾部的索引
que #对于左边的点x,若其在增广路中,则将其记录到队列中
pre #对于右边的点y,记录使得left_ver[x]+right_ver[y]-weight[x,y]最小的那个x
'''
class bfsKM(object):
def __init__(self, N, ... | true |
37a08e5bd6331a41d7edbd9cd52d5615b59ac1f7 | Python | saiphaniedara/Python | /LCMof2no's.py | UTF-8 | 230 | 4.0625 | 4 | [] | no_license | #LCM of Two Numbers using GCD
a=int(input('Enter first number: '))
b=int(input('Enter second number: '))
x,y=a,b
while a is not b:
if a>b:
a-=b
else:
b-=a
lcm=int((x*y)/a)
print('GCD=',a)
print('LCM=',lcm)
| true |
dcb5e37cd4ab0f94125c52595cd92dd59b1fe4c1 | Python | Korimse/Programmers_Practice | /level3/이중우선순위큐.py | UTF-8 | 728 | 2.8125 | 3 | [] | no_license | from collections import deque
import heapq
def solution(operations):
answer = []
result = []
status = 1
for operation in operations:
a, b = operation.split(" ")
if a == "I":
heapq.heappush(result, int(b))
elif a == "D":
if len(result) == 0:
... | true |
fd3b749a76aa147a912686ef24266fbf6e0bd2b8 | Python | LeonHanml/Python | /Python3/sklearning/Preprocessing_StandardScaler.py | UTF-8 | 1,144 | 2.984375 | 3 | [] | no_license | import sklearn.preprocessing as preprocessing
import pandas as pd
import numpy as np
# preprocessing.StandardScaler()
# preprocessing.LabelEncoder()
data_train = pd.read_csv('D:\\www\\data\\Titanic\\train.csv')
df = data_train
'''归一化方法'''
scaler = preprocessing.StandardScaler()
age_scale_param = scaler.fit(df['Age'])
... | true |
a3c08d378ba5431a2dd3a85d73d72d77e20d01d3 | Python | zebdelrosario/cp1404practicals | /prac_02/exceptions_demo.py | UTF-8 | 903 | 4.375 | 4 | [] | no_license | """
CP1404/CP5632 - Practical
Answer the following questions:
1. When will a ValueError occur?
2. When will a ZeroDivisionError occur?
3. Could you change the code to avoid the possibility of a ZeroDivisionError?
"""
valid_denominator = False
while not valid_denominator:
try:
numerator = int(input("Enter t... | true |
e4a850483b4328e980b27a63abcc565cc058a51e | Python | isun-dev/baekjoon_algorithm | /goorm_3.py | UTF-8 | 147 | 3.640625 | 4 | [] | no_license | # 3과 5의 배수
num = int(input())
sum_num = 0
for i in range(1, num + 1):
if i % 3 == 0 or i % 5 == 0:
sum_num += i
print(sum_num) | true |
68bbb1468cff6584e7356e670caa057f369afcf6 | Python | tcarmelveilleux/CheapDrawBot | /Software/activities/activity.py | UTF-8 | 9,379 | 2.625 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Base class for activities. Activities have a parameters panel, handle events and
can make requests to the robot controller.
Author: tennessee
Created on: 2017-03-21
Copyright 2017, Tennessee Carmel-Veilleux.
"""
import logging
import sys
if sys.version_info[0] < 3:
... | true |
3e79ce07774c838fafc4e757caea9885e2c29b65 | Python | love554468/leetcode | /solution/92_Reverse_Linked_List_II.py | UTF-8 | 590 | 3.546875 | 4 | [] | no_license | class Solution:
def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode:
if left == right:
return head
dummy_head = ListNode()
dummy_head.next = head
cur, prev = head, dummy_head
i = 1
while(cur and i <= left-1):
p... | true |
ffa253ef35f873d12bd109d44192b210a228f3b1 | Python | walt-su/Crawler | /MLB/MLB_UpdateScorefromFox.py | UTF-8 | 3,324 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import urllib.request as ur
from urllib.error import URLError, HTTPError
import json
from pprint import pprint
import datetime
import MySQLdb as mariadb
import time
conn = mariadb.connect(user="", passwd="", db="", charset="utf8")
cursor = conn.cursor()
def UpdateDB(InsertValue):
print(Inser... | true |
c12a4aa2af95a6f09c9f6f3bcfae267a5ac1d94b | Python | meokey/ReOrgMovies | /rom_rt.py | UTF-8 | 4,484 | 2.53125 | 3 | [] | no_license | #ReOrgMovies Module: Rotten Tomatoes
import re
from bs4 import BeautifulSoup
from difflib import SequenceMatcher as matcher
from rom_common import *
def rt_grabinfo(title,year):
"""search_rt(title)
return {'title':p[bestguess][0].strip(),'url':p[bestguess][2].strip(),'Rotten Tomatoes Score':p[bestguess][3].strip()}... | true |
226e6cc86dce6ff7830fe640169bfc07c36c5225 | Python | jbaisani/coding-interview-python | /tests/test_p17.py | UTF-8 | 589 | 3.234375 | 3 | [
"MIT"
] | permissive | """
test_p17
~~~~~~~~~~~~~~
:copyright: (c) 2017 by 0xE8551CCB.
:license: MIT, see LICENSE for more details.
"""
import pytest
from src.problems.p17_power_of_n import power1, power2
@pytest.fixture(params=[power1, power2])
def fn(request):
return request.param
def test_power(fn):
# 功能测... | true |
49e3b3649b4b8c7fbbb2130a62b475bf8469894d | Python | EnzoStudy/capture_automation | /캡쳐 자동화_재호.py | UTF-8 | 1,228 | 2.96875 | 3 | [] | no_license | """
직접 원하는 위치 잡아서 캡쳐
최종 수정일자 :21.09.11
# 설치방법
# py -m pip install pyautogui
"""
import time
import pyautogui as pygui
pygui.hotkey('alt', 'tab')
print("3초뒤 좌측 위 마우스 위치를 입력합니다.")
time.sleep(3)
leftup_position = pygui.position()
print(leftup_position)
pygui.hotkey('alt', 'tab')
time.sleep(0.5)
pygui.hotkey('alt'... | true |
32f067e05438e0d1f1fc2a4480953e067095b074 | Python | esit1/python_Breakout_Spiel | /screen/game_menu.py | UTF-8 | 3,239 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Displays the main menu. The following buttons are available, play, manual and quit.
If the user presses the play button, a new game is started. If the user presses the Manual button,
the menu with the manual is called up. If the player presses the Exit button, th... | true |
319cf742ae638bb6a6ae12eafb3d78f6d48493de | Python | fserrey/eolo-project | /src/to_do/pickle_save_load.py | UTF-8 | 369 | 3.046875 | 3 | [
"MIT"
] | permissive | import pickle
import pandas as pd
def to_pickle(input_file):
print("Enter desired name:")
name = input()
pickle_out = open(name + '.pickle','wb')
pickle.dump(input_file, pickle_out)
pickle_out.close()
def import_pickle_as_pd(file_path):
pickle_in1 = open(file_path,'rb')
test_df=pickle.loa... | true |
e6632466a0330c9ec138ab52984346255beedf84 | Python | kckotcherlakota/algoexpert-data-structures-algorithms | /Hard/ambiguous-measurements.py | UTF-8 | 790 | 3.171875 | 3 | [
"MIT"
] | permissive |
# AMBIGUOUS MEASUREMENTS
# O(low * high * n) time and O(low * high) space
def ambiguousMeasurements(measuringCups, low, high):
# Write your code here.
cache = {}
return canMeasureInRange(measuringCups, low, high, cache)
def canMeasureInRange(measuringCups, low, high, cache):
key = createKey(low, high)
if ... | true |
6539850257e88840d205d6374367a54c27dcbfa5 | Python | jiacaiyuan/sram_test | /proj/sram_sip_3/host/sram_sip_manual.py | UTF-8 | 3,149 | 2.765625 | 3 | [] | no_license | import struct
import socket
from time import sleep
def eth_recv():
recive =s.recv(1500)
data=str(recive,encoding="utf-8")#or using bytes.decode(b) to change the bytes to str
print(data)
return data
def write_data(package):
s.send(package)
def initial_eth():
s.connect(('202.118.229.189',30))
eth_recv()
def tr... | true |
9dd29ab0628684a2ad09144fa77847f5a5664f3b | Python | nacuong/cs294-98 | /tests/computeDeriv-s1.py | UTF-8 | 272 | 3.3125 | 3 | [] | no_license | def computeDeriv(poly):
length = len(poly)-1
i = length
deriv = range(1,length)
if len(poly) == 1:
deriv = [0]
else:
while i >= 0:
new = poly[i] * i
i -= 1
deriv[i] = new
return deriv
| true |
99ec20b495204fc9dd7ce49f17622be0396dd66d | Python | huleya2017/Spider | /PicSpider.py | UTF-8 | 700 | 2.84375 | 3 | [] | no_license | import requests
import os
"""spider a pic and save it"""
def getHTTPRequest(root,path,url):
try:
if not os.path.exists(root):
os.mkdir(root)
if not os.path.exists(path):
response=requests.get(url)
with open(path,'wb') as f:
f.write(response.conte... | true |
3afc815542097f83f15fc9b58d393653bbaf496d | Python | andrewjouffray/AILU | /examples/getROI_example.py | UTF-8 | 511 | 2.671875 | 3 | [] | no_license | import cv2
import ailu_python.image_processing.getROI as getROI
import ailu_python.utils.display as display
# open video from avi file
cap = cv2.VideoCapture('./data/1569604389.9166079output.avi')
while True:
# read each frame
ret, frame = cap.read()
# gets the coordinates of the roi
rois = getROI.us... | true |