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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
97241fe4394bb278e8b83efe82dbf28dd47f7336 | Python | abeelashraf98/pgm-lab-abeel | /CO2Pg11.py | UTF-8 | 286 | 4.03125 | 4 | [] | no_license | a=int(input("Enter length:"))
b=int(input("Enter breath:"))
c=int(input("Enter height of triangle:"))
sq=lambda a:a**2
rect=lambda a,b:a*b
tri=lambda b,c:(0.5*b*c)
print("Area of square : ",sq(a))
print("Area of Rectangle : ",rect(a,b))
print("Area of Triangle : ",tri(b,c))
| true |
fee98e96a70e6291865a1bc9b4ffc6eab38e1cae | Python | pandasamanvaya/Number-Theory | /cryptocodes/string_xor.py | UTF-8 | 492 | 3.203125 | 3 | [] | no_license |
from base_convs import *
def xor_str(a, b):
xor = ''
for i in range(len(a)):
xor += str(int(a[i]) ^ int(b[i]))
return xor
def pad_zeros(a, l):
a = a[::-1]
while len(a) != l:
a += '0'
a = a[::-1]
return a
def str_xor(a, b):
if len(a) > len(b):
b = pad_zeros(b, len(a))
elif len(a) < len(b):
a =... | true |
d3400def1edd1faddbd8002f750a1d3994702552 | Python | Abdeljalil97/automation-with-python | /strings/version_python.py | UTF-8 | 120 | 2.609375 | 3 | [] | no_license | import sys
print("pythin version : \n")
print(sys.version)
print("python version info :\n")
print(sys.version_info)
| true |
96f96c85377858c8fd0c32143cb609165180a058 | Python | gnudrew/LeetCode | /Python/658. Find K Closest Elements/main.py | UTF-8 | 1,697 | 3.734375 | 4 | [] | no_license | class Solution(object):
def findClosestElements(self, arr, k, x):
"""
:type arr: List[int]
:type k: int
:type x: int
:rtype: List[int]
"""
size = len(arr)
# Simple Case:
if size == 1:
return arr
i = self.binarySearc... | true |
2747e08151c58c3af14b5828883623dc4f735fe8 | Python | anantoni/doop-tools | /tracediff/native.py | UTF-8 | 507 | 2.828125 | 3 | [] | no_license | import stats
class Refinement(stats.Refinement):
def __init__(self, conn):
stats.Refinement.__init__(self)
self.native = conn.native_methods()
self.pruned_methods = set()
def prune_method(self, meth):
# Then, check for missing method
if meth in self.native:
... | true |
d1266644ea408f0e8b87cfc632838abf022b50a0 | Python | everwind/gtn_applications | /datasets/iamdb.py | UTF-8 | 10,393 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import collections
import itertools
import multiprocessing as mp
import os
import PIL.Image
import random
import re
import torch
from torchvi... | true |
484fbd4b50334d1487e568478af9c4124933e3b2 | Python | synesissoftware/CLASP.Python | /pyclasp/section_specification.py | UTF-8 | 809 | 2.96875 | 3 | [
"BSD-3-Clause",
"Python-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
from .specification import Specification
class SectionSpecification(Specification):
def __init__(self, name, extras):
super(SectionSpecification, self).__init__(name, None, None, extras)
def __str__(self):
return "<%s.%s: name=%s; help=%s; aliases=%s; extras=%s>" %\
(self.__mod... | true |
17bb62283cd3eb98c1634d52180cb8b90a069ca0 | Python | p768lwy3/torecsys | /torecsys/utils/decorator.py | UTF-8 | 2,137 | 2.6875 | 3 | [
"MIT"
] | permissive | """
torecsys.utils.logging.decorator is a sub model of utils including decorator functions
to tag features of functions.
"""
import warnings
from functools import wraps
def in_development(func: callable):
"""a decorator to write a message in a layer or an estimator where they have not been tested
Args:
... | true |
8b794540318f5f9703555ecdcbedcbf77f332a2b | Python | lanjingjing1992/1510F_appium | /review/Case_Meituan.py | UTF-8 | 1,298 | 2.546875 | 3 | [] | no_license | import time
import unittest
from appium.webdriver.common.touch_action import TouchAction
from appium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
class Meituan(unittest.TestCase):
... | true |
4aed0685442f4b265ad847ac401b7149247508c7 | Python | danidim13/pid-motor-yarp | /yarpMotor.py | UTF-8 | 1,663 | 2.671875 | 3 | [] | no_license | #!/usr/bin/python
#Importacion de paquetes y clases
import yarp as y
from PMSM import PMSM
import numpy as np
import time
y.Network.init()
##### Declaracion de Puertos ####
## Puertos de Entrada
mtentrada = y.BufferedPortBottle()
mtsalida_theta = y.BufferedPortBottle()
mtsalida_omega = y.BufferedPortBottle()
mtsal... | true |
18a258e4f5065012ebffdfc3ba01f67079c72112 | Python | Kmmanki/bit_seoul | /keras2/keras82_imdb.py | UTF-8 | 1,945 | 2.765625 | 3 | [] | no_license | from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.datasets import imdb
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from tensorflow.keras.layers import Embedding, LSTM, BatchNormalization, Activation, Dense, Bidirectional
from tensorflow.keras.models import Seque... | true |
b4095db55d73468199ba38cb42e92ccd258af016 | Python | AmyShackles/algo-practice | /LeetCode/Easy/Python3/tests/test_distributecandies.py | UTF-8 | 797 | 3 | 3 | [] | no_license | import unittest
from Python3.distributecandies import Solution
class TestdistributeCandies(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_1(self):
# For sanity checking:
# Input: candyType = [1,1,2,2,3,3]
# Output: 3
self.ass... | true |
67a6bd068e98a87baf8705660be61e5171079320 | Python | K2018B/IS362_Assignment1 | /SQL and Tableau.sql | UTF-8 | 2,269 | 3 | 3 | [] | no_license | #!user/bin/env python
# -*- coding: utf-8 -*-
"""IS 362 - SQL and Tableau"""
# Q1: How many airplanes have listed speeds? What is the minimun & max lsited speed?
SELECT * FROM planes;
SELECT COUNT(speed) AS 'Airplane_Listed_Speed',
MIN(speed) AS 'Min_Speed',
MAX(speed) AS 'Max_Speed'
FROM planes;
# Q2: What is t... | true |
180cc50fb3cab524a0e175f66aab1d5bb7e0e436 | Python | LebedevOleg/kursPy | /venv/People.py | UTF-8 | 824 | 2.890625 | 3 | [] | no_license | import random
import datetime
import time
from Elevator import*
from Floor import*
from People import*
class People:
def __init__(self, floorMax):
self.needF = random.randint(0,floorMax)
self.time_waitF = 0
self.time_waitE = 0
self.start = time.clock()
def __str__(self):
... | true |
332052a04ad4b0ba4caad77a709eb80c0a13d4ed | Python | Naveduran/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/2-uniq_add.py | UTF-8 | 225 | 3.234375 | 3 | [] | no_license | #!/usr/bin/python3 #squaring a matrix
def uniq_add(my_list=[]):
my_list.sort()
new = 0
for i in range(len(my_list)):
if i == 0 or my_list[i] != my_list[i - 1]:
new += my_list[i]
return new
| true |
8439c64a000a10d442d44e7a93640ea4c6243f6f | Python | proteneer/timemachine | /tests/test_centroid_rescaler.py | UTF-8 | 2,497 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
import pytest
from timemachine.md.barostat.moves import CentroidRescaler
from timemachine.md.barostat.utils import compute_intramolecular_distances
np.random.seed(2021)
pytestmark = [pytest.mark.nocuda]
def _generate_random_instance():
# randomly generate point set of size between 50 and 100... | true |
bc3e83a84cf9df1bcaac2ade199c78395ced8d82 | Python | HydPy/HydPy-meetups | /2016/2016-10-22/Example/inheritance_example.py | UTF-8 | 816 | 3.5625 | 4 | [
"MIT"
] | permissive |
class Base(object):
def __init__(self, a):
self.a = a
print 'Base'
def getMethod_(self):
self.a = 10
print 'Base derived getMethod'
def getValue(self):
return self.a+10
class Base1(object):
def __init__(self, c):
self.c = c
print 'Base 1'
... | true |
e67ce5f5dc04e29d49e98c46a0c5b0a1163abf78 | Python | x7rishi/hackerankPrac | /noidea2.py | UTF-8 | 172 | 2.671875 | 3 | [] | no_license | if "__main__" == __name__ :
x,y = [int(x) for x in input().spli()]
integers , happiness = list(), 0
seta, setb = set()
for _ in range(x):
| true |
c758f7204fd8568cf96065da91def8a315cadd78 | Python | googlefonts/fontdiffenator | /Lib/diffenator/hbinput.py | UTF-8 | 13,827 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | """Taken from Nototools
TODO (M Foley) Remove this module
"""
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/... | true |
4b99a6f5bcb33f8c7d1e3348a5425e56b0c4e6e8 | Python | Team-Q-Drone/qdrone | /testing/usb_connect.py | UTF-8 | 3,222 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | '''
Connect to flight controller over USB and get live sensor output
'''
import dronekit
from dronekit import connect, VehicleMode
import time
# Connect to the Vehicle (in this case a UDP endpoint)
# vehicle = connect('tcp:192.168.4.2:139', wait_ready=True, baud=115200)
vehicle = connect('0.0.0.0:14550', wait_ready=Fal... | true |
7abcbe6f339bdce7f37425833af44295101acd7f | Python | anggahadna/palindrome-py | /palindrome.py | UTF-8 | 405 | 3.265625 | 3 | [] | no_license | test = ['aba','abcd','abcde','aebcbea','aaaaabcbaaaaa','ppppssss','psasp','abcda']
for words in (test):
a = len(words)
b = a // 2
i=1
checkList = []
for x in range(b):
temp1 = words[x]
temp2 = words[a-i]
check = temp1==temp2
checkList.append(check)
print(temp1 + " " + temp2)
i+=1
fi... | true |
80a17931dd691bb38eb21b57f2a944216c6cb59d | Python | piyushkv1/hunter | /tests/mesh_ping_pods.py | UTF-8 | 1,486 | 2.53125 | 3 | [] | no_license | import paramiko
import json
import itertools
import random
import concurrent.futures
def run_command(ip, cmd):
with paramiko.SSHClient() as ssh:
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username='root', password='ca$hc0w')
stdin, stdout, stderr = ssh.exec_c... | true |
36af43a64eb1549028305c84e99f921d592250bb | Python | gautamgitspace/leetcode_30-day_challenge | /125_valid_palindrome.py | UTF-8 | 399 | 3.53125 | 4 | [] | no_license | class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
container = []
for char in s:
if not char.isdigit():
if char.isalpha():
container.append(char.lower())
else:
... | true |
deca947ece09c0a927ec07667da83b3df2867cc4 | Python | AndersonHJB/Student_homework | /早期代码/作业二/yunshi_1.py | UTF-8 | 7,710 | 3.40625 | 3 | [] | no_license | import random
# 输入性别或退出
while True:
gender = input('请输入您的性别(F/M),输入(exit)退出:\r\n')
if gender.upper() == 'F' or gender.upper() == 'M':
gender = gender.upper()
break
elif gender.upper() == 'EXIT':
print('\r\n\r\n感谢使用,再见!')
exit()
else:
print('您的输入有误,请重新输入\r\n')
# 输入年龄并判断年龄层
while True:
ag... | true |
e1e8d297e2cb8d8f772d139be804d7b25b10cf49 | Python | jmwenda/news_serve | /news_serve/recording/views.py | UTF-8 | 2,490 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from flask import Blueprint, render_template, flash, request, redirect, url_for
from flask.ext.login import login_required
from news_serve.app import db
from models import Recording
from news_serve.translation.models import Translation
from news_serve.utils import get_or_create
from forms import... | true |
c0802aba42f7e55340d6e60e43352501448fedd8 | Python | ArnabBasak/PythonRepository | /NLTK gender guesser/Gender_Guesser.py | UTF-8 | 515 | 2.96875 | 3 | [] | no_license | import nltk
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox
import os
MainWindow = Tk()
MainWindow.title('Gender Guessing')
MainWindow.state("zoomed")
def AddFile():
file_path = filedialog.askopenfilename()
if os.stat(file_path).st_size > 0:
messagebox.showinfo("Fil... | true |
4219cc25cb6c688e0b43e54a0e66b4533e68f33b | Python | SILKYMAJOR/atcoder_repo | /past_q/abc/148_d.py | UTF-8 | 305 | 3.265625 | 3 | [] | no_license | def main():
n = int(input())
n_list = list(map(int, input().split()))
previous = 0
for i in range(n):
if n_list[i] == previous + 1:
previous += 1
if previous == 0:
print("-1")
else:
print(n - previous)
if __name__ == '__main__':
main()
| true |
ad7ca58fad3f692512d1f941aa50450383a4691e | Python | JaneHappy/Code | /Google_DL_framework/chap-5.3_last.py | UTF-8 | 11,965 | 3.078125 | 3 | [] | no_license | # coding: utf-8
# chapter 5.3 at last
# modify "inference" on the basis of 5.2.1
#------------------------------------
# basic: chap 5.2.1 train NN
#------------------------------------
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
INPUT_NODE = 784 # 输入层的节点数。
O... | true |
e8124d2d9231c3acccd9d220e092515b231c1e84 | Python | samirchar/code_snippets | /models/ensembles.py | UTF-8 | 149 | 2.734375 | 3 | [] | no_license | import numpy as np
def linear_combination_betas(n,round_to = 10):
betas = np.random.rand(n)
return np.round(betas/sum(betas),round_to)
| true |
e1132bcac2b62eff0fb55f5ec7af2347dbf3f631 | Python | HansAnonymous/hans-vs-software | /Project 1 - Tic Tac Toe/game_test.py | UTF-8 | 220 | 2.921875 | 3 | [] | no_license | from tictactoe_game import TicTacToe
game = TicTacToe()
game.print_board()
while(not game.game_over(game.get_board())):
game.ai_move(game.PLAYERONE)
game.print_board()
game.ai_move(game.PLAYERTWO)
game.print_board() | true |
b0e706438060736673f2e7b80ad2cd1822776af5 | Python | matrujillo10/sockets-chat-room | /bot/cmds/stock.py | UTF-8 | 1,740 | 2.8125 | 3 | [] | no_license | """Stock command process module"""
import csv
import logging
from urllib.parse import quote
import requests
from . import server
# Valid messages
RESULT_MSG = "{} quote is ${} per share."
# Errors messsages
LESS_PARAMS_ERROR_MSG = "I need the stock code to work with :)"
MORE_PARAMS_ERROR_MSG = (
"Seems like you ... | true |
f08189f3f3a5ac53c24da92ab4a0ceaef2624c8f | Python | wafflestudio/waffle-algorithm | /baekjoon/week6/11404/euncheon_11404.py | UTF-8 | 899 | 3.234375 | 3 | [] | no_license | import sys
INF = 987654321
def floyd(w, n, m):
for k in range(1, n+1):
for i in range (1, n+1):
for j in range(1, n+1):
if w[i][j] > w[i][k] + w[k][j] :
w[i][j] = w[i][k] + w[k][j]
for i in range(1, n+1):
for j in range(1, n+1):
... | true |
2a6b411211a6b082a28d1cc457ec3018fb6bec06 | Python | fabrilopez/Python | /dictionary_creation.py | UTF-8 | 782 | 3.953125 | 4 | [] | no_license | '''
dictionary creation
'''
#1 load a variable with sentences
sentence='Pablito clavo un clavito que clavito clavo palblito'
'''
Peter Piper picked a peck of pickled peppers A peck of pickledpeppers\
Peter Piper picked If Peter Piper picked a peck of pickled \
peppers Wheres the peck of pickled peppers Peter ... | true |
f2f3cca6dba1950461ec7346240615673deeb21c | Python | muveso/UnityBuilder | /util/fileLogger.py | UTF-8 | 1,036 | 2.890625 | 3 | [
"MIT"
] | permissive | import os
import time
from threading import Thread
from . import logger
class ContinuousFileLogger(Thread):
def __init__(self, filename, no_timer):
self._filename = filename
self._logger = logger.Logger(no_timer)
self._stop_reading = False
self._content = []
Thread.__init__... | true |
9a55076b0d1ae2099560ede61e138b73e5257322 | Python | interactiveinstitute/watthappened | /energykit/fake/datastream.py | UTF-8 | 1,290 | 2.53125 | 3 | [
"MIT"
] | permissive | import energykit
import tornado.web
class _Handler(tornado.web.RequestHandler):
def initialize(self, stream):
self.stream = stream
def get(self):
self.write_form()
def post(self):
value = self.get_argument('value', '50')
if value: self.stream.set_value(value)
self.write_form()
def write_... | true |
4e1ee0f5d0154ab392c9bb6fc5abd9a993c88e15 | Python | DF-thangld/virtual_oulu | /database.py | UTF-8 | 1,589 | 2.59375 | 3 | [] | no_license | import config
import sqlite3
def create_connection():
conn = sqlite3.connect(config.DATABASE_FILE)
conn.row_factory = sqlite3.Row
return conn
def close_connection(connection, commit=False):
if commit:
connection.commit()
connection.close()
def run_command(sql_script, parameter=None, c... | true |
d8cc8c9bb79dd38deac3bdf9db2fef5af2ce2b4a | Python | poncho901/python | /Unfair Districts.py | UTF-8 | 6,419 | 2.8125 | 3 | [
"MIT"
] | permissive | import numpy as np
from copy import deepcopy
record = 0
row = 0
column = 0
people = 0
groups = 0
units = []
it = 0
record = 0
class unit:
def __init__(self, x, y, win, loss):
self.x = x
self.y = y
self.win = win
self.loss = loss
self.t = self.win+self.loss
class group:
... | true |
010c626f87fe673e6240d62c15317dc18a10deac | Python | hardenmvp13/Python_code | /笔记/练习/验证.py | UTF-8 | 602 | 2.875 | 3 | [] | no_license | # a = ["a", "b", "c"]
# b = "a"
# if b not in a:
# print(a)
# else:
# print(a)
aa = {"a": 1, "b": 2, "c": 3}
xue_yuan = []
xiang_xi = {"学院信息": {"广东财经大学": {"统计与数学学院": {"15统计学2班": [1, 2, 3, 4, 5, 6], "14统计学1班": {"哈登": "男,29岁"}}}}}
print(xiang_xi["学院信息"]["广东财经大学"]["统计与数学学院"].get("15统计学2班"))
print(xiang_xi["学院信息... | true |
95ef1ce52335843a295f7133794e1e95d319adbf | Python | DonggyuLee92/solving | /2020 Dec/1210/6299/6299.py | UTF-8 | 254 | 3.265625 | 3 | [] | no_license | input_list = [5, 6, 77, 45, 22, 12, 24]
# ans = []
# for i in input_list:
# if i%2 !=0:
# ans.append(i)
# # ans = [if x for x%2!=0 in input_list]
# print(ans)
# ans = [x for x in input_list if x%2!=0]
print([x for x in input_list if x%2!=0]) | true |
cbe07ec82bfb5c59b5ff5aab49dc12449f8b8d4a | Python | AIDRI/PlaneAI | /3.taxiways/lane_control.py | UTF-8 | 1,639 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | import cv2
import numpy as np
from PIL import Image
from lane_finding import angle_to_side, crop, select_rgb_yellow, convert_gray
from lane_finding import apply_smoothing, detect_edges, hough_lines, draw_lines
from road import one_moov, get_nb_moov, remove_moov, get_angle
from road import get_data
line = get... | true |
bcb49d915fb3c0fbf2826ebbf93394cb7cfd6eb9 | Python | sockduct/myblog | /app/search.py | UTF-8 | 1,373 | 2.515625 | 3 | [] | no_license | # This module abstracts away elasticsearch
# If we decide to switch out the search engine in the future, only this module
# should have to be changed
from flask import current_app
# Add model to the full text search index
def add_to_index(index, model):
# If no instance then bail
if not current_app.elasticsea... | true |
4d8294aa10ae39226ac51b075ea841e88fd38100 | Python | akanshadas/Yelp-Stream-Data-Processing | /task1 - bloom filtering.py | UTF-8 | 2,785 | 2.6875 | 3 | [] | no_license | from pyspark import SparkConf, SparkContext
import sys
import json
import csv
import itertools
import time
import math
import random
import operator
import os
import glob
import re
import binascii
# variables
first_json_path = sys.argv[1]
second_json_path = sys.argv[2]
out_file_path = sys.argv[3]
print("first_json_pa... | true |
44ab00ea52051507eebc915879350fb714979a8d | Python | ku70t6h1k6r1/auto_music | /SongGenerator/mikakunin/AnalogSynthesizer/AnalogSynthesizer.py | UTF-8 | 35,940 | 2.59375 | 3 | [] | no_license | # coding:utf-8
#default
import numpy as np
#option
import wave as wv
import struct
import scipy.signal
import math
from enum import Enum
"""
TODO:
エフェクターっぽいのは消す。Effector.pyに移行。
"""
class Waveform(Enum):
sine = "sine"
sawtooth = "sawtooth"
square = "square"
whitenoise = "whitenoise"
class FilterName(... | true |
19ba046cfb26a7b1a66b856e4038ba01d8aba541 | Python | AliciaDeng24/Doc2Vec-on-CareerVillage-dataset | /text_processor.py | UTF-8 | 1,773 | 3.453125 | 3 | [] | no_license | from init import *
from nltk.corpus import stopwords
class text_prossessor():
'''
Preprocess text body (A string)
'''
def __init__(self):
self.stopwords = set(stopwords.words('english'))
self.stemmer = PorterStemmer()
def prossessor(self, txt_str):
'''
Input: an n... | true |
7151d20ced462776f76673dc8186ea70b6474ade | Python | NamrataRaikwar2002/Function | /python2.py | UTF-8 | 143 | 2.6875 | 3 | [] | no_license | def increased(x):
# a=a+x here a is not define in local, because of it ,it is showing error.
return
a=20
b=5
increased(b)
print(a) | true |
fad99656071514219289f44de8806cebb7a432c5 | Python | n0thing233/n0thing233.github.io | /noodlewhale/amazon/VO/algorithm/postfix_to_infix.py | UTF-8 | 532 | 3.515625 | 4 | [] | no_license | def getInfix(str):
stack=[]
for j in range(len(str)) :
if operand(str[j]) :
stack.append(str[j])
else :
operator1=stack.pop()
operator2=stack.pop()
stack.append("(" + operator2 + str[j] + operator1 + ")")
return stack.pop()
def operand(... | true |
7737648708580a6a8d5916e533aa0ceb2852941d | Python | x3medima17/zaschecoin_bot | /models.py | UTF-8 | 5,047 | 2.59375 | 3 | [] | no_license | import re
import hashlib
from random import randint
from peewee import *
from telebot import TeleBot
from config import *
import strings as s # все строки хранятся здесь
bot = TeleBot(token)
sid = lambda m: m.chat.id
uid = lambda m: m.from_user.id
cid = lambda c: c.message.chat.id
db = SqliteDatabase('db.sqlite3'... | true |
bc8d47d1719be3c3f3b7d2186b0342058bdc1391 | Python | Relyn13/cat_detection | /detector.py | UTF-8 | 1,544 | 3.125 | 3 | [] | no_license | import argparse
import cv2
import csv
import os.path
import sys
# FOR EVALUATE.PY
def detect(filename):
# load the input image and convert it to grayscale
image = cv2.imread(filename)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# load the cat detector Haar cascade, then detect cat faces
# in the input image
... | true |
fb67678d2ebe3a71a3a485e5ae1a63ca2f408127 | Python | amahiner7/ImageDatasetProcess-Yolov5 | /data/bound_box_data.py | UTF-8 | 2,533 | 3.265625 | 3 | [] | no_license | import numpy as np
class BoundBoxData:
def __init__(self):
self.image_width = 0
self.image_height = 0
self.x_min = 0
self.y_min = 0
self.x_max = 0
self.y_max = 0
self.center_x_ratio = 0.0
self.center_y_ratio = 0.0
self.width_ratio = 0.0
... | true |
2a93024e8cdfa64ed6edc60b6771fa467f31b6eb | Python | MuhammadVT/imf_sudden_turning | /data_preprocessing/run_all.py | UTF-8 | 15,241 | 2.578125 | 3 | [] | no_license | import datetime as dt
import sqlite3
import multiprocessing as mp
import sys
import numpy as np
import logging
def move_to_db(stms, etms, rads, channels, db_name,
ftype="fitacf", dbdir="../data/sqlite3/",
run_in_parallel=False):
""" Reads data from a given radar """
from move_sddata_to... | true |
a932241ffe7ad9a711282352c9363c7aa2051588 | Python | RH-cmd/python-challenge | /PyBank/main.py | UTF-8 | 2,919 | 3.5 | 4 | [] | no_license | #Import os and csv modules
import os
import csv
#Set path for file
budget_path = os.path.join("Resources", "budget_data.csv")
#Set variables for total months and net profit and loss
total_months = []
net_profit_and_loss = []
monthly_profit_loss_change = []
#Open budget_data as a csv file
with open(budget_path) as cs... | true |
cb0b812f4afe8511b172ece45a8525d6a4051e77 | Python | ga154/pyKasir | /kasir.py | UTF-8 | 469 | 2.59375 | 3 | [
"MIT"
] | permissive | __author__ = 'Gunawan Ariyanto'
from daftar_stok_barang import data_barang # import data barang agar bisa dibaca di sini
# inisialisasi data belanjaan yang akan dibeli dan diproses di lasir
belanja = []
item_belanja=[]
# Masuk ke LOOP untuk memasukan data barang yang dibeli
while True:
pass # bagian ini harus ... | true |
1cd6431f570976c88128b1e61f2739591b52ad3f | Python | alexpopov23/hydralex | /framenet_as_graph/parse_single_fn_file.py | UTF-8 | 11,683 | 2.59375 | 3 | [] | no_license | '''
Created on Oct 19, 2017
@author: jennifersikos
'''
import re
import codecs
from frame_instance import FrameInstance
from role_instance import RoleInstance
from sentence_instance import SentenceInstance
import xml.etree.ElementTree as et
class ReadSingleFileFrames(object):
'''
This class reads a single par... | true |
b78dd46841d2441a8b898ddb8e70afba4d9f7f31 | Python | victor-estrade/SystGradDescent | /model/minibatch.py | UTF-8 | 7,822 | 3.03125 | 3 | [
"MIT"
] | permissive | # coding : utf-8
import numpy as np
from collections import Generator
def assert_arrays_have_same_shape(*arrays):
length = arrays[0].shape[0]
# Assert that every array have the same 1st dimension length:
for i, arr in enumerate(arrays):
assert arr.shape[0] == length, "Every array should have the ... | true |
944477718f3a2361f66c9d3c5049a0f6b823c747 | Python | sbiauek/ALX_Zadanie_Domowe | /Zadanie 2.3.py | UTF-8 | 278 | 3.015625 | 3 | [] | no_license | # Napisz program, który odczytuje od użytkownika wiele liczb.
#
# Program powinien wyliczyć i na końcu wypisać następujące statystyki:
#
# - liczba podanych liczb (ile sztuk),
# - suma,
# - średnia,
# - minimum
# - maksimum
#
# NIE używaj funkcji wbudowanych!
| true |
0bf4dcadf10146c8b83c49b81fe56e046b03408c | Python | abrance/mine | /w2020/w12/w12_21/study_id_obtain.py | UTF-8 | 2,927 | 2.59375 | 3 | [
"MIT"
] | permissive | import sys
import time
from datetime import datetime
from threading import Thread
import requests
import json
init_time = ''
stop_time = ''
class Controller(Thread):
"""
控制运行
"""
def __init__(self):
super(Controller, self).__init__()
self.loop()
@staticmethod
def rest_study... | true |
2b0b539aec55e41cb0b14b30fe3ca5d851dc2961 | Python | henrykironde/Geodata | /unpack/python_code/1138OS_Code/1138OS_Code/Chapter 4/1138_04_18-json.py | UTF-8 | 492 | 2.6875 | 3 | [] | no_license | # Parse GeoJson data
jsdata = """{ "type": "Feature", "id": "OpenLayers.Feature.Vector_314", "pro
perties": {}, "geometry": { "type": "Point", "coordinates": [ 97.03125, 39.72656
25 ] }, "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.
3:CRS84" } } }"""
# Try to eval() the data
point = eval(jsda... | true |
81184eadca209330384f6dca7b05add830c30488 | Python | daniel-reich/ubiquitous-fiesta | /EfEpbcGjXQYDFcdxF_18.py | UTF-8 | 104 | 3.1875 | 3 | [] | no_license |
def filter_list(lst):
return [i for i in lst if str(i)!=i]
filter_list([1, 2, "a", "b"])
| true |
d5e99c729664fabd3a4c91497564f78c6feeb1f6 | Python | isaac-oliveira/GioWatch | /funcoes.py | UTF-8 | 16,621 | 2.609375 | 3 | [] | no_license | from geopy.distance import geodesic
import turtle
import tkinter
import datetime
import dados
import strings
import grafico
import puras
import utm
import math
flag = dados.SEM_FLAG # Indica se a pausa vai ser considerada ou não
def le_timestamps(i, list_linhas, registros):
linha = list_linhas[i].split()
if i... | true |
718376a3b7a52a3a0c56dc0e93f6bf6302919b89 | Python | tanersyn/Project-Euler | /Problem03.py | UTF-8 | 479 | 3.640625 | 4 | [] | no_license | # 13195'in asal çarpanları 5,7,13 ve 29'dur
# 600851475143 sayısının en büyük asal çarpanı nedir?
i = 2
sayı = 600851475143
liste=[]
while (i < sayı):
if sayı % i == 0:
sayac = 0
for j in range(2,i):
if (i % j == 0):
sayac +=1
break
if... | true |
b91865d2519751fbb5726b53902af262cc469086 | Python | amcm329/PSICOS | /anteriores/Psicos_abril_2012/src/psicos01.py | UTF-8 | 6,281 | 3.796875 | 4 | [] | no_license | #!/usr/bin/env python
from Agente import *
from Mapa import *
from Arma import *
from random import *
#Nota: poner """-----""" despues de cualquier "else" porque si no entonces no jala el programa
"""Programa de agentes autonomos para combate (PSICOS).
Version 3.0
Fecha 14/11/2011
El funcionamiento del programa es... | true |
f0a0e5cb7ccd83ef48500a6e802424d6f9f3da22 | Python | zalando-zmon/opentracing-utils | /opentracing_utils/decorators.py | UTF-8 | 4,091 | 2.765625 | 3 | [
"MIT"
] | permissive | import functools
import opentracing
from opentracing_utils.span import get_new_span, adjust_span, get_span_from_kwargs, remove_span_from_kwargs
def trace(component=None, operation_name=None, tags=None, use_follows_from=False, pass_span=False, inspect_stack=True,
ignore_parent_span=False, span_extractor=No... | true |
126511142038dc90b427b84c9e24ee74e31e33df | Python | williamqin123/old-python | /Game.py | UTF-8 | 1,364 | 3.484375 | 3 | [] | no_license | import random
import os
def game():
count = 1
you_points = 0
cpu_points = 0
you = False
cpu = False
while True:
if count == 1:
you_num = random.randint(1, 26)
print "You got %s" % you_num
count = 2
you = True
elif coun... | true |
eb053c832b7c2000668a93177fb69c1906ababe6 | Python | ateneva/python-oop-2020-06 | /design_patterns/converters/decorators/PrimitiveValuesDecoratorConverter.py | UTF-8 | 748 | 2.734375 | 3 | [
"MIT"
] | permissive | from converters.factories.PrimitivesConverterFactory import PrimitivesConverterFactory
from converters.streams.StreamConverter import StreamConverter
primitives_converter_factory = PrimitivesConverterFactory()
class PrimitiveValuesDecoratorStreamConverter(StreamConverter):
def __init__(self, converter: St... | true |
4eaa29341a38e165b2678a238c10416c97074cc0 | Python | beatrizadm/data-structures | /src/python/matriz_transposta.py | UTF-8 | 238 | 2.8125 | 3 | [
"MIT"
] | permissive | def transposta(matriz):
transposta = []
for j in range(len(matriz[0])):
linha = []
for i in range(len(matriz)):
linha.append(matriz[i][j])
transposta.append(linha)
return transposta
| true |
fc08d8105f24a8623a5a93832ce045f2debdd656 | Python | coderlzy/python- | /比赛训练7天/day1字符串/字符串最后一个单词的长度.py | UTF-8 | 251 | 3.9375 | 4 | [] | no_license | #计算字符串最后一个单词的长度,单词以空格隔开。
str1=input("请输入字符串:")
list1=str1.split(" ")
count=0
lenght=0
for i in range(len(list1)):
count+=1
str2=list1[count-1]
for i in str2:
lenght+=1
print(lenght) | true |
ad8a3718e609f50186247b5090a3314e09215b25 | Python | pritamKarmokar/da4event-experiments | /N-ROD/evrepr/thirdparty/matrixlstm/opticalflow/src/event_augmentation.py | UTF-8 | 14,786 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | import numpy as np
import tensorflow as tf
def get_mask(h, w, partial_mask):
if partial_mask is not None:
return partial_mask
else:
return tf.ones([h, w], dtype=tf.uint8)
def apply_event_mask(events, mask):
with tf.name_scope('apply_event_mask'):
# For each event coordinate, dete... | true |
f828f7e126632fb3d5e3c54903c42d042c327df8 | Python | Yang-Jianlin/python-learn | /LeetCode/T-5.py | UTF-8 | 920 | 3.28125 | 3 | [] | no_license | class Solution:
def longestPalindrome(self, s: str):
s1 = s
m = list(s)
m.reverse()
s2 = ''.join(m)
len1 = len(s1)
len2 = len(s2)
array = [[0 for i in range(len2 + 1)] for j in range(len1 + 1)]
maxNum = 0 # 最长匹配长度
p = 0 # 字符串匹配的终止下标
... | true |
9e26da4f9e569a42c294b79ae0d1d657828e302d | Python | JamieVic/VIC-LGA-Status | /lgastatus.py | UTF-8 | 938 | 2.828125 | 3 | [] | no_license | import csv, urllib.request
url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vSshBgCbldwtXKoqWsumyzaG6Q063vWGLEmZWDkdjK49MVf7YvcVso4v8yrPfo8CN1t_Q4Hp8TF_MPm/pub?gid=1798358420&single=true&output=csv"
response = urllib.request.urlopen(url)
lines = [l.decode('utf-8') for l in response.readlines()]
zoneReader =... | true |
726ab5744f9c14505040bbfcd8d7bf1fa08d0e3a | Python | davedgd/studentcourse | /studentcourse.py | UTF-8 | 2,261 | 3.1875 | 3 | [] | no_license | # ------------
# Instructions
# ------------
# To run this script, first install the necessary libraries via pip:
# pip install mysql-connector colorama pandas
# Alternatively, in conda/mamba, see: mysql-connector-python
# Next, run this script via python:
# python studentcourse.py
# Note that you m... | true |
0cf4d59ee96cf3f7c31268622c1e384bd709d900 | Python | mazelado/quiz | /quiz_cli/Question.py | UTF-8 | 4,078 | 4 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 5/14/19 2:01 PM
@author: matt
"""
import random
from string import ascii_uppercase
from typing import List
class Question(object):
"""
This is a class to define the questions, true answers, and false answers.
"""
def __init__(self,
... | true |
3e082861d2ac99b7f2b15ccc62502840abd6e049 | Python | kho226/facebook_messenger_scraper | /send_random_sms.py | UTF-8 | 1,204 | 2.875 | 3 | [] | no_license | '''
A module to send a random sms from a MongoDB
'''
from pymongo import MongoClient
from twilio.rest import Client
import pprint
from random import randint
import os
import sys
#create MongoClient
client = MongoClient('localhost', 27017)
#databases and collections are created lazily in MongDB
db = client['moti-db']... | true |
6f2bb5d38d5bd046fc04837a682d36759055c7d7 | Python | 17770367343/..1 | /day22/作业.py | UTF-8 | 1,288 | 3.5 | 4 | [] | no_license | # class Circle:
# '''创造一个圆对象,其包含一个半径属性radius,以及两个方法面积area、周长perimeter'''
# def __init__(self,radius):
# self.radius = radius
# def area(self):
# return round(3.14*self.radius**2,3)
# def perimeter(self):
# return round(2*3.14*self.radius,3)
#
# circle1 = Circle(5)
# circle2 = Cir... | true |
ae1ca67ecf0a28223a6d6513c28dcc4f6cfcf388 | Python | nostalgicpenguin/pythonplaytime | /Twisted/dataclient.py | UTF-8 | 3,322 | 2.890625 | 3 | [] | no_license | from twisted.internet import reactor, protocol
class DataClient(protocol.Protocol):
def __init__(self):
self.cmds = [
(self.put, ['a', 'AAAA']),
(self.get, ['a']),
(self.get, ['b']),
(self.put, ['b', 'BBBB']),
(self.get, ['b']),
(sel... | true |
eb67d9e58cd2d60fb8afbec805bb93d7a0b732a2 | Python | kalsotra2001/practice | /bloomberg-codecon/matching-datasets.py | UTF-8 | 673 | 3.265625 | 3 | [] | no_license | def diff(a, b):
total = 0.0
for i in range(len(a)):
total += abs(a[i] - b[i])
return total
def minimum_index(mins):
m, ind = mins[0], 0
for i in range(len(mins)):
if mins[i] < m:
m, ind = mins[i], i
return ind
n = int(raw_input())
original, approximate = [], []
for ... | true |
e156991c50889f9cc36a865a6b201dc14b21fd49 | Python | VEnriquez89010/CODE | /Clases/ListaLigada.py | UTF-8 | 2,811 | 3.53125 | 4 | [] | no_license | # from time import sleep
class nodo():
def __init__(self,valor):
self.value=valor
self.next=None
def get_value(self):
return self.value
def get_next(self):
return self.next
def set_value(self,valor):
self.value=valor
def set_ne... | true |
4b4dfed352445454c45df3bcbf02160ccd83a32c | Python | orange2120/ML_2020Spring | /hw7/data_processing.py | UTF-8 | 3,321 | 2.671875 | 3 | [] | no_license | import re
import torch
from glob import glob
from PIL import Image
import torchvision.transforms as transforms
import numpy as np
dataset_dir = './data'
class ImgDataset(torch.utils.data.Dataset):
def __init__(self, x, y=None, transform=None):
self.x = x
# label is required to be a LongTensor
... | true |
39de60e78a1266148763cfcefb36e721908145c7 | Python | AbhishekScariyaMB/RMCA_S1_A_-Abhishek-Scariya-M-B | /Python Lab/17-02-2021/CO3/rectangle.py | UTF-8 | 210 | 4.15625 | 4 | [] | no_license | def area(a,b):
print('Area of rectangle with sides',a,'and',b,'is: ','%.2f'%(a*b),'Sq.units')
def perimeter(a,b):
print('Perimeter of rectangle with sides',a,'and',b,'is:','%.2f'%(2*(a+b)),'units')
| true |
0fe43642344f9840c0351e2d96ee749368646dd7 | Python | KeyHiro/TCSFP | /Codigos/controlador_autos.py | UTF-8 | 6,955 | 2.90625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3 as s
def __crear_tablas():
"""Crea las tablas del proyecto de no existir."""
query = """CREATE TABLE IF NOT EXISTS """
tablas = {
'marcas':"""marcas (id_marca INTEGER PRIMARY KEY AUTOINCREMENT, nombre TEXT, pais TEXT)""",
'tipos':"""tipos (id_tipo INTEG... | true |
cd7a0dbf1d7aba966a222dcc8ecc7b14c7ea0a17 | Python | Kiddalingur/rob6 | /simulation_handinVersion/controllers/my_controller2/my_controller2.py | UTF-8 | 3,281 | 2.6875 | 3 | [] | no_license | """my_controller controller."""
from math import sqrt, acos
from controller import Supervisor, Lidar, Motor, Node, Field, Robot
import numpy as np
import pandas as pd
import math
# You may need to import some classes of the controller module. Ex:
# from controller import Robot, Motor, DistanceSensor
def get_my_... | true |
e61b248d34daa091cc7703b4d78d81394d6f04df | Python | hsinlei/Iris | /web_ranking.py | UTF-8 | 7,440 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 21 21:03:11 2019
@author: marley
"""
import requests
import json
import gzip
import io
import lxml.html
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from collections import Counter, defaultdict
import time
import numpy... | true |
9e1ebc99d202418c2523de692dfe57454d0eea19 | Python | LeynilsonThe1st/python | /curso-em-video/Desafio56.py | UTF-8 | 798 | 3.734375 | 4 | [] | no_license | import colors
mNome = ''
idades = 0
maior = 0
media = 0
f = 0
fIdades = 0
fMaior = 0
for i in range(1, 6):
print('{}----- {}ª PESSOA -----'.format(colors.blue, i))
nome = str(input('NOME: '))
idade = int(input('IDADE: '))
sexo = str(input('SEXO [M/F]: '))
idades += idade
if idade > maior:
... | true |
1b14fba2abfba1291758cc2550654652e007d1ef | Python | jangwoopark/exercises-python | /highest-value-palindrome/highest-value-palindrome.py | UTF-8 | 1,143 | 3.03125 | 3 | [] | no_license | #!/bin/python3
import math
import os
import random
import re
import sys
def highestValuePalindrome(s, n, k):
if (n == 1):
if (k == 1):
return '9'
else:
return '-1'
arr = list(s)
changes = [0 for _ in range(n)]
for i in range(int(n / 2) + (n & 1)):
if (ar... | true |
97414cb320fd31370f2d389754461d42943c541b | Python | oprk/project-euler | /p052_permuted_multiples/permuted_multiples.py | UTF-8 | 562 | 4.1875 | 4 | [] | no_license | # Permuted multiples
# Problem 52
# It can be seen that the number, 125874, and its double, 251748, contain
# exactly the same digits, but in a different order.
# Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
# contain the same digits.
import time
def permuted_multiples(i):
digits = lis... | true |
45c8e1dd477b7949f94ed45c183a85d7f44e48c0 | Python | nicolebarleta/web-335 | /week-8/barleta_calculator.py | UTF-8 | 1,781 | 4.75 | 5 | [] | no_license | """
============================================
; Title: Exercise 8.3 - Python in action
; Author: Professor Krasso
; Date: 06 December 2020
; Modified By: Marie Nicole Barleta
; Description: Python in action (calculator)
;===========================================
"""
# function that adds two numbers
def add(nu... | true |
7390a0dd521417c41e514f2cb600bb85662933b7 | Python | shubham0297/Big_Data_Foundations | /Analyzing_Subway_Data_NDFDSI Project/Exercise 2 - Data Analysis/Exercise 2.6 - Histogram_Of_ENTRIESn_hourly/Histogram.py | UTF-8 | 1,819 | 4.25 | 4 | [] | no_license | '''
Exercise 2.6 HISTOGRAMS FOR ENTRIESn_hourly
Problem Statement :
Before you make any analysis, it might be useful to look at the data we want to analyse. More specifically, we will evaluate the entries by hour in our data from the NYC Subway to determine the data distribution. This data is stored in the column ... | true |
3bd9d236b0bd18eea544b17e2cb5222f25b1a5c5 | Python | dada00321/ntust_moodle_resource_crawler | /modules/ex_AutoLogin_NTUST_Moodle_v2.py | UTF-8 | 933 | 2.5625 | 3 | [
"MIT"
] | permissive | """
自動登入台科Moodle網頁
"""
from selenium import webdriver as wd
#from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
def auto_login_moodle():
chrome_options = Options()
chrome_options.add_argument("--headless")
wd_path = r"D:\geckodriver\chromedriver.exe"
... | true |
26dd3872728ab36470b7f24c8f94229c6af9ef9e | Python | nrisse/mwi-srf183 | /src/atmos_viewer/radiosondes_t_rh.py | UTF-8 | 5,054 | 2.921875 | 3 | [
"MIT"
] | permissive | """
Plot radiosonde profiles
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from glob import glob
import os
from helpers import wyo, colors
from dotenv import load_dotenv
load_dotenv()
class Radiosonde:
def __init__(self):
"""
Class to read radiosonde profiles that ... | true |
ef44f2f3cbbb7aa7c9620ed13720a00a84046bd7 | Python | ramixpe/backup-scripts | /bulk_config-gathering.py | UTF-8 | 2,488 | 2.703125 | 3 | [] | no_license | #################### version 1 ######################################
# import datetime
# from netmiko import *
# import re
# #getting the commands from the file
# with open("commands.txt") as cmd_file:
# commands = cmd_file.readlines()
# #getting the hosts IPs
# with open('hosts.txt') as f:
# devices = f.rea... | true |
dd3e277d87fccf0ac530277761e872dbd57f9e07 | Python | kanekyo1234/AtCoder_solve | /ABC/119/A.py | UTF-8 | 300 | 2.640625 | 3 | [] | no_license | a=list(map(int,input().split('/')))
#print(a)
if a[0]==2019:
if a[1]==4:
if 30>=a[2]:
print("Heisei")
else:
print("TBD")
elif 5>a[1]:
print("Heisei")
else:
print("TBD")
elif 2019>=a[0]:
print("Heisei")
else:
print("TBD") | true |
1930efdfb527910de3c1ae1379b8d4d6816f058d | Python | PavelCz/rl-adversarial-attack | /src/selfplay/naive_selfplay_evaluation.py | UTF-8 | 3,245 | 2.921875 | 3 | [] | no_license | import time
from tqdm import tqdm
from src.attacks.fgsm import fgsm_attack_sb3, perturbed_vector_observation
def evaluate(model, env, num_eps: int, slowness=0.05, render=False, save_perturbed_img=False, attack=None,
img_obs=False, return_infos=False):
"""
Evaluate a trained model
:param mod... | true |
f3181e8d6610e0cdd523caa3c37ec2fb5bc6e03c | Python | maq1995/JianZhi_offer_python | /Q31_连续子数组的最大和.py | UTF-8 | 3,735 | 4.53125 | 5 | [] | no_license | # encoding: utf-8
"""
@project:JianZhi_offer
@author: Ma Qian
@language:Python 2.7.2
@time: 2019/9/11 下午5:34
@desc:
"""
'''
题目:输入一个整型数组,数组里有正数也有负数。数组中一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。
例如输入的数组为{1, -2, 3, 10, -4, 7, 2, -5},和最大的子数组为{3, 10, -4, 7, 2}, 和为18.
'''
'''
解法1:我们试着从头到尾逐个累加示例数组中的每个数字。
首先,初始化和为0,
第一... | true |
4afa8f228eaf0652012bef5a68ac6a433424658b | Python | jgquiroga/python3-exercises | /flask-exercises/ex-02-flask-pipenv/flask-pipenv-v2.py | UTF-8 | 816 | 2.546875 | 3 | [] | no_license | from flask import Flask, render_template
app = Flask(__name__)
# TODO: Add this information in a Readme file
# Prerequisites:
# Install pipenv (I'm using anaconda)
# conda install -c conda-forge pipenv
# Install pipenv in the current project:
# pipenv install
# run this application in a pipenv environ... | true |
c4cbf6f89ad8c87e9c134ae0e0af1dee875fb396 | Python | sb-lviv/7_crypto_1 | /main.py | UTF-8 | 5,549 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env python3
import argparse
import random
class Crypto(object):
ACTIONS = [
'enc', # encrypt
'dec', # decrypt
]
ALGORITHMS = [
'sub', # substitution
'per', # permutation
'sca', # scaling
]
FIRST_CHAR = ' '
LAST_CHAR = '~'
def __ini... | true |
9ecabeba4c308c840a72bbb8d3b524a8de319f2e | Python | markcharder/PyUtils | /bioFunctions.py | UTF-8 | 2,160 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import optparse
import re
class FastaManipulator(object):
def __init__(self, object):
self.file = open(object, 'r')
self.previous = ""
self.pline = ""
self.count = 0
self.contigs = dict()
self.lengths = dict()
self.total = 0
self.nf = 0
def noSplit(self):
print "Reading in f... | true |
f80931752b8943246bb92c578f350a03ed493278 | Python | tayyab-razzaq/fyyur | /models.py | UTF-8 | 8,537 | 2.625 | 3 | [
"MIT"
] | permissive | # ==================================================================================================================== #
# Imports
# ==================================================================================================================== #
from datetime import datetime
from flask import Flask
from flask_mo... | true |
792fb031a9105662ea89b758fdd468180adfb880 | Python | DevooKim/algorithm-study | /week10/book/79devoo.py | UTF-8 | 1,282 | 3.265625 | 3 | [] | no_license | import collections
import heapq
import functools
import itertools
import re
import sys
import math
import bisect
from typing import *
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
#1. [a,b]에서 a, b순서로 정렬
#2. 하나씩 추출해서 조건이 맞으면 결과에 저장
#3. people이 남았는데 조... | true |
d2db9fb866e2043e97e5cf90b8b3f00c96fdfd76 | Python | niraj-khatiwada/ML | /Computer Vision/OpenCV/Image Manipulation/sharpen.py | UTF-8 | 280 | 2.625 | 3 | [] | no_license | import cv2
import numpy as np
input_image = cv2.imread("C:/Users/niraj/Anaconda3/Projects/Computer Vision/OpenCV/images/abraham.jpg")
kernel = np.array([[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]])
sharpened = cv2.filter2D(input_image, -1, kernel)
cv2.imwrite("Sharpened.jpg", sharpened) | true |
ec22b2833c94dfd5528a8a9ae056068683185f33 | Python | hrz123/algorithm010 | /Week09/每日一题/剑指 Offer 43. 1~n整数中1出现的次数.py | UTF-8 | 3,100 | 3.53125 | 4 | [] | no_license | # 剑指 Offer 43. 1~n整数中1出现的次数.py
class Solution:
def countDigitOne(self, n: int) -> int:
digit, res = 1, 0
high, cur, low = n // 10, n % 10, 0
while high != 0 or cur != 0:
if cur == 0:
res += high * digit
elif cur == 1:
res += high * di... | true |
30f66d646321775a623172a25da2f599775a1e16 | Python | askintution/segment-distill | /unet.py | UTF-8 | 4,701 | 2.578125 | 3 | [] | no_license | from keras.layers import Input, Conv2D, MaxPooling2D, concatenate, UpSampling2D
from keras.layers import Dropout, BatchNormalization
from keras.models import Model
from keras.optimizers import Adam
from utils.config import LEARNING_RATE, IMAGE_SHAPE
from utils.jaccard_loss import jaccard_coef
def unet(init_channels=6... | true |