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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
965aa705c9603a5e1bfc3a3178bab0d87412086d | Python | Crastchet/DeezerToRekordbox | /main.py | UTF-8 | 4,340 | 2.515625 | 3 | [] | no_license | #!/usr/bin/python
# -*-coding:utf-8 -*
import requests
import json
from lxml import etree
import sys
def getPlaylists_Id_Title_FromUser(userId):
requ = requests.get('https://api.deezer.com/user/{}/playlists'.format(userId))
resp = requ.json()
playlists_id_title = []
for playlist in resp['data']:
... | true |
0890485ae911c89d3bf8bfb60e15400d8d1afd45 | Python | MatiNem/Intro_Biocom_ND_319_Tutorial7 | /exercise7.py | UTF-8 | 614 | 3.234375 | 3 | [] | no_license | import pandas
InFile=open("Lecture11.fasta","r")
sequenceLength=[]
percentGC = []
for line in InFile:
line = line.strip() #remove extra space
if ">" in line:
next
else:
sequenceLength.append(len(line)-1)
percentGC.append(1.0*(line.count("G")+line.count("C"))/len(line))
print(percent... | true |
abcbe962aa44ccc98624f1e88bb53220a212d82a | Python | Shoshin23/A-Crawler | /linkfetcher.py | UTF-8 | 1,731 | 2.5625 | 3 | [] | no_license | #! /usr/bin/env python
from BeautifulSoup import BeautifulSoup
from cgi import escape
import sys
import urllib2
import urlparse
__version__ = "0.0.1"
Agent = "%s/%s" % (__name__, __version__)
class Linkfetcher(object):
def __init__(self, url):
self.url = url
self.urls = []
def _addHeaders(s... | true |
0e9586d212b4d6e2f4a741c4bdb08fa78a395141 | Python | vricha216/Projects | /resume.py | UTF-8 | 4,757 | 2.921875 | 3 | [] | no_license | Header = '>>>This resume is totally made up with the help of python.'
Name = 'Richa Verma'
Title = 'vricha211697@gmail.com'
Contact = '632607'
add ='Lakhimpur-Kheri'
SkillsHeader = 'SKILLS'
SkillsDesc= '. Python\n. C\n. DBMS\n. Creative Thinking\n. SQL\n. Operating System\n. Data Structure and Algorithms\n. Mathematics... | true |
e2d49ea3761ac85485ada7345b2ce7893b9c179f | Python | znnznn/coursera | /week3/сложний процент.py | UTF-8 | 254 | 3.15625 | 3 | [] | no_license | import math
p = float(input())
x = float(input())
y = float(input())
k = int(input())
i = 0
m = x * 100 + y
while k > i:
m1 = ((m * (100 + p)) / 100)
m = int(m1)
x = int(m1 // 100)
y = int(m1 - (x * 100))
i += 1
print(int(x), int(y))
| true |
36a3c7f537076ba23975d6d29a40206a5e4f7bfe | Python | MatthewZhuang/ML | /classifier/test.py | UTF-8 | 1,101 | 2.546875 | 3 | [] | no_license | if __name__ == '__main__':
# pcti = [1] * 2
# pct = [pcti for i in range(3)]
# print pct[2][1]
# print 1/float(2)
#
# pc = [0]*5
# pc[0:3] = [1]*3
# pc[3:5] = [2]*2
# print pc
# import re
# s = 'hello999.'
# res = re.findall('[0-9\.]', s)
# for re in res:
# s ... | true |
50191052b26f1c8a27f4c0dd14122819712bd6c8 | Python | Tusharsaxena3112/Sorting_in_Python | /bubble_sort.py | UTF-8 | 160 | 3.046875 | 3 | [] | no_license | l = [1, 3, 5, 1, 4, 1]
for i in range(len(l)):
for j in range(1, len(l)):
if l[j - 1] > l[j]:
l[j - 1], l[j] = l[j], l[j - 1]
print(l)
| true |
aa1c125d5f79cbd7fa5f5902b9e06f90daec91f1 | Python | radup99/wc.py | /check_arguments.py | UTF-8 | 2,854 | 3.109375 | 3 | [] | no_license | import sys
default_options = { # if no options are specified through command line
"-l": True,
"-w": True,
"-c": True,
"-m": False,
"-L": False,
}
long_options = {
"--lines": "-l",
"--words": "-w",
"--bytes": "-c",
"--chars": "-m",
"--max-line-length": "-L"
}
def check_argume... | true |
8522e007d49b0a9b05936445645452786b4818f9 | Python | luheeslo/design_patterns_python | /Work/commandv2.py | UTF-8 | 607 | 3.84375 | 4 | [] | no_license | # Command
def buy_stock_order(stock):
stock.buy()
# Command
def sell_stock_order(stock):
stock.sell()
# Receiver
class StockTrade:
def buy(self):
print("You will buy stocks.")
def sell(self):
print("You will sell stocks.")
# Invoker
class Agent:
def __init__(self):
sel... | true |
68ac49f324e7461e092abfd2832380172b15292f | Python | oldman3483/Parrot-groundSDK | /out/olympe-linux/staging/usr/lib/python3.6/site-packages/olympe/doc/examples/maxtilt.py | UTF-8 | 972 | 2.546875 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
from __future__ import print_function # python2/3 compatibility for the print function
import olympe
from olympe.messages.ardrone3.PilotingSettings import MaxTilt
DRONE_IP = "10.202.0.1"
if __name__ == "__main__":
drone = olympe.Drone(DRONE_IP)
drone.connect()
maxTiltAction = dro... | true |
e1dc319118cfe2716f6bad76177e283e0b555058 | Python | AniluaR07/AniluaR07.github.io | /AniluaR.py | UTF-8 | 1,046 | 4.1875 | 4 | [] | no_license | import random
# A list of words that
potential_words = ["Masterpiece", "Monster", "Computer", "Improvements", "juice"]
word = random.choice(potential_words)
caracters = len(word)
# Use to test your code:
# print(word)
# Converts the word to lowercase
word = word.lower()
# Make it a list of letters for someone to g... | true |
0ea61b2a13df4fcfeebe5ea52e9f67bcad04dfda | Python | arunachalamev/PythonProgramming | /Algorithms/LeetCode/L0198rob.py | UTF-8 | 336 | 3.1875 | 3 | [] | no_license |
def rob(nums):
if len(nums) ==0: return 0
if len(nums) ==1: return nums[0]
if len(nums) == 2: return max(nums[0],nums[1])
prevPrev, prev = 0, 0
for index,value in enumerate(nums):
current = max(prev, prevPrev+value)
prevPrev= prev
prev= current
return current
print(r... | true |
c974cbbbc0f098b4d188d8cee606646df515128a | Python | abdullateef28/c_l_project_shoyinka_lateef | /list 2.py | UTF-8 | 1,227 | 2.78125 | 3 | [] | no_license | Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============= RESTART: C:/Users/Asus-PC/Documents/phyton/list.py =============
>>>
>>>
============= RESTART: C:/Users/Asus-PC/Documents/phyt... | true |
97640777b50e34707eff39b0e24e4ac6b740627b | Python | Interstellar300/Sudoku-solver | /tool.py | UTF-8 | 1,783 | 3.015625 | 3 | [] | no_license | import Model.model as md
import Utils.find_digit as fd
import Utils.solve as s
import Preprocess.preprocess as pp
from torchvision import transforms
import argparse
import cv2
import numpy as np
import torch
def find_numbers(cells_raw):
cells = []
for cell in cells_raw:
cell = fd.get_digit(cell)
... | true |
3cdad3222ce7374a6bbb2f39aa7d03e10837951c | Python | angeloasl/Projeto-D.O.G | /mestrecerto.py | UTF-8 | 1,789 | 2.6875 | 3 | [] | no_license | #include <Ultrasonic.h>
#include "SoftwareSerial.h" // Inclui a biblioteca SoftwareSerial
Ultrasonic ultrassomPortaCasa(7, 6); // define o nome do sensor(ultrassom)
Ultrasonic ultrassomPortaGaragem(5, 4);
SoftwareSerial blackBoardSlave(2,3); // (RX, TX)
bool dog = false;
const int ledVerde = 11;
const int botao_sistema... | true |
a4b61ed81d92aa831bf8b48fb3fda959cfd9c3d3 | Python | abnoviello23/GeminidSystemsPython | /Script1_PyCharm.py | UTF-8 | 438 | 2.765625 | 3 | [] | no_license | import csv
import json
peopleCSV = open('people.csv')
reader3 = csv.reader(peopleCSV, delimiter=',')
final_csv2 = list(reader3)
region_list = []
found = -1
state_to_region = open('state_to_region.json')
state_data = json.load(state_to_region)
for x in range(len(final_csv2)):
for i in state_data:
found = final_csv... | true |
500a480a0966367232e44a9c9795065b09a32b55 | Python | luchuynh/FaceIdentify | /FaceIdentify.py | UTF-8 | 6,387 | 2.65625 | 3 | [] | no_license | import cv2
from Tkinter import *
import numpy as np
import os
import tkMessageBox
bin_n = 16
# chuyen anh xam
# ten
ten =["",]
# phat hien khuon mat
def detect_face(img):
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
face_cascade = cv2.CascadeClassifier('D:\\OpenCV\\opencv\\build\\etc\\haarcascades... | true |
685a74f7e8fb44455969c0cf3f1afcf01af5d877 | Python | ffpy/Raspbian-Tools | /cpu_status.py | UTF-8 | 522 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import re
import time
def get_cpu_temp():
'''获取CPU温度,单位:摄氏度'''
return os.popen('vcgencmd measure_temp').read().strip()[len('temp='):-len("'C")]
def get_cpu_used():
'''获取CPU使用率'''
s = os.popen("top -n 2 -b").read().strip()
return re.search(r... | true |
4694e13493175947b62fd7beeeb5ec007686e132 | Python | ivaneyvieira/pythonJango | /json_grava.py | UTF-8 | 124 | 2.75 | 3 | [] | no_license | import json
arquivo = open('arquivo.json', 'w')
json.dump(32.3, arquivo)
json.dump([1, 4, 5, 6], arquivo)
arquivo.close() | true |
bd47b72ace3ef8bdbc7a84ce82da527e34e1c750 | Python | rasql/tk-tutorial | /docs/intro/intro.py | UTF-8 | 828 | 3.15625 | 3 | [] | no_license | import tkinter as tk
import tkinter.ttk as ttk
class Label(ttk.Label):
"""Create a Label object."""
def __init__(self, text='Label', **kwargs):
super().__init__(App.stack[-1], text=text, **kwargs)
self.grid()
class Button(ttk.Button):
"""Create a Button object."""
def __init__(self, te... | true |
aadf29724c85cf48545a2b16b0a30418f400cff5 | Python | alon-benari/NewLariat | /LariatProject/LariatApp/forms.py | UTF-8 | 5,614 | 2.640625 | 3 | [] | no_license | from django import forms
from .models import Patient
class PatientForm(forms.ModelForm):
"""
A form to capture data from a patient
"""
YES = 1
NO = 0
MALE = 0
FEMALE = 1
ONE = 0;TWO = 1;THREE = 2;FOUR = 3;FIVE=4
YES_NO= ((YES,'yes'),(NO,'no'))
GENDER = ((MALE,'male'),(FEMALE,'fe... | true |
dd6dd0657475d3472b26a3471b0f9607616ac6b0 | Python | muhrin/apricotpy | /apricotpy/messages.py | UTF-8 | 6,907 | 3.15625 | 3 | [
"MIT"
] | permissive | from collections import namedtuple
import threading
import re
_WilcardEntry = namedtuple("_WildcardEntry", ['re', 'listeners'])
class Mailman(object):
"""
A class to send messages to listeners
Messages send by this class:
* mailman.listener_added.[subject]
* mailman.listener_removed.[subject... | true |
6e88f65740323784be16d36b066e9e65322549a5 | Python | doubledave/botxxy | /src/skeleton.py | UTF-8 | 3,424 | 3.03125 | 3 | [] | no_license | # Import the necessary libraries.
import socket
import ssl
import time
from mylib import myprint, unescape
# Some basic variables used to configure the bot
server = "boxxybabee.catiechat.net" # EU server
#server = "anewhopeee.catiechat.net" # US server
port = 6667 # default port
ssl_port = 6697 # ssl port
chans = ["... | true |
54f5d8a4326c494ed92034adb96e44a41c2009b3 | Python | lucianofalmeida/Desafios_Python | /desafio057.py | UTF-8 | 125 | 3.265625 | 3 | [] | no_license | tupla = ("carro","moto")
tupla[0]= 'bike'
print(tupla) #o erro acontece pq as tuplas não suportam atribuição de itens
| true |
6556b491357f364af329c98a88710bb8f1c5bdb4 | Python | ePlusPS/nexus9000 | /nexusscripts/off-box/cleanup/nexus_delbootflash.py | UTF-8 | 1,969 | 2.578125 | 3 | [] | no_license | """Script Cataloging Information
:Product Info:Nexus::9000::9516::NX-OS Release 6.2
:Category:Cleanup
:Box Type:Off-Box
:Title:Nexus Configuration Cleanup
:Short Description:To delete the switch bootflash configurations
:Long Description:Delete the switch bootflash configurations
:Input:command to delete the configurat... | true |
db7f624d92cc5231802b3693a45fc4c1e2ad9f54 | Python | sherld/LeetCodeForPython | /Solutions/GenerateParentheses.py | UTF-8 | 688 | 3.34375 | 3 | [] | no_license | class Solution:
def generateParenthesis(self, n):
"""
:type n: int
:rtype: List[str]
"""
if n == 0:
return []
ret = []
self.buildParenthesis(ret, '', 0, n)
return ret
def buildParenthesis(self, ret, s, existedNum, remainNum):
... | true |
493eb4573927979a9a46fdfc477a18d7a21677d6 | Python | huangciyin/ashley-madison-dox | /amdoxx/queries.py | UTF-8 | 3,357 | 2.5625 | 3 | [
"MIT"
] | permissive | import MySQLdb as mysql
import util
from members import AmMember
class AmQuery():
def __init__(self):
self.conn = mysql.connect('localhost', user='am_username', passwd='am_password', db='am')
def search_email(self, email):
"""Find a member based on their email, or None if email does not exist"... | true |
daabffb832d1e89c41d858c919495d586062e791 | Python | mingzhu-wu/self-labeling-coref-annotation | /self-labeling/gender.py | UTF-8 | 1,525 | 3.40625 | 3 | [] | no_license | from nltk.corpus import names
from nltk.classify import apply_features
import nltk
import random
class GenderRecoginition:
""" use nltk classfication to identify gender. """
def gender_features(self, word):
return {
'first-letter': word[0], # First letter
'first2-letters': wo... | true |
3ddaad23b87d9f03837867408cb59788916847f9 | Python | lonesloane/Python-Snippets | /Design_Patterns/Creational/Factory/ShapeFactory.py | UTF-8 | 554 | 3.46875 | 3 | [] | no_license | class IShape:
def draw(self): pass
class Circle(IShape):
def draw(self):
print('Circle drawn')
class Square(IShape):
def draw(self):
print('Square drawn')
class ShapeFactory:
@staticmethod
def get_shape(shape_type):
if shape_type == 'circle':
return Circle()... | true |
8d9eb70225b7ffd85708c3ed9fcd7c8caebe7d0f | Python | eyallev25/docker_api_exercise | /tests/support/docker_utils.py | UTF-8 | 2,863 | 2.84375 | 3 | [] | no_license | import docker
import time
import concurrent.futures
images_list = [
'bfirsh/reticulate-splines',
'nginx'
]
client = docker.from_env() # Instantiate docker client
timeout = 30 # Seconds
def print_container_stats():
"""Main method, allocate a new thread for each image from image_list and print stats whe... | true |
ba86f7fabc060bfc6dd61da552239783d8999533 | Python | albertogeniola/MerossIot | /meross_iot/model/plugin/light.py | UTF-8 | 2,184 | 2.8125 | 3 | [
"MIT"
] | permissive | from typing import Union, Optional, Tuple
from meross_iot.model.typing import RgbTuple
from meross_iot.utilities.conversion import int_to_rgb, rgb_to_int
class LightInfo(object):
def __init__(self,
rgb: Union[int, Tuple[int, int, int]] = None,
luminance: int = None,
... | true |
9abef191e3e2942ae1373693d3a0299755d0f9e4 | Python | SimleCat/assignment | /python/20150313/A5.py | UTF-8 | 2,118 | 3.203125 | 3 | [] | no_license | from simpleai.search import SearchProblem, genetic
# from simpleai.search.viewers import ConsoleViewer
import random
class KnapsackProblem(SearchProblem):
def __init__(self, numObjects, maxWeight, weights, values, initial_state=None):
super(KnapsackProblem, self).__init__(initial_state)
self.numObjects = numObjec... | true |
c59196ee45699ad690ef5b1c6e1d9e2186a02c43 | Python | yusufbenliii/Image-to-Text | /draw.py | UTF-8 | 3,570 | 2.8125 | 3 | [] | no_license | from tkinter import *
from PIL import Image, ImageGrab
import pytesseract as tess
import clipboard
import pyautogui
class ScreenShootDisplay:
def __init__(self):
self.root = Tk()
self.root.title("Ss")
path = "cut.ico"
try:
self.root.iconbitmap(r'cut.ico')
except Ex... | true |
abb681dcf41e156fcd8c84fa87c5ae6cc3798154 | Python | bgmacris/100daysOfCode | /Day95/act5.py | UTF-8 | 544 | 4.15625 | 4 | [] | no_license | """
Escribir una función que reciba un DataFrame con el formato del ejercicio anterior,
una lista de meses, y devuelva el balance (ventas - gastos) total en los meses indicados.
"""
import pandas as pd
def gastos(datos, meses):
datos['Balance'] = datos.Ventas - datos.Gastos
return datos[datos.Mes.isin(meses)]... | true |
86076f64c26fa4a56ebd8875dc764cd4365088c4 | Python | nunomota/spatial-inequality | /spatial_inequality/optimization/run_metrics.py | UTF-8 | 12,632 | 2.953125 | 3 | [
"MIT"
] | permissive | """
Structured information container, to track specified metrics over a single run
of our algorithm.
"""
import json
import copy
from time import time
class RunMetrics:
"""
This class is used to track metrics over a single run of the redistricting
algorithm (done over a single state). Most of its methods ... | true |
165199635871198db842d0e6be1425aad7f85153 | Python | Haannbboo/JAQK | /build/lib/jaqk/operations/Open.py | UTF-8 | 4,062 | 2.921875 | 3 | [
"MIT"
] | permissive | import os as _os
import pandas as _pd
import gc as _gc
from ..operations.Path import path as _path
from ..operations.Path import datapath
def open_file(stock, name, setup=False):
"""
opener for opening sheets for client
stock - company name (e.g AAPL for apple inc.)
name - name of the sheet (e.g 'in... | true |
f4ac523f052e6934988ae8051a34deba267300cc | Python | madokast/pythonLearn | /201901/timeLib.py | UTF-8 | 290 | 2.8125 | 3 | [] | no_license | import time
print(time.time())
#1547642050.57
print(time.ctime())
#Wed Jan 16 20:31:01 2019
print(time.gmtime())
#time.struct_time(tm_year=2019, tm_mon=1, tm_mday=16,
# tm_hour=12, tm_min=34, tm_sec=10, tm_wday=2, tm_yday=16, tm_isdst=0)
print(time.strftime("%Y",time.gmtime()))
#2019
| true |
10c4863b8f764e41b76e5d8eed43f65d1e921f30 | Python | DZwell/hacker_rank | /trees/is_present.py | UTF-8 | 756 | 3.6875 | 4 | [] | no_license | """
class BSTreeNode:
def __init__(self, node_value):
self.value = node_value
self.left = self.right = None
"""
from collections import deque
def isPresent(root, val):
if root:
if root.value == val:
return 1
q = deque([root])
while q:
if ... | true |
4a49d47f30afa442a7d9828aa35c8c5602128671 | Python | seattlechem/codewars | /geeks-for-geeks/closest-leaf-in-bt-wt-dist/closest_leaf_in_bt_wt_dist.py | UTF-8 | 1,549 | 3.5 | 4 | [
"MIT"
] | permissive | """When given value k, it returns the closest leaf and its distance."""
import collections
class Node:
"""Node class definition."""
def __init__(self, val):
"""Definition for constructor."""
self.val = val
self.left = None
self.right = None
def find_closest(root, k):
"""... | true |
2e22a56bc95c879b38fb4383086def8c593a4714 | Python | AeekTrue/Neural_network | /src/generate_lesson.py | UTF-8 | 583 | 2.703125 | 3 | [] | no_license | import numpy as np
import time
num_examples = 1000
num_inputs = 2
prefix = 'circle' # round(time.time())
training_file_name = f'training_data_{prefix}.csv'
test_file_name = f'test_data_{prefix}.csv'
def sort_func(x, y):
return (x - 0.5)**2 + (y - 0.5)**2 < 0.1
training = np.random.random((num_examples, num_i... | true |
012e64765e40188a711d3fea0b38014dee03f43e | Python | webclinic017/Intelligent-BackTesing-System | /backtesting/portfolio.py | UTF-8 | 8,885 | 3.0625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 10 16:51:08 2017
@author: ricky_xu
"""
from __future__ import print_function
try:
import Queue as queue
except ImportError:
import queue
import pandas as pd
from event import OrderEvent
from performance import create_sharpe_ratio, create_drawdow... | true |
23a71aaac50a9fcf330b294a54b613d3952e5f4c | Python | pepilipep/stock-price-predictions | /src/feature_dataset_enrichment.py | UTF-8 | 2,763 | 2.734375 | 3 | [] | no_license | import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
import sklearn
import talib
import talib.abstract as tabs
payload=pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')
first_table = payload[0]
tickets = first_table['Symbol'].values.tolist()
tickets.remove('BRK.... | true |
22b5cf58edfe9ca570c3840c8ac8995b70f3ddbe | Python | qiaoyu-jzh/hello-world | /python/test5.py | UTF-8 | 171 | 3.25 | 3 | [] | no_license | #闭包练习
def count():
fs=[]
for i in range(1,4):
def f():
return i*i
fs.append(f)
return fs
f1,f2,f3=count()
#s=f1()
#print(s) | true |
6e8ab3ffa4a6fd27c8fddcf4079d78a002ae9e1c | Python | SaudiWebDev2020/Sumiyah_Fallatah | /Weekly_Challenges/python/week3/testing_python.py | UTF-8 | 500 | 4 | 4 | [] | no_license |
my_list=[]
print(type(my_list))
my_list.append(6)
my_list.append(2)
my_list.append(5)
my_list.append(4)
print(my_list)
# def fun():
# pass
print ("Hello Python")
ob2 = { "name": "Zaphod", "numHeads": 2 }
ob3 = {}
for x in ob2:
ob3[ob2[x]] = x
print(ob3)
#########
name = "Zen"
print("My name is " + name +4... | true |
ddceb8a29f6e3e6b7b29b6779ed5bb5a8d26f1b6 | Python | ChristopherSparling/coding-practice | /dsaawp/circular-linked-list.py | UTF-8 | 1,514 | 4.03125 | 4 | [] | no_license | class CircularQueue:
class _Node:
__slots__ = '_element','_next'
def __init__(self,element,next_node):
self._element = element
self._next = next_node
def __init__(self):
self._tail = None
self._size = 0
def __len__(self):
return self._si... | true |
74b47511f3d202ae6cd3ab12c6ef4b1f6c26dbb7 | Python | Vital77766688/smartphones_parse | /smartphones_parse/pipelines.py | UTF-8 | 635 | 2.578125 | 3 | [
"MIT"
] | permissive | import os
import json
from datetime import datetime
from scrapy.exporters import JsonItemExporter
from itemadapter import ItemAdapter
class JsonWriterPipeline:
def open_spider(self, spider):
dt = datetime.now().strftime('%Y%m%d%H%M%S')
filename = os.path.join(f'output/{spider.name}_{dt}.json')
self.file = ope... | true |
d29550d0bf4696e9ccfdd14fe046ed116814d798 | Python | cucumbyu/rai | /Latihan.py | UTF-8 | 1,171 | 2.6875 | 3 | [] | no_license | import argparse
import getpass
import imaplib
import poplib
import smtplib
IMAP_SERVER = 'outlook.office365.com'
IMAP_PORT = 993
POP_SERVER = 'outlook.office365.com'
POP_PORT = 995
def imap_mail(username):
mailbox = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
password = getpass.getpass(prompt='Enter your e... | true |
500598e1384ef9fc2db361ee70c31f7eb50212bc | Python | irynabidylo/test_automation | /test_Italki.py | UTF-8 | 1,309 | 2.796875 | 3 | [] | no_license | from selenium import webdriver
import unittest
class ItalkiTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome(executable_path="C:\Program Files\Drivers_browsers\chromedriver.exe")
cls.driver.maximize_window()
cls.driver.implicitly_wait(5)
... | true |
7ec2112ac0243c45c4b7b3669ddd432587d12dc8 | Python | SteveHelenCoDevelopment/LeetCodeChallenges | /test_palindrome.py | UTF-8 | 736 | 3.328125 | 3 | [] | no_license | # Test file for calling imported library functions
import unittest
from longestPalindrome import Solution
class TestPalindromeSuite(unittest.TestCase):
def test_longer(self):
y = Solution()
test_cases = ["aaaa","aba","abasskjhghjkz","abasskjhgghjkz"]
responses = ["aaaa","aba","kjhghjk","kj... | true |
80614086b76515d374a450377e20650bbec1a950 | Python | Sandeep8447/interview_puzzles | /src/test/python/com/skalicky/python/interviewpuzzles/test_find_max_length_of_substring_without_repeating_chars.py | UTF-8 | 1,397 | 3.375 | 3 | [] | no_license | from unittest import TestCase
from src.main.python.com.skalicky.python.interviewpuzzles.find_max_length_of_substring_without_repeating_chars import \
Solution
class TestSolution(TestCase):
def test_find_max_length_of_substring_without_repeating_chars__when_input_is_none__then_output_is_0(self):
self.... | true |
1b2b240ba07606eb7e691115ff873244ce208fe1 | Python | zimkies/puzzles | /datastructures/tree.py | UTF-8 | 3,404 | 3.203125 | 3 | [] | no_license | from collections import deque
class Tree():
depth = None
"""My own instance of a tree"""
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
self.depth = self.get_depth()
def printout(self):
treedepth = self.get_de... | true |
d00bc832656762cc42070440a0f7bf494bd45b3d | Python | kirtymeena/DSA | /9.Stack/1.stack.py | UTF-8 | 3,596 | 3.765625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 16 09:51:15 2020
@author: kirty
"""
# implementation using array
class Stack:
def __init__(self):
self.stack = []
self.output = []
self.precedence = {"+":1,"-":1,"/":2,"*":2,"^":3}
def IsEmpty(self):
if self.s... | true |
615d1a556a465a4706c91f3483459ab7abeb64b8 | Python | michaelssavage/eMot | /src/modelTrain/sgdClassifier.py | UTF-8 | 2,138 | 2.625 | 3 | [] | no_license | import sys
import warnings
from pathlib import Path
import pandas as pd
from modelFuncs import saveFiles
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.linear_model import SGDClassifier
from sklearn.metrics import accuracy_score, f1_score
from sklearn.model_selection import train_test_split
f... | true |
4105fe34fb2d831296244c917a771a872346e590 | Python | ai-kmu/etc | /algorithm/2020/1009_simplify_path/daehee.py | UTF-8 | 764 | 3.171875 | 3 | [] | no_license | class Solution:
def simplifyPath(self, path: str) -> str:
paths = path.split('/')
real_paths=[]
for path in paths: # 경로들 걸러내기
if path=='' or path=='.': # 현재위치 그대로
continue
elif path=='..': # 상위 디렉토리
... | true |
034d1b7674ddabeb60fd3f02ba2a2cb95f9d6139 | Python | vishrutkmr7/DailyPracticeProblemsDIP | /2019/11 November/dp11042019.py | UTF-8 | 909 | 4 | 4 | [
"MIT"
] | permissive | # This problem was recently asked by Facebook:
# Given a directed graph, reverse the directed graph so all directed edges are reversed.
# Input:
# A -> B, B -> C, A -> C
# Output:
# B -> A, C -> B, C -> A
from collections import defaultdict
class Node:
def __init__(self, value):
self.adjacent = []
... | true |
744c58b8369cd52732f79c5f0f6d8a4b827bd1a3 | Python | drewhoener/CS220 | /Project 4/src/suffix.py | UTF-8 | 690 | 3 | 3 | [] | no_license | from immdict import ImmDict
import markov_main
def empty_suffix():
return ImmDict()
def add_word(suffix, word):
if word in suffix.keys():
return suffix.put(word, suffix.get(word) + 1)
return suffix.put(word, 1)
def choose_word(chain, prefix, random):
list_total = [dic for dic in chain.get(... | true |
22ffbc5d0f8b39f5087adc8987cd9f4d147eff2e | Python | hansh0112/Sample-Projects- | /twitter_search/twitter_api.py | UTF-8 | 1,579 | 2.84375 | 3 | [] | no_license | import optparse
import sys
import twitter_functions
def main(args):
parser = optparse.OptionParser("""Usage: %prog [-s <search term> | -t | -u <username>]""")
parser.add_option("-s", "--search",
type="string",
action="store",
dest="search_term... | true |
142ae52b8e9d2fb3e1bd21c59be7c99ed872aff6 | Python | dozercodes/Breakout | /tester.py | UTF-8 | 2,234 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python2.6
import main, gui, board, block, ball, paddle
import unittest
class MyTest(unittest.TestCase):
def testMain(self):
complete = main.main()
self.assertTrue(complete)
def testGUIStartGame(self):
complete = gui.GUI.startGame(self)
self.assertTrue(complete)
... | true |
2553a06e332b1b8b2cb84b7367c81523d548a8c7 | Python | HOZH/leetCode | /leetCodePython2020/153.find-minimum-in-rotated-sorted-array.py | UTF-8 | 487 | 2.921875 | 3 | [] | no_license | #
# @lc app=leetcode id=153 lang=python3
#
# [153] Find Minimum in Rotated Sorted Array
#
# @lc code=start
class Solution:
def findMin(self, nums: List[int]) -> int:
def helper(arr, l, r):
if l+1 >= r:
return min(arr[l], arr[r])
if arr[l] < arr[r]:
... | true |
4dabeca3d3893017c32d8e98a3ba8be193d43613 | Python | dora23/KEMET-Python | /tests/header_section_tests/support_nav_section_tests.py | UTF-8 | 1,950 | 2.578125 | 3 | [] | no_license | import time
import pytest
from pages.header_section import support_nav_section
from tests import config
class TestSupportMenu:
@pytest.fixture()
def support(self, driver):
return support_nav_section.SupportSection(driver)
# Print all Support categories and test their links
def test_applicat... | true |
90b3845d106677844ccc5a412ed4e04a8e1609a9 | Python | jsverch/practice | /hourglass.py | UTF-8 | 358 | 3.09375 | 3 | [] | no_license |
arr = [(1, 1, 1, 0, 0, 0),
(0, 1, 0, 0, 0, 0),
(1, 1, 1, 0, 0, 0),
(0, 0, 2, 4, 4, 0),
(0, 0, 0, 2, 0, 0),
(0, 0, 1, 2, 4, 0)]
hgs = list()
for x in range(0, 4):
for y in range(0, 4):
ch = arr[x][y] + arr[x][y+1] + arr[x][y+2] + arr[x+1][y+1] + arr[x+2][y]\
+ arr[x+2][y+1] + arr[x+2][y+2]
... | true |
793e1191a9f34a87e242a2f7dc8ff5c9a2e559c8 | Python | Omega97/quantum_logic_gates | /quantum_gates.py | UTF-8 | 1,199 | 2.5625 | 3 | [] | no_license | from algebra import *
from numpy import pi
def identity(n_bits):
"""identity given number of q-bits"""
return Operator(np.identity(2**n_bits))
I = identity(1)
H = Operator([[1, 1], [1, -1]]).n()
X = Operator([[0, 1], [1, 0]])
Y = Operator([[0, -1j], [1j, 0]])
Z = Operator([[1, 0], [0, -1]])
... | true |
16cc7f8c77ffc3fa7fb0484cbe2ca38bad2c8fa1 | Python | MartinHarvey/NetDucky | /server_app/app/routes.py | UTF-8 | 924 | 2.71875 | 3 | [] | no_license | import os
from flask import request
from app import server_app
#Basic route. Used to test if server is running and responding to requests
@server_app.route('/')
@server_app.route('/index')
def index():
return "Hello, World!"
# <duckey_name> corresponds to the name each ducky client has. This allows you
# to iss... | true |
2058faf87a09cea366a03e2076d406c6c9fa3311 | Python | ketchup-doraemon/Morphology_Team4 | /src/two_net_model.py | UTF-8 | 3,767 | 2.65625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
__author__ = 'Daisuke Yoda'
__Date__ = 'December 2018'
import numpy as np
from gensim.models.keyedvectors import KeyedVectors
import matplotlib.pyplot as plt
from chainer import Chain, Variable, optimizers
import chainer.functions as F
import chainer.links as L
class Second_Network(... | true |
23178b6086cb71f59bcba56acffbc026116fbf00 | Python | ghcjssla/reinforceNLP | /01-cartpole/model.py | UTF-8 | 763 | 2.8125 | 3 | [] | no_license |
import torch
import torch.nn as nn
import torch.nn.functional as F
"""
Cartpole Network
"""
class CartpoleNet(nn.Module):
def __init__(self, n_state, n_action, softmax=True):
super(CartpoleNet, self).__init__()
self.softmax = softmax
self.layer1 = nn.Linear(n_state, 256)
... | true |
683c9aa9e558ed96397a640731e3702124f48d8f | Python | hakgyu2298/Python_test | /20210622_실습2C-3.py | UTF-8 | 197 | 4.5625 | 5 | [] | no_license | # 리스트의 모든 원소를 enumerate()함수로 스캔하기(1부터 카운트)
x = ['John', 'George', 'Paul', 'Ringo']
for i, name in enumerate(x,1):
print(f'{i}번째 = {name}')
| true |
36a8d58933181c4bdb5ab8fe2bd0c1a27de89d86 | Python | mrwizard82d1/py_mem_pwds | /mem_pwds/cmd/memorable_pwds.py | UTF-8 | 1,251 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env python
#
"""An interactive, text-based application to generate strong, easily
memorized passwords."""
import cmd
import os
import string
import sys
try:
# if it is installed
from mem_pwds.MemorablePwds import MemorablePwds
except ImportError:
# if it is in development
sys.path.append... | true |
8cbc0d778e803293770404e118d9c8efa5134653 | Python | workcookiestw/Python-GetGovOpenData | /opendata.py | UTF-8 | 596 | 2.546875 | 3 | [] | no_license | import time
import urllib3
import datetime
import requests
import urllib.request
import re
#REF: https://docs.python.org/2/library/xml.etree.elementtree.html
response = urllib.request.urlopen("http://opendata.epa.gov.tw/webapi/api/rest/datastore/355000000I-000001/?format=xml&limit=1&offset=0")
'''soup = bea... | true |
b15adde56fafc03ff9debcfc2e3df41bc3b1bd0e | Python | fodierna/Natural-Language-Technologies | /CONCEPT_SIMILARITY/utilities.py | UTF-8 | 3,441 | 3.046875 | 3 | [] | no_license | import csv
from math import log
import numpy as np
from numpy import cov, std
from scipy.stats import rankdata
import nltk
from nltk.corpus import wordnet as wn
import sys
# read a file containing two words and a similitary score associated to
def read(path):
#nltk.download('wordnet')
with open(path) as csv_fi... | true |
a38e93b306c95168c59da6e6bfdc51438bf1f3e6 | Python | livan123/DataMining | /03统计算法/common_used.py | UTF-8 | 861 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# 1)因子分析(FA)
# 2)主成分分析(PCA)
# 3)独立成分分析(IDA)
# 4)线性判别分析(LDA)
# 5)离群点分析
# 6)时间序列法
# ACF:样本自相关函数,样本序列存在周期性;
# ADF:单位根检验,表明序列平稳性;
# AR:自回归模型;
# MA:滑动平均模型;
# ARMA:平稳序列的自回归滑动平均;
# ARIMA:非平稳序列的自回归滑动平均(需要进行差分处理)
# 主要有四类:
# 1)趋势:
# 2)季节变动:就是计算周期内各时期季节性影响的相对数;
# 3)循环变动:
# 4)不规则波动:
# 7)假设检验
# 8)相关分... | true |
f59d926f199abdd6f4e5939462a65578e67afad4 | Python | IMSY-DKFZ/simpa | /simpa/core/simulation_modules/acoustic_forward_module/__init__.py | UTF-8 | 3,375 | 2.5625 | 3 | [
"MIT"
] | permissive | # SPDX-FileCopyrightText: 2021 Division of Intelligent Medical Systems, DKFZ
# SPDX-FileCopyrightText: 2021 Janek Groehl
# SPDX-License-Identifier: MIT
from abc import abstractmethod
import numpy as np
from simpa.core import SimulationModule
from simpa.utils import Tags, Settings
from simpa.io_handling.io_hdf5 import ... | true |
51ed90864f2656805bc17eaddcafec9a1c36d7f1 | Python | aap488/meal_planner | /meal_data.py | UTF-8 | 219 | 2.65625 | 3 | [] | no_license |
class MealData:
""" Class designed to store the information used in a Meal class. """
def __init__(self, meal_list, meal_name):
self.meal_list = meal_list
self.meal_name = meal_name
| true |
83aa67f8ca2a2a66ba8429aed38626d18057ef21 | Python | Jonathan-aguilar/DAS_Sistemas | /Ene-Jun-2021/perez-gutierrez-julio-cesar/Examen Extraordinario/Ejercicio-7/users.py | UTF-8 | 1,525 | 3.15625 | 3 | [
"MIT"
] | permissive | "A Singleton Dictionary of Users"
from decimal import Decimal
from wallets import Wallets
from reports import Reports
class Users():
"A Singleton Dictionary of Users"
#_users: dict[str, dict[str, str]] = {} # Python 3.9
_users = {} # Python 3.8 or earlier
def __new__(cls):
return ... | true |
0449740770b74d78537a37e1c26953370fe42024 | Python | waqar-ahmed-malik/python | /tutorials/pythonModules/csvModule/code.py | UTF-8 | 502 | 2.75 | 3 | [] | no_license | import csv
with open("Read.csv", "r", encoding="utf8") as csv_read:
csv_reader = csv.DictReader(csv_read)
fieldnames = list()
for line in csv_reader:
for key, value in line.items():
if key not in fieldnames:
fieldnames.append(key)
csv_read.seek(0)
with open("Wri... | true |
c482816b0fc38bd50ed12fa5e312c8f26c2d4ec2 | Python | chiendb97/naive_bayes | /main.py | UTF-8 | 1,126 | 2.625 | 3 | [] | no_license | from utils.data_loader import DataLoader
from utils.model import NaVieBayes
from sklearn.metrics import accuracy_score, f1_score
import pickle
loader = DataLoader()
len_vocab = len(loader.vocab)
features, target = loader.get_data()
n = len(target)
indexs = [i//2 if i % 2 == 0 else i//2 + n//2 for i in range(n)]
featur... | true |
06020790a21b2cbaf6d3822768e2c1f32013c418 | Python | Aasthaengg/IBMdataset | /Python_codes/p02595/s715817534.py | UTF-8 | 221 | 3.109375 | 3 | [] | no_license | import math
N, M = map(int, input().split())
counter = 0
for _ in range(N):
a, b = map(int, input().split())
distance = math.sqrt(abs(a)**2 + abs(b)**2)
if distance <= M:
counter += 1
print(counter) | true |
878ea2bb15b453403d577d459b613c0b082bde3a | Python | yukiao/to-do-list | /Home.py | UTF-8 | 1,888 | 2.609375 | 3 | [] | no_license | from PyQt5 import QtWidgets
from PyQt5.QtWidgets import *
import Login as login
import User
import Account as account
class Home(QWidget):
def __init__(self):
super(Home,self).__init__()
self.setContentsMargins(20,20,20,20)
self.initUi()
def initUi(self):
self.usernameLabel... | true |
8cfc7f5623958c41a4a22db619ed2e6bfe30c54e | Python | eddyxq/Intro-to-Computer-Science | /Full A3/A3.py | UTF-8 | 14,603 | 3.84375 | 4 | [] | no_license | # Author: Eddy Qiang
# Student ID: 30058191
# CPSC 231-T01
"""
Patch History:
Date Version Notes
May 16, 2017 Ver. 1.0.0 initial creation
May 27, 2017 Ver. 1.0.1 added three new rooms
June 02, 2017 Ver. 1.0.2 reorganized code into functi... | true |
24b9111c3b0a39a50079e3897c934f5fb622773a | Python | whitphx/stlite | /packages/sharing-editor/public/samples/011_component_gallery/pages/widget.checkbox.py | UTF-8 | 88 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | import streamlit as st
agree = st.checkbox("I agree")
if agree:
st.write("Great!")
| true |
266055bf5aac610145d1659d34215c386e9e9671 | Python | ClarkeJ2000/CA117-Programming-2 | /square_122.py | UTF-8 | 979 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env python3
import sys
import math
def trim(a):
trimmed = []
for x in a:
if '\n' in x:
trimmed.append(x[:-1])
else:
trimmed.append(x)
return trimmed
def distance(a, b, c, d):
distance = math.sqrt((c - a) ** 2 + (d - b) ** 2)
return distance
def main():
lines... | true |
2d69fdab55c93d516472aafbb07e9f5d40e5cbaf | Python | fourswordsio/SpaceX-Chainlink-Adapter | /elonmusk.py | UTF-8 | 761 | 2.609375 | 3 | [] | no_license | import requests
class SpaceX:
def __init__(self):
self._api_endpoint = "https://api.spacexdata.com/v3/launches/next"
def get_launch_info(self):
response = requests.get(self._api_endpoint).json()
try:
flight_data = {
"launch_time": response["laun... | true |
e91215ac23c3c23fbfb78d658f246b503a89bfdb | Python | sisyphean-labs/json-toolkit | /json-to-csv | UTF-8 | 381 | 2.75 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import argparse
import csv
import json
import sys
def main():
parser = argparse.ArgumentParser(description="Converts json on stdin to csv on stdout")
args = parser.parse_args()
rows = json.load(sys.stdin)
csv_writer = csv.writer(sys.stdout, dialect='unix')
csv_writer.writer... | true |
560e5e8018ab906ac393dec557ad68d8f4c71681 | Python | guiaramos/algorithms-data-structures | /python/challenges/anagrams.py | UTF-8 | 1,025 | 3.953125 | 4 | [] | no_license | # checkAnagrams check if two strings are anagrams O(n)
def checkAnagrams(firstString, secondString):
# check if the length is same
if len(firstString) != len(secondString):
return False
# create a lookup dict for record the frequency of letters
freqFirstString = {}
# loop thru the first st... | true |
8714fd8a085abf03c19870adf199a031329cfd69 | Python | vranand1/empirical_workshop_2021 | /1_reproducibility_KLC_intro/time.py | UTF-8 | 405 | 4.15625 | 4 | [] | no_license | #######################################
# Printing the time every 10 seconds ##
#######################################
# libraries used
import time
# first statement
print("This file tells you the time after every 10 seconds.")
# print the time after every 10 seconds
for i in range(10000):
print("The time is no... | true |
2d64264f055ea325fd0375a27a1a194f1f675c55 | Python | sayakchak/SnackDown2019 | /Qualifier.py | UTF-8 | 478 | 2.796875 | 3 | [] | no_license | sum = 0
T = int(input())
if T>1000 or T<1:
exit(0)
for i in range(T):
N, K = [int(x) for x in input().split()]
sum += N
if K<1 or N<1 or K>N or K>100000 or N>100000 or sum>1000000:
exit(0)
S = [int(x) for x in input().split()]
if min(S)<1 or max(S)>1000000000:
exit(0)
S.sort(... | true |
2dfdc52d4ae7a361fe74813367dba6f755acf019 | Python | lruhlen/project_euler | /python/problem3.py | UTF-8 | 1,480 | 4.125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 1 23:15:38 2016
@author: lruhlen
Problem 3:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
# Code
import numpy as np
def get_next_prime():
list_of_primes = [2]
while True:
current_max_p... | true |
56463773a9b46746f2610de9f1fb1a9a04b36935 | Python | JasonGlazer/EP-Launch3 | /eplaunch/tests/utilities/test_version.py | UTF-8 | 1,728 | 2.828125 | 3 | [] | no_license | import unittest
import os
from eplaunch.utilities.version import Version
class TestVersion(unittest.TestCase):
def test_numeric_version_from_string(self):
v = Version()
self.assertEqual(v.numeric_version_from_string("8.1.0"), 80100)
self.assertEqual(v.numeric_version_from_string("8.8.8")... | true |
cdd2018273518cf35e20caf2322154f73f0cd146 | Python | ywyz/IntroducingToProgrammingUsingPython | /Exercise03/3-6.py | UTF-8 | 244 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | '''
@Date: 2019-08-19 17:46:38
@Author: ywyz
@LastModifiedBy: ywyz
@Github: https://github.com/ywyz
@LastEditors: ywyz
@LastEditTime: 2019-08-19 17:46:39
'''
number = eval(input("Enter an ASCII code: "))
print("The character is ", chr(number))
| true |
501cb7117f643eda44f060522ae3758b05d95ef7 | Python | akey96/Programacion-Taller- | /project/model/vo/movement.py | UTF-8 | 793 | 3.171875 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
class Movement():
def __init__(self):
self.__time = None
self.__movement = None
self.__pincer = None
# setters of atrribs
def __settime(self, timeM):
self.__time = timeM
def __setmovement(self, movement):
self.__moveme... | true |
9023dbf12f559f133e88976efe07b5429eeac080 | Python | KevvinHoo/MGC | /grace_dl/torch/compressor/mgc.py | UTF-8 | 2,836 | 2.53125 | 3 | [] | no_license | import torch
from grace_dl.torch import Compressor
class MGC(Compressor):
#
def __init__(self, compress_ratio):
super().__init__(tensors_size_are_same=False)
self.compress_ratio = compress_ratio
def compress(self, tensor, name):
shape = tensor.size()
tensor = tensor.fla... | true |
cc8328f13a6515433d7efdbe833fcea2ec14fb1e | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2578/60792/258944.py | UTF-8 | 257 | 3.171875 | 3 | [] | no_license | import math
def Sum(list1,n):
sum=0
for i in range(0,len(list1)):
sum=sum+math.ceil(list1[i]/n)
return sum
list1=list(map(int,input().split(",")))
n=int(input())
i=1
sum=Sum(list1,1)
while sum>n:
i=i+1
sum=Sum(list1,i)
print(i) | true |
7dcfe80e56632bcdde709f06389aa83e6a8907e1 | Python | prajwollamichhane11/ML-Algorithm-Tutorial-Implementations | /Dual Variable Linear Regression/DualVar_linregression.py | UTF-8 | 1,693 | 3.578125 | 4 | [] | no_license | from numpy import *
def compute_error_for_line_given_points(b,m,points):
totalError = 0
for i in range(0, len(points)):
x = points[i,0]
y = points[i,1]
totalError += (y-(m*x + b)) **2
return totalError/float(len(points))
def gradient_descent_runner(points, starting_b, starting_m, learning_rate, num_ite... | true |
79e55f05b82c07ef53bb5ceb747c431e9198149d | Python | LuckyLub/python-onsite | /week_04/web_scraping/01_your_page.py | UTF-8 | 772 | 2.984375 | 3 | [] | no_license | '''
Using python's request library, retrieve the HTML of the website you created
that now lives online at <your-gh-username>.github.io/<your-repo-name>
BONUS: extend your python program so that it reads your original HTML file
and returns True if the HTML from the response is the same as the
the contents... | true |
7b935300ea75a8f1cd354b606362f871b43c48bb | Python | OrianaLombardi/Python- | /fundamentos/listas-ej.py | UTF-8 | 182 | 3.421875 | 3 | [] | no_license |
#for numero in range(10):
# if numero%3==0:
# print(numero)
listaNumeros=[0,1,2,3,4,5,6,7,8,9,10]
for numero in listaNumeros:
if numero%3 ==0:
print(numero)
| true |
f7388ec2ac672a7433fde4e5b7f9121c36bfc08b | Python | jzcoder/dfwpythoneers_asyncio | /exercises/48_executor_process_pool.py | UTF-8 | 960 | 2.734375 | 3 | [] | no_license | """
Use a ProcessPoolExecutor instead of default thread pool.
Note: The overhead compared to thread pool executor. But, it was really easy to switch
to the process pool.
"""
import asyncio, demo, time, os
from concurrent.futures import ProcessPoolExecutor
NUM_TASKS = 20
def blocking_call(timeout, ndx):
demo.L... | true |
ace38ade56fccf36cbedd9839d10608e66d5fc2c | Python | sergey-msu/notebook | /ml/how-to/scipy.py | UTF-8 | 1,557 | 3.046875 | 3 | [] | no_license | import scipy.stats as sts
# Optimization
from scipy import optimize
def f(x):
return (x[0] - 3.2)**2 + (x[1] - 1)**4 + 3
x_min = optimize.minimize(f)
x_min.x # [3.2 1]
# Solve SLE
from scipy import linalg
A = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]])
b = np.array([2, 4, -1])
x ... | true |
a586a8bd6d1f4468dd069b1bd382e161a9020946 | Python | karmueo/traclus_impl | /integ_tests/deer_tests/traclus_runner.py | UTF-8 | 881 | 2.515625 | 3 | [] | no_license | '''
Created on Jan 20, 2016
@author: Alex
'''
from traclus_impl.coordination import run_traclus
from deer_file_reader import read_test_file
import os
import cProfile
""" This is useful for profiling performance on the datasets in this directory"""
def run_deer_stuff():
file = os.path.join(os.path.dirname(__file_... | true |
9a13f66221d8e8c4c11b2752eba926ada73e8566 | Python | denkho/CourseraPython | /week1/ex_18.py | UTF-8 | 249 | 3.28125 | 3 | [] | no_license | # За день машина проезжает N километров.
# Сколько дней нужно, чтобы проехать маршрут длиной M километров?
n, m = int(input()), int(input())
print((n + m - 1) // n) | true |
e304dbda40fa9460d23800d868f2d7c082e480a7 | Python | waldisjr/JuniorIT | /_2019_2020/Classworks/_18_18_01_2020/_1.py | UTF-8 | 333 | 3.421875 | 3 | [] | no_license | import string
ab = ['abc','cv','Fd','fg','eYty','eryT',]
def f(a):
abc = string.ascii_lowercase
minn = len(ab[0])
for i in a:
if len(i) <= minn:
minn = len(i)
varients = []
for i in a:
if len(i) == minn:
i = i.lower()
varients.append(i)
c = f(a... | true |
b65c79fad62ac98ae8cc21368b17d700b3bfb649 | Python | wemporcode/SDPerfTool | /lmdd.py | UTF-8 | 2,754 | 2.515625 | 3 | [] | no_license | #!/usr/bin/python
__author__ = 'bigzhang'
import datetime
from pyadb import ADB
from lmdd_processor import LmddProcessor
from lmdd_speed import LmddSpeed
from optparse import OptionParser
target_list=['data', 'sdcard', 'sdcard1']
if __name__ == '__main__':
usage = "usage: %prog [-d target]{-t times}"
parser... | true |