blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
bbc67b4b1e11ad38bbe8f18cf07d8cb2c4d68bd9 | hexaclock/challenges | /projecteuler/problem2.py | UTF-8 | 313 | 3.453125 | 3 | [] | no_license | memo={}
count = 0
def fastFib(N):
if N==0 or N==1:
return N
elif memo.has_key(N):
return memo[N]
else:
fibber = (fastFib(N-1) + fastFib(N-2))
if fibber%2==0:
global count
count = count+fibber
memo[N] = fibber
return fibber
print fastFib(33)
print count | true |
294d86ddaf3557fcd7160fde3344f36cd3440d3c | linhnt31/Python | /Competitive Progamming/CodeSignal/Tourements/15_04_2019.py | UTF-8 | 1,303 | 3.234375 | 3 | [] | no_license | """
-Link: https://app.codesignal.com/tournaments/XMbCQfgcxkgbyi2aE
"""
#
def rightmostRoundNumber(inputArray):
ans = -1
for i in range(len(inputArray)):
if inputArray[i] % 10 == 0:
ans = i
return ans
#
def robotPath(instructions, bound):
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0, -... | true |
776d413bcd24e563ff829955da475e661fcc254d | cecepnrhya/rizky | /servo_control (1).py | UTF-8 | 579 | 3.09375 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
class ServoControl:
def __init__(self):
self.servoPIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.servoPIN, GPIO.OUT)
self.p = GPIO.PWM(self.servoPIN, 50) # GPIO 17 for PWM with 50Hz
def move_servo(self):
self.p.start(2.... | true |
97d33f8c4670a6faf6de6b75e4c05b333cb9f51d | ShivaniThakare/MusicRecommendation | /connectivity_trial.py | UTF-8 | 11,103 | 2.546875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from flask import Flask, render_template, request, redirect, url_for, jsonify
from flask_mysqldb import MySQL
from datetime import timedelta
import random
import os
import sys
from music import Music
from the_user import Myuser
import numpy as np
import time
np.set_printoptions(th... | true |
41b855fb57ec348754aa70c3c078d7663e2474eb | acerDebugman/JumpJump | /img.py | UTF-8 | 6,986 | 2.5625 | 3 | [] | no_license | import cv2
import numpy as np
import subprocess
import sys
from open_close_op import *
def adjust(x):
temp=x.copy()
#print(temp)
for i in range(4):
cnt1=0;cnt2=0
for j in range(4):
if x[i][0]<x[j][0]:
cnt1=cnt1+1
if x[i][1]<x[j][1]:
cnt2=cnt2+1
#print cnt1,cnt2
if cnt... | true |
49b7d8a07b3ce0122baec775c414a208a3b5b079 | Ezeaobinna/Python-Basics-Algorithms-Data-Structures-Object-Oriented-Programming-Job-Interview-Questions | /Algorithms/Sorting and Searching/sorting/insertion sort/insertion-sort.py | UTF-8 | 383 | 3.90625 | 4 | [
"MIT"
] | permissive |
alist: list = [54,26,93,17,77,31,44,55,20]
def insertionSort(alist: list):
for i in range(1, len(alist)):
current:int = alist[i]
pointer: int = i
while pointer > 0 and alist[pointer - 1] > current:
alist[pointer] = alist[pointer - 1]
pointer -= 1
alist[point... | true |
2db3c8c9ca73b2348fd7c920660b7d3759788afa | joaks1/python-argparse-demo | /demo.py | UTF-8 | 1,347 | 3.5625 | 4 | [
"CC-BY-4.0"
] | permissive | #! /usr/bin/env python3
import argparse
if __name__ == '__main__':
# Create a command-line parser object
# We will specify a `formatter_class` that includes the default values for
# arguments in the help documentation.
parser = argparse.ArgumentParser(
formatter_class = argparse.ArgumentD... | true |
334b6168e6d1ff04a75919bf5403dc3d05221919 | Amir-19/M4-ACRL | /discrete_exp_offline_plotter.py | UTF-8 | 1,011 | 2.765625 | 3 | [] | no_license | import numpy
from dynamic_plotter import *
import time
def main():
d1 = DynamicPlot(window_x = 150, title = 'Servo Controller state-reward-action', xlabel = 'time_step', ylabel= 'value')
d1.add_line('Angular Position')
d1.add_line('Reward * 2')
d1.add_line('Chosen Action (0 for -0.1, 1 for +0.1)')
... | true |
0ae0dc9855929a0b8d50f1f61bbe569e16f14ce6 | hanysz/go_game_utilities | /profile_sgf.py | UTF-8 | 8,396 | 2.84375 | 3 | [] | no_license |
# Turn an SGF file into a "profile file".
# The profile file is a CSV with one row per move for the selected colour,
# and the following columns:
# move_num, game_move, game_policy, game_winrate, best_move, best_policy, best_winrate
# opening, midgame, endgame, intuition_error, reading_error
# I'll do some follow-u... | true |
c6cf23d47aa7e16efd86a687276e282f050e2cc7 | christopher-burke/warmups | /python/misc/stack_the_boxes.py | UTF-8 | 690 | 3.8125 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
"""Stack the Boxes.
Write a function that takes a number n and returns the number of stacked boxes
in a model n levels high, visible and invisible.
Source:
https://edabit.com/challenge/SKdpWwgKMAwMPHvRK
"""
def stack_boxes(boxes: int):
"""Number of boxes that can be stacked."""
retur... | true |
2e19384515719eda55e322efb5b9a4f0a5569136 | zhaoyu20150930/leetcode-test | /LeetCode/l4.py | UTF-8 | 3,599 | 3.765625 | 4 | [] | no_license | from typing import List
"""
给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。
请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。
你可以假设 nums1 和 nums2 不会同时为空。
示例 1:
nums1 = [1, 3]
nums2 = [2]
则中位数是 2.0
示例 2:
nums1 = [1, 2]
nums2 = [3, 4]
则中位数是 (2 + 3)/2 = 2.5
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/median-of-two-sorted-arrays... | true |
a2cc6d641381f23fac51eac5d8c9c0c24ceec3c0 | hernandez87v/pythonScraper | /practice.py | UTF-8 | 164 | 4.34375 | 4 | [] | no_license | # Nested for loops
num_list = [1, 2, 3]
alpha_list = ['a', 'b', 'c']
for number in num_list:
print(number)
for letter in alpha_list:
print(letter)
| true |
753368a3d0f5f44d91a46812d5dffd2fd3164738 | jaga4494/Peer-to-Peer-with-centralized-index | /Server.py | UTF-8 | 7,377 | 2.953125 | 3 | [] | no_license | #!/usr/bin/python
import socket
from threading import Thread
# {statuscode: phrase}
status = {'200': 'OK', '400': 'Bad Request', '404': 'Not Found', '505': 'P2P-CI Version Not Supported'}
# {hostname: port}
active_peers = {}
# {rfcnumber: rfctitle}
rfc_info = {}
# {rfcnumber: [hostname1, hostname2..]}
rfc_peer_map = {... | true |
9cd72eb3c68a627903a9bb51d0b81438b5a3eacc | codacy-badger/rtk | /rtk/_reports_/Tabular.py | UTF-8 | 7,833 | 2.78125 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
"""
Contains classes for creating analysis reports.
"""
__author__ = 'Andrew Rowland'
__email__ = 'andrew.rowland@reliaqual.com'
__organization__ = 'ReliaQual Associates, LLC'
__copyright__ = 'Copyright 2014 Andrew "Weibullguy" Rowland'
# -*- coding: utf-8 -*-
#
# tabular.py is... | true |
92726570c1370a90b9df7750bca36eb7852e9cca | neslisahgamze/marsRoverCodeChallenge | /tests/test_plateau.py | UTF-8 | 728 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from marsrover.position import Position
from marsrover.plateau import Plateau
import pytest
def test_illegal_plateau():
with pytest.raises(ValueError):
Plateau(0,0)
def test_ok_plateau():
assert Plateau(1,2).max_x == 1
assert Plateau(1,2)... | true |
f192078d839d3c7fdec131ad5b917f6d84f122fe | yehongyu/acode | /2019/dynamic_programming/largest_sum_of_averages_813.py | UTF-8 | 691 | 3.15625 | 3 | [] | no_license | class Solution(object):
def largestSumOfAverages(self, A, K):
"""
:type A: List[int]
:type K: int
:rtype: float
"""
n = len(A)
acc = [0]
dp = []
for i in range(K+1):
dp.append([0] * (n+1))
for i in range(n):
acc.... | true |
ef0f1ac9b48d6536b13e9725cbd4dd8996327e9b | deepakhb2/algorithms | /python/data_structures/linked_list.py | UTF-8 | 2,157 | 4.125 | 4 | [] | no_license | class LinkedList():
def __init__(self, value):
self.head = { 'value': value, 'next': None }
self.tail = self.head
self.length = 1
def __str__(self):
return str(self.head)
def append(self, value):
new_node = { 'value': value, 'next': None }
self.tail['next'] ... | true |
69b5700ea6558b2c5525f1f570f5055335a663d7 | vanyarock01/numerical-methods | /3/point_5.py | UTF-8 | 1,905 | 3.609375 | 4 | [] | no_license | var = """y = 1 / (x^3 + 64)
x0 = -2
xk = 2
h1 = 1.0
h2 = 0.5
"""
def runge_romberg(h1, h2, y1, y2, pow=2):
return abs((y1 - y2) / ((h2 / h1) ** pow - 1.0))
def f(x):
return 1 / (x ** 3 + 64)
def f_(x):
return x / ((3*x + 4) ** 2)
def arange(x0, xk, step=0.1):
x = x0
r = []
while x <= x... | true |
e59b400c5afb1138baeafda3c9ded7c4a3e27fb2 | ray24021/DeviceInfo | /os_info.py | UTF-8 | 198 | 2.65625 | 3 | [] | no_license | # -*- coding:UTF-8 -*-
def get_os_info():
with open('/etc/issue') as fd:
for line in fd:
osver = line.strip()
break
return{'osver':osver}
print(get_os_info()) | true |
4eb3e7ada5a9952e965157ee0822b96a2787e3cd | Zhouchuanwen/metadata-hub | /crawler/doc/benchmark/script.py | UTF-8 | 719 | 2.828125 | 3 | [
"MIT"
] | permissive | import json
import numpy as np
import matplotlib.pyplot as plt
with open('data.json', 'r') as fp:
data = json.load(fp)
for title in data:
fname = title.replace(';', '').replace(':', '').replace(' ', '')
x_values = np.array(data.get(title).get('X'))
y_values_v10 = np.array(data.get(title).get('Y').get... | true |
f710e50620d429a8b1fb7e629e13ce9c9e9617ac | code-in-public/leetcode | /replace-all-digits-with-characters/solution.py | UTF-8 | 501 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env python3
class Solution(object):
def shift(self, char, idx):
print(char)
print(idx)
return chr(ord(char) + idx)
def replaceDigits(self, s):
"""
:type s: str
:rtype: str
"""
idx = 0
result = ''
while idx < len(s):
... | true |
8d7ba2e58e45e81af5dcc89a1eaaab02553d5899 | eivhav/Abstractive_Summarization | /Analysis/novelty.py | UTF-8 | 2,028 | 2.703125 | 3 | [] | no_license | import json
import glob
import unicodedata
'''
files = list(glob.iglob('/home/havikbot/MasterThesis/Data/CNN_dailyMail/DailyMail/tokenized4/'+"*.txt"))
data = dict()
for f in files:
d = json.load(open(f))
for k in d.keys(): data[k] = d[k]
'''
def compute_n_grams(text, n):
return {"~".join([text[i+k] for k ... | true |
e706f570025296c8e0207bbfb72746783e59e847 | annekeaps/cnn4sft | /data.py | UTF-8 | 4,175 | 2.515625 | 3 | [] | no_license | # Copyright UCL Business plc 2017. Patent Pending. All rights reserved.
#
# The MonoDepth Software is licensed under the terms of the UCLB ACP-A licence
# which allows for non-commercial use only, the full terms of which are made
# available in the LICENSE file.
#
# For any other use of the software not covered by the ... | true |
56b5517352dc6561743b82b4659a8005d0c9088a | OnroerendErfgoed/crabpy_pyramid | /crabpy_pyramid/utils.py | UTF-8 | 2,735 | 2.828125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Utility functions to help with range handling.
.. versionadded:: 0.1.0
"""
import re
MAX_NUMBER_ITEMS = 5000
def parse_range_header(range):
"""
Parse a range header as used by the dojo Json Rest store.
:param str range: The content of the range header to be parsed.
... | true |
b84437e0a08a6aa385afac9913d8be02a93a9852 | craig-sh/hearthstone-tourney | /app/models.py | UTF-8 | 5,604 | 2.6875 | 3 | [] | no_license | from app import db
from sqlalchemy import types
from datetime import datetime
MAX_EVENTS_PER_DAY = 20
class SqlLiteArray(types.TypeDecorator):
""" Since sqllite doens't support arrays store it as a space delimited
string of ints.
"""
impl = types.String(128)
def process_bind_param(self, va... | true |
a0adcb4ae02353ecd30a4b89dedfbc1f21db239c | Kimonili/data-structures-and-algorithms-python | /binary_search_tree_p1.py | UTF-8 | 2,407 | 4.5 | 4 | [] | no_license |
class BinarySearchTree:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def add_child(self, data):
if data == self.data:
return
if data < self.data:
if self.left:
self.left.add_child(data)
else:
self.left = BinarySearchTree(data)
if data > self.data:
i... | true |
d5317f35519529fdda03da3d8a7a12fa4a58e318 | b-bellecour/arp-flooder | /arp-flooder.py | UTF-8 | 2,181 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
from scapy.all import *
from time import sleep
import time
import sys, os, re, commands
def title():
if os.name == "posix":
os.system("clear")
else:
os.system("cls")
info = '''
_/_/_/ _/_/_/ _/_/_/_/
... | true |
78311212d66f3627fe93be1f04ed96a69081bb33 | balajic19/DataStructures | /Easy_DS/Arrays/ChefAndStreetFood.py | UTF-8 | 2,139 | 3.828125 | 4 | [] | no_license | '''
In Chefland, there is a very famous street where N types of street food (numbered 1 through N) are offered. For each valid i, there are Si stores that offer food of the i-th type, the price of one piece of food of this type is Vi (the same in each of these stores) and each day, Pi people come to buy it; each of the... | true |
fc781b864b826edb1633efb97dca4e17444252cc | CoreSheep/stereopy | /stereo/preprocess/qc.py | UTF-8 | 946 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# coding: utf-8
"""
@author: Ping Qiu qiuping1@genomics.cn
@last modified by: Ping Qiu
@file:qc.py
@time:2021/03/26
"""
from scipy.sparse import issparse
import numpy as np
def cal_qc(andata):
"""
calculate three qc index including the number of genes expressed in the count matrix, the... | true |
8493e267fde9a31a9577377fd7aecf7adea9d0f6 | w470062742/rai | /RAI/include/rai/function/tensorflow/pythonProtobufGenerators/functions/DeterministicRecurrentModel.py | UTF-8 | 1,261 | 2.625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | import BaseClasses as bc
import tensorflow as tf
import core
class DeterministicRecurrentModel(bc.SpecializedFunction):
input_names = ['state', 'action']
output_names = ['nextState', 'hiddenState']
def __init__(self, dtype, gs):
super(DeterministicRecurrentModel, self).__init__(dtype, gs)
... | true |
edf2bfbcfc5813e8485cf5e39eff61cde477e58d | AndrewLesiuk/amis_python | /km72/Lesiuk_Andrew/9/task2.py | UTF-8 | 381 | 4.15625 | 4 | [] | no_license | def power(a, n):
if n < 0:
a = 1.0/a
n = -n
res = 1
while n > 0:
res = res * a
n = n-1
return res
print("Програма рахує степінь числа a")
a = float(input("Введіть число а:"))
n = float(input("Введіть степінь числа а:"))
print("Результат:", power(a, n))
| true |
9dd541f19456c2416ce96e8b363e77d052e93cf4 | snwhd/retrotracker | /gamestate.py | UTF-8 | 17,473 | 2.515625 | 3 | [
"blessing"
] | permissive | #!/usr/bin/env python3
from __future__ import annotations
from typing import (
Callable,
Dict,
List,
Optional,
Iterable,
Set,
Tuple,
)
import jellyfish
import logging
import enum
import re
from ocr import OCR
from player import Player
from database import Database
from event import (
Ev... | true |
387be832f6d30283676d52b324000deae822528b | FabrizioFubelli/machine-learning | /11-scaling.py | UTF-8 | 1,300 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env python3
"""
Machine Learning - Scale the features
Video:
https://youtu.be/j3Csuz26heo
KNeighborsClassifier:
https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
"""
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.dataset... | true |
9b39ccab0bb61ff3cd3978e7a42d9f6cbbf13bc1 | lrpopeyou/pynlp | /text-classification/a10_DeepCNN/data_process.py | UTF-8 | 1,513 | 3.09375 | 3 | [
"MIT"
] | permissive | import pandas as pd
from collections import defaultdict
import numpy as np
def load_data_from_csv(data_path):
data = pd.read_csv(data_path)
return data
def explore_data_analysis(data):
sents = data.iloc[:, 0]
print(sents)
sents_len = np.array(list(map(lambda x: len(x), sents)))
print("the i... | true |
41014685d89fb62b13f6cbce532b3aedb07d0c55 | sgriffith3/july_pyb | /handling_exceptions_challenge.py | UTF-8 | 971 | 4.75 | 5 | [] | no_license | # Handling Errors Challenge
# Create a function that takes a required argument of a list, and an optional parameter of an integer
def using_try(my_list, num=5):
# Iterate through each item of the list
for item in my_list:
print(item)
# Use a try/except block to "try" to divide each item by yo... | true |
13f3043d7131e5cce362ffe5b54a5e159361b832 | TeddyTeddy/robot-fw-seleniumlibrary-tests | /Libraries/Unittests/setup_pythonpath.py | UTF-8 | 1,464 | 2.9375 | 3 | [] | no_license | import os
import re
if __name__ == '__main__':
current_abs_path = os.path.abspath(os.getcwd()) # gets the current abs path to this py file
sep = os.path.sep # get os specific path seperator (either '\' for Windows or '/' for linux)
pattern = f'(.+)\{sep}Unittests'
# grabs everything from current_... | true |
ff4d0f8792636a47f73963b54adc5987691cf8cf | MYadnyesh/Aatmanirbhar_program | /Week 1/CompInterest.py | UTF-8 | 831 | 3.96875 | 4 | [] | no_license | # Program 4:- To find the compound interest
def compIntr(prin, rate, time):
result = prin*(pow((1+ rate/100),time))
return result
while True:
p = float(input("Enter the principal amount: "))
r = float(input("Enter the rate of interest: "))
t = float(input("Enter the time in years:"))
amount =... | true |
98275b0cdf022123ae1f63c13706ec3e70bdcad6 | creusvictor/F.I.R.E | /main_MotorController___UltrasoundSensor_TEST.py | UTF-8 | 1,913 | 2.828125 | 3 | [] | no_license | from Color import * #Red(),Green(),Blue(),Black(),White()
from IRSensor import *
from MotorController import *
from Robot import *
from ServoMotor import *
from TempHumSensor import *
from UltrasoundSensor import *
from View import *
from Interface import *
from DummyObject import *
from WebCam import *
import time
im... | true |
de7baa27bd8716b0207d0b2e27e039b8043a36ac | coirl/coirl_code | /Real_world/ICMDP.py | UTF-8 | 53,661 | 2.6875 | 3 | [] | no_license | #######################################################################################################################
# file name: ICMDP
# version 1. for usage with the driving environment.
# description:
# this file defines ICMDP class and all of its functions.
# ICMDP is an Inverse Contextual Markov De... | true |
bb55cea8e58950918fce59b7dcdbe4a818292c7d | Isaivargas/machineLearningAgents | /duelingDoubleQLearning/breakOut-v4/procesFrame.py | UTF-8 | 827 | 3.09375 | 3 | [] | no_license | import cv2
import numpy as np
# This function process the frames with OpenCv Library resizing the frames to 84x84 frames
def processFrame(frame, shape=(84, 84)):
"""Preprocesses the breakOutGame Env 210x160x3 frame to 84x84x1 grayscale
Arguments:
frame: The frame to process. Must have values ranging ... | true |
b31b1b845f38c4ac898c8e1e1fb4f2dc76666945 | h1r0mu/traceroute-based-tlfa-detection | /Proof-of-assumption/src/proof_of_assumption2.py | UTF-8 | 1,768 | 2.609375 | 3 | [] | no_license | import networkx as nx
import numpy as np
import math
import pickle
import random
from collections import Counter
from functools import reduce
from tqdm import tqdm
from multiprocessing import Pool
from lib.network import Network
from lib.target import Target
from models.models import (
attack,
send,
)
def ru... | true |
77960e7ada99f198597f8bb65773544f982133ef | zzy0371/Py1901Advance | /day0408/demo32.py | UTF-8 | 1,246 | 3.359375 | 3 | [] | no_license | import os
from multiprocessing import Process
import time
# p1 进程入口函数
def p1process():
time.sleep(4)
print("进程p1执行了", os.getpid())
def p2process():
while True:
print("进程p2执行了", os.getpid())
time.sleep(1)
def main():
# 1创建进程, 创建Process类的实例
# 2通过target指定进程入口函数
p1 = Process(target=p... | true |
654515b0be4f1308754e7a2b49c008f3fb18c53f | facundocabrera/label_representations | /cifar.py | UTF-8 | 4,624 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import numpy as np
import torch
from torchvision import datasets, transforms
from torch.utils.data.dataset import Dataset
from torch.utils.data.sampler import SubsetRandomSampler
from pathlib import Path
# Dataset for CIFAR10 and CIFAR100.
class CIFARDataset(Dataset):
# Initializes the dataset for the given datat... | true |
d68c52738cf14046585dd155eaa876c85f2a96af | jesuisundev/leet-code-fun | /easy/953-verifying-alien-directory/solution.py | UTF-8 | 1,908 | 3.65625 | 4 | [] | no_license | class Solution(object):
def isAlienSorted(self, words, order):
"""
not working solution since i did not get the problem at the first place
to redo (lexicographicaly)
"""
# max_index_seen = 0
# order_hash_map = self._buildHashMap(order)
# for word in words:
... | true |
9d0e182dac05b7d7793ab181e5a7d84ccbaa4150 | JerryLead/SparkProfiler | /src/python/statistics/BoxPlotStatistics.py | UTF-8 | 3,131 | 2.625 | 3 | [] | no_license | class BoxPlotStatistics:
# metric = ("app.duration", "Time (s)", 1000)
def __init__(self, metric):
self.name = metric[0]
self.ylabel = metric[1]
self.unit = metric[2]
self.title = metric[3]
self.Parallel = {}
self.Parallel['label'] = 'Parallel'
self.Paral... | true |
20c041b9fbe157e2b06ec4984ee136ffe4697e2c | A-blackfish/research-tools | /class_hundred.py | UTF-8 | 10,204 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Training a classifier
=====================
sourced from https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html
Modified by : Harold Mouchère / University of Nantes
2018
"""
import time
import copy
import os
import torch
import torchvision
import torc... | true |
7281605888925625ce73d367fb2749ec9f6119ba | lixiang2017/leetcode | /explore/2020/november/Permutations_II.py | UTF-8 | 530 | 2.984375 | 3 | [] | no_license | '''
You are here!
Your runtime beats 30.81 % of python submissions.
https://docs.python.org/2/library/itertools.html#itertools.permutations
'''
class Solution(object):
def permuteUnique(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
from itertools impor... | true |
39a76b4630a2ae36d09fed4ddd446c82e96a980a | YeskendirK/CtCI-6th | /Chapter 1. Arrays and Strings/isUnique.py | UTF-8 | 231 | 3.5 | 4 | [] | no_license | def is_unique(s):
if len(s) > 128:
return False
arr = [0] * 128
for w in s:
val = ord(w)
if arr[val] == 1:
return False
arr[val] = 1
return True
print(is_unique('arb'))
| true |
6808928d9ac062eb6a0cedb97d16a1407a303465 | jeancharlles/CursoOM | /join.py | UTF-8 | 162 | 3.640625 | 4 | [] | no_license | string = 'O Brasil é Penta.'
lista1 = string.split(' ') # em cada espaço será separado
string2 = ' '.join(lista1)
print(string)
print(lista1)
print(string2)
| true |
2f1354d58cf0262a7467ca310ac097a0fc7ed019 | collective/collective.table | /collective/table/tests/test_table.py | UTF-8 | 1,404 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""Tests for Table content type."""
from collective.table.tests.base import TableIntegrationTestCase
from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import login
from plone.app.testing import setRoles
import unittest2 as unittest
... | true |
9423747356d2740910f08c07d14382bfa40fc84b | diego-rapoport/basic-funcs | /smallest_lex_name.py | UTF-8 | 574 | 4.4375 | 4 | [] | no_license | def smallest_lex_name(names):
''' This function takes a list of names and returns the smallest name lexicographically,
which means almost like a common dictionary order but capital letters always comes first.
Ex.:
With names ['anne', 'jane', 'Brody', 'Carol'] the name "Brody" returns in... | true |
e54ba7ca45632793f2d4062a9e3071554d9257d4 | LANCEREN/ares | /ares/benchmark/distortion.py | UTF-8 | 18,822 | 2.6875 | 3 | [
"MIT"
] | permissive | import numpy as np
import tensorflow as tf
from ares.benchmark.utils import load_attack
from ares.dataset import dataset_to_iterator
class DistortionBenchmark(object):
''' Distortion benchmark. '''
def __init__(self, attack_name, model, batch_size, goal, distance_metric, session, distortion,
... | true |
199d647cfa27efa3afa8977f995c88d28e2b34dc | tejas777x/DjangoProject | /selenium_test/Test2.py | UTF-8 | 1,098 | 2.984375 | 3 | [] | no_license | import excel_function # import the excel_function.py file
from selenium import webdriver # import selenium webdriver
driver=webdriver.Chrome('E:\python\chromedriver') # path of chrome
driver.get("https://www.netflix.com/in/Login?nextpage=https%3A%2F%2Fwww.netflix.com%2Fbrowse") # url of the website
driver.maximize_wi... | true |
56672d6e1e8932db0a3fc747695de542b303bfc3 | asc-lka/comphySS17 | /Uebungen/exercise1.2.py | UTF-8 | 389 | 3.703125 | 4 | [] | no_license | q = input("Tippen Sie die Zahl ein, die sie für q wählen wollen. \n")
q=float(q)
n=0
n=int(n)
s=1
s=float(s)
es = 0
es = float(es)
while s > es:
es = s
n = n+1
s = es+q**n
print("Die Summe ändert sich für q = " + str(q) + " ab dem " + str(n-1) + ". Summanden nicht mehr und der Grenzwert lautet: " + str(s) + " u... | true |
c6cd990acf87c39f0472b35c710fd19ca096783f | zqzas/sumline | /server/controller.py | UTF-8 | 3,829 | 2.5625 | 3 | [] | no_license | # coding=utf8
import datetime
from extractfirst import extract_first, extract_web_num, extract_main_frame
from urlencoder import genurl, genurl_web
import json
date_today = datetime.date.today()
RANGE_DAYS = 120
PAST_DAYS = 120
FUTURE_DAYS = 120
def find_peak(query):
'''
@param query
@return : an a... | true |
684649b5f4028f6458a2df04d71fa8d12250c99f | cwinsor/bootstrap | /project/test/test_bootstrap_02_mouse.py | UTF-8 | 1,140 | 3.265625 | 3 | [] | no_license | import Bootstrap
import numpy as np
from scipy import stats
# This example (Chapter 2, Table 2.1, page 11 "Mouse Data" in text)
# This just runs the Bootstrap procedure on the two tables.
class TestClass(object):
# "s" (the measure) in this case is just the sample mean
def my_s(self, x_star_i):
retu... | true |
c8b4dda3508e2ef3427578205e366c8a41fca139 | chetanpachpohe/Bookyourmovie_Project | /main.py | UTF-8 | 651 | 3.34375 | 3 | [] | no_license | from book import Movie
global row
global seats
row=int(input("Enter the number of rows: "))
seats=int(input("Enter the number of seats in each row: "))
while True:
print("*** Welcome to Bookyourmovies ***")
catlog=input("1. show seats\n2. Buy tickets\n3. view statistics\n4. show booked tickets customer... | true |
9437576756ca56b8d03c27172367eb4a912f475f | aakash2309/Guvi | /prime number.py | UTF-8 | 318 | 3.546875 | 4 | [] | no_license | a=[]
num=int(input('enter the no of items:'))
for i in range(num):
item=int(input())
print(a.append(item))
print(a)
for j in a:
l=1
count=0
for k in range(j):
if j%l==0:
count=count+1
l=l+1
if count==2:
print(j,"is a prime no")
else:
print(j,"is not a prime no")
| true |
01840b3645308a06fd3a454807fc12de5b2a8340 | dreamteamai/guess-num | /guess.py | UTF-8 | 648 | 4.5 | 4 | [] | no_license | # 產生一個隨機整數1~100(不要印出來)
# 讓使用者重複輸入數字去猜
# 猜對的話 印出"終於猜對了"
# 猜錯的話 要各素他 比答案大/小
import random
start = input('決定隨機數字開始值')
end = input('決定隨機數字結束值')
start = int(start)
end = int(end)
r = random.randint(start, end)
count = 0
while True:
count += 1
num = input('猜一個1~100的數字')
num = int(num)
if num == r:
print('猜對了')
print... | true |
b8b6be631806551f83dfc62ef29d93bfec0bf1b2 | qbeightol/unix-tools-and-scripting | /a5/moo.py | UTF-8 | 4,870 | 3.265625 | 3 | [] | no_license | #! /usr/bin/python
# moo.py
import random, re, socket, SocketServer, sys
# constants/definitions #######################################################
digits = '123456789'
size = 4
# helper functions #############################################################
# create one for parsing valid secrets/input (make ... | true |
3c4a017ee098c72d01643f13b642bc0f1ca6d97e | irc-poker/hellmuth | /src/poker/sidepots.py | UTF-8 | 1,873 | 3.421875 | 3 | [] | no_license | from .pot import Pot
def l(msg):
print(f"[SIDEPOTS] {msg}")
class SidePots:
def __init__(self):
self.main = 0
self.has_side_pots = False
def set(self):
self.has_side_pots = True
def reset(self):
self.main = 0
self.has_side_pots = False
def deposit(self, ... | true |
f9eff0bdb8886fc5386d01846aeda2665e1f17e8 | Hie308/IR | /irsystem/buildVocab.py | UTF-8 | 899 | 3.03125 | 3 | [] | no_license | import re
import os
import csv
from Stemming import stemming
SW = []
for line in open("stopwords.txt", 'r').readlines():
SW.append(line.strip())
pathToData = 'data'
dictionary = []
count = 0
for fileName in os.listdir(pathToData):
if (os.path.isdir(pathToData + "/" + fileName) ):
for subfileName in os.listd... | true |
77b9bc321c73bc80897542f5d7915896c00533d0 | csudcy/rgb_strip | /RGBStrip/__main__.py | UTF-8 | 2,013 | 2.625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf8 -*-
import traceback
from typing import Optional
import click
from RGBStrip.manager import RGBStripManager
@click.group()
def main() -> None:
"""Configurable interface for driving addressable RGB LEDs."""
@main.command()
@click.argument('config')
def run(config: str):
# Cr... | true |
e1b94cd3538d80711b4881776ee7be169bf1d369 | KalinHar/Advanced-Python-SoftUni | /workshop/four_in_line/checks.py | UTF-8 | 1,035 | 3.4375 | 3 | [] | no_license | def num_of_player(turn):
if turn % 2:
return 1
return 2
def check_for_winner(i, j, num, rows, columns, game_board):
winning_lines = [
[[[+1, -1], [+2, -2], [+3, -3]], [[-1, +1], [-2, +2], [-3, +3]]], # diagonal: left,down - right,up
[[[+1, +1], [+2, +2], [+3, +3]], [[-1, -1], [-2,... | true |
181cd10d255b1616528f6939aba90d85055d2c9f | JeonJe/Algorithm | /3.beakjoon/jungle/week4/15486_퇴사2.py | UTF-8 | 764 | 2.921875 | 3 | [] | no_license | N = int(input())
arr = [ list(map(int,input().split())) for _ in range(N)]
dp = [0] * (N+2)
M = 0
for i in range(N):
#t = i번째 일을 하는데 걸리는 시간
t = arr[i][0]
#p = i번째 일을하고 얻을 수 있는 가치
p = arr[i][1]
#M : 현재까지 저장된 M의 값
#dp[i] : i일까지 벌 수 있는 최대가치
M = max(M, dp[i]) #이전가치와 i일까지 가치 중 큰 가치를 가져옴
i... | true |
af4e95aa98e679a430b22c1f17e598a174485d11 | afcarl/CarND-Behavioral-Cloning | /bc_helper/sync_driving_data.py | UTF-8 | 1,015 | 2.84375 | 3 | [] | no_license | # /bin/python
import os
import zipfile
from bc_helper import s3
from bc_helper.full_path import full_path
# Used to push and pull driving data to S3. Useful when working between AWS and local machine.
# Used in ./bin/get_data.py and ./bin/put_data.py.
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dir... | true |
14ef1db9052e7303a079f4230ac177baeb04c02d | lyscop/img-crawler | /weibo/read_preset.py | UTF-8 | 569 | 2.71875 | 3 | [] | no_license | def read_preset(path):
users = []
with open(path) as fr:
for line in fr:
if line[0] == "#":
continue
else:
args = line.strip().split(" ")
if len(args) == 2:
users.append({'name': args[0], 'uid': args[1]})
... | true |
b461ef4f79a4a0009660188d3be679d98670f9f0 | branislavjenco/advent2020 | /day4/solution.py | UTF-8 | 3,476 | 2.953125 | 3 | [] | no_license | from utils import file_into_string
import re
required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
input_string = file_into_string("day4/input.txt")
passport_strings = input_string.replace("\n\n", "$").split("$")
passport_strings = [s.replace("\n", " ") for s in passport_strings]
def part_1():
def ... | true |
f602bbc0c22da2fd38fef40b68d6ddc6a10285be | MamdouhAlShamy/HackerRank | /30DaysOfCode/Arithmetic.py | UTF-8 | 279 | 3.65625 | 4 | [] | no_license |
# read M T X
# M = float(raw_input())
# T = int(raw_input())
# X = int(raw_input())
M = 12.00
T = 20
X = 8
tip = M * T / 100
tax = M * X / 100
finalPrice = M + tip + tax
finalPrice = int(round(finalPrice))
print("The final price of the meal is $" + str(finalPrice) + ".") | true |
a5fef048406f9c0b06f11b535c9702864a721a30 | chrishokamp/qe_sequence_labeling | /scripts/create_factor_corpus.py | UTF-8 | 1,570 | 3.046875 | 3 | [
"MIT"
] | permissive | """
Given two sentence and token-aligned parallel corpora, output a corpus where each token is factor1|factor2
"""
import codecs
import logging
import sys
import argparse
import json
import numpy as np
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
from sequence_qe.data... | true |
49124d72a9d73835fcdc5b2c916bb16af392200d | vincent123354/NeuralNetworkNumpy | /mnist.py | UTF-8 | 1,882 | 2.65625 | 3 | [] | no_license | from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
from src import *
def train(dataloader, model, criterion, optimizer, n_epochs=10):
for epoch in range(1,n_epochs+1):
running_loss = 0
for idx, (x, y) in enumerate(dataloader):
print(... | true |
b5ff91a9d074b17a1a51a12ae14851486f21a77d | komlenicm/Catch-the-ball | /primer.py | UTF-8 | 8,348 | 3.0625 | 3 | [] | no_license | import random
import pygame
import time
pygame.init()
collision_sound = pygame.mixer.Sound("collision2.wav")
pygame.mixer.music.load("lineOfFire.mp3")
screen_width = 600
screen_height = 600
black = (0,0,0)
white = (255,255,255)
red = (200,0,0)
green = (0, 200, 0)
bright_red = (255,0,0)
bright_green = (0, 255, 0... | true |
5b75308b80fdc4be57f5a7573266158ba5e3001e | xuev/BookDownloader | /mpzw.py | UTF-8 | 3,947 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
@Author: xuev
@Contact: xuewei918@gmail.com
@Project: BookDownloader
@FileName: mpzw.py
@Version: 0.0.1
@License: MIT Licence
@Created on: 2017/12/13 02:48
@Description: Downloa... | true |
6a12db318ae0751913eb21f2c8459caa7433386f | cemchwei/design-recipes | /Processors/StringSplitter.py | UTF-8 | 1,192 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env python
from autopkglib import Processor, ProcessorError
__all__ = ["StringSplitter"]
class StringSplitter(Processor):
description = "Splits string on specified delimiter and returns substring at specified index."
input_variables = {
"string": {
"required": True,
... | true |
5dbc16e71f3e11ab492ebc27ec610203df4ef11d | vformanyuk/PyBoardAccelerometerLogger | /AccelLog/dataDecode.py | UTF-8 | 792 | 2.625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import struct
import constants
x_data = []
y_data = []
z_data = []
with open('c:\\Temp\\acl4586.log','rb') as f:
data = f.read(constants.data_len)
while len(data) > 0:
(x,y,z) = struct.unpack(constants.data_fmt,data)
x_data.append(x)
y... | true |
9d2f2589223483e779512c67d63af9c3c5700754 | kevinshenyang07/Data-Structures-and-Algorithms | /algorithms/design_x/design_snake_gam.py | UTF-8 | 2,106 | 4.25 | 4 | [
"MIT"
] | permissive | # Design Snake Game
class SnakeGame(object):
def __init__(self, width, height, food):
"""
Initialize your data structure here.
@param width - screen width
@param height - screen height
@param food - A list of food positions
E.g food = [[1,1], [1,0]] means the first f... | true |
96742b1b049bbd5e5f8be5923bbedb55709ee0f8 | DFKI-NLP/OLM | /olm/config.py | UTF-8 | 1,185 | 2.65625 | 3 | [
"MIT"
] | permissive | from typing import Dict
import json
from olm.occlusion.strategy import STRATEGY_REGISTRY
class Config:
def __init__(self, **kwargs: Dict[str, str]) -> None:
strategy = kwargs.pop("strategy", None)
if strategy is None:
raise ValueError("No strategy specified.")
strategy = stra... | true |
8862a0c13a117a2552bbaad527c6a5a0b2bc5926 | ksayid/a211w20 | /HW04_starter.py | UTF-8 | 1,769 | 3.046875 | 3 | [] | no_license | import numpy as np
from codes.cosmology import d_L_vectorized
from codes.interpolation import polyfit2d
def xtr(ntr, method, start = 0, stop = 1):
'''
Input number of training points: ntr
method of spacing nodes: method
on interval [start, stop]
Return nodes spaced as specified... | true |
8a553623e89a589790205238b1d8ca565c99056d | JunhyeongBak/Caffe_Light_Field | /layers/vertical_mean_layer.py | UTF-8 | 670 | 2.515625 | 3 | [] | no_license | import caffe
import numpy as np
class VerticalMeanLayer(caffe.Layer):
def setup(self, bottom, top):
pass
def reshape(self, bottom, top):
self.src = bottom[0].data[...]
self.src_shape = bottom[0].data[...].shape # lf center sai's shape
top[0].reshape(self.src_shape[0], self.... | true |
7e30da802e154b2a411819f388cc134ff0ce2200 | johnatasr/AG | /PD_Top_Down._Memoizaçãopy.py | UTF-8 | 1,142 | 3.828125 | 4 | [] | no_license | def corte_haste(p, n):
r = [-1] * (n + 1)
s = [-1] * (n + 1)
corte_haste_helper(p, n, r, s)
return r, s
def corte_haste_helper(p, n, r, s):
"""Pegue uma lista p de preços, o comprimento da haste n, uma lista r de receitas máximas
e uma lista de cortes iniciais e retornar a receita máxima que... | true |
2af38f4c85c3130fc4585e359d321316f5cd1d19 | marbaugh/PiHomeControl | /bin/doorSensorStatus.py | UTF-8 | 606 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
from homecontrol.automation import DoorSensor
import requests
import sys
import time
door = DoorSensor()
def door_event(self):
messagedata = door.status()
webserver = 'http://192.168.3.107:5000'
url = webserver+"/doorSensor/status/"
if messagedata == True:
print "Doo... | true |
df334330c2c0179a7f5e6f7a4cb0b1ddeb710672 | Navy881/atlas-api | /BookingReport/booking_report.py | UTF-8 | 1,146 | 2.625 | 3 | [] | no_license |
import datetime
from AtlasApi import AtlasApiConnect
from pymongo import MongoClient
stand = ''
username = ''
password = ''
atlas = AtlasApiConnect(url=stand, username=username, password=password)
MONGO_HOST = ""
MONGO_PORT = 0
MONGO_DB = ""
MONGO_USER = ""
MONGO_PASS = ""
# Connecting
client = MongoClient(MONGO_HO... | true |
4d08981d052a29880299f848094121981197831c | AapoPitkanen/BLT-RL | /components/status_effects.py | UTF-8 | 11,153 | 2.9375 | 3 | [] | no_license | from random import randint, random
from types import MethodType
from game_messages import Message
import tcod
class Effect():
def __init__(self,
name,
duration=None,
start_message=None,
end_message=None,
resist_message=None,
... | true |
2707482b268c5bfe8b53645733b2bafc8dd415c7 | solomonovum/algorithms | /data structures/linked list/main.py | UTF-8 | 1,244 | 4.09375 | 4 | [
"MIT"
] | permissive | from linkedlist.singlylinkedlist import Node
from linkedlist.singlylinkedlist import SinglyLinkedList
if __name__ == '__main__':
node1 = Node(15)
node2 = Node(8.2)
node3 = Node(3)
track = SinglyLinkedList()
# Append
print('append')
track.append(56)
track.append(40)
track.append(1)... | true |
9c5d3afc68ccaaa02570a833ce9b3770e5d5751e | Jeconias/uriissues | /Iniciante/1009.py | UTF-8 | 137 | 3.140625 | 3 | [
"MIT"
] | permissive | name = str(input());
money = float(input());
vendas = float(input());
print('TOTAL = R$ {:5.2f}'.format((15 / 100.0) * vendas + money));
| true |
63900dd7ea4705b154e10cdbdd132bef5e5f32a3 | atique597/demo | /python_portion.py | UTF-8 | 49 | 2.625 | 3 | [] | no_license | import numpy as np
a= np.array([1,3,4])
print(a)
| true |
71aebcfddd7c0be9390f22eb6bf09f9e1c9f60a6 | tanjatang/CAN | /models/multiatt/test.py | UTF-8 | 883 | 2.5625 | 3 | [] | no_license | import torch
l1 = list()
a = torch.arange(-10,30)
a = a.view(2,2,5,2)
print(a)
a1 = a.view(4,5,2)
a2 = a1.view(2,2,5,2)
print(a1)
print(a2)
l1.append(a)
b = torch.arange(10,20)
b = b.view(1,2,5)
l1.append(b)
max_len_question_mask = max([i.size(1) for i in l1])
question_mask_list = list()
for i in l1:
# i.cpu()... | true |
e0db771fbaa1f294dc839517a0f223726767460b | simunipramod/python | /filemm.py | UTF-8 | 145 | 3.140625 | 3 | [] | no_license | for x in range(20):
file = open("demo.txt", 'ra')
#w means
file.write("\nthis is third line")
print(file.read())
file.close() | true |
ff9be32d46360482ccae13aebb81490b93150d3e | jaleson/Python | /Fibonacci_number.py | UTF-8 | 159 | 3.390625 | 3 | [] | no_license | #! python
def fab(n):
a,b = 0,1
while n >=2:
b, a = a+b, b
n = n-1
return b;
print fab(3)
print fab(5)
print fab(10)
| true |
7cd6b99651599be0109635c371b18352b471781b | NLGRF/numcom | /hww3-8-33.py | UTF-8 | 2,847 | 3.578125 | 4 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
def func(w):
Z = 75 # impedance (ohm)
# 1/Z = np.sqrt((1/R**2) + ((wC - (1/wL))**2))
C = 0.6 * 1e-06 # (F)
R = 225 # (ohm)
L = 0.5 # (H)
result = np.sqrt((1/R**2) + ((w*C - (1/(w*L)))**2)) - (1/Z)
# result = round(result,4)
return ... | true |
996be3e30c61f96f9f5e560132ab201ad8d475ca | shafiqul-islam/URI_solve | /uri1021.py | UTF-8 | 1,155 | 3.453125 | 3 | [] | no_license | a=float(input())
print("NOTAS:")
# n6=a%100
n5=a//100
n6=a-(n5*100)
n5a=int(n5)
print(str(n5a) +" nota(s) de R$ 100.00")
#n4=n6%50
n3=n6//50
n4=n6-(n3*50)
n3a=int(n3)
print(str(n3a) +" nota(s) de R$ 50.00")
#n2=n4%20
n1=n4//20
n2=n4-(n1*20)
n1a=int(n1)
print(str(n1a) +" nota(s) de R$ 20.00")
#n8=n2%10
n7=n2//10
n8=n... | true |
22dc776c6a22a342bfcc5bf3121cb27272265e3a | DrewEdgette/Spongebot | /spongebot.py | UTF-8 | 3,324 | 2.828125 | 3 | [] | no_license | import discord
from discord.ext import commands
import requests
from bs4 import BeautifulSoup
import pyshorteners
from pyshorteners import Shorteners
import random
bot_on = True
# Scrapes spongebob fandom for a specified input
def get_search_link(message):
url = "https://spongebob.fandom.com/wiki/Special:Search?q... | true |
7e0cc613b2230d08994550f86c1dc3ff611affa2 | hxctr/IPC2_Proyecto3_201807220 | /backend/manage.py | UTF-8 | 10,145 | 2.78125 | 3 | [] | no_license | from dte import DTE
import sys
import re
from xml.dom import minidom
import datetime
class Manager(object):
def __init__(self):
self.bills = []
def add_bill(self, date, reference, sender_nit, receiver_nit, value, iva, total):#I have to add "reference"
date_response = self.check_date(date)... | true |
8808f562f07e43b242998b8f15081250529f2bfb | sharleenclement/py-proj | /Calculator.py | UTF-8 | 834 | 3.90625 | 4 | [] | no_license |
import re # RegEx module
print("This is a calculator.")
print("Type 'quit' when you want to stop.\n")
value = 0
run = True
# variable scope
def performMath():
global run
global value
if value == 0:
equation = input("Enter the equation: ")
else:
equation = input(str(va... | true |
930753b5772ac65e9aad7734e4fc6e332251046c | luoshanya/Vue_Study | /python高级编程io/study06/code02_getattr.py | UTF-8 | 586 | 3.65625 | 4 | [] | no_license | from datetime import date
class User_date():
def __init__(self, name, birthday):
self.name = name
self.birthday = birthday
# 查找属性的魔法函数
def __getattr__(self, item):
# item是属性名
return '找不到属性%s' % item
# 无论属性存在与否,属性都会进入这个魔法函数 最好别用 用框架的时候才会到
# def __getattribute__(self... | true |
fd42cd6703cfb7639c4f1f5b54839a80c3e94d04 | StompRocket/RootEd | /backend/server.py | UTF-8 | 2,048 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | from flask import Flask
from flask_cors import CORS
import json
import db
import os
app = Flask(__name__)
CORS(app)
@app.route("/")
def return_all():
return json.dumps(db.dump())
@app.route("/possible/<word>")
def get_possible_defs(word):
# search through this word's roots and choose
# fairly similar wor... | true |
a610720ceb7cbd63d29c7621a8ffeba6af917b9b | furkandurmus/WebScraping | /ImdbWebScrapingProject.py | UTF-8 | 1,790 | 3.109375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""@author: furkan
"""
from requests import get
from bs4 import BeautifulSoup
import requests
import pandas as pd
import re
import pandas as pd
# this is the url that we wanna dig in
url = 'https://www.imdb.com/search/title/?release_date=2019-01-01,2019-12-31'
response = g... | true |
d91b2345404ee662a8a1fa99890587c27982853b | JonnyKelso/journal | /journal.py | UTF-8 | 3,700 | 2.984375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python3
import argparse
import time
import os
import shutil
#import StringIO
import csv
entry_count = 0
content = {}
# TODO -
# add tagged entries
# allow searching by tag(s)
# allow listing all tags
def count_entries():
print("counting entries")
with open(fname) as f:
global content
... | true |
1755100beea59ac770dff17bdda6243e5e964b16 | natasha/naeval | /naeval/ner/datasets/bsnlp.py | UTF-8 | 1,082 | 2.609375 | 3 | [
"MIT"
] | permissive |
from corus import load_bsnlp as load_bsnlp_
from naeval.span import (
Span,
filter_overlapping_spans
)
from ..markup import Markup
from ..adapt import adapt_bsnlp
class BsnlpMarkup(Markup):
@property
def adapted(self):
return adapt_bsnlp(self)
def iter_find(text, substring):
start = t... | true |
f3cfcad098fe280dd4b5b328ea7bde8e92d3966f | cafpereira/coding_practice_2018 | /interview-bit/07_two_pointers/merge_lists.py | UTF-8 | 700 | 3.578125 | 4 | [] | no_license | class Solution:
# @param A : list of integers
# @param B : list of integers
# @return A modified after the merge
def merge(self, A, B):
size = len(A) + len(B)
M = [0] * size
i, j = len(A) - 1, len(B) - 1
k = size - 1
while i >= 0 and j >= 0:
if A[i] ... | true |