blob_id large_string | language 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4649e8d590333ce0a2d8aa044ff96f680ee70a5d | Python | zhengjianyu/Stock-analyze-python-project | /webwork.py | UTF-8 | 1,990 | 3.3125 | 3 | [] | no_license | # Jianyu Zheng 33062456. ICS 32 Lab sec 5. Lab asst 3.
import urllib.request
def data(symbol, start_date, end_date) -> list:
'''takes the symbol and two dates and returns the information of the stock'''
try:
start = split_date(start_date)
end = split_date(end_date)
respon... | true |
e0c13678aa6f7e9f191c9c675dc47f1056abc59d | Python | JasonNDao/Card-Games | /Blackjack.py | UTF-8 | 18,540 | 2.96875 | 3 | [] | no_license | '''
@ author: Jason Dao
Blackjack Rules: Naturals pay 1.5 to 1, split blackjacks pay 1:1, insurance pays 2:1, no resplitting, can only double down on 9,10,or 11 ONLY, only one card given for each ace split
Info: 8 decks are used with a cut card mixed in
'''
import BlackjackSetup
from util.Cards import *
from Bla... | true |
8920df5f15607807d78e66225ca744dff780a236 | Python | DKassai/Artificial-Intelligence- | /AI_Assignment1/binary_heap/binary_heap.py | UTF-8 | 2,821 | 4.0625 | 4 | [] | no_license | import node as n
import math
floor = math.floor
class Heap():
def __init__(self, values=[]):
'''
Creates new Binary Min Heap of Node objects
Nodes can be added by passing the costs as a list into the constructor or by using the add method
'''
self.heap = []
for i i... | true |
e47cd0b487c43327963d8d5eb2c707a5396e89e3 | Python | backflipsciboy/ControlsHW | /homework_template_folders/e_ballbeam/python/hw8/ballController.py | UTF-8 | 912 | 2.65625 | 3 | [] | no_license | import numpy as np
import sys
sys.path.append('..') # add parent directory
import ballbeamParam as P
class ballController:
def __init__(self):
# Instantiates the PD object
self.kptheta = P.kptheta
self.kdtheta = P.kdtheta
self.kpz = P.kpz
self.kdz = P.kdz
... | true |
aca33ba7464494f3f78b8beec0b822d7d4a60589 | Python | frank-zzm/parsing_xml | /helpers2.py | UTF-8 | 449 | 2.8125 | 3 | [] | no_license | import xml.etree.ElementTree as ET
def get_xml_tag_tree(elem, indent = 0):
print(' ' * indent + elem.tag)
f.write(' ' * indent + elem.tag + '\n')
for child in elem.findall('*'):
get_xml_tag_tree(child, indent + 4)
if __name__ == '__main__':
tree = ET.parse("temp_arxml.xml")
r... | true |
195bfef5a55e3315ff56ba4f3b2fc65c2602d726 | Python | PKU-ComNet/school-fiesta | /crawler/school.py | UTF-8 | 2,421 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
class Program:
def __init__(self, data):
self.name = data['name']
self.url = data['url']
self.dept = data['dept']
if data.has_key('text'):
self.text = data['text']
def toJSON(self):
d = {}
d['name'] = self.name
d['url'] = self.url
d['dept'] = self.dep... | true |
57dbccfe26babefbfa366910295410fabd95b99a | Python | keiserlab/trans-channel-paper | /transchannel.py | UTF-8 | 47,785 | 2.78125 | 3 | [
"MIT"
] | permissive | """
This is the core of the necessary code to reproduce the main training and model evaluation results from the tauopathy dataset and the osteosarcoma dataset
This script is divided into three parts:
1) class and method definitions for main results
2) helper functions
3) supplemental code
"""
import torch
import torch... | true |
5214cc75f278d423555ff35625af8e85e94440ee | Python | yindao50/python100 | /python9.py | UTF-8 | 354 | 3.859375 | 4 | [] | no_license | #!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
题目:暂停一秒输出。
程序分析:需要time模块。
"""
import time
myD = {1:'A',2:'B'}
for key,value in dict.items(myD):
print key,':',value
time.sleep(1)#sleep表示程序等一段时间,什么都不干,不推荐使用
#实际效果就是,在输出1:A后,会等一秒在输出2:B | true |
a27955ab389c59dcd60feb648997cb375cc4737c | Python | minnie89/hello-world | /day4.py | UTF-8 | 1,582 | 3.9375 | 4 | [] | no_license | #99 Bottles of Beer on the Wall
# bottles = 100
# while bottles >= 3:
# bottles = bottles - 1
# print(str(bottles) + " bottles of beer on the wall, " + str(bottles) + " bottles of beer, we take one down, pass it around, " + str(bottles - 1) + " bottles of beer on the wall!")
# continue
# break
# bottles = 1
... | true |
2487535eefcc0bc3ddbccf799138de80e20d3923 | Python | mindis/DAA | /daa/historical_data.py | UTF-8 | 1,548 | 2.625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import yfinance as yf
data = yf.download( # or pdr.get_data_yahoo(...
# tickers list or string as well
tickers = "SPY VLUE QUAL SIZE USMV MTUM",
# use "period" instead of start/end
# valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
... | true |
d625eef4daef90cf30deced439a9ec4a646b0a17 | Python | lfq3300/pyhton | /猫眼电影/猫眼电影.py | UTF-8 | 2,448 | 3.03125 | 3 | [] | no_license | import requests
import re
import os
import urllib.request
#解析字符串获取标题等信息
def parse_one_page(url,headers,page):
try:
res = requests.get(url, headers=headers, timeout=20)
if res.status_code == 200:
html = res.text
pattern = re.compile('<dd>.*?board-index.*?>(\d+)</i>.*?data-src... | true |
d63aa2b0eaca1dccf231b7b24f57eed43f6e485c | Python | tsontario/minerva | /pkg/topiclearner/topiclearner.py | UTF-8 | 4,979 | 2.875 | 3 | [] | no_license | from yaml import load_all, dump_all
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
import sys
import os
import time
from itertools import chain
from more_itertools import divide
from collections import Counter
from ..vsm import VectorSpaceModel
... | true |
c38cba0a431a4b92f51e37cbe1f65375ac03f442 | Python | Isaccchoi/wiki | /word/templatetags/link_tag.py | UTF-8 | 974 | 2.640625 | 3 | [] | no_license | import re
from django import template
from django.template.base import VariableNode
register = template.Library()
@register.tag(name='addmark')
def add_mark(parser, token):
nodelist = parser.parse(('end_add_mark','endaddmark'))
parser.delete_first_token()
return MarkDown(nodelist)
class MarkDown(templ... | true |
c717c8c36eca46a6b6357949fa486b69a3c794d2 | Python | wovo/godafoss | /source/godafoss/gf_rectangle.py | UTF-8 | 2,151 | 2.921875 | 3 | [
"MIT"
] | permissive | # ===========================================================================
#
# file : gf_rectangle.py
# part of : godafoss micropython library
# url : https://www.github.com/wovo/godafoss
# author : Wouter van Ooijen (wouter@voti.nl) 2023
# license : MIT license, see license variable in the __init__.py
... | true |
88f1083fc82df7538be1b9940f16e089a1c8f1db | Python | bnbowman/pbhml | /pbhml/reader/HlaToolsReader.py | UTF-8 | 1,864 | 2.6875 | 3 | [] | no_license | __author__ = 'bbowman@pacificbiosciences.com'
from collections import namedtuple
from base import BaseTypingReader
from utils import sorted_set, sample_from_file
HlaToolsRecord = namedtuple('HlaToolsRecord', 'name glen gtype gpctid nmis indel clen ctype cpctid type')
class HlaToolsReader(BaseTypingReader):
"""
... | true |
548424dd7f90eea1c503365664a3ac88b762e473 | Python | kuh0729/Projects | /Autonomous_Vehicle/src/server.py | UTF-8 | 565 | 2.515625 | 3 | [] | no_license | # coding: utf-8
import socket
import time
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.bind(('localhost', 2345))
while True:
socket.listen(5)
client, address = socket.accept()
print ("{} connected".format( address ))
i =0
while True:
... | true |
9729482fd5633118fdd1a251a24c4597f4ba81ee | Python | Adriaandeklerk/Programmeertheorie | /Opdracht/class.py | UTF-8 | 1,278 | 3.640625 | 4 | [] | no_license | class Housing(object):
"""Different housing models
Attributes:
name: Name of housing type.
size: Size of housing in m2.
price: Price per housing unit.
total_space: Necessary space around each housing unit.
metervalue: Added relative value per extra meter space.
... | true |
10b92a094ad672378cc8af7570a6dc5a825e4725 | Python | m1kit/yalm-python | /examples/match_all_ids.py | UTF-8 | 2,134 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
import os
import sys
import argparse
from pathlib import Path
from configuration.config import PACKAGE_PATH
from normalize_license_text import normalizer
from compare_template_text.normalize_template_text import NormalizeTemplate
from compare_template_text.compare_normalized_files import compar... | true |
ecfb712d738aabf2f9e32074a7c485d3680424f5 | Python | kjh-pp/python_hw | /OOP/inheritance/inheritanceEx01.py | UTF-8 | 828 | 3.359375 | 3 | [] | no_license | # 사람 클래스
class Human:
def eat(self):
print('삼시세끼를 잘 먹자')
def sleep(self):
print('쿨쿨 자요')
def walk(self):
print('두 발로 걸어요')
def coding(self):
print('ctrl+c ctrl+v')
# 개 클래스
class Dog:
def eat(self):
print('사료를 맛있게 먹어요')
... | true |
f29cccf05e3024f04ef4cf10a103c184d8f4ecec | Python | wangfuli217/ld_note | /cheatsheet/编程笔记/07.Python/1.基础/1.9.coroutine.py | UTF-8 | 6,431 | 3.890625 | 4 | [] | no_license | https://github.com/18965050/fluent-python/wiki/Fluent-Python%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0(%E5%8D%81%E4%B8%80)
协程
协程和generator很像. 基本格式为:
var = yield [expression]
coroutine是generator的进一步发展:同调用者协同工作,从调用者接受数据并产生结果给调用者
协程和.send(),.throw(),.close()方法配合使用.
>>> def simple_coroutine(): #
...... | true |
7fe7896e17f54e1985590df4328c85d3cddb1c95 | Python | shadowkai0121/myNotes | /RawData/Python/190527/LearnOPENCV.py | UTF-8 | 1,229 | 3.171875 | 3 | [] | no_license | import cv2, time
# 離開視窗用
ESC = 27
# 儲存按鈕
save = 115
# 讀取圖片
load = 108
# 開啟第一個攝影機,需要確認攝影機是否已經開啟。
cap = cv2.VideoCapture(0)
# 設置攝影機畫面的比例。
cv2.namedWindow('video', cv2.WINDOW_AUTOSIZE)
# 設置長寬比
ratio = cap.get(cv2.CAP_PROP_FRAME_WIDTH) / cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
# 用來動態設置畫面大小並且維持視窗比例
WIDTH = 400
HEIGHT = ... | true |
6ebdc85429a8a1a0d0729404fea22d9ce90684e5 | Python | acaciooneto/cursoemvideo | /ex_videos/ex-071.py | UTF-8 | 551 | 3.921875 | 4 | [] | no_license | print('Seja bem-vindo ao bancú!')
saque = int(input('Digite o valor que você quer sacar: R$'))
valor = saque
cedula = 50
total_cedula = 0
while True:
if valor >= cedula:
valor -= cedula
total_cedula += 1
else:
if total_cedula > 0:
print(f'Vão ser {total_cedula} cédulas de R${... | true |
31c374f99d3a32c3892450f46cc497b6cd7cf9fe | Python | bhavinidata/DataStructuresAndAlgorithms | /ProjectEuler/rankPrime.py | UTF-8 | 814 | 4.4375 | 4 | [] | no_license | # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
# What is the 10 001st prime number?
import math
def isPrime(num:int) -> bool:
chkPrime = True
if num <= 1:
return False
elif num == 2:
return True
elif num % 2 == 0:
return F... | true |
6ba73b107cacfcf1906799a1b1b1a1528b3bd084 | Python | nil12285/xmlparser-quiz | /run.py | UTF-8 | 2,711 | 2.765625 | 3 | [] | no_license | #!/usr/bin/python
import sys, getopt, re
from api_rest import ApiREST
from xml.etree.cElementTree import iterparse
from helper import get_temp_file_object, printer
APIURL = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi'
def usage():
printer ('run.py -db <database> -id <identifier> -rgx <reg... | true |
2a2974dbfdc451afffe5a13e12d2412d8a0223e7 | Python | Ekpreet-kaur/python-files | /venv/python6.py | UTF-8 | 381 | 3.203125 | 3 | [] | no_license | ages1 = (10,20,30,40,50,60,30)
ages2 = [10,20,30,40,50,60,30]
ages3 = {10,20,30,40,50,60,30}
print(ages1,hex(id(ages1)),type(ages1))
print(ages2,hex(id(ages2)),type(ages2))
print(ages3,hex(id(ages3)),type(ages3))
#ps: tuple is immutable
# list is mutable
# set is mutable and unordered due to uniquenes
print(ag... | true |
57ac47c89ccddf988db983c397a65a5ecdb5b94a | Python | Ramasupramaniyan/myfiles | /pop_stack.py | UTF-8 | 606 | 3.65625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 6 06:23:29 2020
@author: RAMPRIYAN
"""
class Queue:
def __init__(self):
self.queue=list()
def inserttoq(self,dataval):
if dataval not in self.queue:
self.queue.insert(0,dataval)
return True
retu... | true |
f90130c96c8ad8d2978b3d649fe1b53e79f8795a | Python | joancarrillo/Python3JoseDom | /pildoras/adminstrador/ejemplo_subprocess.py | UTF-8 | 242 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python3
import subprocess
output = subprocess.check_output(["df","-h"])
for fich in output.decode().splitlines()[1:]:
datos=fich.split(" ")
while "" in datos:
datos.remove('')
print(datos[0]," - ",datos[4])
| true |
5accd7e79b1cc4e6bb06f2cfa171b7a0db3aebce | Python | ggayan/radiosity | /functions.py | UTF-8 | 5,888 | 2.546875 | 3 | [] | no_license | from numpy import *
from patch import *
from punto import *
from variables import *
# global patchesList
# recibe 2 parches i y j, retorna el F_ij (al parecer, F_ij != F_ji)
def formfactor(i,j,visib):
if(i==j):
return 0.0
p_i = patchesList[i]
p_j = patchesList[j]
# patchesList = ... | true |
027f4dd057f3b38720e5e61bd16dd8b8de015cb5 | Python | gbanegas/Red_with_mult | /temp/numberOfPolynomials.py | UTF-8 | 333 | 3.40625 | 3 | [
"Apache-2.0"
] | permissive |
def numberOfPolynomials(m, q = 2):
d = divisors(m)
sum_moebius = 0;
for i in d:
to_moebius = 1/i
r = moebius(to_moebius)*(q**i)
sum_moebius = sum_moebius + r
number = (1/m)*sum_moebius
print "Number of irreducible polynomials over ", q, "with degree ", m, " is ", number
... | true |
fa7bbc21cf7f296c64b0f8c66c16c24d6e123a0b | Python | dung98pt/chem_vae_branch | /smiles_to_onehot.py | UTF-8 | 1,571 | 2.5625 | 3 | [] | no_license | from keras.utils import to_categorical
import numpy as np
import os
# chuyển ma trận one-hot
# DICT = {'5': 29, '=': 22, 'N': 31, 'l': 16, 'H': 18, ']': 3, '@': 21, '6': 1, 'O': 17, 'c': 19, '2': 27, '8': 25, '3': 4, '7': 0, 'I': 15, 'C': 26, 'F': 28, '-': 7, 'P': 24, '/': 9, ')': 13, ' ': 34, '#': 14, 'r': 30, '\\': ... | true |
a8e211054bcd138fe98440b3c265b6d82b577302 | Python | sz313/public_transit_status | /producer/test_producer.py | UTF-8 | 670 | 2.78125 | 3 | [
"MIT"
] | permissive | from dataclasses import dataclass
import time
from models import Station, Turnstile, Weather
@dataclass
class Status:
name: str = 'test-status-name'
status = Status()
@dataclass
class Train:
train_id: str = 'test-train-id'
status: Status = Status()
station = Station(12345, 'pleasure house', 'yellow', ... | true |
c5a2dc3db37cb6c0c1bbd580c6a27365a6b89045 | Python | NanoDataCenter/nano_data_center | /presentations/session_4/graph_db_part_1/example_code/redis_graph_py3/serialize_graph_db_py3.py | UTF-8 | 700 | 2.703125 | 3 | [
"MIT"
] | permissive | import redis
import pickle
class Serialize_Graph:
def __init__( self, graph_db= 14 ):
self.redis_handle = redis.StrictRedis( host = "localhost", port=6379, db= graph_db , decode_responses=True)
def serialize_graph( self, out_file = "graph_db.pickle" ):
self.key_list = self.redis_handle.ke... | true |
e8671092aa733b0f07842c041ad56ba519c33b2e | Python | guysof8floor/Location-the-shops | /KNN_wifi_infos.py | UTF-8 | 2,854 | 2.796875 | 3 | [] | no_license | #coding:utf-8
import random
import math
import pandas as pd
from sklearn.cross_validation import train_test_split
# 提取训练集与测试集数据
def extracted_data():
user_behavior = pd.read_csv('ccf_first_round_user_shop_behavior.csv')
test = pd.read_csv('evaluation_public.csv')
X = user_behavior['wifi_infos']
y = us... | true |
87db001d1f8c1e047522dd95babf834283bbb305 | Python | miangangzhen/MachineLearningTools | /ANNs.py | UTF-8 | 5,180 | 3.046875 | 3 | [] | no_license | #!usr/bin/env python3
# -*- coding:utf-8 -*-
from __future__ import division
import numpy as np
import math
np.random.seed(1234)
# definition of sigmoid funtion
# numpy.exp work for arrays.
def sigmoid(x):
return 1 / (1 + np.exp(-x))
# definition of sigmoid derivative funtion
# input must be sigmoid function's res... | true |
e55728f258f37ee101e472e55cb59c98e6819f39 | Python | shaizpunjwani/AudioBook | /AudioBook.py | UTF-8 | 981 | 3.359375 | 3 | [] | no_license | import pyttsx3
import PyPDF2
class Read:
def __init__(self,filename,page):
self.filename=filename
self.page=page
def Page(self):
book=open(self.filename,'rb')
#we used imported module of pdf2 to read the file
pdf=PyPDF2.PdfFileReader(book)
#cal... | true |
1483cd6642bb2ddad9effbf0e402bc5a247ffe6e | Python | KyleGoyette/Stanford_CS231n | /assignment1/cs231n/classifiers/linear_svm.py | UTF-8 | 4,796 | 3.484375 | 3 | [] | no_license | import numpy as np
from random import shuffle
def svm_loss_naive(W, X, y, reg):
"""
Structured SVM loss function, naive implementation (with loops).
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
Inputs:
- W: A numpy array of shape (D, C) containing weights.
... | true |
5cc2b8d0d9ecd0470f6ee07f2399ab98e2b7398a | Python | polyactis/repos | /variation/trunk/src/Output2010SNPs.py | UTF-8 | 2,940 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python2.5
"""
Usage: Output2010SNPs.py [OPTIONS] -o OUTPUT_FILE
Option:
-z ..., --hostname=... the hostname, (papaya.usc.edu is default).
-u ..., --user=... the username, (otherwise it will ask for it).
-p ..., --passwd=... the password, (otherwise it will ask for it).
-o ..., output file
... | true |
b76f07173e4b71cfdd1df8c04624de369ade2dc8 | Python | BarrensZeppelin/humanize-gcode | /humanize_gcode/humanize_gcode.py | UTF-8 | 1,439 | 2.515625 | 3 | [
"MIT"
] | permissive | from collections import namedtuple
from typing import Dict
from requests_html import HTMLSession
GCode = namedtuple('GCode', ['name', 'description', 'long_description', 'arguments'])
def load_marlin_gcodes():
session = HTMLSession()
r = session.get('http://marlinfw.org/meta/gcode/')
d = {}
for gcode_row in r.... | true |
624d01d7d61189011ce98d0120690c638d628ccf | Python | HaguDeGozaru/hagu-tweet-bot | /hg_tweetfeeder/config.py | UTF-8 | 1,628 | 2.78125 | 3 | [
"MIT"
] | permissive | ''' Compile-time configuration data for hg_tweetfeeder.bot '''
from re import search
from tweepy import OAuthHandler
from .file_io import LoadFromFile
class Config:
''' Config data storage and processing for usage inside hg_tweetfeeder.bot '''
def __init__(self):
# EDIT THESE
tweet_time_string... | true |
423701644c7d26049603dbb3e21bfd6563928e37 | Python | brenopoggiali/rounds-cf | /620/D.py | UTF-8 | 75 | 3.0625 | 3 | [] | no_license | t = int(input())
for _ in range(t):
n, s = input().split()
n = int(n)
| true |
6eb6585aedf6eb4d40c2ac674f9aeb79f5a32b54 | Python | jmhy/CS265 | /Labs/Lab4/id.py | UTF-8 | 488 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env python
#
# id.py - reads ids, stores ids and names to a dict and prints the dict sorted by id
#
# Joseph Haggerty
import sys
argc = len( sys.argv )
if argc != 2:
print 'Specify exactly one file, the ids file'
quit()
ids = []
names = []
infile = file(sys.argv[1], 'r')
for line in infile:
ids.appe... | true |
e3658296b344e0596c99d3c5e387cfbd9ac01afc | Python | pamhrituc/cryptohack_scripts | /general/encoding_challenge/fromhex.py | UTF-8 | 132 | 2.515625 | 3 | [] | no_license | import sys
encoded = sys.argv[1]
flag = str(bytes.fromhex(encoded))[2:-1]
result = "{\"decoded\": \"" + flag + "\"}"
print(result)
| true |
c3a80b415812cd388637e06218186fb33db086d8 | Python | LimaRubson/atividades-laboratorio-programacao-I | /Lista_de_exercicio_05/questao02.py | UTF-8 | 1,134 | 4.25 | 4 | [] | no_license | '''
Crie uma agenda telefônica com os seguintes telefones:
Maria – 99887766
Pedro – 92345678
Joaquim – 99887711
Apresente ao usuário os nomes e telefones que já estão disponíveis na agenda e
pergunte se o usuário deseja:
a) Adicionar novo contato
b) Remover contato existente
'''
agenda_telefonica_list = [('Maria'... | true |
79f74a31abc771fea5d23443fade7fc36a7d1d29 | Python | pombredanne/OWL-RL | /RDFClosure/parsers/n3p/n3p.py | UTF-8 | 5,856 | 2.515625 | 3 | [
"W3C"
] | permissive | #!/usr/bin/env python
"""
N3P - An N3 Parser using n3.n3
Author: Sean B. Palmer, inamidst.com
Licence: GPL 2; share and enjoy!
License: http://www.w3.org/Consortium/Legal/copyright-software
Documentation: http://inamidst.com/n3p/
Derived from:
http://www.w3.org/2000/10/swap/grammar/predictiveParser.py
- predictiv... | true |
d08730a5a1a1cd478c2980ef308f38a24b5ea469 | Python | sebaraba/LinkPrediction | /algorithms/test_networkX.py | UTF-8 | 2,856 | 3.1875 | 3 | [] | no_license | import networkx as nx
import matplotlib.pyplot as plt
import csv
from networkx.algorithms import bipartite
with open('../data/test_csv.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
buyers = []
items = []
for row in readCSV:
buyers.append(row[6])
items.append(row[1])
ed... | true |
a151ad0be8d567a34b534e12f3481a8dc79d3813 | Python | fgrando/masters | /crypto/vigenere.py | UTF-8 | 933 | 3.296875 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/python
import sys
import re
# constants
ALPHABET = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ALPHABET_LEN = len(ALPHABET)
USAGE = "Usage: {} plaintext.txt somekey\nThe encryption uses this alphabet: {}".format(sys.argv... | true |
a98c716d03cfc8645c242a7982e105eccaf82427 | Python | rogerlucena/iar | /TDs/4-5/statistics.py | UTF-8 | 1,625 | 2.765625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
with open('log/1571393509.897512-TrialDurations-randomPersist.txt') as fh:
random_data = np.loadtxt(fh)
print("Random Median", np.median(random_data))
print("Random First Quartile", np.percentile(random_data,25))
print("Random Third Quartile", np.percentile(rando... | true |
217c43987196c51e6b6fda938bd47fb0fa175f4b | Python | pawan-shewale/handling-program-flow-in-python-code-along-practice | /code.py | UTF-8 | 5,608 | 3.03125 | 3 | [
"MIT"
] | permissive | # --------------
import json
from collections import Counter
with open(path) as f:
data = json.load(f)
print(type(data))
# Code starts here
class PlayerStat:
def __init__(self,batter,data):
self.batter = batter
self.data = data
def ball_faced(self):
for key,val in d... | true |
8a6b2175e986812a4e82a9350da09d85dcb76856 | Python | elenasacristan/file-io-vscode | /quiz.py | UTF-8 | 89 | 2.578125 | 3 | [] | no_license | f = open('data.txt', 'r')
#lines = f.readlines()
lines = f.read()
f.close()
print(lines)
| true |
f19801a61538ca3a08c30ac1571fee33f5b59b8d | Python | asmitde/TA-PSU-CMPSC101 | /Spring 2017/Homework/Homework3/Q3.py | UTF-8 | 820 | 4.53125 | 5 | [
"Apache-2.0"
] | permissive | # Question 3 - Variable name sanitization
# Asmit De
# 04/28/2017
# Input string
var = input('Enter a variable name: ')
# Assume var to be valid initially
valid = True
# Loop through the characters in the variable name
for ch in var:
# If the character is not an alphabet, digit or underscore
i... | true |
429485036e53b38c8dd1e3f2dda3fa4c18e0fc53 | Python | dcalds/MetodosNumericos | /Trapezio.py | UTF-8 | 559 | 4.21875 | 4 | [
"MIT"
] | permissive | # Algoritimo 13 - Trapézio (Integração Numérica)
import math
def a(x):
return math.exp(x)
def trap(n,x0,xn,f):
if n<0:
print("Divisão por zero")
else:
if n<0:
print("Intervalo Inválido")
else:
h = (xn-x0)/n
x = x0+h
s... | true |
7b4dcdc8552a499dcc25c123839c6c8676b3b584 | Python | jonathanslenders/cycli | /tests/test_completer.py | UTF-8 | 6,569 | 2.578125 | 3 | [
"MIT"
] | permissive | from __future__ import unicode_literals
import pytest
from prompt_toolkit.completion import Completion
from prompt_toolkit.document import Document
@pytest.fixture
def completer():
from cycli.completer import CypherCompleter
return CypherCompleter(
labels=["Movie", "Person"],
relationship_types... | true |
dd729d4ace58199933869f25b5d7c581e1183992 | Python | fillet0117/learn-pygame | /wobble.py | UTF-8 | 777 | 2.953125 | 3 | [] | no_license | import random
import pygame
import math
pygame.init()
windowSide = [400,300]
screen = pygame.display.set_mode(windowSide)
clock = pygame.time.Clock()
width = 200
height = 200
x = windowSide[0] / 2 - width / 2
y = windowSide[1] / 2 - height / 2
colour = pygame.color.Color('#5780F6')
black = pygame.color.Color('#00000... | true |
4c430dc0bc194fe9ece93a1c352eeecce3f2f5a9 | Python | seoul-ssafy-class-2-studyclub/GaYoung_SSAFY | /알고리즘/알고리즘문제/4865_글자수.py | UTF-8 | 443 | 2.5625 | 3 | [] | no_license | def my_set(data):
for i in data:
if
for t in range(int(input())):
str1 = input()
str2 = input()
str1_set = set(str1)
result = {}
for i in str1_set:
result[i] = 0
for j in list(''.join(str2)):
if j in i:
result[i] += 1
print('#%... | true |
d889c53ebccd28bcc70d334389f5f09e6648df12 | Python | agrawalshivam66/python | /NLP/stem_code_by_me.py | UTF-8 | 1,511 | 3.5 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 15 10:21:11 2019
@author: Shivam-PC
"""
from nltk.corpus import wordnet
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
ps = PorterStemmer()
new_text = 'Here is the perfect system for cleaning your room. First, move all of the items that do... | true |
0663b30fb7dacef6c6c0e3d6eb0188f2f2119981 | Python | Thandiwe-Khalaki/alx-higher_level_programming | /0x06-python-classes/3-square.py | UTF-8 | 583 | 4.25 | 4 | [] | no_license | #!/usr/bin/python3
# 3-square.py
"""Define a class Square."""
class Square:
"""Represents a square."""
def __init__(self, __size=0):
"""Initialize a new square.
Args:
__size (int): The __size of the new square.
"""
if not isinstance(__size, int):
raise... | true |
9b876982ae4b9b975c363ec56afc52c1bc850b03 | Python | chptcleo/PythonPractice | /com/date/count_days.py | UTF-8 | 410 | 3.421875 | 3 | [] | no_license | '''
@author: chenhuaping
'''
import datetime
def count():
year = input('input year: ')
month = input('input month: ')
day = input('input day: ')
date1 = datetime.date(year=int(year), month=int(month), day=int(day))
print(date1)
date2 = datetime.date(year=int(year), month=1 , day=1)
print(d... | true |
ebab16eed7d57429e1725e49fb8f3cfeb8892b51 | Python | taro-masuda/leetcode | /0206_ReverseLinkedList.py | UTF-8 | 663 | 3.296875 | 3 | [
"MIT"
] | permissive | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head == None:
return head
else:
pointer = head.next
l = [he... | true |
34d577f1ac7b4950586e93ce479e2d1f9f940f10 | Python | zhuwei233/Python-Data-mining-Homework | /Day-11/Excel文档读写-祝薇.py | UTF-8 | 1,278 | 2.703125 | 3 | [] | no_license | import xlrd
import json
import os
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
cols = []
def json_to_excel(jsfile, excfile):
a = 1
if os.path.exists(jsfile):
with open(jsfile, 'r',encoding='utf8') as fp:
line = fp.readline()
if not line:
print("没有... | true |
ef32cb72275f65560db1f0f08754b636f34afea5 | Python | mikolaje/leetcode_practice | /LinkedList/remove_duplicates.py | UTF-8 | 531 | 3.609375 | 4 | [] | no_license | # coding=u8
class Node(object):
def __init__(self, val=None):
self.val = val
self.next = None
def removeDups(head):
"""
Time Complexity: O(N)
Space Complexity: O(N)
"""
hashset = set()
prev = Node()
while head:
if head.val in hashset:
prev.next = h... | true |
24c2df17bed0db6584e3e3ed47d582bdb00cfe43 | Python | maxchv/LearnPython | /week12/examples/db/extract_sql.py | UTF-8 | 1,405 | 2.703125 | 3 | [] | no_license | movies = """1 Toy Story John Lasseter 1995 81
2 A Bug's Life John Lasseter 1998 95
3 Toy Story 2 John Lasseter 1999 93
4 Monsters, Inc. Pete Docter 2001 92
5 Finding Nemo Andrew Stanton 2003 107
6 The Incredibles Brad Bird 2004 116
7 Cars John Lasseter 2006 117
8 Ratatouille Brad Bird 2007 115
9 WALL-E Andrew Stanton 2... | true |
c3fc10c437b13e56fd612cfe7c169440e056800a | Python | baloda/msprites | /msprites/temp_file.py | UTF-8 | 122 | 2.8125 | 3 | [
"MIT"
] | permissive | class TempFile:
def __init__(self, name):
self.name = name
def cleanup(self):
os.unlink(self.name) | true |
4301e96c409fef8de77e0fc243ec023d8e7f7745 | Python | YANG007SUN/data_structure | /stack/medium/balanced_bracket.py | UTF-8 | 430 | 3.53125 | 4 | [
"Apache-2.0"
] | permissive | # https://www.hackerrank.com/challenges/balanced-brackets/problem
def isBalanced(s):
o = ['(','[','{']
d = {'}':'{',')':'(',']':'['}
stack = []
if s[0] not in o:return 'NO'
for i in s:
if i in o:
stack.append(i)
else:
if len(stack)==0: return 'NO'
... | true |
94cc6ca26cb0811535c6ce012c9d226b6907537e | Python | itbc-bin/1920-owe1a-afvinkopdracht2-BramUt | /NucleotideTeller.py | UTF-8 | 1,218 | 4 | 4 | [] | no_license | # Vragen naar de path van het fasta bestand en zet de inhoud ervan in een variabele
seq_path = input("FASTA path: ")
seq = open(seq_path)
sequentie = ""
# Filteren lines die beginnen met > en der whitespaces halen uit de rest
for regel in seq:
if ">" not in regel:
sequentie += regel.rstrip()
# Definiëren ... | true |
77009bf614a11ec9fd5d54f6d0ea8c24f116ca31 | Python | icemtel/stokes | /mesh/orient.py | UTF-8 | 1,619 | 3.875 | 4 | [
"MIT"
] | permissive | '''
'''
import numpy as np
def check_orientation(origin, points):
'''
*origin* is a point inside a (convex) shape
Meaning of orientation:
- look from origin to the triangle plane
- return True if the triangle points are oriented counter-clockwise, returns True (orientation is suitable for FBEM)
... | true |
ac56d6cfbf3731c6ea57b5b472d4fdf79e7d3ce0 | Python | rupamJoshi/DjangoImageProcessor | /projiproc/filestore/test.py | UTF-8 | 520 | 2.59375 | 3 | [] | no_license | import cv2
s_img = cv2.imread("puppeta.png")
l_img = cv2.imread("a.jpg")
x_offset=y_offset=50
l_img[y_offset:y_offset+s_img.shape[0], x_offset:x_offset+s_img.shape[1]] = s_img
y1, y2 = y_offset, y_offset + s_img.shape[0]
x1, x2 = x_offset, x_offset + s_img.shape[1]
alpha_s = s_img[:, :, 3] / 255.0
alpha_l = 1.0 - al... | true |
3b7a3ed4793f9bcd095fed1dc1fe3137bfdbd62b | Python | wangkai2014/rawdisk | /rawdisk/ui/cli/cli_mode.py | UTF-8 | 2,719 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | import logging
import os
from rawdisk.session import Session
from tabulate import tabulate
from cmd import Cmd
class CliMode:
@staticmethod
def start():
cli = CliShell()
cli.initialize()
cli.cmdloop()
class CliShell(Cmd):
def __init__(self, session=None):
super().__init__... | true |
d8440e95bcb09a1e32348717d929f5fb1d6e66fd | Python | tobias-fyi/challenges | /100DaysofX/01-Code/001_Python_CSV/001_csv_format.py | UTF-8 | 1,916 | 2.859375 | 3 | [
"MIT"
] | permissive | #! /anaconda3/envs/tobias_fyi/bin/python
# 100DaysofCode - Day 001
# 001_csv_format.py
# convert text fields to title case + format phone numbers
import os
import csv
import re
import time
def titlecase(s):
return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
lambda mo: mo.group(0)[0].upper() +
... | true |
628c794c0418b9105df2cb7de6feb3c615804c15 | Python | tango1542/Database-Project | /menu.py | UTF-8 | 1,799 | 3.828125 | 4 | [] | no_license | import os
from create import create_database
from insert import insert_database
from update import update_database
from delete import delete_database
from displayAll import displayAll_database
from inputDisplay import inputDisplay_database
def print_menu(): ## Your menu design here
print ("\nPlease Select a men... | true |
99cf27492ee364bd1d7e5741a16a4800978600bf | Python | jarvis-666/PythonPi | /decimal_module.py | UTF-8 | 1,428 | 3.765625 | 4 | [
"MIT"
] | permissive | from decimal import *
getcontext().prec = 1 # used to set the precision of the decimal numbers, default is 28
a = 0.1 + 0.2
print(a) # this is not accurate
b = Decimal(0.1) + Decimal(0.2) # this is a new datatype
print(b) # this gives precise results
b = float(b) # if we want to convert to... | true |
7ae58b43ece3949aef32235dd274dd0b44804f7e | Python | w0rm/pre-stonegarden-dev | /modules/translation.py | UTF-8 | 1,229 | 2.703125 | 3 | [] | no_license | """
Caches translations and provides _, n_, and N_
"""
import web
import gettext
from config import config
all_translations = dict()
def load_translation(lang):
"""Load translation or create it and then loads."""
if lang in all_translations:
translation = all_translations[lang]
elif lang is None:... | true |
297a11a23b2606d59fcc63bb38d0c90beb425316 | Python | meetchen/something | /Student achievement management system/teacher_windows.py | UTF-8 | 3,482 | 2.640625 | 3 | [] | no_license | import tkinter as tk
import data_porcess as dao
from tkinter import ttk
import os
import tkinter.messagebox
def teacher_windows(data):
teacher_windows = tk.Tk()
teacher_windows.attributes("-alpha", 1)
teacher_windows.title('XXXXXXXX学校学生成绩管理系统')
teacher_windows.geometry('1000x500')
data = data[0]
... | true |
024661d9fa3548ebb5a4a4ff5ebfd93652cca962 | Python | pritishgupta09/Acadview-assignments-Intro-to-python- | /Important Methods.py | UTF-8 | 1,669 | 4.78125 | 5 | [] | no_license | #Q.1) Reverse a list using list methods
n=int(input("Enter the size of the list: "))
list=[]
for i in range(0,n):
a = int(input("Enter the elements: "))
list.append(a)
print("List is: ",list)
print("Reverse list is: ",list[::-1])
#Q.2)Print all the uppercase letters from the string
str=input("Enter a string:... | true |
39758f2dff97914e5bceb43781f0773078b4c17f | Python | exuuwen/study | /document/program/script/python/code/learn/class/school.py | UTF-8 | 796 | 3.84375 | 4 | [] | no_license | #!/usr/bin/python
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
print "initialize the %s" %self.name
def __del__(self):
print "%s say bye" %self.name
def sayhi(self):
print "%s say hi" %self.name
class Teacher(Person):
def __init__(self, name, age, salar... | true |
a45f7ab931346eba0e289134bc64b7ec7f065a40 | Python | rpm4real/foobar-rpm4real | /set3/minion3_1.py | UTF-8 | 1,554 | 3.203125 | 3 | [] | no_license | from fractions import gcd
def answer(M,F):
m = int(M)
f = int(F)
if m==1 and f==1: return 0
result = euc(m,f)
if result == 0: return "impossible"
else: return result
def euc(a, b):
iters = 0
if a==1 or b==1: return abs(a-b)
#print a,b
while a>1 and b>1:
mult = a/b
a, b = b, a%b
iters += mult
#print... | true |
fd80d467a36a5dbb2f2569928976ee4f97a4ef62 | Python | gmnr/advent-of-code | /2018/22/day22.py | UTF-8 | 1,891 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Solution for day22 2018
"""
__author__ = 'Guido Minieri'
__license__ = 'GPL'
with open('input.txt', 'r') as f:
data = f.read().splitlines()
import heapq
def get_index(coord, caves, target, depth):
x, y = coord
if coord == (0, 0) or coord == target:
... | true |
126b4ad4715e35e9c69971db85b39b3b268a81ad | Python | trevorsummerssmith/vinge | /vinge/tests/test_tokens.py | UTF-8 | 2,239 | 2.75 | 3 | [] | no_license | from vinge.tokens import *
class TestTokens:
def test_is_uuid_id(self):
id = "200d9d90-f544-11e1-a21f-0800200c9a66"
assert is_token_id(id)
def test_is_urn_id(self):
id = "urn:okthen/blah:okthen/foo82i2-ak"
assert is_token_id(id)
def test_part_of_a_uuid_is_not_an_id(self):
... | true |
3703e0bd547f5b1c9ff0e88e0ec6b3b1f057f4b5 | Python | KJagiela/chess-position-evaluation | /poseval/common/transformations.py | UTF-8 | 8,032 | 2.8125 | 3 | [
"MIT"
] | permissive | import numpy as np
class MalformedFenStringError(Exception):
pass
class AlreadyWhiteError(Exception):
pass
class DataSpecs:
tensor6x8x8_sparse = 'tensor6x8x8'
vector6x8x8_flat = 'vector6x8x8'
tensor12x8x8_sparse = 'tensor12x8x8'
vector12x8x8_flat = 'vector12x8x8'
piece2layer_for_6x8x8... | true |
daca1dc71edaf9963e31e1170795003190f40165 | Python | diekhans/pipettor | /lib/pipettor/devices.py | UTF-8 | 8,233 | 2.890625 | 3 | [
"MIT"
] | permissive | # Copyright 2006-2015 Mark Diekhans
"""
pipettor interfaces to files and pipes, as well as some other IPC stuff.
"""
import os
import errno
import threading
from pipettor.exceptions import PipettorException
# note:
# A problem with python threads and signal handling is that SIGINT (C-c) will
# not raise an exception ... | true |
4a9e59401fac17c4104081bbd8d2b953fbef0d22 | Python | gnilps/mcwarn | /mcwarn.py | UTF-8 | 4,951 | 2.5625 | 3 | [
"MIT"
] | permissive | import asyncio
import re
import shelve
import discord
import praw
from credentials import redditcreds, discordcreds
# Initialize reddit connection
reddit = praw.Reddit(client_id=redditcreds['id'],
client_secret=redditcreds['secret'],
password=redditcreds['password'],
... | true |
50851199efd7b8f35081adcfa40e4f2a3e16904a | Python | mayur-jagtap/Hacktoberfest | /Basic Programs/Python/Strings/string_slicing.py | UTF-8 | 307 | 3.71875 | 4 | [] | no_license | greeting="good morning,"
name="ALPHA"
# print(type(name))
# concanicating two string
c=greeting+name
print(c)
print(name[2])
print(name[1:4])
#name[3]="d"-->does not work
print(name[:4]) # is same as name [0:4]
print(name[1:])# is same as name[1:5]
c=name[-4:-1] #is same is name[1:4]
print(c) | true |
ec74392bdfb0c793c9193a786b1c37fecfda6981 | Python | awbdallas/awbdallas-cogs | /league/league.py | UTF-8 | 3,833 | 2.625 | 3 | [] | no_license | import discord
import aiohttp
import os
from discord.ext import commands
from json import loads, dumps
from cogs.utils.dataIO import dataIO
from cassiopeia import riotapi
from cassiopeia.type.core.common import LoadPolicy
"""
TODOS:
Want to add timed strawpoll?
"""
file_path = 'data/league/accounts.json'
endpoint = ... | true |
74c9da6e76d9c5ceef71f86b5c856ff7e4e5eb94 | Python | borislavstoychev/Soft_Uni | /soft_uni_fundamentals/Dictionaries/lab/03_statistics.py | UTF-8 | 464 | 3.671875 | 4 | [] | no_license | products = {}
while True:
commands = input()
if commands == "statistics":
break
key, value = commands.split(": ")
value = int(value)
if key not in products:
products[key] = value
else:
products[key] += value
print("Products in stock:")
for (key, value) in pr... | true |
322e679b922c3999f8122aba7048f9052b56bcae | Python | smehra3/Breast-Cancer-Diagnosis-Classifier | /Breast Cancer Classifier.py | UTF-8 | 6,792 | 3.84375 | 4 | [] | no_license | import numpy as np
import pandas as pd
from sklearn.datasets import load_breast_cancer
cancer = load_breast_cancer()
print(cancer.DESCR) # Print the data set description
# The object returned by `load_breast_cancer()` is a scikit-learn Bunch object, which is similar to a dictionary.
cancer.keys()
type(cancer)
np... | true |
32903416449fd3452f79442ba2007fc275ca03d7 | Python | biellls/streamlitNeuralNetworks | /plotting.py | UTF-8 | 402 | 2.8125 | 3 | [] | no_license | from typing import Callable, Tuple
import matplotlib.pyplot as plt
import numpy as np
import streamlit as st
def plot_equation(f: Callable[[float], float], linspace: Tuple[float, float] = (-50., 50.)):
x = np.linspace(0.2, *linspace)
fig, ax = plt.subplots()
ax.plot(x, f(x))
ax.grid(True, which='bot... | true |
3f70f3d7d326de49af4d205a4f41df8b9135fd96 | Python | kingflyfly/python_study | /第6章-函数/6.5.py | UTF-8 | 472 | 3.265625 | 3 | [] | no_license | x = 1
print (x)
scope = vars()
scope['x']
scope['x'] += 1
print (x)
def foo():x = 2
x = 1
foo()
x
print (x)
def output(x):print (x)
x = 2
y = 5
output(y)
output(x)
x = "sdfsdf"
def huibing(h):print(h+x)
huibing("ninhao")
print
def combine(parameter):
print(parameter + globals()['parameter'])
parameter = 'berry'
co... | true |
d37a985bf36bb72fa8ba44440eadaca2af17faa5 | Python | csm10495/AzInfo | /az_info.py | UTF-8 | 5,526 | 2.84375 | 3 | [] | no_license | '''
a sketchy script that tries to recursively get info about an azure resource
MIT License - Charles Machalow
'''
import argparse
import dataclasses
import logging
import json
import subprocess
import typing
from concurrent.futures import ThreadPoolExecutor
logger = logging.getLogger(__file__)
AzIn... | true |
5d4978b70e3933a0814c0ac8175c9b4a7124fb31 | Python | Aasthaengg/IBMdataset | /Python_codes/p02918/s764538913.py | UTF-8 | 152 | 2.71875 | 3 | [] | no_license | # ABC140 D
N,K=map(int,input().split())
S=input()
s=''
happy=0
for i in range(N):
if s==S[i]:
happy+=1
s=S[i]
print(min(happy+2*K,N-1)) | true |
8ee007a9db96a1f591421531f057908603d88990 | Python | mkmozgawa/ecc | /Message.py | UTF-8 | 1,328 | 2.796875 | 3 | [] | no_license | import binascii
from helpers import generate_random_number, get_y_2, get_legendre_symbol_value, get_root_from_legendre, get_hash_sha256_hex, get_hash_sha256_bytes
from EPoint import EPoint
class Message:
def __init__(self, message_ascii):
self.__text = message_ascii
self.__number = int(bin(int.fr... | true |
77d11cc31eab3eab2db4dcbf6ad81177875e9699 | Python | jqu224/Fan_hhkr101 | /6_math/3_Integers.py | UTF-8 | 1,764 | 4.3125 | 4 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
power mod,
two function with different input arguments: 2 arguments or 3 arguments
if 2 arguments: pow(a,b) == a**b == a^b
with 3 arguments: pow(a,b,w) == (a**b)%w == mod(a**b, w)
# solution a
a = int(input())
b = int(input())
c = int(input()... | true |
f46f745d1255b134c4fa9ed2de8904285c94d7c6 | Python | vaishnav67/WebMining | /7. Inverted Index/inv_ind.py | UTF-8 | 1,637 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
def tokenize(file):
read = file.read()
file.seek(0)
punc = '''!()-[]{};:'"\, <>./?@#$%^&*_~'''
for ele in read:
if ele in punc:
read = read.replace(ele, " ")
read=read.lower() ... | true |
a11e707076f96f3c94811902a06519b3bb467f7b | Python | arek-czerwinski/algorithms-in-python | /chapter_3/exercises.py | UTF-8 | 849 | 3.78125 | 4 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import math
# R-3.1
def plot_function(math_functions):
x = np.arange(0, 1000, 0.1)
fig, ax = plt.subplots()
for f in math_functions:
y = [f[0](x_element) for x_element in x]
ax.plot(x, y, label=f[1])
# ax.set_yscale('log') # enable... | true |
5ce0e87b7ea9a8788612d3a92ee0ee94a9539e82 | Python | agrawal-prateek/Gramener-Flask | /task3.py | UTF-8 | 200 | 3.234375 | 3 | [] | no_license | if __name__ == '__main__':
L1, L2 = ['a', 'b', 'c'], ['b', 'd']
print('Common Elements in L1 and L2 =', set(L1).intersection(L2))
print('Present in L1 but not in L2 =', set(L1) - set(L2))
| true |
296fea3845c76bf9f9b90bc7de9247ec80dcf688 | Python | srajangarg/moodle-sync | /mfunctions.py | UTF-8 | 1,974 | 2.71875 | 3 | [] | no_license | import os
class MyFile:
URL=""
Name=""
Extension=""
Course=""
Type=""
def download(self,BASEDIR,HTTPSession):
if not os.path.exists(os.path.join(BASEDIR, self.Course, self.Type)) :
print "Made " + self.Course + "/" + self.Type
os.makedirs(os.path.join( BASEDIR, self.Course, self.Type))
if os.path.... | true |
3e87f570a690801ff8d859a7f72f358d499c2e2f | Python | jilljenn/das3h | /utils/this_queue.py | UTF-8 | 1,034 | 3.203125 | 3 | [
"MIT"
] | permissive | class OurQueue:
"""
A queue for counting efficiently the number of events within time windows.
Complexity:
All operators in amortized O(W) time where W is the number of windows.
From JJ's KTM repository: https://github.com/jilljenn/ktm.
"""
def __init__(self):
#self.now = None
... | true |
d2b3e546e677f5e79808e2dce12e8dcff0432b56 | Python | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/17_10.py | UTF-8 | 1,377 | 4.4375 | 4 | [] | no_license | Python program to find the power of a number using recursion
Given a number N and power P. The task is to write a Python program to find
the power of a number using recursion.
**Definition:** The power of a number can be defined as multiplication of the
number repetitively the number of times of its power.... | true |
bacf7fd048778a50c3bc38c9303907be066ae5c0 | Python | ola-sk/Full-Stack-Nanodegree-Udacity | /MODULE_1/psycopg2_intro/psycopg2-app.py | UTF-8 | 2,882 | 2.9375 | 3 | [
"MIT"
] | permissive | import psycopg2
from psycopg2.extensions import AsIs
from psycopg2 import sql
from psycopg2 import extensions
# dbname – the database name, needs to exist already [`database` is a deprecated alias]
# user – user name used to authenticate
# password – password used to authenticate
# host – database host address (defau... | true |
b40b3ee48e21aa04233972e6cd9f89e312d1a493 | Python | chromy/ferrous | /tests.py | UTF-8 | 399 | 2.5625 | 3 | [] | no_license | #! /usr/bin/env python
import os
from cmdtest import Program
abspath = os.path.abspath
fe_path = abspath('./fe')
fe = Program(fe_path)
@fe.test
def should_evaluate_constants():
fe(_in='1')
p = Program('./a.out')
assert '1' in p().out
@fe.test
def should_evaluate_sums():
fe(_in='1+2')
p = Program(... | true |
4623ec0a91c90aa8173c2ff47a3609dae283ca23 | Python | rafaelpascoalrodrigues/programming-contests | /uri-online-judge/python3/1021.py | UTF-8 | 1,498 | 3.34375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# https://www.urionlinejudge.com.br/judge/en/problems/view/1018
def decompose(total, value, rate = 1):
decomposed = int(total * rate // value)
return (total * rate - decomposed * value) / rate, decomposed
def main():
MONEY = float(input())
MONEY, NOTES_100 = decompose(MON... | true |
e194726ee5baffb445c99cc99df9239e734e4b68 | Python | lcy1254/Lung_Nodule_Segmentation | /FPR_Model/no_aug_volume.py | UTF-8 | 6,772 | 2.859375 | 3 | [] | no_license | '''
load data & preprocess & perform augmentation
adapted from https://github.com/shervinea/enzynet and https://keras.io/examples/vision/3D_image_classification/
'''
import tensorflow as tf
from tensorflow import keras
import numpy as np
from scipy import ndimage
import os
import h5py
import random
class DataGenerato... | true |