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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8c9ede3bb7f9724ebd700bbbda189af02ac9e358 | Python | kev1/snt | /main.py | UTF-8 | 5,663 | 2.9375 | 3 | [] | no_license | import os
# print(env.variables.config['theme']['palette']) # access palette color. Automatic toggle of color ?
def define_env(env):
"Hook function"
#---------------- <exo perso>--------------------
env.variables['compteur_exo'] = 0
@env.macro
def exercice():
env.variables['compteur_exo'] +... | true |
baacbe025c2a055ffd3dff7b6520cd9b841d6425 | Python | BLUECARVIN/Several-ReinforcementLearning | /atari_game/Agent/DoubleDQN.py | UTF-8 | 10,939 | 2.515625 | 3 | [
"MIT"
] | permissive | import sys
sys.path.append("..")
import torch
from torch import nn
from torch.nn import functional as F
from torch.autograd import Variable
import os
import copy
import pickle
import gym
import numpy as np
import random
from PIL import Image
from Utils import hard_update
from MLP import QNet
import ReplayBuffer
cl... | true |
5e74f80f6b69e6ba959e3c0c8fb221bc414e18a5 | Python | mj-will/nessai | /nessai/utils/indices.py | UTF-8 | 1,684 | 3.03125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Utilities related to insertion indices.
"""
import numpy as np
from scipy import stats
def compute_indices_ks_test(indices, nlive, mode="D+"):
"""
Compute the two-sided KS test for discrete insertion indices for a given
number of live points
Parameters
----------
i... | true |
79e1b3a06f9e493296db4d8e2aa39d53e46c66d7 | Python | LucasMaiale/Libro1-python | /Cap2/Programa 2_10.py | UTF-8 | 940 | 4.21875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
@author: guardati
Solución del problema 2.10
Calcula e imprime el total a pagar por alimento, a lo largo de un mes,
en un refugio para perros en el cual viven perros de distinta edad y tamaño.
Se considera que el mes tiene 30 días.
"""
precio_alim_ad = float(input('Ingrese el preci... | true |
8c95f82d65e97ad13aff5abca8b5121bed89f185 | Python | sixty-north/added-value | /source/added_value/tabulator.py | UTF-8 | 15,887 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | from collections import deque
from collections.abc import Mapping
from itertools import product, chain, repeat
from added_value.items_table_directive import NonStringIterable
from added_value.multisort import tuplesorted
from added_value.sorted_frozen_set import SortedFrozenSet
from added_value.toposet import TopoSet
... | true |
4a582c4364f53a3d0844e8aa2a44063f6d4a8577 | Python | sunary/image-process | /preprocess/edge_detect.py | UTF-8 | 3,918 | 2.515625 | 3 | [] | no_license | __author__ = 'sunary'
import cv2
from utils import helper
from preprocess import histogram_equalization
import numpy as np
def basic(pix):
temp_x = [[0] * len(pix[0]) for _ in range(len(pix))]
temp_y = [[0] * len(pix[0]) for _ in range(len(pix))]
edge_pix = [[0] * len(pix[0]) for _ in range(len(pix))]
... | true |
36c306b33199594ed1d4b1a05ce2758bf99318e8 | Python | Haestad/datatek | /oving5/kpc.py | UTF-8 | 4,324 | 3.171875 | 3 | [] | no_license | """ This module contains the KeyPad Controller (KPC) class. """
from time import sleep
from typing import Callable
from keypad import Keypad
from led_board import LEDBoard
class KPC:
""" Class that contains all the logic for operating the keypad. """
def __init__(self):
self.keypad = Keypad()
... | true |
e57813e7a7871b3b99db5957b4aac3e31d0cd66a | Python | gistable/gistable | /all-gists/1770447/snippet.py | UTF-8 | 11,267 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# zmqc: a small but powerful command-line interface to ZMQ.
## Usage:
# zmqc [-0] (-r | -w) (-b | -c) SOCK_TYPE [-o SOCK_OPT=VALUE...] address [address ...]
## Examples:
# zmqc -rc SUB 'tcp://127.0.0.1:5000'
#
# Subscribe to 'tcp://127.0.0.1:5000', reading messages from it and printing
# the... | true |
cd90be762ee720db02d613d2c8dacbc2d103514c | Python | P-ppc/leetcode | /algorithms/SpiralMatrixIII/solution.py | UTF-8 | 934 | 3.0625 | 3 | [] | no_license | class Solution(object):
def spiralMatrixIII(self, R, C, r0, c0):
"""
:type R: int
:type C: int
:type r0: int
:type c0: int
:rtype: List[List[int]]
"""
res = []
directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]
direction_index = 0... | true |
581e4bc4765822601bb0593ee3c64bee539611e6 | Python | c0indev3l/btccharts-tick2candlestick | /tick2candlestick.py | UTF-8 | 12,641 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
.. module:: symbol
:platform: Unix, Windows, Mac OS X
:synopsis: Module to download tick data from BitcoinCharts
http://api.bitcoincharts.com/v1/csv/
.. moduleauthor:: Working4coins <working4coins@gmail.com>
Copyright (C) 2013 "Working4coins" <wo... | true |
3609e44572690965cb83d8cb123eaa89b7a23e56 | Python | papadave11/DeepLearnig | /datatime_to_string.py | UTF-8 | 1,447 | 2.9375 | 3 | [] | no_license | from pandas import read_csv
from datetime import datetime
from pandas import DataFrame
from pandas import concat
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import MinMaxScaler
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from keras.mode... | true |
6e06351a7a4fdefe6d608ea87d394fdae8933789 | Python | laolee010126/algorithm-with-python | /problems_solving/baekjoon/acm_craft.py | UTF-8 | 1,242 | 3.21875 | 3 | [] | no_license | """Get the mininum cost of building a wanted building
url: https://www.acmicpc.net/problem/1005
"""
import sys
sys.setrecursionlimit(10 ** 9)
def get_building_time(w, time, rule_cache):
total_time_cache = [-1 for _ in range(len(time))]
for i in rule_cache[0]:
total_time_cache[i] = time[i]
def ... | true |
74acff7cf11e5086d5d5edc9eaa3c47acbb27e40 | Python | GarciaJhonLucas/colorise | /src/colorise/__init__.py | UTF-8 | 8,066 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Python module for easy, cross-platform colored output to the terminal."""
import atexit
import itertools
import os
import platform
import sys
import colorise.formatter
from colorise.attributes import Attr # noqa: F401
_SYSTEM_OS = platform.system().lower()
__author... | true |
a6e1cadf4e950f07e61e81db37b3e056e61b552f | Python | stbman/cs5228 | /latlong/pairdist_latlong.py | UTF-8 | 1,201 | 2.953125 | 3 | [] | no_license | import pandas as pd
import numpy as np
df = pd.read_csv("pairs.csv")
db = pd.read_csv("latlong.csv")
def updateLat(port):
port = db[db["Port"] == port]
assert(port is not None)
assert(port.shape == (1,3,))
return port.iloc[0,1]
def updateLong(port):
port = db[db["Port"] == port]
assert(port i... | true |
9836e64bf7656bf1a2b2d36573c55bb408a24646 | Python | spadwal7039/ttl255.com | /netbox/pynetbox-part4/prep_tags_for_search.py | UTF-8 | 1,030 | 2.6875 | 3 | [
"MIT"
] | permissive | import ipaddress
import itertools
import pynetbox
from config import NETBOX_URL, NETBOX_TOKEN
# Instantiate pynetbox.api class with URL of your NETBOX and your API TOKEN
nb = pynetbox.api(url=NETBOX_URL, token=NETBOX_TOKEN)
# Prepare tags we want to combine
mc_side = ["a_side", "b_side"]
mc_exchange = ["nasdaq", "n... | true |
19190c777abe5418ab6a3ac218cfdb7ebfc5d2a6 | Python | mahmoud-taya/OWS-Mastering_python_course | /Files/064.Files_handling_part_three_write_and_append_in_files.py | UTF-8 | 1,184 | 3.734375 | 4 | [] | no_license | # -------------------------------------------------
# --- File handling => write and append in file ---
# -------------------------------------------------
# Write => Replace the new value with the old value
my_file = open("C:\Users\حسن صلاح\Google Drive\1. Projects_\Python course (Osama)\Learning code\hasan.txt", "... | true |
f4ebb288aa151fcd939f80917040a35c37834565 | Python | slominskir/rfwtools | /rfwtools/example_set.py | UTF-8 | 51,218 | 2.5625 | 3 | [] | no_license | """This package is for managing a collection of Examples.
ExampleSet objects are typically created by a DataSet, but may be created directly.
Basic Usage Examples:
Start by saving this data in my-sample-labels.txt in the Config().label_dir directory (defaults to ./data/labels/).
**THESE FIELDS SHOULD BE TAB SEPARATE... | true |
30e8d065634dd196eea631bda8532f71801958a7 | Python | Matiyaa/kattis | /1.0/heartrate.py | UTF-8 | 185 | 3.15625 | 3 | [] | no_license | n = int(input())
for i in range(n):
b, p = map(float, input().split())
bpm = (60*b)/p
min_bmp = bpm - (60 / p)
max_bpm = bpm + (60 / p)
print(min_bmp, bpm, max_bpm)
| true |
dafe2fc9be51dbb54fa5b860d82aed591ca39e23 | Python | nickwu241/coding-problems | /leetcode/1103-distribute-candies-to-people.py | UTF-8 | 524 | 3.265625 | 3 | [] | no_license | # https://leetcode.com/problems/distribute-candies-to-people/
import itertools
class Solution:
def distributeCandies(self, candies: int, num_people: int) -> List[int]:
result = [0] * num_people
candies_to_give = 0
for i in itertools.cycle(range(num_people)):
candies_to_give += 1... | true |
14ae7e311f29b2a70a0a6a757358570d2c37d99a | Python | zjarci/schematic-file-converter | /upconvert.py | UTF-8 | 2,461 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python
""" A universal hardware design file format converter using
Upverter's Open JSON Interchange Format """
# upconvert.py - A universal hardware design file format converter using
# Upverter's Open JSON Interchange Format
# (http://upverter.com/resources/open-json-format/)
#
# Authors:
# Alex Ray... | true |
ae723561829c3badd2f53ac6b8f498a7814ecf70 | Python | rafaelmsartor/python-studies | /PythonAndBlockchain/assignments/assignment2.py | UTF-8 | 1,100 | 4.84375 | 5 | [] | no_license |
def print_header(header_text):
print(header_text)
print('-' * len(header_text))
# 1) Create a list of names and use a for loop to output the length of each name (len() ).
names_list = ['Rafael', 'Fernanda', 'Anthony',
'Maria', 'Ana', 'Joe', 'Nathaly', 'Noah']
print_header('First Task')
for n... | true |
412e026e9e1b85bf1f6dbcb68485e4f05cb9e398 | Python | PurpleBubble123/pp | /basic/list.py | UTF-8 | 511 | 4.40625 | 4 | [] | no_license | # information about using list
list1 = [1, 2, 3, "a", "b", "c", [1, 2, 3]] # 嵌套列表
#print(list)
#print(type(list)) ## 查看type
# 访问
# print(list1[0:3]) ## 左开右闭
# print(list1[1:])
# 添加
# list1.append("m")
# list1 = list1 + ["n"]
# print(list1)
# 数据 CRUD 增删改查
# 更新
# list1[1] = "9"
# print(l... | true |
8e7828cddcf57767ed8107fd22bfe9933ed524b0 | Python | Christian-Fisher/SYSC3010T6_IRPS | /Python codes/IRpoller.py | UTF-8 | 1,410 | 2.84375 | 3 | [] | no_license | import RPi.GPIO as IO
import time
import socket
IO.setwarnings(False)
IO.setmode(IO.BCM)
IRPins = [12,13,14,15,16,17,18,19,20] # array of GPIO pins
Socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
receiveSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
receiveSocket.bind(("", 3001))
port =2001
local... | true |
ac238bf130461ca382c2fe277569145a9a2fcaad | Python | uchenna-j-edeh/dailly_problems | /arrays_manipulations_algorithms/run_length_encoding.py | UTF-8 | 1,491 | 3.890625 | 4 | [] | no_license | """
Author: Uchenna Edeh
Run-length encoding is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".
Implement run-length encoding and decoding. You can assu... | true |
57872fddc9ef4f3724a37856bdcc44674063dd46 | Python | rositahbakken/prosjekt | /MessageParser.py | UTF-8 | 2,789 | 2.921875 | 3 | [] | no_license | __author__ = 'Anna'
import json
class MessageParser():
def __init__(self):
self.possible_responses = {
'error': self.parse_error,
'info': self.parse_info,
'message': self.parse_message,
'history': self.parse_history,
'login': self.parse_login,
... | true |
790769dd2837866dd1ea5e3e5d7d2fcb2f6c68c1 | Python | sberbank-ai-lab/embeddings-valid | /embeddings_validation/file_reader.py | UTF-8 | 4,514 | 2.640625 | 3 | [] | no_license | import os
import pickle
import numpy as np
import pandas as pd
ID_TYPE_MAPPING = {
'str': str,
'int': np.int32,
'date': 'datetime64[D]',
'datetime': 'datetime64[s]',
}
class BaseReader:
def __init__(self, conf):
self.conf = conf
self.source_path = []
self.df = None
... | true |
9a5b6520c8c66baeccce1ebdc98bb447c5432f8d | Python | bryceklinker/rasperry-pi-fun | /simple-lights/simple_lights/start.py | UTF-8 | 212 | 2.625 | 3 | [
"MIT"
] | permissive | from gpiozero import LED
from time import sleep
pin_18_led = LED(18)
pin_17_led = LED(17)
while True:
pin_17_led.off()
pin_18_led.on()
sleep(1)
pin_17_led.on()
pin_18_led.off()
sleep(1)
| true |
3e0ac4257eb29fe4aea3231e33d786c74ed8bccc | Python | pseudonym117/Riot-Watcher | /src/riotwatcher/_apis/league_of_legends/LeagueApiV4.py | UTF-8 | 3,875 | 2.71875 | 3 | [
"MIT"
] | permissive | from .. import BaseApi, NamedEndpoint
from .urls import LeagueApiV4Urls
class LeagueApiV4(NamedEndpoint):
"""
This class wraps the League-v4 Api calls provided by the Riot API.
See https://developer.riotgames.com/api-methods/#league-v4/ for more detailed
information
"""
def __init__(self, ba... | true |
0a33a4f4cc388f29ac47e01f18e8845e45fcb0dd | Python | YnievesDotNet/calysto_lc3 | /calysto_lc3/lc3.py | UTF-8 | 75,203 | 3.09375 | 3 | [
"BSD-2-Clause"
] | permissive | """
This code based on:
http://www.daniweb.com/software-development/python/code/367871/
assembler-for-little-computer-3-lc-3-in-python
Order of BRanch flags relaxed, BR without flags interpreted as BRnzp
(always).
"""
from array import array
import sys
try:
from IPython.display import HTML
except:
pass
def a... | true |
c6850d346c0bbf1368263b8514100fb7f064e8c2 | Python | mjepronk/euler-python | /problem20.py | UTF-8 | 172 | 2.84375 | 3 | [] | no_license | # vim: sw=4:ts=4:et:ai
from math import factorial
def main(n=100):
return sum(int(d) for d in str(factorial(n)))
if __name__ == '':
print("Result: %i" % main())
| true |
80ab507197305726b100bd90acee6b8442d5f6a9 | Python | thorwhalen/ut | /ut/daf/struct.py | UTF-8 | 2,866 | 2.734375 | 3 | [
"MIT"
] | permissive | __author__ = 'thor'
import ut as ms
import pandas as pd
import ut.pcoll.order_conserving
from functools import reduce
class SquareMatrix(object):
def __init__(self, df, index_vars=None, sort=False):
if isinstance(df, SquareMatrix):
self = df.copy()
elif isinstance(df, pd.DataFrame):
... | true |
699c0b3aa9af299ab971d6580ef6fcf35e449d7e | Python | Mniharbanu/guvi | /code kata/positive.py | UTF-8 | 112 | 3.25 | 3 | [] | no_license | aaa=int(input())
if(aaa>0):
print("Positive")
elif(aaa<0):
print("Negative")
else:
print("Zero")
| true |
26b51fac6d96d5bb239868b5dbce620eefc14b4d | Python | ZoranPandovski/al-go-rithms | /math/Matrix multiplication/python/matrixmul.py | UTF-8 | 1,521 | 4.1875 | 4 | [
"CC0-1.0"
] | permissive | """ SQUARE Matrix Multiplication
Matrix multiplication is a binary operation that produces a matrix from two matrices.
For matrix multiplication, the number of columns in the first matrix must be
equal to the number of rows in the second matrix.
The resulting matrix, known as the matrix product, h... | true |
341707b940695b2069d93e4c3e3fa346159db254 | Python | astrozot/imks | /imks/units_mcerp.py | UTF-8 | 4,075 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import mcerp
import mcerp.umath as umath
import math
import uncertainties
from .units import Value
from . import units
def umathdoc(f):
"Decorator to copy the uncertainties.umath __doc__ string."
f.__doc__ = getattr(umath, f.__name__, {"__doc__": ""}).__doc__
return f
@umathdoc
... | true |
74a58a86128dc0b4884dc38d002d2dcc34ab4e76 | Python | vdmklchv/simple_weather_retriever | /main.py | UTF-8 | 768 | 3.453125 | 3 | [] | no_license | import requests
import config
api_key = config.API_KEY
while True:
city = input("Enter a city. Enter quit to exit: ").lower()
if city == "quit":
break
try:
response_data = requests.get(f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric").json()
... | true |
bdea9cf7dbe7c417d424012892e784b5a5a15c76 | Python | ParkJiSu28/Python_cote | /1419.py | UTF-8 | 224 | 3.203125 | 3 | [] | no_license | s = input()
tmp = list(s)
answer = 0
for i in range(len(tmp)):
if tmp[i] =='l':
if i+3 <len(tmp):
if tmp[i+1] =='o' and tmp[i+2] =='v' and tmp[i+3] =='e':
answer +=1
print(answer)
| true |
08659868f0e78ee296306397e563686d41f4dbb9 | Python | heiwushi/MyFlow | /myflow/optimizer.py | UTF-8 | 7,112 | 2.796875 | 3 | [] | no_license | import abc
import numpy as np
import functools
from myflow.ops import Tensor, Op, ones, zeros, add
from myflow.common import _GradientMode
from myflow.graph import Graph
class ApplyGradient(Op):
'''
用计算好的梯度更新Variable
'''
def __init__(self, compute_var_delta):
'''
:param compute_var_d... | true |
4328d49dcbf8c4386078f9833526075cdb36dedb | Python | ideoforms/isobar | /tests/test_pattern_sequence.py | UTF-8 | 5,571 | 2.71875 | 3 | [
"MIT"
] | permissive | import pytest
import isobar as iso
def test_psequence_ints():
a = iso.PSequence([1, 2, 3], 1)
assert list(a) == [1, 2, 3]
def test_psequence_tuples():
a = iso.PSequence([(1, 2), (3, 4), (5, 6)], 2)
assert list(a) == [(1, 2), (3, 4), (5, 6), (1, 2), (3, 4), (5, 6)]
def test_psequence_keys():
a = i... | true |
f85d766ababb30ac625661420851dea2f4810277 | Python | sujiny-tech/preparing-for-coding-test | /leetcode/Palindrome Linked List.py | UTF-8 | 593 | 3.796875 | 4 | [] | no_license | class ListNode:
def __init__(self, val=0, next=None):
self.val=val
self.next=next
def isPalindrome(head:ListNode) -> bool:
isTrue=True
list_=[]
while head!=None:
list_.append(head.val)
head=head.next
print(list_)
left, right=0, len(list_)-1
while... | true |
48e4c539554a7155433b336524d5f72e32e1a03c | Python | lizhaodong/PrunedYOLO | /spar_v3.py | UTF-8 | 2,552 | 2.9375 | 3 | [] | no_license | #This is the library for weights sparsification
import tensorflow as tf
import numpy as np
#masks is a list of tuple, each tuple is (var_name, mask)
masks = []
#name_tfv is a dictionary, where key is the variable name,
#and value is tf.variable
name_tfv = {}
#name_ph, key variable name and value is tf.placeholder (... | true |
5d2a37897de4a1e1444c39f2b735d65a4cc79fcf | Python | gxsgxs/1808 | /13day/06-列表遍历的坑.py | UTF-8 | 297 | 4 | 4 | [] | no_license | list = [1,2,3,4,5,6,7,8,9]
#注意 最后不要用循环去删除列表
'''
for i in range(len(list)):#0 1 2 3 4 5 6 7 8
list.pop(i)
print(list)
'''
'''
for i in list:
print(i)
list.pop()
#list = [1,2,3,4,5,6,7,8]
'''
for i in range(len(list)-1,-1,-1):
list.pop(i)
print(list)
| true |
367a1fd5dfd3ebec60cfe31572944291e44adc45 | Python | zingzheng/LeetCode_py | /117Populating Next Right Pointers in Each Node II.py | UTF-8 | 1,861 | 3.328125 | 3 | [] | no_license | ##Populating Next Right Pointers in Each Node II
##Follow up for problem "Populating Next Right Pointers in Each Node".
##What if the given tree could be any binary tree? Would your previous solution still work?
##2015年8月26日 18:05:48 AC
##zss
# Definition for binary tree with next pointer.
class TreeLinkNode(object):... | true |
f32ba6b90c374c6076d66420b138c27d1c8020a3 | Python | marwahaha/studio_xkcd | /app/model.py | UTF-8 | 2,939 | 2.75 | 3 | [] | no_license | import logging
from peewee import *
from utils.settings import Settings
settings = Settings.get_instance()
mysql_db = MySQLDatabase(
settings['mysql']['database'],
user=settings['mysql']['username'],
password=settings['mysql']['password'],
host=settings['mysql']['hostname'],
port=settings['mysql']... | true |
f53e11fa4c8e3a568308f3f3f64c62be824b1f82 | Python | dtdannen/LUiGi-hierarchical-GDA | /experiments/GraphScripts/src/TestSetup.py | UTF-8 | 602 | 2.859375 | 3 | [
"MIT"
] | permissive | '''
Created on Apr 7, 2014
@author: dustin
'''
"""
You can use the proper typesetting unicode minus (see
http://en.wikipedia.org/wiki/Plus_sign#Plus_sign) or the ASCII hypen
for minus, which some people prefer. The matplotlibrc param
axes.unicode_minus controls the default behavior.
The default is to use the unicode... | true |
6f8af1a97b71b8c7c88737cf1993b9de7913cf47 | Python | gregoritoo/UI_Anomaly_Detection | /Alertes/Alert_Prediction.py | UTF-8 | 4,461 | 2.609375 | 3 | [] | no_license |
import os
path_to_kap = os.environ['kapacitor']
path_to_script = os.environ['script']
class Alert_Prediction():
def __init__(self, host, measurement):
self.host = host
self.measurement = measurement
self.texte = ""
def create(self, message, form, period):
self.form = form
... | true |
1a9c665d367165827a3b803197573f65af5c9e56 | Python | gtieng/web-scraping-challenge | /app.py | UTF-8 | 729 | 2.515625 | 3 | [] | no_license | #import dependencies
from flask import Flask, render_template, redirect
from flask_pymongo import PyMongo
import scrape_mars
app = Flask(__name__)
# Use PyMongo to establish Mongo connection
mongo = PyMongo(app, uri="mongodb://localhost:27017/mars_app")
# Set route
@app.route('/')
def index():
# Find one recor... | true |
b8338fb2ac6972260f90e061ef0f0a99c7b603aa | Python | ramki123456/newrepository | /python/pythonclass/pratice/dictionaries.py | UTF-8 | 1,817 | 3.75 | 4 | [] | no_license | '''#dictionaries:- the group of items which are enclosed by two {} are known as dictionaries.
in dictionaries items are separated by comma.
an item is a combination of key and value fair. key and value separated by :
dictionaries are mutable datastructures so we can modify a dictionary.
syntax: dictionary_name={ite... | true |
406700c61cad11c1eedb31d49f8e83ee37020e79 | Python | karwootang-gft/tb-houston-service | /solution.py | UTF-8 | 11,318 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | """
This is the deployments module and supports all the ReST actions for the
solutions collection
"""
# 3rd party modules
from flask import make_response, jsonify, abort
from config import db, app
from models import Solution, SolutionSchema
from models import ModelTools
from extendedSchemas import ExtendedSolutionSche... | true |
de7f3d5ab6bb2f29f7951974483170f9f0144848 | Python | alanespinozaz/S1-TAREA_1 | /14.py | UTF-8 | 780 | 3.953125 | 4 | [] | no_license |
# """ Determinar si un número entero proporcionado por el usuario es primo.
# Un número primo es un entero que no tiene más divisores que él mismo y la unidad. """
class Ejemplo14:
def __init__(self):
pass
def evaluarprimo(self):
divisor, num, res= 0,0,0
primo = True
... | true |
f2c35140f8cfed45fb952a4ddc2f260a9d58780b | Python | RajkumarMittal/DS-ALGO | /Sorting/BubbleSort.py | UTF-8 | 382 | 3.75 | 4 | [] | no_license | def bubble_sort(array):
length = len(array)
if length <= 1:
return array
for i in range(length-1):
for j in range(i+1, length):
if array[i] > array[j]:
array[i], array[j] = array[j], array[i]
return array
def selection_sort(arr):
if len(arr) <= 1:
... | true |
d552ee40a25fda6a17f3416a6bebf26dde74dcf6 | Python | alegarpa/warmupp2 | /logincounter/tests.py | UTF-8 | 5,554 | 2.734375 | 3 | [] | no_license | from django.test import TestCase, Client
from logincounter.models import User
import json
class TestUsers(TestCase):
MAX_LENGTH_INPUT = "abcdefghjiklmnopqrstuvwxyzabcdefghjiklmnopqrstuvwxyzabcdefghjiklmnopqrstuvwxyzabcdefghjiklmnopqrstuvwxyzabcdefghjiklmnopqrstuvwxyz"
def setUp(self):
self.client = Clie... | true |
8ffdf10f3ee959f30bfb90e5292f9e918908f228 | Python | vmarcella/DS23 | /spark/rdd.py | UTF-8 | 1,061 | 3.359375 | 3 | [] | no_license | import math
from pyspark import SparkContext
sc = SparkContext()
yeet = [2.3, 3.4, 4.4, 2.4, 3.3, 4.0]
# Parallelize the list, yeet
parallel_yeet = sc.parallelize(yeet, 2)
# Collect all of the yeets
print(parallel_yeet.collect())
# Take two elements from the list
print(parallel_yeet.take(2))
# Get the number of ... | true |
aadabbcad1d951c1333eaca0b102bc3ab21e72ac | Python | pytest-dev/pytest-xdist | /src/xdist/scheduler/loadfile.py | UTF-8 | 2,172 | 2.84375 | 3 | [
"MIT"
] | permissive | from .loadscope import LoadScopeScheduling
from xdist.remote import Producer
class LoadFileScheduling(LoadScopeScheduling):
"""Implement load scheduling across nodes, but grouping test test file.
This distributes the tests collected across all nodes so each test is run
just once. All nodes collect and s... | true |
66a9c733e91025c7d548c3d3515595b448978dc0 | Python | JeyFernandez/proyecto-de-pytohn- | /este es mi codigo/main.py | UTF-8 | 1,379 | 3.65625 | 4 | [] | no_license | from Registro import Registro
from Matricula import Matricula
if __name__ == '__main__':
run = True
while(run):
print("\n|REGISTRO DE ESTUDIENTES|\n")
select = int(input("Seleccione la opcio que hara:\n1-Asignar Carrera\n2-Matricular estudiantes\n3-Revisar la matricula\n4-Salir\n:"))
... | true |
f64fd4078ca205be03c8096cb39932650fe35dd6 | Python | baraloni/IntroToCS | /ex8/ship_helper.py | UTF-8 | 761 | 3.890625 | 4 | [] | no_license | def direction_repr_str(direction_class, direction):
"""
Converts a direction to string.
:param direction: The direction to convert to string. Should be one of the
constants of the Direction class ([UP, DOWN, LEFT, RIGHT, NOT_MOVING)
:return: A string representation for a valid direction input or th... | true |
38d42ce3da88f3ced4649a5b033405f4e23834b7 | Python | ZoranPandovski/al-go-rithms | /data_structures/Tree/Binary-tree/left-view.py | UTF-8 | 2,623 | 3.59375 | 4 | [
"CC0-1.0"
] | permissive |
#Initial Template for Python 3
import atexit
import io
import sys
import queue
from collections import defaultdict # default dict used as a map, to store node-value mapping.
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER
@ate... | true |
3a0ff29ee1ef3c21586885d3190e3e537b0b347b | Python | geolee1/Covid-Entry-Log | /src/console/SearchConsole.py | UTF-8 | 1,634 | 3.359375 | 3 | [
"MIT"
] | permissive | from core.database import find_db, time_search_db, get_all_db
from core.person import print_person
from core.setting import get_search_time
from core.tools import menu_input, yes_or_no, clear
def type_input() -> str:
while True:
user_input = input("검색할 항목을 선택하세요. (이름/전화번호/날짜/모두)\n>> ")
if... | true |
b383ea732e760828c027104f515a2ebdc9b2af94 | Python | sasazlat/UdacitySolution-ITSDC | /data_structure/other_data_structures.py | UTF-8 | 5,563 | 4.34375 | 4 | [] | no_license |
# coding: utf-8
# # Other Data Structures [optional]
#
# The purpose of this notebook is to show you some of the many other data
# structures you can use without going into too much detail. You can learn
# more by reading [documentation from Python's collections
# library](https://docs.python.org/3.3/library/collect... | true |
92df7e86f102356fa8dc4d1f29c47f3398dac423 | Python | andreu-gonzalez/socio | /sociocontroller.py | UTF-8 | 1,905 | 2.984375 | 3 | [] | no_license | from socio import socio
class sociocontroller:
def __init__(self):
self.listasocios={}
self.productos={'naranja':5,'platano':10,'manzana':3}
def addsocio(self,socio):
if socio.getIdsocio() not in self.listasocios:
if socio.getDni() not in self.listasocios:
sel... | true |
85235c00e1aedc41ff781a44dc38b26cb82476c8 | Python | Jozkings/wag | /degrees.py | UTF-8 | 2,124 | 3.578125 | 4 | [] | no_license | class Degrees(object):
"""object for saving degree informatians about graph"""
def __init__(self, graph):
self.max_degree_node = None
self.max_degree_value = float("-inf")
self.min_degree_node = None
self.min_degree_value = float("inf")
self.avg_degree = 0
... | true |
64f42544224f6681c30780e7e21b6b0d56d3d7c2 | Python | davidliii/Automatic-INO-Deploy | /arduino_command_line.py | UTF-8 | 2,200 | 2.875 | 3 | [] | no_license | #===================================================================================================
# Developped by: David Li
# Email: davidli2881@gmail.com
# Date: 1/14/2020
#
# This is a lightweight arduino command line interface, created with the purpose of
# selecting LED strip patterns more easily (as each patter... | true |
fd1622a3b7788afd4d3675257b60519f7d66842d | Python | Scarygami/aoc2019 | /19/19.py | UTF-8 | 1,686 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | import os
import sys
currentdir = os.path.dirname(os.path.abspath(__file__))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
try:
from lib.intcode import IntcodeVM
except ImportError:
print("Intcode library could not be found")
exit(1)
def check_square(machine, startx, starty, size=... | true |
25fd0539a07bcf835d5a104adba05848f89e20fb | Python | littlesnell/learngit | /python/ceshi_little.py | UTF-8 | 2,182 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env python
#encoding=utf-8
# 导入MySQL驱动
import MySQLdb
#进行连接数据库
conn = MySQLdb.connect(host="localhost",user="root",passwd="111111",db="littledog",port=3306,charset="utf8")
cursor = conn.cursor()
# 创建用户表
#cursor.execute('create table ceshi (id varchar(20) primary key, name varchar(20),age int,class varchar(50... | true |
4e2204630faf0c48b5157bfce5672d0ce3498a82 | Python | roni-kemp/python_programming_curricula | /CS1/0200_turtles/project_turtle_funny_face/student_code/funny_face_BCS.py | UTF-8 | 2,041 | 3.734375 | 4 | [
"MIT"
] | permissive | #Brendan Clark-Slakey
#9/27/2017
# Funny Face Project
import turtle, time
#Create and name a variable for the turtle
tommy = turtle.Turtle()
tommy.shape("turtle")
#All our circles will be this size
size = 30
#Draw the right eye
tommy.penup()
tommy.color("red")
tommy.fillcolor("red")
tommy.goto(200,70)
tommy.begin_fi... | true |
e5e5105913dea8c99b217f5759f92190e1c8c7d3 | Python | peterk87/blast2xl | /blast2xl/util.py | UTF-8 | 233 | 2.875 | 3 | [
"MIT"
] | permissive | from typing import Mapping, Dict, Any, Set
def invert_dict(d: Mapping) -> Dict[Any, Set]:
out = {}
for k, v in d.items():
if v in out:
out[v].add(k)
else:
out[v] = {k}
return out
| true |
7be5aa5b585cc292f8af5679a5fdbd87f8f6c562 | Python | arita37/d-script | /recurnets/basic_recurrent.py | UTF-8 | 5,622 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive |
# coding: utf-8
# # Basic Recurrent Neural Network
#
# Testing out original code for a simple LSTM to understand the sequential writing of an author from left to right. (To do: bi-directional recurrent LSTMs.)
#
# Details:
# We require two additional layers that I've written to make the dimensions of the input to ... | true |
e715d9b161daafa82f24e07e3cb1ff9996609e03 | Python | TeamKun/MineTexTool | /main.py | UTF-8 | 1,922 | 2.703125 | 3 | [] | no_license | import glob
import os
import shutil as ut
import numpy as np
from PIL import Image
def md(path):
if not os.path.isdir(path):
os.makedirs(path)
print("makedir: " + path)
size = float(input())
... | true |
3da103b85a9f322bea8709b48a3ff00551eff581 | Python | leejz/misc-scripts | /randomize_fasta.py | UTF-8 | 2,786 | 3.265625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
--------------------------------------------------------------------------------
Created: Jackson Lee 12/4/12
This script reads in a fasta file and randomizes the lines
Input fasta file format:
4098968.combined_unique.fa
>Sequence0000000001
GCGCCCCTACGGGGAACGTTTTACTTCCAGTTTTAAAGCAGC... | true |
85ce3bb57a6072a065f82a2f089d28040170cdb3 | Python | phlax/aio.signals | /aio/signals/tests/test_signals.py | UTF-8 | 3,398 | 2.703125 | 3 | [] | no_license | import unittest
import asyncio
import aio.testing
from aio.signals import Signals
class AioSignalsTestCase(unittest.TestCase):
def test_listen(self):
def signal_called(signal):
pass
signals = Signals()
signals.listen('test-signal', signal_called)
self.assertEqual(
... | true |
27955c81c418f80de63fcff5d29cc09590996d50 | Python | clockworksspheres/ramdisk | /src/ramdisk/lib/libHelperExceptions.py | UTF-8 | 1,515 | 2.5625 | 3 | [] | no_license | """
Class for ramdisk management specific creations
Should be OS agnostic
@author: Roy Nielsen
"""
class UnsupportedOSError(Exception):
"""
Meant for being thrown when an action/class being run/instanciated is not
applicable for the running operating system.
@author: Roy Nielsen
"""
def __... | true |
a891507491a0dd3ffb583adb51caf021734d79dc | Python | israelferrazaraujo/dcsp | /quantum classifier/cin/pennylane/templates/dc_hqc.py | UTF-8 | 1,175 | 2.59375 | 3 | [] | no_license | import pennylane as qml
from pennylane import numpy as np
from cin.pennylane.qml.hierarchical_classifier import circuit as circuit_hierarchical_classifier
from cin.pennylane.encoding.divide_and_conquer import Encoding
def config(X):
n = int(np.ceil(np.log2(len(X[0])))) # pylint: disable=no-member
n... | true |
bd9ea365241d35234622b0938ed9229256051be8 | Python | gdamjan/Scalable | /Echo/client-old.py | UTF-8 | 918 | 3.015625 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env python
import asyncore, socket
class Client(asyncore.dispatcher_with_send):
def __init__(self, host, port, message, n):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect((host, port))
self.out_buffer = message
... | true |
4dea064d0ba3a8536ada5cbcedcc567be4c0fe8c | Python | RomanYatsuniak/physics-projects | /4/Project.py | UTF-8 | 4,615 | 2.765625 | 3 | [] | no_license | import numpy as np
import io
from sympy import *
import sympy
import matplotlib.pyplot as plt
import math
s = io.BytesIO(open('input.txt', 'rb').read().replace(b',', b';').replace(b')', b' ').replace(b'(', b' ').replace(b'[',b' ').replace(b']', b' '))
data1 = np.genfromtxt(s, dtype=(float, float,float, float, float, fl... | true |
8981e87b88ac1ef036c1d88e80c017870be53590 | Python | unblest/python | /ex15.py | UTF-8 | 635 | 4 | 4 | [] | no_license | # exercise 15: reading files
# import the argument variable per "normal"
from sys import argv
# define the input for the file name we're going to read
script, filename = argv
# define and new variable with the open verb which is new
txt = open(filename)
# print the contents of the file
print "Here's your file %r:" ... | true |
0bcf8020288a8b32849d3debd40e22da7b705781 | Python | CheKey30/leetcode | /0114/114.py | UTF-8 | 943 | 4.15625 | 4 | [] | no_license | ```
Given a binary tree, flatten it to a linked list in-place.
For example, given the following tree:
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
\
6
```
# Definition for a binary tree node.
# class TreeNode:
# ... | true |
c8e606c100e756dcdad5b315f4ee3a6a7a95db80 | Python | rsk2327/Blog | /MisclassCost/ClassExtractor.py | UTF-8 | 1,677 | 2.78125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 9 20:14:18 2016
@author: rsk
"""
import cPickle
import gzip
import os
import sys
import time
import numpy
import theano
import theano.tensor as T
from collections import Counter
from LogLayer import *
dataset = "/home/rsk/Documents/MNIST/Misclassification/mnist.pk... | true |
687b18a9a0dd8bcb0c7b785313582760642c210d | Python | Aasthaengg/IBMdataset | /Python_codes/p02848/s105798212.py | UTF-8 | 138 | 3.203125 | 3 | [] | no_license | n=int(input())
s=list(input())
# z=90=>65
for i in s:
x=ord(i)
y=x+n
if y>90:
z=chr(y-26)
else:
z=chr(y)
print(z,end='') | true |
b9b6daf6eb6d535c1a76a9f0d79b96b47c73389d | Python | darkangelcraft/SPLI-RSA | /Bruteforce attack/test.factor.py | UTF-8 | 191 | 3 | 3 | [] | no_license | n = 100123
flag = True
i = 2
if(n%2 == 0):
i=2
flag=False
i = i - 1
i = i + 1
while flag:
print("Numero sotto test %i" %i)
if (n%i == 0):
flag=False
else:
i = i + 2
print("i %d" %i) | true |
56369b5e1b657f5ba1a66167bb44eee995a38071 | Python | diogobaeder/moneypertime | /moneypertime/stores/models.py | UTF-8 | 1,502 | 2.96875 | 3 | [
"BSD-2-Clause"
] | permissive | from django.db import models
PRICE_TYPE_CHOICES = (
('C', 'Cash'),
('G', 'Gold'),
)
class Store(models.Model):
name = models.CharField(max_length=200, unique=True)
price = models.IntegerField(help_text='Price of the store itself')
price_type = models.CharField(choices=PRICE_TYPE_CHOICES, max_len... | true |
0ae912b847faaeeeba975a4d01b98684014f427f | Python | Subash45/Multiplication_cipher | /multiplicative_cipher.py | UTF-8 | 1,045 | 3.953125 | 4 | [
"CC0-1.0"
] | permissive | # get word and the key from the user
word = input("\nEnter Your Password : ")
key = int(input("Enter The Key Value : "))
crypted = ""
# creating dict with alphabets
alpha = {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f', 6: 'g', 7: 'h', 8: 'i', 9: 'j', 10: 'k', 11: 'l', 12: 'm',
13: 'n', 14: 'o', 15: 'p', 16... | true |
944e1047d077fffbacc92a4fd7fe70373c77c2c2 | Python | 49257620/reboot | /studysrc/example/exam089.py | UTF-8 | 992 | 3.953125 | 4 | [] | no_license | # encoding: utf-8
"""
【程序89】
题目:某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:
每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。
1.程序分析:
2.程序源代码:
"""
code_li = [8, 4, 5, 6]
print('code:', code_li)
def encode(code_li):
for i in range(len(code_li)):
code_li[i] = (code_li[i] + 5) % 10
code_li[0], code_l... | true |
da80964eac1ac1f0e8d227d5d2458ca338d99fde | Python | eshandinesh/gis_based_crime_mapping | /mapping/gis/yoink/feed.py | UTF-8 | 2,349 | 2.796875 | 3 | [
"MIT"
] | permissive | import ConfigParser, datetime, logging, os, time
import feedparser
from .download import download
from .util import catching
logger = logging.getLogger('yoink.feed')
class Feed(object):
'''Represents a single feed from which files are downloaded.
'''
TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
def __init__(... | true |
a67df7ec61ff33f67c48659d771be02bfca87c86 | Python | CharlesLaforte/learning | /python/Minecraft/Classes/GhostCastle.py | UTF-8 | 1,048 | 2.65625 | 3 | [] | no_license | from mcpi.minecraft import Minecraft
mc = Minecraft.create("smalldell1")
import time
class NamedBuilding(object):
def __init__(self, x, y, z, width, height, depth, name):
self.x = x
self.y = y
self.z = z
self.width = width
self.height = height
self.depth = depth
... | true |
2ca91efd9c7ebf25d33aa2d948df64a020defb64 | Python | mfsuve/DeepReinforcementLearning | /blg604ehw2/dqn/model.py | UTF-8 | 12,154 | 3.109375 | 3 | [] | no_license | """
Deep Q network implementations.
Vanilla DQN and DQN with Duelling architecture,
Prioritized ReplayBuffer and Double Q learning.
"""
import torch
import numpy as np
import random
from copy import deepcopy
from collections import namedtuple
from blg604ehw2.dqn.replaybuffer import UniformBuffer
from blg604ehw2.dqn.... | true |
8c0554c6e2ab73333b430a59538f930013c4b425 | Python | manasa0917/python_code | /Class 8/maths_module.py | UTF-8 | 409 | 3.46875 | 3 | [] | no_license | def add(a,b):
return a+b
def factorial(n):
if (n>10000):
return 0
mult=1
for i in range(1,n+1):
mult=mult *i
return mult
def driverFucntion():
num1 = int(input("num 1: "))
num2 = int(input("num 2: "))
print("sum = {}".format(add(num1,num2)))
print("Factorial of sum ... | true |
fccf01d4dccc1083afa4a1d034f22a127eb76214 | Python | mkvenkatesh/Random-Programming-Exercises | /max_positive_sub_array.py | UTF-8 | 2,847 | 4.125 | 4 | [] | no_license | """
Problem Description: Given an array of integers, A of length N, find out the
maximum sum sub-array of non negative numbers from A.
The sub-array should be contiguous i.e., a sub-array created by choosing the
second and fourth element and skipping the third element is invalid.
Maximum sub-array is defined in terms... | true |
90ba7c97636889461b2ee8d0c69f2abd209a3841 | Python | mhcrnl/pygtk | /book/02-App_and_AppWindow/Application1.py | UTF-8 | 1,255 | 2.6875 | 3 | [] | no_license | class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(*args, application_id="org.example.myapp",
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
**kwargs)
self.window = None
self.add_main_option("test", o... | true |
cb3e4054fd5bf34156955b2c99dd091e01bb59d3 | Python | s-rachmaninoff/Algorithm-1 | /Python_Algorithm/solve/section_4/solution_8.py | UTF-8 | 476 | 3.203125 | 3 | [] | no_license | # 침몰하는 타이타닉 (그리디)
def solution(n, m, people):
people.sort()
cnt = 0
while people:
if len(people) == 1:
cnt += 1
break
if people[0] + people[-1] <= m:
cnt += 1
people.pop(0)
people.pop()
else:
cnt += 1
... | true |
875b714c1ad0dd93b044e6d4c078ae3cd35184f8 | Python | 6306022610113/INE_Problem | /exam/comm.py | UTF-8 | 304 | 3.515625 | 4 | [] | no_license | Sales = int(input("ENTER YOUR SALES : "))
Commission = 0
if Sales > 2000 :
if Sales > 4000:
if Sales > 6000:
Commission = 0.1
else:
Commission = 0.07
else:
Commission = 0.04
else:
Commission = 0.02
print("ํYOUR COMMISSION : ",Commission)
| true |
8e0685bb3f8eeb35bd71f19d11e45a7be7c04aff | Python | Vinceeee/mypy | /py3.6/async_guides/async_http.py | UTF-8 | 903 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
import asyncio
from random import randint
from urllib import request
"""
Non-blocking url-open by asyncio
"""
async def openurl(url):
print("opening {} ".format(url))
u = request.urlopen(url, timeout=10)
print(u.read())
st = randint(2, 3)
await asyncio.sleep(st)
print("ta... | true |
8bc2cb156c3eb31266fac9f1b12499e8193d4daa | Python | BABIN2D/Health-Management-System | /Health Management System.py | UTF-8 | 2,737 | 3.71875 | 4 | [] | no_license | import datetime
def gettime():
'''Time Function To Get The Current Time'''
return datetime.datetime.now()
choice = input('Enter R to read\nEnter L to log\t') # Decision on whether to write or read the txt file.
if choice in('L','l'): # Entering the log or write func... | true |
50ffb52975944c90498abfa29667b3ef5cfbecc2 | Python | jditlee/tmdSurprise_leetcode_hot100 | /[124]二叉树中的最大路径和.py | UTF-8 | 1,656 | 3.46875 | 3 | [] | no_license | # 路径 被定义为一条从树中任意节点出发,沿父节点-子节点连接,达到任意节点的序列。同一个节点在一条路径序列中 至多出现一次 。该路径 至少包含一个 节点,且不
# 一定经过根节点。
#
# 路径和 是路径中各节点值的总和。
#
# 给你一个二叉树的根节点 root ,返回其 最大路径和 。
#
#
#
# 示例 1:
#
#
# 输入:root = [1,2,3]
# 输出:6
# 解释:最优路径是 2 -> 1 -> 3 ,路径和为 2 + 1 + 3 = 6
#
# 示例 2:
#
#
# 输入:root = [-10,9,20,null,null,15,7]
# 输出:42
# ... | true |
8a25b4f460b990576fb0e14eabe56cfa30d77960 | Python | nickcoats/kattis-assignments | /get_shorty/get_shorty.py | UTF-8 | 1,752 | 3.078125 | 3 | [] | no_license | import sys
#
# Code Sample from Kattis Get Shorty Assignment
# URL: https://open.kattis.com/problems/getshorty
# Execute: pyhton get_shorty.py < get_shorty.in
#
tests = []
testSet = []
i = 0
valid = False
validData = False
for row in sys.stdin:
row = row.replace('\r', '').replace('\n', '')
row = row.split()... | true |
e883ffa06f8f4589c6cf35ff4cf4a2b769816f45 | Python | ISIS2503/Grupo7 | /Experimento2/Persistencia/consumerMedidas.py | UTF-8 | 1,505 | 2.640625 | 3 | [
"MIT"
] | permissive | import json
import requests
from kafka import KafkaConsumer
def post(p_sensetime, p_type, p_dataValue, p_unit):
payload = {
"sensetime": p_sensetime,
"type": p_type,
"dataValue": p_dataValue,
"unit": p_unit
}
url = 'http://localhost:8080/measurements'
response = requests.post(url, data=json.... | true |
d0c6c97c71faaa21f45e40125255f088eb15ed7d | Python | andreafresco/Project-Euler | /p003.py | UTF-8 | 1,097 | 3.765625 | 4 | [] | no_license | #
# Solution to Project Euler problem 3
# Copyright (c) Andrea Fresco. All rights reserved.
#
# https://projecteuler.net/problem=3
# https://github.com/andreafresco/Project-Euler
#
def smallest_prime(n): # return the smallest prime of n or n itself
# if it is prime
assert n > 0
i = 2
... | true |
2e908bc075d4955811ebf0360f8270f622d4d305 | Python | alina-pavaluc/extract_pe_features | /classifier.py | UTF-8 | 4,532 | 2.703125 | 3 | [] | no_license | import csv
import pickle
import numpy as np
import pandas as pd
from sklearn import tree
from sklearn.ensemble import RandomForestClassifier
from sklearn.neural_network import MLPClassifier
from extract_features import extract_features_from_file, extract_features_from_folder
class Classifier:
def __init__(self,... | true |
dc760cee1fc366f930e2494d232d30b9995c6870 | Python | VilenShvedov/Myprojects | /005_001_2.py | UTF-8 | 113 | 2.71875 | 3 | [] | no_license | import 005_001_Functions
print(functions.doubles(10))
print(functions.triples(10))
print(functions.squares(10)) | true |
2ab955390f3bbf5f9bd123814a26831b6805d087 | Python | ngvanryneveld/CapstoneProject-L1Task15 | /own_game.py | UTF-8 | 12,080 | 3.703125 | 4 | [] | no_license |
# import pygame allows for the game library functions to be included in the program
# import random allows for the program to generate random numbers
import pygame
import random
# this initializes the pygames modules to get everything started
pygame.init()
# the size of the screen display will be adjusted through th... | true |
025bc17d7f2d4ff41468d8ec02e77a429ca54410 | Python | DockerNAS/yamlscript-formula | /_utils/voluptuous.py | UTF-8 | 35,512 | 2.703125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
#
# Copyright (C) 2010-2013 Alec Thomas <alec@swapoff.org>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.
#
# Author: Alec Thomas <alec@swapoff.org>
"""Schema validation for Python data structures.
... | true |
7383f5100571ba71f80321c14faa4fcf6bd2b317 | Python | xunathan96/CSC420 | /Assignment 1/code/boundary.py | UTF-8 | 1,337 | 3.0625 | 3 | [] | no_license | import numpy as np
def crop_filter(filter):
height, width = filter.shape
# Crop filter to be odd x odd
if height%2 == 0:
height = height - 1
if width%2 == 0:
width = width - 1
filter = filter[:height, :width]
return filter
def zero_pad(image, filter):
height, width = filter... | true |