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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dc71e907837b989e97060330ae8e518b154fbd4f | Python | Alexfordrop/Basics | /дробные.py | UTF-8 | 284 | 3.421875 | 3 | [] | no_license | format(0.1, '.17f')
print(format(0.1, '.17f'))
from decimal import Decimal
Decimal(1) / Decimal(3)
print(Decimal(1) / Decimal(3))
Decimal(1) / Decimal(3) * Decimal(3) == Decimal(1) # False
from fractions import Fraction
Fraction(1) / Fraction(3) * Fraction(3) == Fraction(1) # True | true |
9dbfc0078482636a00ff558a8afc75c532fd3dca | Python | Ilovezilian/pythonProject | /base/funtion.py | UTF-8 | 56 | 2.84375 | 3 | [] | no_license | i = 5
def f(arg = i):
print(arg)
i = 6
f()
| true |
8d9a8ba00025a304dd7e9a3a807075cd7c69b060 | Python | ping521ying/piaoying | /LearnPytest/test_register.py | UTF-8 | 1,963 | 2.90625 | 3 | [] | no_license | '''
pytest命名规则:
1.测试文件以test_开头或结尾
2.测试类以test开头
3.测试方法、函数以test_开头
'''
import requests
import json
def register(data):
url = "http://jy001:8081/futureloan/mvc/api/member/register"
r = requests.post(url,data=data)
return r
# 手机号码格式不正确
def test_register_001():
# 测试数据
data = {"mobilephone":"1801234567"... | true |
b713aef7dd0fcb1a49587650104d85c7170e5d21 | Python | zamirzulpuhar/zamir- | /1 неделя/яблако 2.py | UTF-8 | 69 | 2.921875 | 3 | [] | no_license | n = int(input())
k = int(input())
ostatok = k % n
print(ostatok)
| true |
9d2565fce0f0affe25675db6990bd8b871d73568 | Python | dabaicai233/Base-Prooject | /15的阶乘.py | UTF-8 | 67 | 3.203125 | 3 | [] | no_license | i = 1
add = 1
while i <=15:
add *=i
i+=1
print(add) | true |
960a68d8bac2ec1fb9a9b682319f993145180e4a | Python | Pradeep1321/LeetCode | /xorOperation-Array.py | UTF-8 | 173 | 3.328125 | 3 | [] | no_license | def xorOperation(n, start):
outarr = []
val= 0
for i in range(n):
val = val ^ (start+2*i)
return val
n = 5
start = 0
print(xorOperation(n,start)) | true |
6e3a6a7bdc69ddc8746fff74133f71efadfebf11 | Python | nrohankar29/Python | /Factorial.py | UTF-8 | 184 | 4.03125 | 4 | [] | no_license | def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
t = int(input())
print('\n')
for num in range(t):
n = int(input())
print(factorial(n))
print('\n') | true |
05aa0cfe3bec62597882559681341dd9d6138495 | Python | MicrosoftDX/liquidintel | /IOController/src/FifoQueue.py | UTF-8 | 1,618 | 3.65625 | 4 | [
"MIT"
] | permissive |
class _FifoItem(object):
def __init__(self, previousItem, nextItem, data):
self.previousItem = previousItem
self.nextItem = nextItem
self.peekCount = 0
self.data = data
# Doubly-linked list implementation of a FIFO queue
class Fifo(object):
def __init__(self):
self._f... | true |
33dbce65c055440936533a41c2b757f68a010dd5 | Python | Zemllia/rpgram2 | /GameObjects/WorldObject.py | UTF-8 | 516 | 2.78125 | 3 | [] | no_license | from GameObjects.MapObject import MapObject
class WorldObject(MapObject):
name = "Void"
sign = "#"
is_walkable = False
object_type = "player"
controller = None
world = None
def __init__(self, position, name, sign, is_walkable, object_type, controller, world):
self.position = posit... | true |
4b4b0deab620e41bee2c3e8e13e85a640768698a | Python | WanNJ/Wiki-QA-Magic | /question_generator/qtype_handlers/eo_generator.py | UTF-8 | 8,445 | 2.5625 | 3 | [] | no_license | import re
import sys
sys.path.append("../..")
import util_service
import random
from question_generator.qtype_handlers.get_is_are_was_were_loc import which_acomp
def get_is_idx_from_ner(ner_tags):
for idx, entry in enumerate(ner_tags):
if entry[0].lower() == "is":
return idx
return -1
de... | true |
3d226d8240e10ff220b25b3d705d555012ae4168 | Python | gjmingsg/Code | /leetcode/minimum-path-sum.py | UTF-8 | 1,067 | 3.171875 | 3 | [] | no_license | class Solution(object):
def minPathSum(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
if grid == None:
return None
h = len(grid) - 1
w = len(grid[0]) - 1
i = j =0
while h>=i:
j = 0
... | true |
f7e35e4d16f77d9ae02b13f401bebf2c3e0f8d11 | Python | yuki2006/topcoder | /src/GraphWalkWithProbabilities.py | UTF-8 | 3,624 | 2.703125 | 3 | [] | no_license | import math,string,itertools,fractions,heapq,collections,re,array,bisect,random
class GraphWalkWithProbabilities:
def findprob(self, graph, winprob, looseprob, Start):
g=[];n=len(winprob)
for i,j in zip(winprob,looseprob):g+=[1.*i/(i+j)]
for _ in range(55):
for i in range(n):
... | true |
159b3eaf0e7b7b4b7693cc0515c397bd3727996c | Python | mtcomb/rigol | /test_h5.py | UTF-8 | 267 | 2.8125 | 3 | [] | no_license | import matplotlib.pyplot as plot
import h5py
f = h5py.File('test.h5','r')
time = f['time']
data1 = f['data1']
data2 = f['data2']
plot.plot(time,data1)
plot.plot(time,data2)
plot.ylabel("Voltage (V)")
plot.xlabel("Time (S)")
plot.xlim(time[0], time[-1])
plot.show()
| true |
4b0f571622de50d6674210d661e7ff5f9d5f4208 | Python | zakuro9715/aoj | /10020.py | UTF-8 | 208 | 3.328125 | 3 | [] | no_license | import sys
mem = [0] * 26
for s in sys.stdin:
for c in s.upper():
if(c < 'A' or c > 'Z'):
continue
mem[ord(c) - ord('A')] += 1
for i in range(26):
print chr(i + ord('a')) + " : %d" % mem[i]
| true |
c811eaa6d71a42ff8682adf072115f1b46d01998 | Python | zunayed/puzzles_data_structures_and_algorithms | /practice_problems_python/1.8_is_rotation.py | UTF-8 | 366 | 4.03125 | 4 | [] | no_license | """
Given 2 strings write a function that checks if s2 is a rotation of s1
"""
def is_rotation(s1, s2):
if s1 != "" and len(s1) == len(s2):
s1s1 = s1 + s1
if s2 in s1s1:
return True
return False
s1 = "waterbottle"
s2 = "erbottlewat"
assert is_rotation(s1, s2) == True
s2 = "erb... | true |
f052f400598cba5f8b10e9c9aacc2d7f594db2e1 | Python | z1165419193/spark | /datasearch/universitesnews/zhongyuangongxueyuan/zhongyuangongxueyuan.py | UTF-8 | 1,514 | 2.6875 | 3 | [] | no_license | import urllib.request
from bs4 import BeautifulSoup
import re
def resapce(word):
return word.replace('\n','').replace('\r','').replace('\t','').replace(' ','').replace('\xa0','').replace(' ','')
def get_text(url1):
html1=urllib.request.urlopen(url1).read().decode('utf-8')
soup1=BeautifulSoup(html1)
... | true |
9e862acb1bb92fef2d59a000b5292274b8ea56a5 | Python | Conanjun/chatting_for_multiple_person | /client.py | UTF-8 | 1,736 | 2.78125 | 3 | [] | no_license | import socket
import select
import threading
import sys
HOST = '127.0.0.1' # Symbolic name meaning all available interfaces
PORT = 5963 # Arbitrary non-privileged port
addr = (HOST, PORT)
def socket_ready_to_connect():
# creat a socket ready to connect
# s = None
# for res in socket.getaddrinfo(HOST,... | true |
2e2f01667c52b89243fb09d7362ae5995f64246c | Python | chenrongs/python01 | /py/findAndinsert.py | UTF-8 | 1,098 | 3.34375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2018/4/21 21:08
# @Author : CRS
import os
import stat
import re
def test1():
"""
找出以什么开头的和什么结尾的字符串
re.sub 组合每组字符串 并替换
:return:
"""
list = os.listdir(".")
print(list)
filters = [name for name in os.listdir(".") if name.endswith('.py')]
p... | true |
022d55b6813398c8d13ea9a95992ebf0c6dcf539 | Python | lxmwust/synthnn | /synthnn/models/nconvnet.py | UTF-8 | 1,696 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
synthnn.models.nconvnet
define the class for a N layer CNN with
no max pool, increase in channels, or any of that
fancy stuff. This is generally used for testing
purposes
Author: Jacob Reinhold (jacob.reinhold@jhu.edu)
Created on: Nov 2, 2018
"""
__all__ = ['SimpleC... | true |
9add3c8e09df145aa23ed01b9dcc268bb1790239 | Python | boredom101/speculative-spectacular | /listener.py | UTF-8 | 156 | 2.578125 | 3 | [
"MIT"
] | permissive | import sys
import webbrowser
import serial
device = sys.argv[1]
ser = serial.Serial(device)
while True:
url = ser.readline()
webbrowser.open(url)
| true |
055cb89d7fea4d21a542f2880658976db8cd4da4 | Python | groscoe/pynads | /pynads/utils/internal.py | UTF-8 | 4,931 | 3.6875 | 4 | [
"MIT"
] | permissive | """A collection of utilities used internally by pynads. By no means are they
off limits for playing with, however, they aren't exported by pynads.
"""
from collections import Iterable, Mapping
from inspect import isfunction
__all__ = ('_iter_but_not_str_or_map', '_propagate_self',
'_single_value_iter', 'w... | true |
015046401aa0522131d3fd738a07431a17510dcf | Python | petuum/nni | /nni/utils.py | UTF-8 | 9,969 | 2.53125 | 3 | [
"MIT"
] | permissive | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import functools
from enum import Enum, unique
import json_tricks
from schema import And
from . import parameter_expressions
to_json = functools.partial(json_tricks.dumps, allow_nan=True)
@unique
class OptimizeMode(Enum):
"""O... | true |
ac12689f67c77fa7683c90d6abe6e615d6efa1ea | Python | JoshHill15/algos | /arrays/most_frequent_k_elements.py | UTF-8 | 698 | 3.265625 | 3 | [] | no_license | from heapq import heappop, heappush, heapify
class Solution(object):
def topKFrequent(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: List[int]
"""
heap = []
hm = {}
result = []
for num in nums:
if num in hm:
... | true |
e466a6c36b11f95cdf098bfb1723af3855a529e1 | Python | ewewwe/cautious-eureka | /hej.py | UTF-8 | 1,103 | 3.625 | 4 | [] | no_license | poäng=0
n=0
f=0
def kontrollera_gissning(gissning,svar):
global n
if gissning.lower() == svar.lower():
global poäng
print('Rätt svar')
if n == 0 or n == 3 or n == 6:
poäng=poäng+3
elif n == 1 or n == 4 or n == 7:
poäng=poäng+2
else:
... | true |
466125f38ebcda3f4d7de821aa352deafadf1058 | Python | gsaurabh98/machine_learning_basics | /mlPackage/pandas/multi_level_index.py | UTF-8 | 583 | 3.203125 | 3 | [] | no_license | import pandas as pd
from numpy import random
#index levels
outside = 'G1 G1 G1 G2 G2 G2'.split()
print outside
inside = [1,2,3,1,2,3]
print inside
heir_index = list(zip(outside,inside))
print heir_index
new_heir_index = pd.MultiIndex.from_tuples(heir_index)
print new_heir_index
df = pd.DataFrame(random.randn(6,2),... | true |
ee377f33712ce6549a446377ab7f3001dff752ae | Python | jpuigcerver/miarfid-ann | /statlog/Prepare-KFold.py | UTF-8 | 1,424 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import system
from random import seed, shuffle
from sys import argv, stdin, stderr, stdout
FOLDS = 5
SEED = 0
i = 1
while i < len(argv) and argv[i][0] == '-':
if argv[i] == '-k':
FOLDS = int(argv[i+1])
if FOLDS <= 1: FOLDS = 5
i = i + 2... | true |
035cc86a140ffeb29c8ec34e025e038a5dc1bf4e | Python | skditjdqja/chatting | /chat_server.py | UHC | 13,724 | 2.65625 | 3 | [] | no_license | import sys, socket, select, string
HOST = 'localhost'
SOCKET_LIST = []
NAME_LIST = []
RECV_BUFFER = 4096
PORT = 11000
def chat_server():
#creating TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4 ͳ
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # ̹... | true |
acf44fc5320ee48ac7eac50b4ef2e53bad6c4e3d | Python | rajeevdodda/Codeforces | /CF-A/701-800/CF710-A.py | UTF-8 | 234 | 3.078125 | 3 | [] | no_license | # https://codeforces.com/problemset/problem/710/A
s = input()
if s[0] in {'a', 'h'}:
if s[1] in {'8', '1'}:
print(3)
else:
print(5)
else:
if s[1] in {'8', '1'}:
print(5)
else:
print(8) | true |
4f7f0acbad803c54a5b3e0245f9d773b9b86a25f | Python | thelunchbox/ggj-2020 | /rbt/game_components/hud.py | UTF-8 | 1,519 | 2.734375 | 3 | [] | no_license | import pygame
from rbt.game_components.button import Button
from rbt.utils.constants import *
class Hud:
def __init__(self):
self.buttons = []
self.generate_all_buttons()
def generate_attack_tool_button(self):
btn = Button((204, 0, 0), ATTACK_BUTTON_X, ATTACK_BUTTON_Y, TOOL_BUTTON_WI... | true |
743ed7792827fedde4f16d82174ff71f2a2b7eff | Python | neelambuj2/Dynamic-Programming | /recursion.py | UTF-8 | 1,344 | 2.8125 | 3 | [] | no_license | def get_inline( account_relation: dict, current_key):
if type(account_relation) is dict:
for key in account_relation.keys():
iterable = get_inline(account_relation[key], key)
for element in iterable:
if element != key:
yield (key + "." + element)
... | true |
a73aa3a0d1b227c5bfb9b95ac476d6c05b82dafc | Python | Cynth42/computer-vision-projects | /project1/models (1).py | UTF-8 | 3,442 | 3.28125 | 3 | [] | no_license | ## TODO: define the convolutional neural network architecture
import torch
import torch.nn as nn
import torch.nn.functional as F
# can use the below import should you choose to initialize the weights of your Net
import torch.nn.init as I
class Net(nn.Module):
def __init__(self):
super(Net, self).__init_... | true |
6fc8ba61d65ca2f1fec0af3ed16b90b6f6579e5e | Python | webdynamik/python-websocket | /commands/penOff.py | UTF-8 | 260 | 2.859375 | 3 | [] | no_license | import RPi.GPIO as GPIO2
import time
servoPIN = 21
GPIO2.setmode(GPIO2.BCM)
GPIO2.setup(servoPIN, GPIO2.OUT)
p = GPIO2.PWM(servoPIN, 50) # GPIO 17 als PWM mit 50Hz
p.start(1) # Initialisierung
p.ChangeDutyCycle(20)
time.sleep(0.5)
p.stop();
GPIO2.cleanup()
| true |
1f9e0bdc58a19cf7c97015ff7ef5dadbfcf31bfe | Python | TheShubham-K/opencv | /result/class04.py | UTF-8 | 1,004 | 2.734375 | 3 | [] | no_license | import cv2
import matplotlib.pyplot as plt
img1 = cv2.imread("res/logic_1.jpg")
img2 = cv2.imread("res/logic_2.jpg")
bit_and = cv2.bitwise_and(img1, img2)
bit_or = cv2.bitwise_or(img1, img2)
bit_xor = cv2.bitwise_xor(img1, img2)
img1_not = cv2.bitwise_not(img1)
img2_not = cv2.bitwise_not(img2)
cv2.imshow("AND", bit... | true |
0b202782299902f3f285bd30dad1ee4cb9f21985 | Python | firth/nexrad_sr | /data_manager.py | UTF-8 | 6,367 | 2.625 | 3 | [] | no_license | #loads and processes NEXRAD dataset
from glob import glob
from imageio import imread
import numpy as np
from multiprocessing import Pool
from functools import partial
from os import path
from PIL import Image
#CONSTANTS:
#the range of reflectivity values:
max_ref = 94.5
min_ref = -32.0
#parallel processing:
THREADS = ... | true |
7704c63ccbdae6226bba06e2db71675a3c2e4996 | Python | faixan-khan/AI-BOT | /team35.py | UTF-8 | 7,703 | 2.640625 | 3 | [
"MIT"
] | permissive | import random
import datetime
import copy
class Team35:
def __init__(self):
self.one_value = 5
self.two_value = 10
self.twohalf_value = 50
self.three_value = 100
self.ALPHA = -100000000
self.BETA = 100000000
self.dict = {}
self.lenght = 0
self.HIGH_POS = [(0,0),(1,1),(2,2),(1,2),(2,1)]
self.LOW_P... | true |
0839a18fd25980bc8d0e31d8d6bcb2652ddb7e9a | Python | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/ravi_g/lesson08/test_circle.py | UTF-8 | 1,775 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env python3
# Testing circle.py
import math
import circle as cir
def test_check_rad_diameter():
'''
checks radius and diameter
'''
# initialized with radius 5
c1 = cir.Circle(5)
assert c1.radius == 5
assert c1.diameter == 10
# Set diameter
c2 = cir.Circle()
c2.diam... | true |
e3a52a55b7fbeaf4f58204483c829969e5f76ada | Python | oneiromancy/leetcode | /easy/1108. Defanging an IP Address.py | UTF-8 | 188 | 3.203125 | 3 | [] | no_license | def defangIPaddr(address):
return ''.join(['[.]' if char == '.' else char for char in address])
# Input: address = "1.1.1.1"
# Output: "1[.]1[.]1[.]1"
print(defangIPaddr("1.1.1.1"))
| true |
7e66e235fd93fcce6b43d80499f0732df89beec1 | Python | marcelochavez-ec/Python-Algoritmos_y_programacion | /MASTERMIND_GAME.1.0.py | UTF-8 | 2,048 | 3.921875 | 4 | [] | no_license | #!/usr/bin/env python
#-*-coding:utf-8-*-
"""
Juego MASTERMIND genera un numero al azar y te permite adivinar cual es dandote
pistas de cuantas cifras coinciden y cuantas existen;
"""
import random
def cls():
print "\n"*100
return
def contador(cadena, caracter):
"""
Determina si un caracter esta en una cadena
... | true |
99fa270fa756460b4c37bddb3ea91f994d9e8982 | Python | iiichtang/sqlalchemy_example | /04_query_2.py | UTF-8 | 2,955 | 2.8125 | 3 | [] | no_license | from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, Date
from sqlalchemy.orm import sessionmaker
from config import *
from sqlalchemy import and_
from sqlalchemy import or_
Base = declarative_base()
class User(Base):
__table... | true |
232dc23563e1249b0ec1ec693c138dedfdec780c | Python | prajwal60/ListQuestions | /learning/List Excercises/insertChar.py | UTF-8 | 202 | 3.875 | 4 | [] | no_license | # Write a Python program to insert an element before each element of a list.
color = ['Red', 'Green', 'Black']
res = []
for col in color:
for rag in ("c",col):
res.append(rag)
print(res) | true |
21328a466d3ec8b47e18d2b72f6b0c58e03b4c6d | Python | granularai/polyaxon-schemas | /polyaxon_schemas/ml/constraints.py | UTF-8 | 6,839 | 2.828125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from marshmallow import fields
from polyaxon_schemas.base import BaseConfig, BaseMultiSchema, BaseSchema
class MaxNormSchema(BaseSchema):
max_value = fields.Int(default=2, missing=2)
axis = fields.Int(default=0, missing... | true |
a66b31dc16c4fb2ed83376d471a411f2f15f1670 | Python | dionel-martinez/disaster-storage-api | /api/handlers/user_handler.py | UTF-8 | 2,273 | 2.6875 | 3 | [] | no_license | from api.dao.user_dao import UserDAO
from api.handlers.error_handler import ErrorHandler
from flask import jsonify
class UserHandler(object):
def build_user_dict(self, row):
user_dict = {}
user_dict["user_id"] = row[0]
user_dict["username"] = row[1]
user_dict["password"] = row[2]
... | true |
adb5aa66bfa814eca66bd39fa395e6b6cf2adaf9 | Python | simonscerri/home-control-system | /control-system.py | UTF-8 | 5,721 | 2.78125 | 3 | [] | no_license | #! /usr/bin/python
import threading, time
import sqlite3 as lite
import sys
import datetime
import RPi.GPIO as GPIO
import homeSystem
PIR = 13
LED = 11
GPIO.setmode(GPIO.BOARD)
GPIO.setup(PIR, GPIO.IN)
GPIO.setup(LED, GPIO.OUT)
GPIO.output(LED, GPIO.LOW)
def checkPIRSensor(channel):
print 'Rising edge on PI... | true |
ece646de44a86382d4f58078c23dddeb30d25b53 | Python | BGU-ISE/PlateletsSpreadingQuanification | /main_demo.py | UTF-8 | 1,265 | 2.859375 | 3 | [] | no_license | from SimpleVisualizationTool import *
from rgb_color_manipulator import read_video
from ToTimeSeries import ToTimeSeries
import numpy as np
print('new color green')
new_color = [0,255,0]
print('range is 150-200')
gray_range = range(150,200)
ranges = [gray_range,gray_range,gray_range]
print('reading video and manipulat... | true |
9f3c2f34358711edaeac83e80e3cca51fb1b20b9 | Python | pemo11/pyrepo | /OMI/Allgemein/LambdaParameter.py | UTF-8 | 160 | 3.21875 | 3 | [] | no_license | # Beispiel für eine Function als Parameter
def runlambda(f, args):
return f(args)
def f1(x):
return x**x
#print(f1(5))
print(runlambda(f1, 5))
| true |
bd6bd897ffd3a6b012a0b167c87cb515ee050ef5 | Python | oliver-johnston/advent-of-code-2020 | /04.py | UTF-8 | 1,469 | 2.96875 | 3 | [] | no_license | import re
required_fields = {
"byr": lambda x: re.match("^[0-9]{4}$", x) and 1920 <= int(x) <= 2002,
"iyr": lambda x: re.match("^[0-9]{4}$", x) and 2010 <= int(x) <= 2020,
"eyr": lambda x: re.match("^[0-9]{4}$", x) and 2020 <= int(x) <= 2030,
"hgt": lambda x: is_height_valid(x),
"hcl": lambda x: re... | true |
00e34eed8cc394b8a19c5fc8eb63b59d79a3077d | Python | oddcoder/spam_filter | /prediction_function.py | UTF-8 | 2,756 | 3.328125 | 3 | [] | no_license | from probability_tables import *
from math import log10
from features import *
#extras
from collections import Counter
import os.path
import sys
PSPAM = 0.5
PHAM = 1 - PSPAM
ham,spam,hamCounter,spamCounter=remove_big_words_from_list()
counter = hamCounter + spamCounter
def word_spam_probability(word):
probability... | true |
92789c1a8a5ab5d57887c8b89f1a2a7dacf5514b | Python | christopherUCL/Pipelength | /Functions/pipelengthCal.py | UTF-8 | 4,946 | 2.59375 | 3 | [] | no_license | # 1. API call to fluid properties website
def calculatePipeLength():
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from flask import request
import math
import os
import chromedriver_binary
WaterTemperature = "42.5"
AtmosphericPressure = "100"
ur... | true |
7490c0b085a235de42db14628aa1821c57ec248c | Python | allenchen/randomstuff | /naive_bayes_spam_classifier/create_validation_sets.py | UTF-8 | 604 | 2.703125 | 3 | [] | no_license | import os
import shutil
import random
def get_files(path):
for f in os.listdir(path):
f = os.path.abspath( os.path.join(path, f ) )
if os.path.isfile( f ):
yield f
# Ham
x = 1
for filename in get_files("train/ham"):
print "Placed " + str(filename)
shutil.copyfile(filename, "xva... | true |
9fa481619b16dadcca87ce52c5da27ae3bcba0a5 | Python | pndupont/news_tracker | /apps/login/models.py | UTF-8 | 2,076 | 2.734375 | 3 | [] | no_license | from __future__ import unicode_literals
from django.db import models
from datetime import datetime
import re
EMAIL_REGEX = re.compile(r'^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$')
# No methods in our new manager should ever receive the whole request object as an argument!
# (just parts, like request.POST)
class ... | true |
aa023debf9a199d14c78854b6793ff5f1f474ae4 | Python | kalicc/feapder_project | /lagou-spider/main.py | UTF-8 | 1,428 | 2.625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on 2021-03-19 20:42:55
---------
@summary: 爬虫入口
---------
@author: Boris
"""
from feapder import ArgumentParser
from spiders import *
def crawl_list():
"""
列表爬虫
"""
spider = list_spider.ListSpider(redis_key="feapder:lagou_list")
spider.start()
def crawl_deta... | true |
ab2ecc2ec3f369ceab23eb268eda6ee942d713e0 | Python | lcls-psana/CalibManager | /src/H5Print.py | UTF-8 | 13,690 | 3 | 3 | [] | no_license | #--------------------------------------------------------------------------
# File and Version Information:
# $Id: H5Print.py 13101 2017-01-29 21:22:43Z dubrovin@SLAC.STANFORD.EDU $
#
# Description:
# Module H5Print
#------------------------------------------------------------------------
"""Print structure and cont... | true |
3f0937e6be0edf8af3eb76df1e5880cac04d717f | Python | phanisai22/HackerRank | /Practice/30 Days/10-Day Binary Numbers.py | UTF-8 | 516 | 3.40625 | 3 | [] | no_license | decimal_number = int(input())
remainders = ""
while decimal_number > 0:
remainders += str(decimal_number % 2)
decimal_number = int(decimal_number / 2)
# Reverse the remainder's array will give you the binary number.
# In this task it doesn't matter
consecutive_ones = remainders.split("0")
# Find the maximum ... | true |
609803391d92c2eb4ef33994464c4a651c9c0178 | Python | DayGitH/Python-Challenges | /DailyProgrammer/DP20170627A.py | UTF-8 | 989 | 3.453125 | 3 | [
"MIT"
] | permissive | """
[2017-06-27] Challenge #321 [Easy] Talking Clock
https://www.reddit.com/r/dailyprogrammer/comments/6jr76h/20170627_challenge_321_easy_talking_clock/
**Description**
No more hiding from your alarm clock! You've decided you want your computer to keep you updated on the time so you're
never late again. A talking clo... | true |
1c667db7271db6dfd07f5bb5aeea7e223d3a08b9 | Python | nickyfoto/lc | /python/893.groups-of-special-equivalent-strings.py | UTF-8 | 2,806 | 3.5625 | 4 | [] | no_license | #
# @lc app=leetcode id=893 lang=python3
#
# [893] Groups of Special-Equivalent Strings
#
# https://leetcode.com/problems/groups-of-special-equivalent-strings/description/
#
# algorithms
# Easy (62.75%)
# Total Accepted: 15.7K
# Total Submissions: 25K
# Testcase Example: '["abcd","cdab","cbad","xyzz","zzxy","zzyx"]... | true |
679cbe13c564288964f5acf1ed09076a28fa0f3c | Python | jerrylance/LeetCode | /122.Best Time to Buy and Sell Stock II/122.Best Time to Buy and Sell Stock II.py | UTF-8 | 793 | 4 | 4 | [] | no_license | # LeetCode Solution
# Zeyu Liu
# 2019.3.20
# 122.Best Time to Buy and Sell Stock II
from typing import List
# method 1 Greedy,观察规律,可知只要后一个数比前一个数大,就把两数差加起来,较快
class Solution:
def maxProfit(self, prices: List[int]) -> int:
value = 0
for i in range(len(prices)-1):
if prices[i] <... | true |
881344f1da90e52c7dbc2bb12d76061b054db5bb | Python | lucieperrotta/ASP | /helpers.py | UTF-8 | 1,369 | 2.859375 | 3 | [] | no_license | import numpy as np
import scipy.signal as sgn
# Do not use this one, it's only used in the next function!!!
def butter_bandpass(lowcut, highcut, fs, order=5):
nyq = 0.5 * fs
low = lowcut / nyq
high = highcut / nyq
b, a = sgn.butter(order, [low, high], btype='band')
return b, a
# Bandpass filter ap... | true |
73bdd86d17aca8bb4545703a0461f78f50436d59 | Python | ThallesTorres/Curso_Em_Video_Python | /Curso_Em_Video_Python/ex089.py | UTF-8 | 1,505 | 4.03125 | 4 | [
"MIT"
] | permissive | # Ex: 089 - Crie um programa que leia nome e duas notas de vários alunos e
# guarde tudo em uma lista composta. No final, mostre um boletim contendo a
# média de cada um e permita que o usuário possa mostrar as notas de cada
# aluno individualmente.
print('''
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--Seja bem-vindo!
-... | true |
5367f19bda12cfe170e0ca2329cc5a4bf86f6bc8 | Python | wchkong/crawler-demo | /com.cdqd/back/zilian3.py | UTF-8 | 2,210 | 2.765625 | 3 | [] | no_license | import csv
import time
import requests
from fake_useragent import UserAgent
class Zhilian():
def __init__(self):
self.headers = {
'User-Agent': str(UserAgent().random),
}
self.proxies = {"http": "http://121.232.194.196:9000"}
self.base_url = 'https://fe-api.zhaopin.com... | true |
1d2afc6d4105e445681203cc25a02253c7be0edd | Python | alhedlund/Hospital_Webscrape | /data_acquisition/hospital_specific_data_pulls.py | UTF-8 | 1,242 | 3.015625 | 3 | [] | no_license | """
Some hospitals have several tabs or different formatting from the bulk of others.
These functions pull and output data specifically for them.
"""
import logging
import pandas as pd
from logging import DEBUG
import requests as r
import csv
from pprint import pprint as p
logger = logging.getLogger(__name__)
logger.se... | true |
4034499253286c1fdf00064651fcb9b93d52e40e | Python | risomt/codeeval-python | /37.py | UTF-8 | 1,833 | 4.3125 | 4 | [] | no_license | #!/usr/bin/env python
"""
Challenge Description:
The sentence 'A quick brown fox jumps over the lazy dog' contains every single letter in the alphabet. Such sentences are called pangrams. You are to
write a program, which takes a sentence, and returns all the letters it is missing (which prevent it fr... | true |
a06f2ada86831d2c27069511c002bfe009931d36 | Python | muriox/ToDoListApp | /ToDoList/userMainTaskPage.py | UTF-8 | 5,532 | 2.6875 | 3 | [] | no_license | #!/usr/bin/python3
import tkinter
from tkinter import*
from tkinter import messagebox
from userAddTaskPage import userAddAndEditTaskGUI, viewTaskDetailsGUI
# ************* CLASS FOR DISPLAYING USER TASK ***************** #
class userTaskPageGUI:
# Constructor specifications
def __init__(self):
print("C... | true |
5fe39709dcc0b7b9a290b42b83d7f3a2b2661df5 | Python | SeokJong/problemsolving | /baekjoon/b1761.py | UTF-8 | 1,477 | 2.796875 | 3 | [] | no_license | import sys
from math import log2, ceil
sys.setrecursionlimit(400000)
input = sys.stdin.readline
def get_tree(now, parent, val):
depth[now] = depth[parent] + 1
if now != 1:
dist[now] = dist[parent] + val
parent_mat[now][0] = parent
for i in range(1, log_max_depth):
tmp = parent_mat[now]... | true |
0946a9cafd4d94bee30b17fecae08d713b26eee1 | Python | deeprob-org/deeprob-kit | /deeprob/spn/learning/learnspn.py | UTF-8 | 10,014 | 2.71875 | 3 | [
"MIT"
] | permissive | # MIT License: Copyright (c) 2021 Lorenzo Loconte, Gennaro Gala
from enum import Enum
from collections import deque
from typing import Optional, Union, Type, List, NamedTuple
import numpy as np
from tqdm import tqdm
from deeprob.utils.random import RandomState, check_random_state
from deeprob.spn.structure.leaf impo... | true |
b3de4279ea7fe83fd15785508f94ed3ca150e58f | Python | knightrohit/data_structure | /list/spiral_matrix.py | UTF-8 | 1,176 | 3.421875 | 3 | [] | no_license | """
Time Complexity = O(row*col)
Space Complexity = O(1)
"""
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
out = []
if not matrix:
return out
row, col = len(matrix), len(matrix[0])
left = top = 0
bottom = row - 1
... | true |
7a2df10e8f08d95512df2ab4ddd2c7894d9e33e6 | Python | bakarys01/bakary_test_solution | /histogram.py | UTF-8 | 2,169 | 3.90625 | 4 | [] | no_license | from random import randint
import matplotlib.pyplot as plt
def compute_histogram_bins(data=[], bins=[]):
"""
Question 1:
Given:
- data, a list of numbers you want to plot a histogram from,
- bins, a list of sorted numbers that represents your histogram
bin thres... | true |
02c6427aad623bc602e473d98477090a8c3890c8 | Python | damirmarusic/kremlin | /kremlin/pipelines.py | UTF-8 | 2,669 | 2.609375 | 3 | [] | no_license | # Define your item pipelines here
from scrapy import log
from twisted.enterprise import adbapi
import time
import pymysql.cursors
import sqlite3
class SQLitePipeline(object):
def __init__(self):
log.start('logfile')
self.conn = sqlite3.connect('russia.db')
self.c = self.conn.cursor()
... | true |
5d08c940d2d9e43553ee5a63c2131d7a73a06024 | Python | django-group/python-itvdn | /домашка/starter/lesson 6/MaximKologrimov/Task Dop.py | UTF-8 | 726 | 4.25 | 4 | [] | no_license | # Задание
# Напишите рекурсивную функцию, которая вычисляет сумму натуральных чисел, которые
# входят в заданный промежуток.
x = int(input('Введите натуральное число №1: '))
y = int(input('Введите натуральное число №2: '))
def sum(a, b):
def minimal(a, b):
rmin = min(a, b)
return rmin
... | true |
ac1c88cb55c73c46373a4cf20abfc4c656498ec1 | Python | jlambdev/journal-creator | /doc_generator.py | UTF-8 | 3,342 | 3.515625 | 4 | [] | no_license | """
A Markdown document template generator (Python 3.5).
Navigate to the Journal folder in Windows Explorer.
Run using 'python3 doc_generator.py <year> <month>'.
Month should be zero-padded, e.g. 02 for February.
"""
import datetime
import argparse
import sys
import os
parser = argparse.ArgumentParser(description='Cr... | true |
2dcfd80e72925eb23c1a78442010701c24b5f33f | Python | ZhikunWei/maml-regression | /maml_regression.py | UTF-8 | 17,981 | 2.734375 | 3 | [] | no_license | import pickle
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.utils.data
import torch.nn.functional as F
def loss_mse(v1, v2):
result = 0
for a, b in zip(v1, v2):
result += (a - b) ** 2
return result / len(v1)
def sample_data(task_num, sample_per_task, amplitude=Non... | true |
5448b8c6925727a28ae080e5fe059110a70ba42a | Python | ryan-yang-2049/oldboy_python_study | /fourth_module/多线程多进程/new/多进程/13 JoinableQueue.py | UTF-8 | 1,127 | 3.109375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
__title__ = '13 JoinableQueue.py'
__author__ = 'yangyang'
__mtime__ = '2018.02.07'
"""
# 多个生产者,多个消费者
from multiprocessing import Process,JoinableQueue
import os, time, random
def consumer(q):
while True:
res = q.get()
time.sleep(random.randint(1, 3))
print("\033[45m %s 消费了 %s \033[0m... | true |
b98aa9dfeeb2d76bddb923c39b6d93382e516e5e | Python | dianarg/geopm | /integration/test/check_trace.py | UTF-8 | 4,076 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
#
# Copyright (c) 2015 - 2021, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, thi... | true |
0014792a1ae7455d3ab48bd9408ad8e901434d72 | Python | ashutoshkmr21/server_command_run_tool | /save_command.py | UTF-8 | 502 | 2.828125 | 3 | [] | no_license | import json
from util import read_json, SAVED_COMMANDS
def write_file(filename, data):
with open(filename, 'w') as saved_commands:
saved_commands.write(json.dumps(data, sort_keys=True, indent=4))
command_name = raw_input('Enter command name:').strip()
command = raw_input('Enter command with {} for paramet... | true |
2d3a01bfdcb5f8f98c0a375fae8b5475050eb35d | Python | ocefpaf/yodapy | /yodapy/datasources/datasource.py | UTF-8 | 1,101 | 2.5625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
class DataSource:
def __init__(self):
self._source_name = None
self._start_date = None
self._end_date = None
def __repr__(self):
return "Data Source... | true |
a84be55bb5e4fe20224a4006ec9ca691d4d60332 | Python | belleyork/hw2 | /hw2s.py | UTF-8 | 2,519 | 3.71875 | 4 | [] | no_license | num = int(
input('enter amount of matrices you would like to add, subtract, or multiply '))
#converts strings of numbers entered by users into integers
matricesList = ['d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
... | true |
75ec6decd8173ba5f1372b00e354fc111445ac69 | Python | cealexander/python4astro | /numpy_polyfit.py | UTF-8 | 1,332 | 3.375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
import sys
X = np.linspace(0,10,100)
# Line
# slope, y intercept
m = 0.5
b = 5
# Generate data with noise
np.random.seed(0)
lin_data = m*X + b + np.random.normal(0.0, 0.2, X.shape)
# Perform fit
lin_fit = np.polyfi... | true |
eaf9e9b96fffba5e7b22ba32de4f50b15ef552a8 | Python | monarch-initiative/ontogpt | /src/ontogpt/evaluation/go/eval_go.py | UTF-8 | 6,167 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | """Evaluate GO."""
from dataclasses import dataclass
from pathlib import Path
from random import shuffle
from typing import Dict, List
import yaml
from oaklib import get_implementation_from_shorthand
from oaklib.datamodels.obograph import LogicalDefinitionAxiom
from oaklib.datamodels.vocabulary import IS_A
from oaklib... | true |
9e62d43cee804547140fbedc6c9a172a77e0d8f3 | Python | Johannse1/assignment_12 | /Driver.py | UTF-8 | 3,776 | 4.375 | 4 | [] | no_license | # Evan Johanns
# assignment 12
# 4/21/2020
import re
choice = 0
# should print the menu after every action is made, unless user enters 11
while choice != 11:
my_string = input("Please type here: ")
print("Please select an action by typing the number.")
print(" 1. Does this contain 'q'?")
print(" 2. Doe... | true |
4105cd6086acf4354c8b35813065f4bb6d5f6ba6 | Python | kbm1422/husky | /.svn/pristine/2a/2ac5df4b6b9ca2c37d52a9b4c13a9d06f8304ba3.svn-base | UTF-8 | 1,402 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
logger = logging.getLogger(__name__)
import os
import time
import ImageGrab
import ctypes
import win32gui
from pywinauto import application
class RECT(ctypes.Structure):
_fields_ = [('left', ctypes.c_long), ('top', ctypes.c_long), ('right', ctypes.c_long)... | true |
327e00cec2be054809e146e3a3ec8ed9f1914ffb | Python | aclyde11/pytorch_example | /train.py | UTF-8 | 2,854 | 2.84375 | 3 | [] | no_license | from model import VAE
import numpy as np
from torch import optim
from torch.utils import data
from torch import nn
import torch
from tqdm import tqdm
# return a single sample perfectly
class DataSet(data.Dataset):
def __init__(self, x, y):
self.x = x
self.y = y
def __len__(self):
retur... | true |
48cf5463288626d4d953b0310931906ad138586d | Python | deadoggy/Centroid-Index | /src/test.py | UTF-8 | 2,040 | 2.796875 | 3 | [
"MIT"
] | permissive | import numpy as np
from centroid_index import _label_to_list
from centroid_index import _sum_orphan
from centroid_index import _center_as_prototype
from centroid_index import centroid_index
from sklearn.cluster import KMeans
def load_test_dataset():
data = []
ctr = []
with open('../dataset/s1.txt') as data... | true |
18f3cdf20382436f176d63e36ee2fbb9df421191 | Python | qjy981010/CRNN.pytorch.IIIT-5K | /utils.py | UTF-8 | 4,398 | 2.703125 | 3 | [] | no_license | import os
import pickle
import torch
import scipy.io as sio
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
from torchvision import transforms
from PIL import Image
from crnn import CRNN
class FixHeightResize(object):
"""
Scale images to fixed height
"""
def __init__(sel... | true |
645a894a8f0a31feb83773010fe664c70f83c722 | Python | KamarajuKusumanchi/sampleusage | /python/arbitrary_arguments.py | UTF-8 | 265 | 4.25 | 4 | [] | no_license | # Passing arbitrary number of arguments
def greet(*names):
"""This function greets all
the person in the names tuple."""
# names is a tuple with arguments
for name in names:
print("Hello", name)
greet("Monica", "Luke", "Steve", "John")
| true |
792f121b2f1157d213d7291b33d11eb2817f2cef | Python | rishabh108/Python_programs | /Subarray.py | UTF-8 | 621 | 3.703125 | 4 | [] | no_license | def subarray(arr):
max1 = 0 # stores maximum sum sub-array found so far
max2 = 0 # stores maximum sum of sub-array ending at current position
end = 0 #stores end-points of maximum sum sub-array found so far
Start = 0
beg = 0 #stores starting index of a positive sum sequence
f... | true |
d830f015ef6b9c948cc404dc29abb80923777a8d | Python | yuichiro-cloud/coder | /abc164/b.py | UTF-8 | 160 | 3.234375 | 3 | [] | no_license | a,b,c,d = map(int,input().split())
a2 = a
c2 = c
while True:
c2-=b
if c2 <= 0:
print('Yes')
exit()
a2-=d
if a2 <= 0:
print('No')
exit() | true |
1c79bf1c311afcc1123507cef371bb4a83c34876 | Python | kylebradley/NFL_twitter_analysis | /tweetExample.py | UTF-8 | 927 | 2.859375 | 3 | [] | no_license | '''
This is an example of usning tweepy to scrape Twitter Data based on a hashtag of your choice.
'''
import tweepy
import csv
import pandas as pd
CONSUMER_KEY = 'ltXoBgzF9LqA1M7XHDRhuGWEv'
CONSUMER_SECRET = '2J9nJ8XGYou050YHRJk5pTkAOmyhSeJ3jZlzhq2Dnyfn4YAFIJ'
ACCESS_TOKEN = '2899848858-YTSlSMiyxU2yHkWimjmLHjukUvmjNw... | true |
092256a696420fd5ecac598971c8b18a9baf183f | Python | Aasthaengg/IBMdataset | /Python_codes/p03805/s142424680.py | UTF-8 | 446 | 2.9375 | 3 | [] | no_license | from itertools import permutations
n, m = map(int, input().split())
edge = [[False] * n for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
edge[a-1][b-1] = True
edge[b-1][a-1] = True
res = 0
for t in permutations(list(range(1, n))):
l = list(t)
l.insert(0, 0)
flag = True
... | true |
44072c2663d71bf16b747c94f00a3ca997e3f71e | Python | nux123/painter | /com/test/painter/painter.py | UTF-8 | 1,038 | 2.984375 | 3 | [] | no_license | import pygame
from brush import Brush
from pygame.locals import *
from brushColor import BrushColor
from sys import exit
class Painter():
def __init__(self):
self.screen = pygame.display.set_mode((680,480),0,32)
self.time_passed = pygame.time.Clock()
self.brush = Brush(self.screen)
... | true |
1ecfcc9c74f5e03a415015e3bb70e2f34c3c4d37 | Python | etsakov/del_bot | /de_bot.py | UTF-8 | 5,235 | 2.5625 | 3 | [] | no_license | from datetime import datetime
from glob import glob
import logging
import pickle
import random
import time
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, RegexHandler, ConversationHandler
from telegram.ext.dispatcher import run_a... | true |
dfa65445f846423f55bbc63cb3a34ecaf2646cd3 | Python | Mario2334/OCR_Implementation | /vision_api/vision_api_pan_implementation.py | UTF-8 | 3,310 | 2.578125 | 3 | [] | no_license | from google.cloud import vision
from google.cloud.vision import types
import os
import re
# response = client.annotate_image({
# 'image': {'content': file,
# }, 'features': [
# {'type': vision.enums.Feature.Type.DOCUMENT_TEXT_DETECTION}]})
def parse_pan_no(text):
pattern = '[A-Z]{5}[0-... | true |
ca992fc322513314c4d0654c11515e03e90840fa | Python | thagberg/python-training | /truthiness.py | UTF-8 | 592 | 3.890625 | 4 | [] | no_license | #!/usr/bin/env python
truth_string = ""
if truth_string:
print "Empty string is true"
else:
print "Empty string is false"
truth_string = "not empty"
if truth_string:
print "Non-empty string is true"
else:
print "Non-empty string is false"
truth_integer = -5
if truth_integer:
print "Negative numbe... | true |
731234d0ed56cab40bc2f4d6bd26192887ecde79 | Python | Aasthaengg/IBMdataset | /Python_codes/p03387/s819371247.py | UTF-8 | 161 | 2.671875 | 3 | [] | no_license | A,B,C=map(int,input().split())
M=max(A,B,C)
tmp=M*3
Sum=A+B+C
Check=tmp-Sum
if Check%2==0:
ans=(tmp-Sum)//2
else:
tmp2=(M+1)*3
ans=(tmp2-Sum)//2
print(ans) | true |
8f19bebcd62f4fa5be8dab52ad657777fd3105e5 | Python | twohlee/python_basic | /basic/p1.py | UTF-8 | 843 | 3.234375 | 3 | [] | no_license | # 목록 확인22
# $ dir
# $ ls
# 디렉토리 이동
# $cd basic
# 파이썬 버전 확인 및 path 확인
# $ python -V **이 때 V는 대문자**
# => python 3.7.4
# 파이썬 구동(실행) 명령
# 1. $ python p1.py
# 2. 우클릭 > run python file in terminal
# 3. F5 > python 선택 (디버깅 모드)
# or 주피터 노트북으로 진행
print('hello world')
# 여러줄 주석 표현은 """ 주석으로 표현할 내용 """ <- 이렇게 표현
# 어떤 변수도 받지 ... | true |
eba66a4572efe1ac84584805b91d0310862313bd | Python | denizkarya1999/spectrum_database_system | /adminterminal.py | UTF-8 | 242 | 2.515625 | 3 | [] | no_license | import os
SpectrumAdmin = input("SpectrumAdmin@System: ")
if SpectrumAdmin == str("studentlist"):
os.system('studentlist.py')
elif SpectrumAdmin == str("exit"):
quit()
else:
print("Wrong")
os.system('adminterminal.py')
| true |
c3dd7a5faefd793cca2d0867b4f5923fc437d782 | Python | kartikeya-shandilya/project-euler | /python/207.py | UTF-8 | 393 | 3.203125 | 3 | [] | no_license |
from math import floor, log, sqrt
def getFrac(k):
num = log((1+sqrt(1+4*k))/2.0)//log(2)
den = (1+sqrt(1+4*k))//2-1.0
return num / den
check = 1/12345.0
def search(l,r):
print "searching...", l, r
m = (l+r)//2
y1 = getFrac(m)
y0 = getFrac(m-1)
if y1<check and y0>=check:
print m
return
elif... | true |
7c7a220e71c20f8894cc88c4fe8e4aab77b6ba2e | Python | zhaipro/acm | /leetcode/LCP11.py | UTF-8 | 105 | 2.53125 | 3 | [
"MIT"
] | permissive | class Solution:
def expectNumber(self, scores: List[int]) -> int:
return len(set(scores))
| true |
42c6f22af7abfb15c0d5bdd0b0008c5d1f0973ed | Python | matitalatina/randommet-telegram | /oracles/number.py | UTF-8 | 2,212 | 3.09375 | 3 | [
"MIT"
] | permissive | import random
import re
from oracles.oracle import Oracle
class NumberOracle(Oracle):
def handle(self):
message = self.update.message.text
message_wo_string_numbers = self.replace_text_numbers(message)
numbers = self.extract_numbers_from_string(message_wo_string_numbers)
len_numb... | true |
a46d902b12083521172efcb46bed35f7ee251ae7 | Python | Terry-Ma/Leetcode | /560-和为K的子数组-timeout.py | UTF-8 | 323 | 3.15625 | 3 | [] | no_license | class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:
res = 0
for left in range(len(nums)):
cur_sum = 0
for right in range(left, len(nums)):
cur_sum += nums[right]
if cur_sum == k:
res += 1
return r... | true |
28cee6590baecf2e094b2dda592408ad3fc337aa | Python | lakshmi2710/LeetcodeAlgorithmsInPython | /Q13ProductExceptSelf.py | UTF-8 | 503 | 2.6875 | 3 | [] | no_license | class Solution(object):
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
n = len(nums)
if(n == 0):
return
prodArray = [1]*n
prod = 1
for i in range(1,n):
prod = prod * nums[i-1]
... | true |
6385b27ad331f063508ac2e71fce63024a013b9b | Python | amikulichmines/AlgoBOWL | /input_gen.py | UTF-8 | 2,363 | 3.546875 | 4 | [] | no_license | import random as rand
import matplotlib.pyplot as plt
import numpy as np
def addUp(s, diff):
for element in s:
x = binary_search_boolean(s, diff-element)
if x:
return (s[x],element)
return False
# Complexity works out to O(nlog(n)) + O(nlog(n)), so just O(nlog(n))
def binary_se... | true |