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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8edf2482f1a249b4a156f4d5e08eb5e79a4b4422 | Python | ssgalitsky/pymm | /pymm/access.py | UTF-8 | 11,266 | 3.390625 | 3 | [
"MIT"
] | permissive | import re
class ChildSetupVerify:
"""hold onto method to verify ChildSubset or SingleChild setup
arguments
"""
@staticmethod
def _verify_identifier_args(identifier):
"""verify that identifier dict keys contain valid (and only
valid) identifiers. tag and tag_regex must contain stri... | true |
ca26b74cefb845b55fc2cff0d80250a6ad6627c0 | Python | sitesh221b/learningPythonAcadView | /assignment7.py | UTF-8 | 1,410 | 4.53125 | 5 | [] | no_license | # QUESTION 1
def circle_area(radius):
return 3.14*radius**2
r = int(input('Enter a radius: '))
print('Area is: ', circle_area(r))
# QUESTION 2
def perfect(num):
s = 0
for i in range(1, num):
if num % i == 0:
s += i
if s == num:
print('It is a Perfect Numbe... | true |
64958df313a8d1f1b38de80636078b6e95082f67 | Python | wmporter/advent2019 | /day11/police.py | UTF-8 | 5,580 | 3.09375 | 3 | [] | no_license | import sys
input_file = 'input'
rel_base = 0
# Return current panel color or black if panel has not been painted
def get_input():
try:
input_value = panels[current]
except KeyError:
input_value = 0
return input_value
# Addition and multiplication operations
# Opcodes 1 and 2
def add_or... | true |
bfcb3495299c13c77a55eec49aa061aa976f823d | Python | shen-huang/selfteaching-python-camp | /19100401/shense01/1001S01E05_array.py | UTF-8 | 923 | 4.46875 | 4 | [] | no_license | #将数组[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]翻转
#翻转后的数组拼接成字符串
#用字符串切片的方式取出第三到第八个字符(包含第三和第八个字符)
#将获得的字符串进行反转
#将结果转换为int类型
#分别转换成二进制,八进制,十六进制
#最后输出三种进制的结果
shu=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
shu.reverse() #将数组翻转
print(shu)
s = '' #翻转后的数组拼接成字符串
for i in range(0,10):
shu[i]=str(shu[i])
zifuchuan=s.join(shu)
print(zifuchua... | true |
5395634db3b488f4e2b5afbd594315b286771961 | Python | ymwondimu/PracticeAlgos | /binary_search.py | UTF-8 | 716 | 3.8125 | 4 | [] | no_license | import math
def binary_search(arr, low, high, x):
mid = get_midpoint(low, high)
if len(arr) == 0:
return False
elif len(arr) == 1:
if arr[0] == x:
return True
else:
return False
elif arr[mid] == x:
return True
elif arr[mid] > x:
return... | true |
4bab9b09ca28dbace0505b32bc85dce2436ce1d1 | Python | ray-tracer96024/ProjectEulerProblems | /problem_44_pent_nums.py | UTF-8 | 834 | 3.875 | 4 | [] | no_license | def is_pentagonal_number(n):
if ((((24*n) + 1)**0.5)+1)%6 == 0:
return True
return False
# def generate_pentagonal_numbers(n, array_of_nums):
# for i in range(n+1):
# array_of_nums.append(int(i*((3*i)-1)/2))
# return array_of_nums
def main():
# n = 15
# array_of_num... | true |
4b3689f705ffa501b5f881e41e92546ae16f9761 | Python | JinYeJin/algorithm-study | /November,2020~July,2021/2020-11-13/2671_최민영_잠수함식별.py | UTF-8 | 468 | 3.140625 | 3 | [] | no_license | import re
sound = input()
def solution(str):
check = True
sound = str
try:
regx = re.compile('(100+1+|01)+')
result = regx.fullmatch(sound)
s, e = result.start(), result.end()
parseData = sound.replace(sound[s:e],"")
if len(parseData) > 0:
check = False
... | true |
7ca59c01eef19d14b17b59836e18e8e11156622c | Python | nelimee/qtoolkit | /qtoolkit/data_structures/nearest_neighbour_structure.py | UTF-8 | 8,293 | 2.59375 | 3 | [
"BSD-3-Clause",
"CECILL-B",
"MIT",
"LicenseRef-scancode-cecill-b-en"
] | permissive | # ======================================================================
# Copyright CERFACS (October 2018)
# Contributor: Adrien Suau (adrien.suau@cerfacs.fr)
#
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify an... | true |
91ca566714b759acf5ad09e212889f596f867215 | Python | 365sec/texam | /llh329/20190329/2-合并数组.py | UTF-8 | 253 | 3.125 | 3 | [] | no_license | import sys
arr = input("")
num = [int(n) for n in arr[1:-1].split(",")]
arr1 = input("")
#arr1="['a', 'b', 'c']"
str1 = [n.strip()[1:-1] for n in arr1[1:-1].split(",")]
dest=[]
for i in range(len(num)):
dest.append({num[i]:str1[i]})
print(dest)
| true |
0eb1788fa0a45e4e71a5e8f42370ad7c8ecf1108 | Python | Haslas/encryption_entry | /simulations/sim6.py | UTF-8 | 2,481 | 3.390625 | 3 | [] | no_license | import hashlib
title="""
_____ ____ _
| __ \ / __ \ (_)
| |__) |__ _ __ | | | |_ _ _ ____
| ___/ _ \| '_ \ | | | | | | | |_ /
| | | (_) | |_) | | |__| | |_| | |/ /
|_| \___/| .__/ \___\_\\__,_|_/___|
| |
... | true |
c8f3d26eef0aa116651848190cc9644105b825e2 | Python | maulberto3/netw | /zOthers/ftp_standard.py | UTF-8 | 1,061 | 2.75 | 3 | [] | no_license | from ftplib import FTP
from pprint import pprint
from random import randint
from time import sleep
# SIMPLE FTP standard
import socket as s
def rand_adr():
return f'{randint(0,223)}.{randint(0,223)}.{randint(0,223)}.{randint(0,223)}'
with open('ftp_ok_hosts.txt', 'w+') as file:
file.write(randint())
with o... | true |
8ad095d09a0258fbfd16e38c1508157484d14f77 | Python | haok61bkhn/Motion_detection | /test.py | UTF-8 | 591 | 2.65625 | 3 | [] | no_license |
import imutils
import cv2
import numpy as np
from motion_detection import Motion_Detection
cap = cv2.VideoCapture(0)
_,frame=cap.read()
mtd=Motion_Detection(first_frame=frame)
font = cv2.FONT_HERSHEY_SIMPLEX
while True:
ret, frame = cap.read()
if(mtd.detect(frame)):
text="movement"
el... | true |
fa69fa198e5f56668b5be43e1c9b8291166010f6 | Python | Blowoffvalve/OpenCv | /DL4CV/utilities/preprocessing/imagetoarraypreprocessor.py | UTF-8 | 596 | 2.984375 | 3 | [] | no_license | from keras.preprocessing.image import img_to_array
class ImageToArrayPreprocessor:
"""
The dataFormat can either be 'channels_first' i.e. d h * w or 'channels_last' h * w * d. if set to None, it uses the keras default dataFormat specified in ~/.keras/keras.json.
"""
def __init__(self, dataFormat = None... | true |
ed5e27a5e27d9913d5a00067e3ce6f7e7f2cfba1 | Python | NKcell/leetcode | /108.Convert Sorted Array to Binary Search Tree/108.py | UTF-8 | 1,245 | 3.734375 | 4 | [] | no_license | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def sortedArrayToBST(self, nums):
"""
:type nums: List[int]
:rtype: TreeNode
"""
if len(nums) == 0:
... | true |
f42826c5f0df2f0ae259a1d40a8269b3cb92aca1 | Python | wdbronac/cooking | /code/naive_bayes_classification.py | UTF-8 | 7,737 | 3.234375 | 3 | [] | no_license | import os.path
import json
import numpy as np
import pandas as pd
def load_data(path, proportion): #proportion = 1: all training set is used
json_data=open(path)
data = json.load(json_data)
#implement a prediction of the class with the naive bayes method
#Divides between the training set and the va... | true |
f183d24102f16c778b5521865007fbf24cf5a8e6 | Python | mchao409/KeyMathPy | /Combinatorics/tests/PermutationTest.py | UTF-8 | 140 | 2.71875 | 3 | [] | no_license | def main():
# examples
print(permutation(8,3))
print(permutation(5,5))
print(permutation(12,2))
if __name__== "__main__":
main()
| true |
7356710da3c8a1ff87cdd1c89be190d1c97b9543 | Python | dtbinh/swarm-simulator | /tests/vectors_tests.py | UTF-8 | 6,546 | 3.125 | 3 | [
"MIT"
] | permissive | # tests.vectors_tests.py
# Tests for the vectors package
#
# Author: Benjamin Bengfort <benjamin@bengfort.com>
# Created: Thu Apr 24 09:57:20 2014 -0400
#
# Copyright (C) 2014 Bengfort.com
# For license information, see LICENSE.txt
#
# ID: vectors_tests.py [] benjamin@bengfort.com $
"""
Tests for the vectors packag... | true |
4a6ac517994a89e4fcc572d6956d276ac86fd795 | Python | jack-t/monkey-interpreter | /ast.py | UTF-8 | 1,847 | 3.125 | 3 | [] | no_license | from typing import NamedTuple, List
from enum import Enum
# unlike exprs, statements don't have value
class Statement:
pass
class Program(NamedTuple):
stmts: List[Statement]
class Expr:
pass
class ExprStmt(NamedTuple, Statement):
expr: Expr
# both are optional: if you have only an expr, then you execute an exp... | true |
49f8b075506a09ceb2286be4fa42736cedcbc2fa | Python | bonly/exercise | /2009/20091217_regex.py | UTF-8 | 1,937 | 2.6875 | 3 | [] | no_license | #!/usr/bin/python
#-*-coding:utf-8-*-
import subprocess
import re
import urllib2
def get_second_by_strip():
#res = subprocess.Popen(["time /home/bonly/worksp/mysql/Debug/mysql 0"],stderr=subprocess.PIPE,stdout=subprocess.PIPE,shell=True)
res = subprocess.Popen(["time ls -l"], stderr=subprocess.PIPE, stdout=subpr... | true |
670ea0994f13e2d87ab58273ba0260fcc632df7a | Python | stanfordnlp/stanza | /stanza/utils/datasets/ner/conll_to_iob.py | UTF-8 | 2,128 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | """
Process a conll file into BIO
Includes the ability to process a file from a text file
or a text file within a zip
Main program extracts a piece of the zip file from the Danish DDT dataset
"""
import io
import zipfile
from zipfile import ZipFile
from stanza.utils.conll import CoNLL
def process_conll(input_file, ... | true |
c874a697e28816c1584dfabebc9820002c347646 | Python | fafafariba/coding_challenges | /python/two_characters.py | UTF-8 | 1,638 | 4.28125 | 4 | [] | no_license | # String t always consists of two distinct alternating characters. For example, if string t's two distinct characters are x and y, then t could be 'xyxyx' or 'yxyxy' but not 'xxyy' or 'xyyx'.
# You can convert some string s to string t by deleting characters from s. When you delete a character from s, you must delete ... | true |
e7ef3354a253015573adb897f9fb8e37615c7ff6 | Python | Arkleseisure/old-chess-bot | /Bits_and_Pieces.py | UTF-8 | 11,988 | 3.453125 | 3 | [] | no_license | import time
import Global_variables as Gv
from Button import Button
import pygame
import pygame.freetype
pygame.freetype.init()
# loads an image
def load_image(name):
f = pygame.image.load(name + ".png")
return f
# turns a letter coordinate into a numerical x coordinate on the board
def un_... | true |
cace1fa90e2f146d2f4fb06fa3c7dfc98a6bfe3d | Python | oftensmile/indra | /indra/sources/trips/drum_reader.py | UTF-8 | 3,034 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
import os
import sys
import random
import logging
try:
from kqml import KQMLModule, KQMLPerformative, KQMLList
have_kqml = True
except ImportError:
KQMLModule = object
have_kqml = False
logger = logg... | true |
824c61844696aaebb6999ed46efb28b8c50e2823 | Python | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/02-pyth/python-ds-master/data_structures/graphs/Adjacency_matrix.py | UTF-8 | 828 | 3.46875 | 3 | [
"MIT"
] | permissive | class Graph:
def __init__(self, vertices, directed: bool):
self.V = vertices
self.e = 0
self.d = directed
self.graph = []
for i in range(self.V):
lst = [0] * self.V
self.graph.append(lst)
def add_edge(self, ver1, ver2):
if self.d:
... | true |
73e07aa4f6ca294155783fb2041d7034c753d3db | Python | RJHughes/TwitterSentiment | /app/sentiment.py | UTF-8 | 3,422 | 3.296875 | 3 | [] | no_license | import ast
def get_sentiment(query):
""" Given a query, this function returns the sentiment for the items in
that query and returns the dates and sentiment for each date """
print('Num entries:' + str(len(query)))
# Now we're going to extract the sentiment and date information and get the average sen... | true |
8f45354095106802a32c4f2b53ca8aee3524f982 | Python | ANoonan93/Python_code | /Euler_7.py | UTF-8 | 382 | 3.90625 | 4 | [
"MIT"
] | permissive | import math
def isprime(number):
if number <= 1:
return False
if number == 2:
return True
if number %2 == 0:
return False
for i in range(3, int(math.sqrt(number))+1):
if number %i == 0:
return False
return True
num = 0
prime = 0
while prime < 10001:
if isprime(num) == True:
... | true |
ebc65190e47b7c044429939955bd0ac4e094030b | Python | wlstjdpark/EffectivePython | /Chapter29/Chapter29.py | UTF-8 | 4,224 | 3.578125 | 4 | [] | no_license | # 메타클래스와 속성
# 메타클래스를 이용하면 파이썬 class 문을 가로채서 클래스가 정의될 때마다 특별한 동작을 제공할 수 있다.
# 속성 접근을 동적으로 사용자화하는 파이썬의 내장 기능이 있다.
# 동적 속성을 오버라이드 하다가 예상치 못한 부작용을 일으킬 수 있고,
# 메타클래스는 내부적으로 동작하는게 많기 때문에 최소한으로 사용하는 것이 좋다.
# 게터와 세터 메서드 대신에 일반 속성을 사용하자.
class OldResistor(object):
def __init__(self, ohms):
self._ohms = ohms
... | true |
cd825a14a0684cc33991992235bda855781e5de3 | Python | bingli8802/leetcode | /0030_HARD_Substring_with_Concatenation_of_All_Words.py | UTF-8 | 3,331 | 3.234375 | 3 | [] | no_license | class Solution(object):
def findSubstring(self, s, words):
"""
:type s: str
:type words: List[str]
:rtype: List[int]
"""
from collections import Counter
if not s or not words:
return []
one_word = len(words[0])
all_len = len(words) ... | true |
00fe4b6659968c8697a6ae19ebf6ae514d718481 | Python | zhudaxia666/shuati | /左神算法课代码/day2/2荷兰国旗.py | UTF-8 | 1,095 | 3.96875 | 4 | [] | no_license | '''
给定一个数组arr,和一个数num,请把小于nums的数放在数组的左边,等于nums的数放在数组的中间,大于nums的数放在数组的右边
要求时间空间复杂度为o(1),时间复杂度o(n)
'''
'''
思路和第一个相似。只不过要设置两个指针,前指针less和后指针more,less在从前面开始,more从后面开始,0-less局域表示小于nums的区域,初始值less为-1,more为n
如果当前遍历的元素cur小于nums,将less后一个元素与cur交换,less加1
如果当前元素等于nums,将继续遍历
如果当前遍历的元素cur大于nums,将more-1后与cur交换,然后在判断交换后的cur值与nums的关系
'... | true |
845ac7a4ee4f535f673fd658b59e61ff4ea72a44 | Python | shiwuhao/python | /再谈抽象/demo7.py | UTF-8 | 490 | 3.203125 | 3 | [] | no_license | # /usr/bin/env python3
from abc import ABC, abstractmethod
class Talker(ABC):
@abstractmethod
def talk(self):
pass
class knigget(Talker):
def talk(self):
print(111)
k = knigget()
k.talk()
print(isinstance(k, Talker))
class Herring:
def talk(self):
print('Blub')
h = Her... | true |
f96e0663119ba51d645fe13698cb35187728f4fb | Python | kylemede/SMODT | /sandbox/pythonSandbox/OpticalIRProblemSet3.py | UTF-8 | 6,177 | 3.015625 | 3 | [] | no_license | import math as m
H = 0.2#m
T = 273.0#K
p = 18.5e-6#m
d = 37.888e-3#m
F = 12.0#unitless
f = 12.0 #m
h = 6.626e-34 #Js
c = 299792458 #m/s
print "PROBLEM SET 3 ANSWERS\n"
## PROBLEM 3-1
print "\nAnswers to problem 3-1:\n"
# First for Ks-band
Lambda = 2.15 ##microns
deltaLambda = 0.3 ##microns
Na = (d*m.pow(p,2.0)*delt... | true |
640ee16dbf96e97f0b65d0023a55f54011321afe | Python | schnitzelbub/bocadillo | /bocadillo/views.py | UTF-8 | 4,556 | 3.125 | 3 | [
"MIT"
] | permissive | import inspect
from functools import partial, wraps
from typing import List, Union, Any, Dict
from .app_types import Handler
from .compat import call_async, camel_to_snake
from .constants import ALL_HTTP_METHODS
MethodsParam = Union[List[str], all]
class HandlerDoesNotExist(Exception):
# Raised to signal that n... | true |
688a13e792aa6360f053a959a75465c995a4e141 | Python | ivenpoker/Python-Projects | /online-workouts/codewars/python/who_likes_it.py | UTF-8 | 1,268 | 3.671875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
#######################################################################################
# #
# Program purpose: Recreation of facebook feature on post likes. #
# ... | true |
ce3a22ea0da51d3ee2b1497d6c9012e11cf479ab | Python | Acheros/Dotfiles | /python_exercise/exercise24.py | UTF-8 | 594 | 3.921875 | 4 | [] | no_license | #!/usr/bin/python3
import math
contents = []
print("please input a set of instruction:")
while True:
try:
a = input("")
except EOFError:
break
contents.append(a)
x = 0
y = 0
distant = 0
for value in contents:
new_value = value.split(" ")
if new_value[0] == "UP":
y += ... | true |
89923f713cce1ccab80a71c540ffe74d730a8bb5 | Python | gavinconran/ArtNet | /ArtNet_Supporting_Documentation/05_Descartes/Codes/06b_FourierSeries_SawToothWave.py | UTF-8 | 2,064 | 3.25 | 3 | [] | no_license | # Plotting Code for Saw Tooth Wave
import numpy as np
import math
import matplotlib.pyplot as plt
import matplotlib as mpl
from scipy import signal
import scipy.fftpack
mpl.style.use('classic')
def FS_SawTooth(k, tt):
'''
k, waveNumbers, is a list of integer wave numbers
tt is a list of time stamps
... | true |
dfe1438ad6dd0a609c88ec2a488a0cebf0475796 | Python | DrDABBAD/Raspberry-pico-tetris-st7735 | /test/graphistestremote.py | UTF-8 | 9,711 | 2.75 | 3 | [
"MIT"
] | permissive |
# Our supplier changed the 1.8" display slightly after Jan 10, 2012
# so that the alignment of the TFT had to be shifted by a few pixels
# this just means the init code is slightly different. Check the
# color of the tab to see which init code to try. If the display is
# cut off or has extra 'random' pixels on the top... | true |
71d0579d1eaab787e267103f0bc329a022ebfa02 | Python | maayan20-meet/FinalProjBenandJerrys | /database.py | UTF-8 | 1,040 | 2.890625 | 3 | [] | no_license | from model import Base, Store
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///stores.db?check_same_thread=False')
Base.metadata.create_all(engine)
DBSession = sessionmaker(bind=engine)
session = DBSession()
def add_store(name, city, street, phone):
"... | true |
484bcd15785f9ae4feb9afb36c3c2107434527dd | Python | dungmv56/Xierpa3 | /xierpa3/components/container.py | UTF-8 | 3,212 | 2.640625 | 3 | [
"MIT"
] | permissive | # -*- coding: UTF-8 -*-
# -----------------------------------------------------------------------------
# xierpa server
# Copyright (c) 2014+ buro@petr.com, www.petr.com, www.xierpa.com
#
# X I E R P A 3
# Distribution by the MIT License.
#
# ---------------------------------------------------------------... | true |
58f9367caeff97d697790683664d377696e5e3c3 | Python | farmergirl13/PGSS-Team-Project | /hw3_stroopTest.py | UTF-8 | 3,823 | 3.4375 | 3 | [] | no_license | ####################################################
# 2017 PGSS CS HW3
####################################################
# Instructions:
# https://docs.google.com/document/d/17fCC9mQ5j4UiGi-BQv4h8f1pQsZODcZr8lFZQOCwBrA
# More colors:
# https://wiki.tcl.tk/37701
###################################################... | true |
b0cb1da10148411775c82108eaef94e252751e3d | Python | virginiah894/python_codewars | /7KYU/get_factorial.py | UTF-8 | 138 | 3.21875 | 3 | [
"MIT"
] | permissive | # from math import factorial as fact
def factorial(n: int) -> int:
return 1 if n <= 1 else n * factorial(n - 1)
# return fact(n) | true |
5818529d7f174496b19e559756ba3e5f3cc99ef6 | Python | CronoxAU/Euler | /python/Problem18/problem18.py | UTF-8 | 723 | 3.796875 | 4 | [] | no_license | #Solution to Project Euler problem 18 - https://projecteuler.net/problem=18
#Maximum path sum
#Work from the bottom to the top
#work through each position taking the highest number from the two below positions and adding that to the current position to produce the maximum sum for that position.
#Once we work through t... | true |
f4d68c3f36ec30883f01e9453e0d9b021664f992 | Python | neilb14/cryptotracker | /parsers/sample_parser.py | UTF-8 | 389 | 2.71875 | 3 | [] | no_license | import pprint,re
from datetime import datetime
def parse(row):
result = {'valid':True}
date = datetime.strptime(row[0], '%d-%m-%y')
result['date'] = date
result['from_currency'] = row[1]
result['to_currency'] = row[3]
result['amount'] = float(row[4])
rate = re.sub('[",]', '', row[5])
re... | true |
27f37b4b8b0de90a1ecea355261d3b064c64b05c | Python | jfinocchiaro/long-term-fair-mdps | /political-influence-refactored/src/platform_opt.py | UTF-8 | 6,356 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
"""
Plartform optimizations, fair, half and unconstrained
"""
#############################################Required libraries####################################################
import numpy as np
import cvxpy as cp
from scipy.special import betainc
import sims
... | true |
17b6588d08291512ecb362fe018036601a931364 | Python | srcole/sdburritodash | /create_df.py | UTF-8 | 2,942 | 2.953125 | 3 | [] | no_license | import pandas as pd
import geocoder
import numpy as np
# Get data from Google Sheet
url = 'https://docs.google.com/spreadsheet/ccc?key=18HkrklYz1bKpDLeL-kaMrGjAhUM6LeJMIACwEljCgaw&output=csv'
df = pd.read_csv(url)
# Make lower
df.Location = df.Location.str.lower().str.strip()
df.Reviewer = df.Reviewer.str.lower().str... | true |
64ebcd487e7dc7672d9df792e17b9b6375d5aa8c | Python | pelthe/random | /Python/test.py | UTF-8 | 67 | 2.9375 | 3 | [] | no_license | import math
word1 = "key"
print(word1)
print("The word was ",word1) | true |
210588a8948c2daafe96bb5b5d2a37959bee4817 | Python | narru888/PythonWork-py37- | /Web網頁框架/框架(Django Rest Framework)/200505_DRF(版本、解析器)/mysite/api/views.py | UTF-8 | 1,953 | 3.015625 | 3 | [] | no_license | from django.shortcuts import render, HttpResponse
from rest_framework.views import APIView
from rest_framework.versioning import BaseVersioning, QueryParameterVersioning, URLPathVersioning
from rest_framework.parsers import JSONParser, FormParser, MultiPartParser
class UsersView(APIView):
"""
QueryParameterVe... | true |
2a9e525384636ce02a69a1ec06fd52e849969ef9 | Python | palisadoes/pattoo | /pattoo/db/schema/chart_datapoint.py | UTF-8 | 3,749 | 2.765625 | 3 | [
"GPL-3.0-only"
] | permissive | """pattoo ORM Schema for the DataPoint table."""
# PIP3 imports
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType
# pattoo imports
from pattoo.db import db
from pattoo.db.models import ChartDataPoint as ChartDataPointModel
from pattoo.db.schema import utils
from pattoo_shared.constants import DATA_... | true |
1390571eed87cb94833dfb0c23e5ae0391a31e06 | Python | zanixus/py-hw-mcc | /creditcard_km.py | UTF-8 | 2,301 | 4.46875 | 4 | [] | no_license | #!/usr/bin/python3
"""
Kevin M. Mallgrave
Professor Janet Brown-Sederberg
CTIM-285 W01
05 Apr 2019
This is a modular Python script that checks the validity of a credit card number.
It checks length and rejects bad input and non-digit strings.
It uses the Luhn algorithm to check credit card ... | true |
b80681fddc14574c8a0f77be6d073ae6b0365d9d | Python | Justus-M/dsti-metaheuristics-justus-mulli | /griewank/griewank.py | UTF-8 | 780 | 2.9375 | 3 | [] | no_license | import pandas as pd
import numpy as np
from scipy.optimize import minimize
import time
import matplotlib.pyplot as plt
def griewank(x):
z = x - shift[:len(x)]
val = (sum(z**2)/4000)-np.cumprod(np.cos(z/np.sqrt(np.arange(len(z))+1))).values[-1]+1+bias
converge.append(val)
return val
def minimize_griewa... | true |
7771e82cf40c916d4b0401fef487852fc94d525c | Python | knighton/sunyata_2017 | /sunyata/backend/base/layer/dot/separable_conv.py | UTF-8 | 989 | 2.578125 | 3 | [] | no_license | from ...base import APIMixin
class BaseSeparableConvAPI(APIMixin):
def __init__(self):
APIMixin.__init__(self)
def separable_conv(self, x, depthwise_kernel, pointwise_kernel, bias,
stride, pad, dilation):
raise NotImplementedError
def separable_conv1d(self, x, dept... | true |
d6bc2960fbe30fd0121bfab329f6c910da127206 | Python | the-astronot/Project-Doge | /src/Node.py | UTF-8 | 789 | 3.0625 | 3 | [] | no_license | class Node():
def __init__(self, bias, prev_weights = None, value = None):
self.bias = float(bias)
if prev_weights is None:
self.weights = []
else:
self.weights = []
for x in prev_weights:
self.weights.append(float(x))
if value is None:
self.value = 0.0
else:
self.value = flo... | true |
a6439528bccfd44b249d2c8b31a012ce01f9ec17 | Python | daretogo/find_common_pandas_flask | /compare_data.py | UTF-8 | 3,076 | 2.828125 | 3 | [] | no_license | import pandas, pandas_usaddress, pdb, flask
from flask import Flask, request, render_template
from flask import Flask
app = Flask(__name__)
#############################################################################################################################
def Comparison(newv_filename, newv_sheet, newv_stre... | true |
e6aa9b6d7b9c15916cebabf6ee155b87b6db9cd3 | Python | Jasonsey/Fern | /fern/data/data_tokenize.py | UTF-8 | 6,641 | 3.40625 | 3 | [
"Apache-2.0"
] | permissive | # Fern
#
# Author: Jason Lin
# Email: jason.m.lin@outlook.com
#
# =============================================================================
"""data tokenize"""
from typing import *
import re
from collections import Counter
import jieba
import pandas as pd
from sklearn.preprocessing import LabelBinarizer, MultiLabe... | true |
d93397ef41845e2059a7b48c3bac30416d2a8cc5 | Python | jf20541/CointegratedPairsTrading | /src/main.py | UTF-8 | 1,186 | 3.625 | 4 | [
"MIT"
] | permissive | import pandas as pd
import config
from sklearn.linear_model import LinearRegression
from statsmodels.tsa.stattools import adfuller
import matplotlib.pyplot as plt
df = pd.read_csv(config.TRAINING_FILE)
ETH = df["ETH"].values.reshape(-1, 1)
BTC = df["BTC"].values.reshape(-1, 1)
def hedge_ratio(dv, iv):
"""Hedge ... | true |
5a56bce582568b445f98a8b6e99785314636115f | Python | andreagonz/cripto-tareas | /tareas/tarea2/src/ej4/cifrado.py | UTF-8 | 6,165 | 3.421875 | 3 | [] | no_license | '''
Andrea Itzel González Vargas
Carlos Gerardo Acosta Hernández
'''
import sys
import os
from math import floor
'''
Clase que cifra y descifra mensajes con los
esquemas de cifrado cesar, afin, mezclado y vigenere
'''
class Cifrado:
'''
Constructor de la clase
'''
def __init__(self, clave, entrada):
... | true |
a4daf1682bbc4d5860be5a8826fec498bee2083c | Python | akhawaja2014/Deep-learning-for-image-registration | /feature_extraction/FirsttutorialImageregistration.py | UTF-8 | 1,554 | 2.515625 | 3 | [] | no_license | import numpy as np
import cv2
import matplotlib.pyplot as plt
img1_color = cv2.imread('/home/tgiencov/Registration Codes/Python image registration/im1.JPG') # Image to be aligned.
img2_color = cv2.imread('/home/tgiencov/Registration Codes/Python image registration/im2.JPG') # Reference image.
print(img1_color.sh... | true |
f1c9dab32e30468a12f89cebe3fefa2e4144ed3a | Python | seancawley35/CS3A04-Coursework | /CS3A04-LAB6-SCAWLEY (3).py | UTF-8 | 10,783 | 3.9375 | 4 | [] | no_license | Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> '''-----------------LAB 6--------------------------'''
'''----------------PART 1-------------------------'''
'''
-----------------PART 1: CODE... | true |
6a87ea55ea6ea6f949a22fd558cd9255b6984893 | Python | JuanRx19/TallerFinal | /Ejercicio 5.py | UTF-8 | 284 | 3.59375 | 4 | [] | no_license | PC = eval(input("Por favor digite la cantidad de dinero en pesos Colombianos"))
D = PC/3500 - (PC/3500 * 0.2)
print("Peso Colombiano a Dolar: ", D)
Ye = PC/34 - (PC/34 * 0.2)
print("Peso Colombiano a Yenes: ", Ye)
E = PC/4300 - (PC/34 * 0.2)
print("Peso Colombiano a Euro: ", E) | true |
25f03ca26b6c2dab225d26a3ed012eb8eb875d94 | Python | keleshev/docopt-dispatch | /test_docopt_dispatch.py | UTF-8 | 1,929 | 2.828125 | 3 | [
"MIT"
] | permissive | from pytest import raises, yield_fixture as fixture
from docopt_dispatch import Dispatch, DispatchError
class OptionMarker(Exception):
pass
class ArgumentMarker(Exception):
pass
doc = 'usage: prog [--option] [<argument>]'
@fixture
def dispatch():
dispatch = Dispatch()
@dispatch.on('--option')
... | true |
5ab3749e3a922cf0568b6a43005932aba4858757 | Python | stare-star/Keras-Snake-DQN | /snake-DQN.py | UTF-8 | 12,145 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import print_function
import argparse
import time
import skimage as skimage
from skimage import transform, color, exposure
from skimage.transform import rotate
from skimage.viewer import ImageViewer
import sys
sys.path.append("game/")
import snake as game
import random
import n... | true |
52a9b58db7dfc76b0ca0aea9a0228e59ac4e9c69 | Python | nickliqian/team-learning | /数据挖掘实践(二手车价格预测)/quantile2.py | UTF-8 | 875 | 3.3125 | 3 | [] | no_license | import pandas as pd
import numpy as np
def box_plot_outliers(data_ser, box_scale):
"""
利用箱线图去除异常值
:param data_ser: 接收 pandas.Series 数据格式
:param box_scale: 箱线图尺度,
:return:
"""
# 3/4分位 - 1/4分位的差,乘上缩放尺度
iqr = box_scale * (data_ser.quantile(0.75) - data_ser.quantile(0.25))
val_low = da... | true |
424ff212880d56915fdafe1dab55068c864da731 | Python | jkrumbiegel/jktools | /jktools/geometry/read_svg_paths.py | UTF-8 | 2,087 | 2.828125 | 3 | [] | no_license | from svg.path import parse_path
from svg.path.path import Path, CubicBezier, Arc, QuadraticBezier, Move
from matplotlib.path import Path as mPath
import xmltodict
import numpy as np
from jktools.geometry import remove_redundant_movetos
from collections import OrderedDict
def read_svg_paths(svg_file):
with open(s... | true |
65e19a8f7c958bda6764c9cdfb1c6141d5a288ad | Python | thejayhaykid/Python | /Geog5222/indexing/rtree2.py | UTF-8 | 4,745 | 2.90625 | 3 | [
"MIT"
] | permissive | """
R-tree, part 2
Contact:
Ningchuan Xiao
The Ohio State University
Columbus, OH
"""
__author__ = "Ningchuan Xiao <ncxiao@gmail.com>"
from math import ceil
from rtree1 import *
# e is an extent
def insert(node, e, child=None):
for ent in node.entries: # already in tree
if ent.MBR == e:
... | true |
0cb6e6ae39b92a935931901d68c5e1e9f09079c9 | Python | oklinux/LRWiki | /lib/tools/payload_generator.py | UTF-8 | 588 | 3.265625 | 3 | [] | no_license | import string
import random
CHARS = (
string.ascii_uppercase + string.ascii_lowercase + string.digits
)
def random_string(length=10, chars=CHARS):
"""
Generate a random alphanumeric string of the specified length.
"""
return str(''.join(random.choice(chars) for _ in range(length)))
def generate... | true |
bcd79ad70538b3f779b5ddbeda8f28353244a647 | Python | adambarnes5000/python-tetris | /buttons.py | UTF-8 | 1,077 | 3.3125 | 3 | [] | no_license | # KY040 Python Class
# Martin O'Hanlon
# stuffaboutcode.com
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
class Buttons:
CLOCKWISE = 1
ANTICLOCKWISE = -1
def __init__(self, callback_map):
self.map = callback_map
for pin, callback in callback_map.items():
... | true |
88b50030eada37a3ae693d91368136efa97aa40f | Python | 20143104/KMU | /2017-1/python/homework(2)/12.py | UTF-8 | 111 | 3.078125 | 3 | [] | no_license | import numpy as np
a = np.arange(5 , dtype = float)
print(a)
a = np.arange(1 , 6 , 2, dtype = int)
print(a) | true |
1a930d6aaf41f80e82d929cf1cc577ff3e4f7cb8 | Python | JD-Canada/OFspbMaster | /turbulence.py | UTF-8 | 580 | 2.6875 | 3 | [] | no_license | import pandas as pd
import math
import numpy as np
surfaceArea=0.0505
flow=0.035
rho=1000
diameter=0.254
viscdy=0.001
radius=0.5*diameter
V=flow/(3.14*(radius*radius))
TLEN=0.038*diameter
reynolds=diameter*V*rho/viscdy
tintensity=0.16*(reynolds)**(-1.0/8.0)
nut=V*tintensity*(3.0/2.0)**(0.5)
k=(3.0/2.0)*(0.69*tinte... | true |
1604290a9cf87961a9240d285c50e81d7ad04917 | Python | Theadre/miniProjetPyhton3-S3 | /correction/index.py | UTF-8 | 611 | 3.0625 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*
html = """
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset="UTF-8">
<title>Front page</title>
</head>
<body>
<br><a href="1-creationEtPeuplement.py">1. Creer et peupler la base</a>
<br><a href="2-ajoutEtu.py">2. Ajouter un etudiant</a>
<br><a... | true |
037a7e7576ddac46142cfee126c5cdf9dcf77eed | Python | masa-su/pixyzoo | /NewtonianVAE/utils/env.py | UTF-8 | 1,168 | 2.859375 | 3 | [] | no_license | import cv2
import numpy as np
import torch
# Preprocesses an observation inplace (from float32 Tensor [0, 255] to [-0.5, 0.5])
def preprocess_observation_(observation, bit_depth):
# Quantise to given bit depth and centre
observation.div_(2 ** (8 - bit_depth)).floor_().div_(2 **
... | true |
a7e126b08d03cdffb193e428d7506c92cc68d2c8 | Python | yash2662/project | /linearReg.py | UTF-8 | 1,343 | 3.5 | 4 | [] | no_license | # Data Preprocessing Template
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
# Splitting the dataset into the Training set and Test set
from sklea... | true |
16cc8e3bf3ac208c4b8a99c6db22a90f364cb2a6 | Python | XiaoyangzZ/pycharm | /strategy/Python_knowledge/df.freq.py | UTF-8 | 649 | 2.65625 | 3 | [] | no_license | """
时间序列的基础频率
D: Day 每日历日
B: BusinessDay 每工作日
H: hour 每小时
T or min: Minute 每分钟
S: 每秒
L or ms: milli 每毫秒(即每千分之一秒)
U: 每微妙(即百万分之一秒)
M: MonthEnd 每月最后一个日历日
BM: BusinessMonthEnd 每月最后一个工作日
MS: MonthBegin 每月第一个日历日
BMS: BusinessMonthBegin 每月第一个工作日
W-MON\W-TUE: Week 从指定的星期几开始算起,每周
WOM-1MON,WOM-2MON: WeekOfMonth 产生每月第一、第二、第三、第四周的... | true |
7b94dd525f6b54273a728f90cd272261adf6516a | Python | 4rlm/python_essential | /get_started.py | UTF-8 | 761 | 3.65625 | 4 | [] | no_license | ## W3 Schools TUTORIAL: https://www.w3schools.com/python/python_getstarted.asp
####################################
## 1. == Version ==
# $ python --version
####################################
## 2. == Execute Script ==
# $ python3 hello.py #=> best
# $ python hello.py #=> ok
####################################
... | true |
0f9014c2e0ecfdb398924842ec3f25a52e7854e0 | Python | MrigankaIsHere/cowin-availability | /Notify.py | UTF-8 | 1,098 | 2.796875 | 3 | [] | no_license |
import smtplib
import os
class Notify:
def __init__(self, to, index, slots, age, date):
self.to = to
self.index = index
self.slots = slots
self.age = age
self.date = date
gmail_user = os.getenv('gmail_user')
gmail_password = os.getenv('gmail_pa... | true |
9f15bea0fdd69d854b24bc80db7264bfed0f5ed1 | Python | zayslash/CSSI | /AppEngine/helloApp/hello.py | UTF-8 | 1,453 | 2.796875 | 3 | [] | no_license | import webapp2
import jinja2
JINJA_ENV = jinja2.Environment( loader= jinja2.FileSystemLoader("Templates") )
html_page= """
<html>
<head>
<title> Hello </title>
</head>
<body>
<p> Hello Brooklyn, CSSI! </p>
</body>
</html>
"""
html_page2= """
<html>
<body>
<form ... | true |
610404bf604c7f5ff259aef7cbe10c13568283ab | Python | jennymhkao/python-projects | /Exercise 08/Exercise 8.5.gyp | UTF-8 | 857 | 3.921875 | 4 | [] | no_license | '''Write a program to read through the mail box data and
when you find line that starts with "From", you will split
the line into words using the split function. We are interested
in who sent the message, which is the second word on the From line.
From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
You will pa... | true |
6318b78392394a366df89d88c1b542b44716b408 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_97/1367.py | UTF-8 | 1,142 | 3.203125 | 3 | [] | no_license | map = {'a': 'y', 'c': 'e', 'b': 'h', 'e': 'o', 'd': 's', 'g': 'v', 'f': 'c', 'i': 'd', 'h': 'x', 'k': 'i', 'j': 'u', 'm': 'l', 'l': 'g', 'o': 'k', 'n': 'b', 'p': 'r', 's': 'n', 'r': 't', 'u': 'j', 't': 'w', 'w': 'f', 'v': 'p', 'y': 'a', 'x': 'm', 'q':'z', 'z':'q'}
def rotate(s, amount):
return s[-amount:] + s[:... | true |
cca868073dcaa9e3d0a4e19338d530bdb6aa8878 | Python | kylin5207/MachineLearning | /数据预处理/特征选择/autoFeatureSelection/Select_base_model.py | UTF-8 | 1,769 | 3.140625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 16 11:27:32 2019
基于模型的特征选择
@author: 尚梦琦
"""
from sklearn.linear_model import LogisticRegression
from sklearn.feature_selection import SelectFromModel
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from skl... | true |
8439a1ed68ae7edadd081b290ad15d71e541303e | Python | sahg4n/FacialRecog | /gausianBlurFR.py | UTF-8 | 973 | 2.59375 | 3 | [] | no_license | import cv2
import face_recognition as fr
webcamStream = cv2.VideoCapture(0)
allFaceLocs = []
while True:
ret, curFrame = webcamStream.read()
currFrameSmall = cv2.resize(curFrame, (0,0), fx=0.25, fy=0.25)
faceLoc = fr.face_locations(currFrameSmall, 2, 'hog')
for index, curFaceLoc in enumerate(faceLoc... | true |
41e498e63d547d357056bbfdcb9c756df5500809 | Python | uncharted-aske/research | /gromet/data/ml4ai_repo/example_call_ex1.py | UTF-8 | 12,334 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | from gromet import * # never do this :)
"""
def bar(y: float) -> float:
return y + 2 # bar_exp
def foo(x: float) -> float:
return bar(x) # bar_call
def main(a: float, b: float) -> float:
a = foo(a) # foo_call_1
b = foo(b) # foo_call_2
return a + b
"""
# -----------------------------------... | true |
bd8ed03e0eee2abd3b226d973102e38be2961b16 | Python | mankabitm/chat | /Chat(TCP)/recv.py | UTF-8 | 274 | 2.703125 | 3 | [] | no_license | #!/usr/bin/python2
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(("",9999))
s.listen(5)
while 4>3:
cliport,cliaddr=s.accept()
print cliport.recv(100)
#print "From client ip->",cliaddr
r=raw_input("Enter your reply:")
cliport.send(r)
s.close()
| true |
89a128655a2cbc4e5295f442bae203efa2b18c69 | Python | GHeeJeon/algorithm-collection | /pythonProject/review_3rd_week.py | UTF-8 | 1,241 | 3.640625 | 4 | [] | no_license | # 외부 정렬 및 탐색은 다루지 않음.
# 탐색 알고리즘이란? 컴퓨터에 저장된 자료를 신속하고 정확하게 찾아주는 알고리즘
# 내부 탐색 외부 탐색으로 나뉨.
# 순차 탐색 알고리즘
class node:
def __init__(self, key = None):
self.key = key
class Dict:
def __init__(self):
Dict.a = []
def search(self, search_key):
left = 0
right = len(Dict.a) - 1
... | true |
53886949a119f7cc2d5bd5de4b6c0d1983ae37a0 | Python | mouradfelipe/channel_decoding | /LAB1/generate_answers.py | UTF-8 | 1,871 | 2.875 | 3 | [] | no_license | import numpy as np
def mourad_check(msg): # msg deve ter tamanho 14
H = np.array([[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1],
[1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0],
[1,0,0,0,0,0], [0,1,0,0,0,0], [0,0,1,0,0,0], [0,0,0,1,0,0], [0,... | true |
c7f0003b57170572676bb9cabc1c5e57baeb5c4e | Python | PvonK/Sudoku | /Interfaz_Sudoku_Test.py | UTF-8 | 10,688 | 3.0625 | 3 | [] | no_license | import unittest
import io
from parameterized import parameterized
from unittest.mock import patch, MagicMock
from Interfaz_Sudoku import Interfaz
from Sudoku import Sudoku
class TestInterfazSudoku(unittest.TestCase):
def setUp(self):
self.user4 = Interfaz()
self.user9 = Interfaz()
lista... | true |
ad3f903a4eb43941eb3846b6790c20208f263a55 | Python | BabaVegato/StratObsGame | /server.py | UTF-8 | 1,225 | 2.96875 | 3 | [
"CC-BY-4.0",
"BSD-3-Clause"
] | permissive | import socket
import threading
import pickle
import select
class Server:
def __init__(self):
self.socket = None
self.running = False
self.conn = None
self.info_rcvd = None
def create_server(self, host, port):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREA... | true |
75bb270f3c54a865a5029a0061f7c0128779e048 | Python | vk-en/python | /One week/1.5.9.py | UTF-8 | 1,086 | 3.953125 | 4 | [] | no_license | class Buffer:
def __init__(self):
self.List = []
def add(self, *a):
self.List.extend(a)
while len(self.List) // 5 > 0:
Sum = sum(self.List[:5])
self.List = self.List[5:]
print(Sum)
def get_current_part(self):
# print(self.List)
ret... | true |
f3053b9b1b8f83eecc3d08bcfc00a62cab1e2cc1 | Python | simone-campagna/mu-language | /lib/python/progressbar/span.py | UTF-8 | 13,768 | 3.265625 | 3 | [] | no_license | #!/usr/bin/env python
class SpanError(Exception):
pass
class SizedObj(object):
def __init__(self, size=None):
self._set_size(size)
def get_size(self):
return self._current_size
def _set_size(self, size):
self._current_size = size
def __add__(self, other):
other = sized_obj(other)
re... | true |
43150a1c2494481111af193036cdf216f429e989 | Python | Utkarsh2802/gspyproj | /random/4.py | UTF-8 | 539 | 3.28125 | 3 | [] | no_license |
def maxSubArraySum(a, size):
max_so_far = -9999999999
max_ending_here = 0
start = 0
end = 0
s = 0
for i in range(0, size):
max_ending_here += a[i]
if max_so_far <= max_ending_here:
max_so_far = max_ending_here
start = s
end... | true |
1ff4b63a433079a022f3907050368e8fdaa4ca97 | Python | ck89119/Algorithm | /LeetCode/minimum_depth_of_binary_tree.py | UTF-8 | 587 | 3.375 | 3 | [] | no_license | #!/usr/bin/python
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param root, a tree node
# @return an integer
def minDepth(self, root):
if root == None: return 0
... | true |
2610fc380cdf39684dbd2ca8984e3691f22169c0 | Python | NieGuozhang/Python-Spider | /07.动态加载数据处理/01.演示程序.py | UTF-8 | 1,083 | 2.984375 | 3 | [] | no_license | from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# 打开Chrome浏览器
# 'r'是防止字符转义的
driver = webdriver.Chrome(r'./chromedriver')
# 浏览器最大化
driver.maximize_window()
# 打开猿人学首页
driver.get('https://www.yuanrenxue.com')
time.sleep(3)
# 滑动到页面中间处
driver.execute_script("window.scrollTo(0,doc... | true |
51d8ca578f6048bd52db01f636077a6439b22a9f | Python | devyash/ctci | /arrays and strings/URLify.py | UTF-8 | 611 | 3.921875 | 4 | [] | no_license | """
replace " " with %20 in a string
"""
def urlify(string1, length1):
"""
Args: string, length of string
Return: replace string
"""
string2 = ""
for i in range(length1):
if string1[i] == " ":
string2 = string2 + "%20"
else:
string2 = string... | true |
974c57c800d76938c4c563d5ddc7b0359a8e746b | Python | omryzw/FakeNewsDetectionNLP | /mixdop.py | UTF-8 | 10,365 | 2.90625 | 3 | [] | no_license | # this module checks if the article already exists
import math
import string
import pymysql
import re
from datetime import date
import random
mydb = pymysql.connect(
host="35.224.191.214",
user="omrizw",
password="omoomo97",
database="edith"
)
mycursor = mydb.cursor(pymysql.cursors.DictCursor)
# trans... | true |
2f6da0839a9a52bbcfa9e190f79af10f79a3f5a0 | Python | AaronNolan/College-Lab-Sheets | /word-counts.py | UTF-8 | 144 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
import sys
li = sys.stdin.readlines()
i = 0
while i < len(li):
li_s = li[i].split()
print(len(li_s))
i += 1
| true |
07778d0438d30d23a7b5966914aadcc3c398cf64 | Python | yuansuixin/Python_Learning | /fishc/009/test1.py | UTF-8 | 432 | 3.34375 | 3 | [] | no_license | # 验证用户密码
times =3
password='hello'
temp=input("请输入密码:")
while times>0:
if '*' in temp:
temp=input("密码中不能有*,您还有3次机会,请重新输入:")
continue
times-=1
if temp=='hello':
print("密码成功,进入程序。。")
break
else:
password=input("密码错误,您还有"+str(times)+"次机会,请重新输入:")
| true |
97ac12936e425c18f869fa3cf57996439d433d77 | Python | ALICE5/Python | /py_demo/哥德巴赫猜想.py | UTF-8 | 679 | 3.59375 | 4 | [] | no_license | # usr/bin/env python3
import time
from math import sqrt
start = time.time()
n = 100000
isprime = lambda p: all([p % d for d in range(2, int(sqrt(p)) + 1)])
# all(iterable): 如果iterable所有元素不为0、''、False或者iterable为空
# all(iterable)返回True 否则返回False
for i in range(6, n + 1, 2):
for j in range(2, i // 2 + 1):
if ... | true |
e65bd5b4c05dc3fbf2b3aea46cadedbe7aba9c20 | Python | melvic-ybanez/nqueens | /NQueens/NQueens.py | UTF-8 | 1,544 | 3.546875 | 4 | [] | no_license | '''
Created on Dec 14, 2014
@author: melvic
'''
import sys
def has_row_threats(board, col):
predicate = lambda i: i != col and board[col] == board[i]
return has_threats(col, predicate)
def has_diagonal_threats(board, col):
predicate = lambda i: abs(i - col) == abs(board[i] - board[col]) != 0
... | true |
47aa3b0d65091b8db945399e0ad5c656cab515d9 | Python | vapelavsky/intersog-testtask | /main.py | UTF-8 | 4,130 | 4.375 | 4 | [] | no_license | # Test Task for Intersog
class Human:
"""This is the human from TikTok and she can entertain you.
Available methods:
1. drink
2. travel
3. sum calculate
4. sleep
5. show hobbies"""
name: str
age: int
sex: str
hobbies: list
country: str
job: str
hair: str
heig... | true |
5fba652d432a1dc5e5c4af102319b4f28a9e00de | Python | AndrewLrrr/otus-big-data | /hw1-data-gathering/storages/tests/test_storages.py | UTF-8 | 2,336 | 2.765625 | 3 | [] | no_license | import os
import shutil
import unittest
from storages import file_storage
class TestFileStorage(unittest.TestCase):
cache_prefix = 'test'
def setUp(self):
self.c = file_storage.FileStorage(self.cache_prefix)
self.test_dir = self.c._directory_path
def tearDown(self):
if os.path.i... | true |
b005e314bbd1215db5b8b6ae53bca82ecfb93365 | Python | jerbarnes/subjectivity_quantified | /Scripts/create_vec_reps.py | UTF-8 | 5,674 | 3 | 3 | [] | no_license | import logging
import sys
import os
import re
from gensim.models import Word2Vec
from nltk import word_tokenize
class MySentences(object):
"""For a corpus that has a number of subfolders, each
containing a set of text files. Supposes that in each text file,
there is one sentence per line. Yields one tokeni... | true |
4bae6178e55beb12e3d8ab8c5b28ffe0961ed0dc | Python | pinnakakalyani/python-programming | /assignment1.py | UTF-8 | 200 | 2.734375 | 3 | [] | no_license |
#create 2 d list of characters in message
#[['H','e','L','P']......]
message=['Help','run','fight','request']
print(list(map(list,message)))
print(list(map(lambda m:m ,list(message))))
| true |
9214db20e5866507a629840bc2e7ed540b21cead | Python | csinva/imodelsX | /imodelsx/sasc/api.py | UTF-8 | 5,670 | 2.71875 | 3 | [
"MIT"
] | permissive | from typing import List, Callable, Tuple, Dict
import imodelsx.sasc.m1_ngrams
import imodelsx.sasc.m2_summarize
import imodelsx.sasc.m3_generate
import numpy as np
import pprint
from collections import defaultdict
def explain_module_sasc(
# get ngram module responses
text_str_list: List[str],
mod: Callabl... | true |