blob_id large_string | language 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e808bdc8050d6a725a27495b9e3927f85d830847 | Python | kobi485/package1 | /Game_cards/test_Deckofcards.py | UTF-8 | 1,235 | 3.21875 | 3 | [] | no_license | from unittest import TestCase
from Game_cards.Deckofcards import Deckofcards
from Game_cards.Card import Card
class TestDeckofcards(TestCase):
def setUp(self):
self.d1 = Deckofcards()
self.d2 = Deckofcards()
self.d3 = Deckofcards()
self.d4 = ''
def test_deck_has_52_cards(self)... | true |
bca68eaf3decbd314bc0229a7a508ee36baaccd4 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_96/819.py | UTF-8 | 854 | 2.96875 | 3 | [] | no_license | #from __future__ import division
import sys
rl = lambda: sys.stdin.readline().strip()
def getA(n):
if n==0:
return [0, 0]
if n%3==0:
if n==3:
return [1, 1]
else:
return [n/3, n/3+1]
if n%3==1:
if n==1:
return [1, 1]
... | true |
93e47093d16db66413b013651ebefc501dc023a1 | Python | ahmedvuqarsoy/Network-Programming | /Lab5 - ZeroMQ/analyzer.py | UTF-8 | 1,390 | 3.234375 | 3 | [] | no_license | import zmq
import json
import datetime
# 0MQ Settings
context = zmq.Context()
# CSV Recevier from Data Seperator
csvReceiver = context.socket(zmq.PULL)
csvReceiver.connect('tcp://127.0.0.1:4444')
# Array and Age Sender to Reducer
arraySender = context.socket(zmq.PUSH)
arraySender.bind('tcp://127.0.0.1:4445')
# Ge... | true |
83a90fe350573f99808eb03475d0e5332525305e | Python | Aasthaengg/IBMdataset | /Python_codes/p02795/s926124861.py | UTF-8 | 392 | 2.515625 | 3 | [] | no_license | import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))
h... | true |
70d889b9b4ada4935fdb4f46250e60d54983ff79 | Python | bryanliem/m26413126 | /try1.txt | UTF-8 | 116 | 2.859375 | 3 | [] | no_license | #!/usr/bin/python
import time; # This is required to include time module.
ticks = time.time()
print "ticks",ticks
| true |
23da4f0073393e6c522f4e08c17796e04e9fda2b | Python | hickeroar/python-test-skeleton | /test/addition.py | UTF-8 | 571 | 3.375 | 3 | [] | no_license | import unittest
from skeleton.addition import Addition
class TestAddition(unittest.TestCase):
def setUp(self) -> None:
self.addition = Addition()
def test_that_adding_two_numbers_yields_correct_answer(self):
result = self.addition.add(3, 4.5)
self.assertEquals(result, 7.5)
def ... | true |
fa335025b298ce8cfc0aca34a711e1a06de4e842 | Python | pahuja-gor/Python-Lectures | /CS 1064/test_requests.py | UTF-8 | 198 | 2.515625 | 3 | [] | no_license | import pprint
import requests
response = requests.get("https://data.cityofnewyork.us/api/views/25th-nujf/rows.json?accessType=DOWNLOAD")
print(response.status_code)
pprint.pprint(response.json())
| true |
ccd3ed1c5c92bac682ca27701e81a7ead3c00cfc | Python | moves-rwth/dft-bdmp | /2021-NFM/KB3TOSCRAM/KB3TOOPSA_MEF.py | UTF-8 | 6,904 | 2.890625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Oct 01 2017
@author: Marc Bouissou
"""
# Transformation of a FT generated by KB3 into format OPSA-MEF
# ATTENTION : the fault tree must be generated with a naming rules group (that may be empty)
# so that EXPORT_NAME structures are present in the file.
# The only basi... | true |
d259bef14589fad96203f98e9c4784c379d83bb9 | Python | Pratyush1014/Algos | /algorithms/DP/9.UnboundedKnapsack.py | UTF-8 | 574 | 2.578125 | 3 | [] | no_license | def UKnapsack (N , s) :
global dp , wt, val
for i in range (N + 1) :
for j in range (s + 1) :
if (i == 0) :
dp[i][j] = 0
elif (j == 0) :
dp[i][j] = 0
else :
if (wt[i-1] > s) :
dp[i][j] = dp[i-1][j]
else :
dp[i][j] = max(dp[i-1][j],val[i-1]+dp[i][j-wt[i-1]])
return dp[-1][-1]
N... | true |
d06e15fa6d0d99cbe753c29a44b6d82258304fa8 | Python | irinatalia/Udacity-DataEng-P1 | /sql_queries.py | UTF-8 | 4,959 | 2.609375 | 3 | [] | no_license | # DROP TABLES
# The following SQL queries drop all the tables in sparkifydb.
songplay_table_drop = "DROP TABLE IF EXISTS songs"
user_table_drop = "DROP TABLE IF EXISTS artists"
song_table_drop = "DROP TABLE IF EXISTS users"
artist_table_drop = "DROP TABLE IF EXISTS time"
time_table_drop = "DROP TABLE IF EXISTS songpla... | true |
e94d907369b641a4727b5995865fdaaee7348a73 | Python | asya229/bar_project | /bar_info/test.py | UTF-8 | 356 | 2.734375 | 3 | [] | no_license | import json
with open('bar_info1.json', 'r', encoding='cp1251') as f:
bar = json.load(f)
for k in bar:
print(
k['Name'],
k['Longitude_WGS84'],
k['Latitude_WGS84'],
k['Address'],
k['District'],
k['AdmArea'],
k['PublicPho... | true |
7ddd3b77cddd5fbfb90b396f5c8989163ae3d7c2 | Python | jeremybaby/leetcode | /Python/169_majority_element.py | UTF-8 | 1,065 | 3.71875 | 4 | [] | no_license | class Solution1:
""" defaultdict计数 """
def majorityElement(self, nums):
from collections import defaultdict
lookup = defaultdict(int)
half_len = len(nums) // 2
for num in nums:
lookup[num] += 1
if lookup[num] > half_len:
return num
clas... | true |
21083aed1d576849ef03e27880dacea25240239a | Python | cha63506/nvnotifier | /serializer.py | UTF-8 | 2,727 | 2.984375 | 3 | [
"MIT"
] | permissive | # from: https://github.com/lilydjwg/winterpy
import os
import abc
import pickle
def safe_overwrite(fname, data, *, method='write', mode='w', encoding=None):
# FIXME: directory has no read perm
# FIXME: symlinks and hard links
tmpname = fname + '.tmp'
# if not using "with", write can fail without exception
w... | true |
484375068f328aa85e3d061b994dd50672a119e7 | Python | shivaji50/PYTHON | /LB4_5.py | UTF-8 | 642 | 4.21875 | 4 | [] | no_license | # a program which accept number from user and return difference between
# summation of all its factors and non factors.
# Input : 12
# Output : -34 (16 - 50)
# Function name : Factor()
# Author : Shivaji Das
# Date : 21 august 2021
def Factor(no):
sum1,sum2=0,0
if no <= 0:
return
... | true |
9115e8b0036eb8b823edf654ce37eb4d0df9f455 | Python | skanda99/Hackerrank-Leetcode | /TwoStrings.py | UTF-8 | 230 | 3.5625 | 4 | [] | no_license |
# problem: "https://www.hackerrank.com/challenges/two-strings/problem"
n = int(input())
for i in range(n):
s1=set(input())
s2=set(input())
if s1.intersection(s2):
print('YES')
else:
print('NO')
| true |
5ca4d0f0f4eb934024b32a3e653e51c1abb3bf62 | Python | lm05985/Client-Server-Hangman-Python | /Hangman_Client_v3.py | UTF-8 | 2,569 | 3.578125 | 4 | [] | no_license | #HANGMAN CLIENT v3
# WORKS!!! USE THIS ONE
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name, this works on local machine
# host = "SERVER IP ADDRESS HERE" #find this out from server
#host =... | true |
b88a9e8d168a67d40871d50d979a0d8836d7d56f | Python | kaushil268/Code-Jam-2020- | /3.py | UTF-8 | 1,232 | 3.1875 | 3 | [] | no_license | def fun1(abc, xyz):
if abc[0] > xyz[0] and abc[0] < xyz[1]:
return True
if abc[1] > xyz[0] and abc[1] < xyz[1]:
return True
return False
def funR(abc, xyz):
return fun1(abc, xyz) or fun1(xyz, abc) or abc[0] == xyz[0] or abc[1] == xyz[1]
t = int(input())
for var1 in ran... | true |
61c619dc42af3f55845095eea334d14ab305f2cd | Python | prise-3d/rawls-tools | /utils/extract_specific_png.py | UTF-8 | 1,636 | 2.734375 | 3 | [] | no_license | import os
import argparse
import glob
def main():
parser = argparse.ArgumentParser(description="Extract specific samples indices")
parser.add_argument('--folder', type=str, help='folder with all rawls files', required=True)
parser.add_argument('--index', type=str, help='current rawls image index', requi... | true |
7fa4e23ff0f288cfd35c7cc397ededcd9dd71e09 | Python | ganeshpodishetti/PycharmProjects | /Hangman/Problems/Beta distribution/task.py | UTF-8 | 116 | 2.796875 | 3 | [] | no_license | import random
random.seed(3)
alpha = 0.9
beta = 0.1
# call the function here
print(random.betavariate(alpha, beta))
| true |
685f82217af5990b4330dfa2cac81c704c61ea20 | Python | DiegoT-dev/Estudos | /Back-End/Python/CursoPyhton/Mundo 03/Exercícios/ex096.py | UTF-8 | 321 | 3.796875 | 4 | [
"MIT"
] | permissive | def cab(msg):
print(f'{msg:^30}\n{"-"*30}')
def área(lst):
a = 1
for n in lst:
a *= n
print(f'A área de um terreno {lst[0]}x{lst[1]} é de {a:.1f}m²')
def cham(txt):
x.append(float(input(f'{txt} (m): ')))
x = list()
cab('Controle de Terreno')
cham('Largura')
cham('Comprimento')
área(x)
| true |
c0f01dba07598d2fdd4a2ebbf77b38fd65d1282b | Python | DropName/infa_2019_primak | /test.2019/1one.py | UTF-8 | 387 | 3.453125 | 3 | [] | no_license | from math import sqrt
def prime_nembers(n):
"""
returns list a of prime numbers up to n
"""
a = []
for i in range(2, n + 1):
for j in a:
if j > int((sqrt(i)) + 1):
a.append(i)
break
if (i % j == 0):
break
else:... | true |
5e690dc821860e05f6578bbdd1f09903acf4be44 | Python | ivenkatababji/pds | /src/membership.py | UTF-8 | 425 | 3.40625 | 3 | [] | no_license | from bloom_filter import BloomFilter
def test(ds):
ds.add(1)
ds.add(2)
ds.add(6)
if 1 in ds :# True
print 'test 1 : +ve'
else:
print 'test 1 : -ve'
if 3 in ds :# False
print 'test 3 : +ve'
else:
print 'test 3 : -ve'
print 'Using Set'
myset = set([])
test(my... | true |
8196d947816f1c2e7d9d70dd6cd37fd658fb18d2 | Python | jameszhan/leetcode | /algorithms/033-search-in-rotated-sorted-array.py | UTF-8 | 1,621 | 4.65625 | 5 | [] | no_license | """
搜索旋转排序数组
假设按照升序排序的数组在预先未知的某个点上进行了旋转。
( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。
搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回 -1 。
你可以假设数组中不存在重复的元素。
你的算法时间复杂度必须是 O(log n) 级别。
示例 1:
输入: nums = [4,5,6,7,0,1,2], target = 0
输出: 4
示例 2:
输入: nums = [4,5,6,7,0,1,2], target = 3
输出: -1
"""
from typing import List
# ... | true |
8d74390592e3014b7391ca9b0921a3ac6907407a | Python | ntnunk/aws_credential_manager | /cred_loader/loader.py | UTF-8 | 2,518 | 2.515625 | 3 | [
"MIT"
] | permissive | import os
import wx
import helpers
from ui import MainWindow
class MainUi(MainWindow):
region_list = []
account_list = []
def __init__(self, parent):
super().__init__(parent)
account_list = helpers.get_local_accounts()
self.combo_accounts.Items = account_list
self.combo_re... | true |
fa980296fa925a8637a950b6cecab1d3c5d05990 | Python | MiyabiTane/myLeetCode_ | /30-Day_Challenge/28_First_Unique_Number.py | UTF-8 | 929 | 3.4375 | 3 | [] | no_license | class FirstUnique:
def __init__(self, nums):
self.queue = []
self.seen = {}
for num in nums:
if num in self.seen:
self.seen[num] += 1
else:
self.seen[num] = 1
self.queue.append(num)
def showFirstUnique(self):
... | true |
57398548af3e4af88f6872715c0c5707e506a589 | Python | tzhou2018/LeetCode | /linkedList/19removeNthFromEnd.py | UTF-8 | 1,291 | 3.453125 | 3 | [] | no_license | '''
@Time : 2020/2/13 21:31
@FileName: 19removeNthFromEnd.py
@Author : Solarzhou
@Email : t-zhou@foxmail.com
'''
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# 为了操作方便,我们引入头结点。
# 首先 p 指针移动 n 个节点,之后 p, q 指针同时移动,
# 若 p.next 为... | true |
0308b89049063f50170a660e6c782d58358fb089 | Python | Aasthaengg/IBMdataset | /Python_codes/p03207/s775367688.py | UTF-8 | 174 | 3.03125 | 3 | [] | no_license | def main():
N = int(input())
prices = [int(input()) for _ in range(N)]
r = sum(prices) - max(prices) / 2
print(int(r))
if __name__ == '__main__':
main()
| true |
0d87ee7fafa06458480ccf1f18cc16e11d5cc6ed | Python | wbsth/f1retstat | /misc.py | UTF-8 | 4,381 | 3.1875 | 3 | [] | no_license | import json
import pandas as pd
def import_race_statuses(file_adr):
"""imports possible race finish statuses"""
statuses_csv = pd.read_csv(file_adr, sep=";")
print('Race statuses imported')
return statuses_csv
def build_season_list(file_name):
"""from season list, returns list of season years"""
... | true |
412ea44988c0bccada695335e418a9ec6f09c40c | Python | arturbs/Programacao_1 | /uni6/Calculo_De_Seguro/calculo_de_seguro.py | UTF-8 | 1,153 | 2.765625 | 3 | [] | no_license | #coding:utf-8
#Artur Brito Souza - 118210056
#Laboratorio de Progamacao 1, 2018.2
#A Primeira Letra em Caixa Alta
def calcula_seguro(valor_veiculo, lista):
idade = lista[0]
relacionamento = lista[1]
moradia_risco = lista[2]
portao = lista[3]
casa = lista[4]
casa_propria = lista[5]
uso = lista[6]
pontos = 0
if... | true |
2ea2d489b7676c7c4d6893a1690225affa475a6f | Python | fabocode/gps-project | /python_test.py | UTF-8 | 808 | 2.796875 | 3 | [] | no_license | import threading
import time
import gps_data
import RPi.GPIO as IO
x = 0
flag = False
gps = gps_data.GPS
# GPS Class
init_gps = gps()
# Setup the GPS Device
gps.setup_skytraq_gps(init_gps)
def loop_thread():
try:
while flag == False:
gps.update_gps_time(init_gps)
#print("gps... | true |
f9e3ffa8f311983a61da4589d40669798a2f4047 | Python | rrajesh0205/python_in_HP | /show.py | UTF-8 | 226 | 3.671875 | 4 | [] | no_license | class Student:
def __init__(self, name, rollno):
self.name = name
self.rollno = rollno
def show(self):
print(self.name, self.rollno)
s1 = Student('Navin', 2)
s2 = Student('Jenny', 3)
s1.show()
| true |
8550004dcb620fe77d49ad91cb2f852cf427b119 | Python | hugolribeiro/Python3_curso_em_video | /World3/exercise085.py | UTF-8 | 579 | 4.8125 | 5 | [] | no_license | # Exercise 085: List with even and odd numbers
# Make a program that the user input seven numeric values and register them into a unique list.
# That list will keep separated the odd and even numbers.
# At the end, show the odd and even values in crescent order.
# numbers = [[even], [odd]]
numbers = [[], []]
for amou... | true |
d9c150ba7eba4a7253c39b822bf2d6bacb1b0425 | Python | Inkiu/Algorithm | /src/main/python/socks_laundering.py | UTF-8 | 1,211 | 3.125 | 3 | [] | no_license | from collections import defaultdict
def solution(K, C, D):
ans = 0
clean_d = defaultdict(lambda : 0)
for c in C:
clean_d[c] += 1
for k in clean_d.keys():
fair = clean_d[k]
ans += fair // 2
clean_d[k] = fair % 2
dirty_d = defaultdict(lambda : 0)
for d in D:
... | true |
8c5a31c13d17372d17374196c4b34d038a761586 | Python | acroooo/aprendizajePython | /Fundamentos/tuplas.py | UTF-8 | 391 | 3.953125 | 4 | [] | no_license | # Tuplas : mantienen el orden pero no se pueden modificar
frutas = ("naranja", "platano", "kiwi", "sandia")
print(frutas)
# largo de la tupla
print(len(frutas))
# accediendo al elemento
print(frutas[0])
# conversion para agregar elementos
frutasLista = list(frutas)
frutasLista[0] = "El modificado"
frutas = tuple(fru... | true |
cb9cad553dac3115d6cb032ad841b7e452ddfbf3 | Python | t-eckert/ctci_solutions | /c16_moderate/q1_Number_Swapper.py | UTF-8 | 501 | 4.3125 | 4 | [] | no_license | """
16.1 Number Swapper: Write a function to swap a number in place.
"""
test_numberPairs = [
(2, 3),
(1, 1),
(362943.273415, 15115234283.9958300288593),
(-3.14159, 3.14159),
]
def swap_in_place(a, b):
a = a - b
b = a + b
a = b - a
return a, b
def main():
for test_numberPair i... | true |
bd47af050b39a24f5291b417b57b19535175bfda | Python | Gunnika/the-cuisine-menu | /app.py | UTF-8 | 2,514 | 2.78125 | 3 | [] | no_license | from flask import Flask, jsonify, request
import json
from flask_sqlalchemy import SQLAlchemy
app= Flask(__name__)
app.config['SECRET_KEY'] = 'thisissecret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///new_database1.mysql'
db= SQLAlchemy(app)
class Cuisine(db.Model):
id = db.Column(db.Integer, primary_key... | true |
30842463d3a646e1adbb8a056299661d8536cb6f | Python | tshauck/phmdoctest | /src/phmdoctest/main.py | UTF-8 | 13,070 | 2.625 | 3 | [
"MIT"
] | permissive | from collections import Counter, namedtuple
from enum import Enum
import inspect
from typing import List, Optional
import click
import commonmark.node # type: ignore
import monotable
from phmdoctest import tool
from phmdoctest import print_capture
class Role(Enum):
"""Role that markdown fenced code block pla... | true |
90a58f8b4ef9682f94d8bbd52e02ee8e9d5f45a0 | Python | nickderobertis/py-ex-latex | /tests/figure/test_inline_graphic.py | UTF-8 | 1,282 | 2.671875 | 3 | [
"MIT"
] | permissive | import pyexlatex as pl
from tests.base import EXAMPLE_IMAGE_PATH, GENERATED_FILES_DIR, INPUT_FILES_DIR
from tests.utils.pdf import compare_pdfs
EXPECT_GRAPHIC = '\\vcenteredinclude{width=0.1\\textwidth}{Sources/nd-logo.png}'
EXPECT_DEFINITION = r"""
\newcommand{\vcenteredinclude}[2]{\begingroup
\setbox0=\hbox{\include... | true |
f79c9b329775b661e5924fb4d9688a22fb600dba | Python | Shantnu25/ga-learner-dst-repo | /Banking-Inferences/code.py | UTF-8 | 4,782 | 3.453125 | 3 | [
"MIT"
] | permissive | #Importing header files
import pandas as pd
import scipy.stats as stats
import math
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.stats.weightstats import ztest
from statsmodels.stats.weightstats import ztest
from scipy.stats import chi2_contingency
import warnings
warnings.filterwar... | true |
3d9391e6b3fd52756954236c544e4d1d46c77fa4 | Python | robodave94/Honors | /ResultsAnalytics/time_Interpret Ball Analytics.py | UTF-8 | 9,102 | 2.515625 | 3 | [] | no_license | import csv
import numpy as np
import cv2
'''
Goal_Area
Time
Classification
Tag
Frame'''
'''
Single Channel Segmentation
Single Channel Segmentation_DoG
Single Channel Segmentation_Lap
Grid Single Channel Scanline
Grid Single Channel Scanline_DoG
Grid Single Channel Scanline_Lap
Vertical Single Channel Scanline
Vertical... | true |
3232d85a11dec97e8719448ea1bf4f79f524560b | Python | hyyoka/text_style_transfer_Tobigs | /Style_Transformer/evaluator/evaluator.py | UTF-8 | 3,695 | 2.734375 | 3 | [] | no_license | from nltk.tokenize import word_tokenize
from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
from pytorch_pretrained_bert import BertTokenizer,BertForMaskedLM
import fasttext
import pkg_resources
import math
from numpy import mean
import torch
from torch.nn import Softmax
class Evaluator(object):
... | true |
42017c5235c4470a4c2b597453009c24e0f7ab89 | Python | mlixytz/learning | /algorithm/limiting/counter.py | UTF-8 | 783 | 3.375 | 3 | [] | no_license | '''
计数器限流法
采用滑动窗口的方式实现,如果不采用滑动窗口的话,会出现临界问题
举例:
假设每秒允许访问100次,则设置一个1秒钟的滑动窗口,窗口中有10个格子,
每个格子100ms,窗口每100ms移动一次,格子里存储计数器的值。每次移动比较
窗口最后一个格子的和第一个格子,如果差值大于100,则限流。(格子越多越平滑)。
'''
import threading
import time
counter = 0
# 列表中元素存储的值为:{time,count}
windows = []
def accept():
if grant():
... | true |
7e98ae05caf76461ca4d1e55d55c6af3778376e8 | Python | niteshagrahari/pythoncodecamp | /OOPs/scratch.py | UTF-8 | 537 | 3.4375 | 3 | [
"MIT"
] | permissive | class A:
def f(self):
print("F in A")
def addAll(*args):
sum = 0
for arg in args:
sum += arg
print(sum)
def f(*args):
print(type(args))
for arg in args:
print(arg)
def ff(**kargs):
print(type(kargs))
for key,value in kargs.items():
print(key,value)
f(1,2,3... | true |
6f88aaad34ad6b136aee4da0833d975c62c87402 | Python | liyuanyuan11/Python | /def/def1.py | UTF-8 | 67 | 2.875 | 3 | [
"MIT"
] | permissive | def firstFunction(name):
str1="Hello "+name+"!"
print(str1) | true |
06da674ca8e793ca758fe6782a3ce3ef679336f7 | Python | IamPatric/pe_lab_4 | /task_2.1.py | UTF-8 | 1,023 | 3.203125 | 3 | [] | no_license |
from task_1 import get_files_count
from task_2 import FileProcessing
from task_2 import list_sorting
def main():
fp = FileProcessing
print(f'Task 1: count files\n{get_files_count("C:/pe_lab_4") = }')
print(f'Task 2: making list from file\n{fp.make_list_from_file("students.csv") = }')
data = fp.make_l... | true |
b2b1a03d1552e07a4298116f3e9e6ac56c45c11a | Python | joaabjb/curso_em_video_python_3 | /desafio031_custo_da_viagem.py | UTF-8 | 195 | 3.421875 | 3 | [] | no_license | d = int(input('Dgite a distância da viagem em Km: '))
if d <= 200:
print(f'O preço da passagem será R$ {0.50 * d :.2f}')
else:
print(f'O preço da passagem será R$ {0.45 * d :.2f}')
| true |
93c22e0e5ccd3339e22f384b32496188de58ed89 | Python | ChetanKaushik702/DSA | /python/trimmedMean.py | UTF-8 | 439 | 3.03125 | 3 | [] | no_license | from statistics import mean
from scipy import stats
def trimmedMean(data):
data.sort()
n = int(0.1*len(data))
data = data[n:]
data = data[:len(data)-n]
mean = 0
for i in data:
mean = mean + i
print(mean/len(data))
data = [1, 2, 1, 3, 2, 1, 2, 5, 5, 10, 22, 20, 24, 129, 500, 23, 356, ... | true |
e1a8a397d5979aff369eb5976393aab78558180c | Python | jbeks/compsci | /code/tests/black_hole.py | UTF-8 | 2,707 | 2.796875 | 3 | [] | no_license | import argparse
import numpy as np
from warnings import warn
import code_dir
from nbody import *
def set_parser_bh(parser):
"""
Adds black hole arguments (speed and distance) to parser.
"""
parser.add_argument(
"dist", type=float,
help="distance of black hole from solar system"
)
... | true |
55ba9c403277818540087edbc294c2e332cfbf1e | Python | mtreviso/university | /Projeto de Linguagens de Programacao/Trabalho 1/python/lacos.py | UTF-8 | 406 | 3.109375 | 3 | [] | no_license | import os, sys
def multMatrix(matrix1, matrix2, n):
mat = [[0 for y in range(n)] for x in range(n)]
for i in range(n):
for j in range(n):
for k in range(n):
mat[i][j] += matrix1[i][k]*matrix2[k][j]
return mat
n = int(sys.argv[1])
mat1 = [[x+y for y in range(1, n+1)] for x in range(1, n+1)]
mat2 = [[x*y ... | true |
8c6590427061a4365c26351e29f1c8fc04bb8c74 | Python | jssvldk/Practicum1 | /Rabota1(№13).py | UTF-8 | 1,350 | 3.15625 | 3 | [] | no_license | Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> """
Имя проекта: Rabota1
Номер версии: 1.0
Имя файла: Rabota1(№13).py
Автор: 2020 © В.А.Шаровский, Челябинск
Лицензия использования: CC BY-NC... | true |
ed40e8f38a0176101a9e510daaf05fb01e005406 | Python | jihoonyou/problem-solving | /Baekjoon/학교 탐방하기.py | UTF-8 | 890 | 3.09375 | 3 | [] | no_license | '''
학교 탐방하기
https://www.acmicpc.net/problem/13418
'''
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
parents = [i for i in range(N+1)]
graph = []
def find(x):
if x == parents[x]:
return x
parents[x] = find(parents[x])
return parents[x]
def union(a,b):
a = parents[a]
... | true |
b6050d26ca021665861861745ad74a1592b816d9 | Python | mwaiton/python-macrobenchmarks | /benchmarks/pytorch_alexnet_inference.py | UTF-8 | 1,393 | 2.578125 | 3 | [
"MIT"
] | permissive | import json
import time
import torch
import urllib
import sys
if __name__ == "__main__":
start = time.time()
model = torch.hub.load('pytorch/vision:v0.6.0', 'alexnet', pretrained=True)
# assert time.time() - start < 3, "looks like we just did the first-time download, run this benchmark again to get a clean... | true |
860c30526bc5b1940fc225c1e1f27ff11aa6ea84 | Python | ethyl2/Intro-Python-I | /src/misc/hackerrank/strings/piglatin.py | UTF-8 | 2,304 | 4.71875 | 5 | [] | no_license | """
https://www.codewars.com/kata/520b9d2ad5c005041100000f/python
Given a string, move the first letter of each word to the end of it, and then add 'ay' to the end of the world.
Leave punctuation marks untouched.
Examples:
pig_it('Pig latin is cool') # igPay atinlay siay oolcay
pig_it('Hello world !') # elloHay o... | true |
80d8ed6b1d415770d61797894c44ae18fddc6ae5 | Python | V4p1d/FPSP_Covid19 | /python/clds/agents/lockdown_policy.py | UTF-8 | 1,768 | 2.734375 | 3 | [
"MIT"
] | permissive | import numpy as np
from ..core import Agent
class BatchLockdown(Agent):
""" Lockdown policy.
Agent returns
[0, ... suppression start]: beta_high
[suppression_start, ..., suppression_end): beta_low
[suppression_end, ..., END]: beta_high
"""
def __init__(self, b... | true |
8dd4ac35a9f88898f96a39908a18479c6b1cb0fe | Python | the-py/the | /test/test_the_exe.py | UTF-8 | 1,297 | 2.765625 | 3 | [] | no_license | import unittest
from the import *
class TestTheExe(unittest.TestCase):
def setUp(self):
self.eq = self.assertEqual
self.neq = self.assertNotEqual
self.r = self.assertRaises
self.true = self.assertTrue
# ---- coders keyworld ----
# true
def test_true(self):
sel... | true |
0e33bc5b900b1a64532df9820c9fcb390222eb3e | Python | MeghnaPrabhu/Multimedia-Text-and-Image-Retrieval | /phase3/LSH.py | UTF-8 | 6,594 | 2.6875 | 3 | [] | no_license | import math
from collections import defaultdict
from functools import reduce
from pprint import pprint
import numpy as np
import pandas as pd
from phase1.csvProcessor import CsvProcessor
SEED = 12
np.random.seed(SEED)
IMAGE_ID_COL = 'imageId'
class LSH:
def __init__(self, hash_obj, num_layers... | true |
fc3109c947a366c848706d7c3b879ad9b69cc06e | Python | InesTeudjio/FirstPythonProgram | /ex14.py | UTF-8 | 302 | 4.375 | 4 | [] | no_license |
# 14. Write a Python program that accepts a comma separated sequence of words as input and prints the unique words in sorted form
items = input("Input comma separated sequence of words")
words = items.split() #breakdown the string into a list of words
words.sort()
for word in words:
print(word) | true |
51586c90b0796158f211dc7b79c67a78f5275c36 | Python | fructoast/Simulation-Eng | /simu1113/trapezoid-simpson.py | UTF-8 | 1,763 | 4 | 4 | [] | no_license | #encode:utf-8
import math
def trapezoid_integral(a,b,power):
n = 10000 #n=サンプリング数,任意の数
h = (b-a)/n
add = 0
for term in range(n+1):
if term==0 or term==n:
if power==3:
add += level3_func(h*term)
elif power==4:
add += level4_func(h*term)
... | true |
79bcd432841a271894629d59268f0ca3afda5517 | Python | carlos2020Lp/progra-utfsm | /diapos/programas/replace.py | UTF-8 | 192 | 3.28125 | 3 | [] | no_license | >>> palabra = 'cara'
>>> palabra.replace('r', 's')
'casa'
>>> palabra.replace('ca', 'pa')
'para'
>>> palabra.replace('a', 'e', 1)
'cera'
>>> palabra.replace('c', '').replace('a', 'o')
'oro'
| true |
38621d67a56d9b4e1fb693372710f37633f67aa0 | Python | 1325052669/leetcode | /src/JiuZhangSuanFa/BinarySearch/457. Classical Binary Search.py | UTF-8 | 571 | 3.453125 | 3 | [] | no_license | class Solution:
"""
@param nums: An integer array sorted in ascending order
@param target: An integer
@return: An integer
"""
def findPosition(self, nums, target):
# write your code here
if not nums: return -1
l, r = 0, len(nums) - 1
while l + 1 < r:
... | true |
df4d859cdc5ce36d607e7e7faf7e72b040d6f98b | Python | MunoDevelop/codingTest | /1197/1197.py | UTF-8 | 1,033 | 3.390625 | 3 | [] | no_license | import sys
import heapq
class DisjointSet:
def __init__(self, n):
self.data = [-1]*n
self.size = n
def find(self, index):
value = self.data[index]
if value < 0:
return index
return self.find(value)
def union(self, x, y):
x = self.find(x)
... | true |
96fc12803b116032be78a8775e0303ce1b7abba1 | Python | sebastianhutteri/RamanFungiANN | /Code.py | UTF-8 | 8,249 | 2.65625 | 3 | [] | no_license | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d
import os
import scipy as sp
from IPython.display import display
from ipywidgets import FloatProgress
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from ke... | true |
ade4c4056f78f0cb67f34fab26d996dffda73886 | Python | slopey112/moomoo | /main.py | UTF-8 | 4,121 | 2.515625 | 3 | [] | no_license | from wrapper import Game
from model import Model
from color import get_heal
from time import sleep
from math import atan, pi
import datetime
import threading
directory = "/home/howardp/Documents/Code/moomoo"
g = Game("fatty", directory)
m = {
"tree": Model("tree_res_s", directory),
"food": Model("food", directory)... | true |
d3dd659e8453627ca759df02d5222bd528ab98cb | Python | arules15/EECS4415Project2019 | /app/steamproject.py | UTF-8 | 8,480 | 3.1875 | 3 | [] | no_license | #!/usr/bin/python
import numpy as np
import csv
from datetime import datetime
from pprint import pprint
import re
#import matplotlib.pyplot as plt
# plt.rcdefaults()
#import matplotlib.pyplot as plt
def wordOccurences(col, list, amount):
occur = dict()
# is is for the break counter, row is the value of the l... | true |
33c8c1e147b274f6e485ded0ee919f25db5a5165 | Python | frvnkly/algorithm-practice | /leetcode/may-2020-challenge/day4/number_complement.py | UTF-8 | 1,867 | 4.125 | 4 | [] | no_license | # Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
# Example 1:
# Input: 5
# Output: 2
# Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.
# Example 2:
#... | true |
171bbee08930484cee0bbe9a1789f5731498cf09 | Python | RyuZacki/PythonStudent | /PyGame/PyGameTest.py | UTF-8 | 291 | 2.609375 | 3 | [] | no_license | import pygame
pygame.init()
screen = pygame.display.set_mode((468, 60)) # Настройка графического режима дисплея
pygame.display.set_caption('Monkey Fever') # Заголовок окна
pygame.mouse.set_visible(0) # Выключаем курсор мыши
| true |
cadc4bd618cf4cfb6e75aa142d17c9da3fbcd6e9 | Python | masakiaota/kyoupuro | /practice/green_diff/dwango2015_prelims_2/dwango2015_prelims_2.py | UTF-8 | 1,084 | 3.453125 | 3 | [] | no_license | # https://atcoder.jp/contests/dwango2015-prelims/tasks/dwango2015_prelims_2
# 25の部分を1文字に置換して連長圧縮
# 連長部分について(n+1)C2が答えかな
def run_length_encoding(s):
'''
連長圧縮を行う
s ... iterable object e.g. list, str
return
----------
s_composed,s_num,s_idx
それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx
'''
s_compos... | true |
be0075bf9420f40c7d6b2499beff53e0a82e2d10 | Python | nakmuayFarang/tf_objectDetection_Script | /1-preprocessing/1-createTestTrain.py | UTF-8 | 1,303 | 2.953125 | 3 | [] | no_license | """Create training and test sample
80% de train, 20% de test.
This script create 2 text files contening the name of the file
"""
import os
import random
import sys
import json
pathScript = str(os.path.dirname(os.path.abspath(__file__))) + '/'
os.chdir(pathScript)
param = '../' + 'param.json'
... | true |
423172b1d3339f63b8bb18be6dbf71d75f904653 | Python | deepanshusachdeva5/Histogram-Equalization | /normal_equalizer.py | UTF-8 | 994 | 2.6875 | 3 | [] | no_license | import cv2
import argparse
import numpy as np
import matplotlib.pyplot as plt
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', required=True, help='image to be prcoessed')
args = vars(ap.parse_args())
image = cv2.imread(args['image'])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
equalize... | true |
bc0bc3e49cd69c88ad89f927d4a1811a814f4cbb | Python | priyatam0509/Automation-Testing | /app/features/network/core/fuel_disc_config.py | UTF-8 | 2,002 | 2.6875 | 3 | [] | no_license | from app import mws, system, Navi
import logging
class FuelDiscountConfiguration:
"""
Core fuel discount config feature class. Supports Concord network. To be extended and overridden for other networks
where needed.
"""
def __init__(self):
self.log = logging.getLogger()
self.navigat... | true |
37d46c03ae3368ac1b7f96b6b023e914155ae010 | Python | trwn/psych_punks | /metadata.py | UTF-8 | 492 | 2.640625 | 3 | [] | no_license | import csv
import os
import json
dirname = os.path.dirname(__file__)
csv_file = open(dirname + '/data/punks.csv','r')
csv_reader = csv.DictReader(csv_file,fieldnames = ('Name:','Background:', 'Type:', 'Mouth:', 'Accessory:', 'Eyes:', 'Hair:', 'Beard:', 'Psych DNA:'))
lcount = 0
for row in csv_reader:
out = json.... | true |
462e29ff5c330c8f58700a125680ab57264d2142 | Python | herohunfer/leet | /1042.py | UTF-8 | 813 | 2.84375 | 3 | [] | no_license | class Solution:
def gardenNoAdj(self, N: int, paths: List[List[int]]) -> List[int]:
m = {}
for p in paths:
i = min(p[0], p[1])
j = max(p[0], p[1])
if j-1 in m:
m[j-1].append(i-1)
else:
m[j-1] = [i... | true |
a32dea39ad7f8a473b418775b98e9de5dd77bb1f | Python | masopust/TicTacToe | /Tester/testSquare.py | UTF-8 | 2,504 | 2.90625 | 3 | [] | no_license | import unittest
try:
from TicTacToe import square
from TicTacToe import field as playingField
from TicTacToe import endValidator
from TicTacToe import clickManager
except ModuleNotFoundError:
import square
import field as playingField
import endValidator
import clickManager
... | true |
3412b6a972ab225295fb2ea1c72c381a535504d1 | Python | WonkySpecs/link-prediction | /AUC_measures.py | UTF-8 | 12,601 | 2.671875 | 3 | [] | no_license | import random
import math
import networkx as nx
import numpy as np
#For indices whose scores can be determined with matrix calculations, it is viable to
#find the scores of all edges.
def mat_AUC_score(score_mat, test_edges, non_edges, nodelist):
total = 0
for i in range(len(non_edges)):
missing_edge = test_edges... | true |
d2f8751575f106b26dbf5b3a90dfd649874efff7 | Python | carlos-novak/kant | /kant/events/serializers.py | UTF-8 | 552 | 2.890625 | 3 | [
"MIT"
] | permissive | from json import JSONEncoder, JSONDecoder
from .models import EventModel
class EventModelEncoder(JSONEncoder):
"""
A class serializer for EventModel to be converted to json
>>> found_added = FoundAdded(amount=25.5)
>>> isinstance(found_added, EventModel)
True
>>> json.dumps(found_added, cls=Ev... | true |
47caa94b5b665cc31fc4e5490e4b3b8729686efa | Python | vishalb007/Assignment15 | /Assignment15.py | UTF-8 | 565 | 2.984375 | 3 | [] | no_license | from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn import datasets
def wine_classifier():
wine_data=datasets.load_wine()
xtrain,xtest,ytrain,ytest=train_test_split(wine_data.data,wine_data.target,tes... | true |
fb72ddbf6d13377e193229eeb601991545f35baa | Python | guenthermi/dwtc-geo-parser | /coverageScores.py | UTF-8 | 1,768 | 3.234375 | 3 | [] | no_license | #!/usr/bin/python3
import ujson as json
import sys
import copy
# make sure that there is no cycle in the graph!!
MAX_ITERATION = 1000 # maximal number of nodes (to prevent infinite loops)
class CoverageTree:
def __init__(self, config):
f = open(config, 'r')
data = json.loads(''.join(f.readlines()))
self.origi... | true |
b3f8ea56bd975bde4f3a8e1abf035c65f4d0143f | Python | monpeco/python-tribble | /so-documentation/mutable-object-02.py | UTF-8 | 261 | 4.28125 | 4 | [] | no_license | x = y = [7, 8, 9] # x and y refer to the same list i.e. refer to same memory location
x[0] = 13 # now we are replacing first element of x with 13 (memory location for x unchanged)
print(x)
print(y) # this time y changed!
# Out: [13, 8, 9] | true |
112d7520299ef8680b35fef41bb58993df5809b0 | Python | qwertyuiop6/Python-tools | /simple_crawl/douban.py | UTF-8 | 394 | 2.640625 | 3 | [] | no_license | import requests
url='https://movie.douban.com/j/new_search_subjects?sort=T&range=0,10&tags=&start=0'
def geturl(mvtype='科幻'):
mvurl=[]
web_data = requests.get(url+'&genres='+mvtype).json()
data=web_data.get('data')
print(data)
for item in data:
mvurl.append(item.get('url'))
print(mvur... | true |
70a52247b5caba772d4ea48a7d945d5b40884de2 | Python | michal93cz/calculator-python | /main.py | UTF-8 | 269 | 2.859375 | 3 | [] | no_license | from add import Add
from subtract import Subtract
from multiple import Multiple
from divide import Divide
operation1 = Add()
operation2 = Subtract(operation1)
operation3 = Divide(operation2)
operation4 = Multiple(operation3)
print(operation4.handle_request("2 + 3"))
| true |
13abe431c0ae00b8366f6519a624a539510bd256 | Python | perovai/deepkoopman | /aiphysim/models/unet.py | UTF-8 | 10,037 | 2.8125 | 3 | [
"MIT"
] | permissive | import math
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
class ResBlock3D(nn.Module):
"""3D convolutional Residue Block. Maintains same resolution."""
def __init__(self, in_channels, neck_channels, out_channels, final_relu=True):
"""Initialization.
Arg... | true |
422c41ad4a627a69ba0d915504ffac1ba09c560e | Python | cltl-students/bosman_jona_el_for_cnd | /src/error_analysis.py | UTF-8 | 1,518 | 2.515625 | 3 | [
"MIT"
] | permissive | import pandas as pd
import spacy
from spacy.kb import KnowledgeBase
def entities_info(path):
entity_info = dict()
with open(path, 'r', encoding='utf8') as infile:
for line in infile:
row = line.split('\t')
entity_info[row[0]] = dict()
entity_info[row[0]]['name'] = r... | true |
f1791b23d466dc70853a5ea4c6c22c75f52ac3f7 | Python | dpaddon/IRGAN | /ltr-gan/ltr-gan-pointwise/gen_model_nn.py | UTF-8 | 2,899 | 2.578125 | 3 | [] | no_license | import tensorflow as tf
import cPickle
class GEN:
def __init__(self, feature_size, hidden_size, weight_decay, learning_rate, temperature=1.0, param=None):
self.feature_size = feature_size
self.hidden_size = hidden_size
self.weight_decay = weight_decay
self.learning_rate = ... | true |
377bd812c429ef0e01b4b5564474463df4394f5b | Python | satyaaditya/MachineLearning | /DecisionTree/FakeBankNoteDetection.py | UTF-8 | 1,641 | 3.21875 | 3 | [] | no_license | from sklearn.metrics import accuracy_score
from sklearn.model_selection import KFold, cross_val_score, train_test_split
from sklearn import tree
import pandas as pd
def load_csv():
data = pd.read_csv('datasets/banknote_authentication.csv')
print('--------------- data preview\n', data.head())
return data
... | true |
120e10e4748f2b0ae356631048c42842399a1df5 | Python | MiaoDX/DataLabel | /track_for_detection_bbox/helper_f.py | UTF-8 | 374 | 2.859375 | 3 | [] | no_license | import os
def generate_all_abs_filenames(data_dir):
files = [os.path.abspath(data_dir+'/'+f) for f in os.listdir(data_dir) if os.path.isfile(data_dir+'/'+f)]
files = sorted(files)
return files
def split_the_abs_filename(abs_filename):
f_basename = os.path.basename(abs_filename)
f_no_suffix = f_bas... | true |
787f2ed060b806bddb39caef852fb277d073b6fd | Python | Upupupdown/Logistic- | /dis_5_6.py | UTF-8 | 12,618 | 3.265625 | 3 | [] | no_license | import operator
from SVM import*
import numpy as np
def load_data(filename):
"""
数据加载函数
:param filename: 数据文件名
:return:
data_mat - 加载处理后的数据集
label_mat - 加载处理后的标签集
"""
num_feat = len(open(filename).readline().split(';')) - 1
data_mat = []
label_mat = []
fr = open(fil... | true |
ea33d48ddfef592d48f0be8b9fc14a4feb8c78bd | Python | rafaelperazzo/programacao-web | /moodledata/vpl_data/59/usersdata/171/61571/submittedfiles/testes.py | UTF-8 | 652 | 3.453125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import math
#COMECE AQUI ABAIXO
def sub(a,b):
c=[]
for i in range(len(a)-1,-1,-1):
if a[i]<b[i]:
sub=(10+a[i])-b[i]
c.insert(0,sub)
a[i]=a[i]-1
else:
sub=a[i]-b[i]
c.insert(0,sub)
a[i]=a[i]
if... | true |
31b9bb38bef964786576907a53e2bfe66d765dbc | Python | bymayanksingh/open-source-api-wrapper | /src/GithubWrapper.py | UTF-8 | 4,815 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
# -*- coding: utf-8 -*-
from datetime import datetime, timezone
from github import Github
from GithubToken import github_token
# Github API Wrapper
class GithubWrapper:
def __init__(self):
"""
handles user authentication &
creates user object
"""
self... | true |
08f777b21c701de8b7f8f533145b20eed3fbed13 | Python | RouganStriker/BDOBot | /plugins/base.py | UTF-8 | 3,073 | 2.8125 | 3 | [
"MIT"
] | permissive | import boto3
TABLE_NAME = 'bdo-bot'
class BasePlugin(object):
# Plugin type is used to uniquely identify the plugin's item in dynamodb
PLUGIN_TYPE = None
# Mapping of attribute names to a type
ATTRIBUTE_MAPPING = {}
def __init__(self, discord_client=None):
self.db = boto3.client('dynamod... | true |
b1c7563682031fbb99c8529666b47c051df31602 | Python | Matacristos/api-flask | /src/predict.py | UTF-8 | 1,660 | 2.796875 | 3 | [] | no_license | import os
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
from src.utils import univariate_data, get_test_data
def predict(
csv_path: str,
model,
past_history: int = 72,
future_target: int = 0,... | true |
1ed83669cb8f4d60d5a7a89834918f0def4c2176 | Python | ShogoAkiyama/rltorch2 | /sentiment/iqn/utils.py | UTF-8 | 6,206 | 2.609375 | 3 | [] | no_license | import string
import re
import os
import io
import sys
import csv
import six
import itertools
from collections import Counter
from collections import defaultdict, OrderedDict
import torch
from torchtext.vocab import Vectors, Vocab
from dataAugment.dataAugment import *
# 前処理
def preprocessing_text(text):
# カンマ、ピリ... | true |
4bfd31139ecef2530cadd3053ae8e332e9a9f808 | Python | rakeshsukla53/interview-preparation | /Rakesh/subsequence-problems/longest_substring_without_repeating_characters.py | UTF-8 | 821 | 3.28125 | 3 | [] | no_license | __author__ = 'rakesh'
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if s is not None:
finalResult = 0
for i in range(len(s)):
frequency = {}
count = 0
fo... | true |
b2304ae38ce3508eff90a6f5ce1fbc1a118a7fc1 | Python | rahmankashfia/Hacker-Rank | /python/bracket_match.py | UTF-8 | 200 | 3.03125 | 3 | [] | no_license | s = ")))((("
t = []
matched = True
for x in s:
if x == "(":
t.append(x)
if x == ")":
if len(t) == 0:
matched = False
else:
t.pop()
if len(t) > 0:
matched = False
print(matched)
| true |
d65f95ff2ed645559c6c1bba3054c0518fd530f9 | Python | maoxx241/code | /Top_K_Frequent_Elements/Top_K_Frequent_Elements.py | UTF-8 | 317 | 3.0625 | 3 | [] | no_license | class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
dic=collections.Counter(nums)
ans=[]
lst=sorted(dic.items(),key=lambda x:x[1],reverse=True)
for i in lst:
ans.append(i[0])
if len(ans)==k:
return ans
| true |
9bd01b34dff6aefad381a3fb1d2fb737e20a5402 | Python | nsidnev/edgeql-queries | /edgeql_queries/contrib/aiosql/queries.py | UTF-8 | 1,515 | 2.5625 | 3 | [
"BSD-2-Clause",
"BSD-2-Clause-Views"
] | permissive | """Definition for aiosql compatible queries."""
from typing import List, Union
from edgeql_queries import queries as eq_queries
from edgeql_queries.contrib.aiosql.adapters import EdgeQLAsyncAdapter, EdgeQLSyncAdapter
from edgeql_queries.models import Query
from edgeql_queries.typing import QueriesTree
class EdgeQLQ... | true |
b39af8ba6fd05a50c0368cb303c6c796c6939096 | Python | roflmaostc/Euler-Problems | /028.py | UTF-8 | 1,494 | 4.25 | 4 | [] | no_license | #!/usr/bin/env python
"""
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the number... | true |
17e308c9ffec08b88e972ac2295a4da44add4000 | Python | shanahanjrs/LR35902 | /opcodes.py | UTF-8 | 2,456 | 2.828125 | 3 | [] | no_license | """
opcodes
https://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
Instr mnemonic -> | INS reg |
Length Bytes -> | 2 8 | <- duration (cycles)
Flags -> | Z N H C |
> Inline version of this: | INS reg 2b 8c Z N H C |
Flag register (F) bits (3,2,1,0 always zero):
7 6 5 4 3 2 1 0
Z N H... | true |
1cb152007c50a4544b223761dd7abe8b2032d927 | Python | 2021Anson2016/tensorflow_note | /tf_ex17_Train Model_v2.py | UTF-8 | 7,474 | 2.53125 | 3 | [] | no_license | import tensorflow as tf
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from PIL import Image
import math
import random
def rgb2gray(rgb):
return np.dot(rgb[..., :3], [0.299, 0.587, 0.114])
def LoadDataFileFolder_gray(path, total):
files = [f for f ... | true |
400e1115d17abac56066840c72596a1e618d4ece | Python | mayaraarrudaeng/preprocessamentodadosCAWM | /calcula_dist_estacoes.py | UTF-8 | 1,946 | 2.71875 | 3 | [] | no_license | import pandas as pd
from datetime import date
import utm
import calendar
import os
from scipy.spatial.distance import squareform, pdist
nome_arquivo = "estacoes.csv"
# diretorio com arquivo
diretorio_estacoes = 'dados'
# diretorio para salvar a matriz gerada
diretorio_resultados = 'resultados'
diretorio_distancias =... | true |
8cc8b5d973cdd586e1198f28d3f5486c645b99c7 | Python | betty29/code-1 | /recipes/Python/577588_Clear_screen_beep_various/recipe-577588.py | UTF-8 | 3,329 | 2.90625 | 3 | [
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | # Clear-screen and error beep module for various platforms.
# ---------------------------------------------------------
#
# File saved as "clsbeep.py" and placed into the Python - Lib drawer or
# where-ever the modules are located.
#
# Setting up a basic error beep and clear screen for Python 1.4 and greater.
# (... | true |