blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
44b8589917443ccd338137e807d86a390c740b4a | morinokami/pymonkey | /tests/test_evaluator.py | UTF-8 | 14,023 | 3.15625 | 3 | [] | no_license | from typing import Any, NamedTuple
from monkey import evaluator, lexer, object, parser
class T(NamedTuple):
input: str
expected: Any
def test_eval_integer_expression():
tests = [
T('5', 5),
T('10', 10),
T('-5', -5),
T('-10', -10),
T('5 + 5 + 5 + 5 - 10', 10),
... | true |
9b21e5ad6d8ee939eebb468fa4e26113769e9a07 | SidneyKim/python-learning-examples-2018 | /day 2 통계/lambda 1.py | UTF-8 | 1,405 | 4.03125 | 4 | [] | no_license |
# 일급함수, first class function
# 함수 참조가능
def show():
print('show')
def fn(a):
a()
fn(show)
# 람다 식
a = lambda a,b:a+b
print(a(1,2))
list = list(range(1,101))
print(list)
#가장 큰값 구하기
def fn_max(list):
a = None
for n in list:
if a == None or a < n:
a = n
return a
... | true |
5c00a9d002b8628dc6ada7f0b3dba5a593d3fd95 | tomlazersheep/python-unsam | /class9/ticker.py | UTF-8 | 877 | 2.875 | 3 | [] | no_license | # ticker.py
from vigilante import vigilar
import
import formato_tabla
def elegir_columnas(rows, indices):
for row in rows:
yield [row[index] for index in indices]
def cambiar_tipo(rows, types):
for row in rows:
yield [func(val) for func, val in zip(types, row)]
def filtrar_datos(filas, nom... | true |
8b6726eee5b937ff92a976a997ad7f2d110f187e | jaydenklam/Odd_Man_Out_Simulation | /Odd_Man_Out_Simulation.py | UTF-8 | 1,041 | 3.5 | 4 | [] | no_license | from random import randrange
total_trials = 1000000
all_different = 0
all_same = 0
odd_man_out = 0
for i in range(total_trials):
player_1 = randrange(1, 4)
player_2 = randrange(1, 4)
player_3 = randrange(1, 4)
if (player_1 != player_2 and player_1 != player_3 and player_2 != player_3)... | true |
07e164363a0e9942bfe11b20d516b8f6516700e2 | Gamer007232/Python-KI | /Python KI 2.py | UTF-8 | 1,063 | 3.3125 | 3 | [] | no_license | #in diesem Abschnitt beginnen wir mit dem Einladen der Libraries
import tensorflow as tf
import numpy as np
#in diesem Abschnitt laden wir die Daten (Bilder und Labels) aus der Datenbank "Mnist Fashion" ein
mnist = tf.keras.datasets.fashion_mnist
(training_images, training_labels), (test_images, test_labels) = mnist.... | true |
3b6886873def01410e749ade1b84f48b8cd71922 | reynoldscem/python-stable-marriage | /Matchmaker/Matchmaker.py | UTF-8 | 6,611 | 3.078125 | 3 | [] | no_license | from collections import defaultdict
class Person:
def __init__(self, obj, higher_is_better=False):
self.name = repr(obj)
self.data = obj
self.higher_is_better = higher_is_better
self.crush = None
self.crush_score = None
@property
def has_crush(self):
retu... | true |
406eeb15061f50b6212f0e7bfd100229184c52f6 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_136/1409.py | UTF-8 | 1,509 | 2.859375 | 3 | [] | no_license | TEST = 0;#If 1 prints to console instead of file
import sys
class casesIO:
def __init__(self,testfilepath,resultfilepath):
self.testfile = open(testfilepath, 'r');
self.outfile = open(resultfilepath, 'w');
self.outlines = 0;
nextline = self.testfile.readline();
if not nextline:
self.total = 0
else:
... | true |
cf94a1cbe5ebcdae7a884ab6cf8f5b43365f0f59 | pzhang15/EPI-solutions-set | /EPI/Python/ch11_searching/11.2_search_entry_equal_to_idx.py | UTF-8 | 413 | 3.546875 | 4 | [] | no_license | '''
take an sorted aray of distinct integer, and return an index such that the element at i is equal to i
A = [-2, 0, 2, 3, 6, 7, 9]
return 2, or 3 would be correct
'''
def sol(A):
l, r = 0, len(A)
while l < r:
mid = (l + r)//2
diff = A[mid] - mid
if diff == 0:
return mid
... | true |
4c8e7b2e5cf4d4d2bdd27d76295c9e64323e8aba | gaohj/nzflask_bbs | /nz_django/day5/class_view_demo_01/front/views.py | UTF-8 | 2,645 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | from django.shortcuts import render
from .models import Article
from django.http import HttpResponse
from django.views.generic import ListView
def add_article(request):
articles = []
for x in range(0,108):
article = Article(title='标题:%s'%x,content='内容:%s'%x)
articles.append(article)
Article.... | true |
d87df69c13dfe7e45201ac789d3273bb1aebae17 | LondonComputadores/tkinter_Desktop_App | /o_codigo_minimo.py | UTF-8 | 569 | 3.171875 | 3 | [] | no_license |
from tkinter import *
import tkinter as tk
janela = tk.Tk()
janela.title('Clinica Conde')
janela['bg'] = "pink"
janela.geometry("1100x700+100+40")
'''
photo = PhotoImage(file = "logo.png.png", width = 900, height = 500)
label = Label(janela, image = photo)
label.pack()
'''
def bt_click():
prin... | true |
3a7cbd37a6d29a40903ea9189b0d650879365e56 | ritikanilosey/pythonProject3 | /main.py | UTF-8 | 2,296 | 3.6875 | 4 | [] | no_license | import datetime
class Pet(object):
def __init__(self):
self.age = 0
def set_name(self, name):
self.name = name
def set_species(self, species):
self.species = species
def set_breed(self, breed):
self.breed = breed
def set_color(self, color):
self.color = ... | true |
32dd2db6d6d08b3fd31542399d2b642ac65c89b6 | cash2one/xai | /xai/body/eye.py | UTF-8 | 1,133 | 2.75 | 3 | [
"MIT"
] | permissive | from xai.python.file import File
import json
class Eye():
'''
'''
def __init__(self, filename=None):
self.filename = filename
pass
#
def read_json(self, filename):
'''
'''
if filename:
self.filename = filename
with open(self.filename) as ... | true |
e2dd12bcc5278fe69e25f716106409bc13955e76 | TareqJudehGithub/python_flask_blog_posts | /main.py | UTF-8 | 1,302 | 2.828125 | 3 | [] | no_license | from flask import Flask, render_template
from post import Post
import requests
from datetime import datetime
app = Flask(__name__)
class Blog:
def __init__(self):
self.posts_url = requests.get(
url="https://api.npoint.io/5abcca6f4e39b4955965").json()
self.posts_list = list()
... | true |
fb2ee12c33f2ee3e41e765ceaaaf1eb86e60f4d5 | alkopop79/Python-learning | /TCP_server.py | UTF-8 | 381 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
import socket
TCP_IP='192.168.0.20'
TCP_PORT=5005
BUFFER_SIZE=1024
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind((TCP_IP,TCP_PORT))
s.listen(1)
conn,addr=s.accept()
print 'Connection address:', addr
while 1:
data = conn.recv(BUFFER_SIZE)
if not data:break
pr... | true |
a74475faf81d19a56073148fc9d7101b4d1e0f63 | brighter23/code | /python/final.py | UTF-8 | 13,912 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# !/D:/py_project/text/python3
# Filename: final.py
import pandas as pd
import numpy as np
import jieba
import jieba.analyse
import sys
import codecs
from textrank4zh import TextRank4Keyword, TextRank4Sentence
import re
import warnings
import os
from collections import Counter
warnings.filterw... | true |
6cb53306befc554acafe39d144bf98557b3431a4 | pajdek/machine-park-simulation | /test/test_simulator_input_data.py | UTF-8 | 2,115 | 2.828125 | 3 | [] | no_license | import simulator.simulator_input_data as simulator_input_data
from datetime import datetime
import pytest
from argparse import ArgumentTypeError
from unittest import mock
def test_valid_date_time_format_returns_datetime_object():
mock_input_string = '2017-11-23 10:10'
assert True is isinstance(simula... | true |
39c6f22920b35f4a6d74b9d264a1a69ceca0f67c | nidhisha-shetty/Python-programs | /creating-nested-list.py | UTF-8 | 165 | 3.3125 | 3 | [] | no_license | li_1=[]
num=int(input("Enter a number"))
for x in range(num):
name=input("Enter a name")
num=input("Enter the marks")
li_1=li_1+[[name,num]]
print(li_1)
| true |
41f3edf12b55be70acbd7dcfbcbf04604c47a508 | rusianh/cours_python_basic_advance_dllt | /Unit7. FileIO - List/38.write_to_text_file.py | UTF-8 | 392 | 3.484375 | 3 | [] | no_license | file = open("data.txt", "r") #"w": mode writing tạo file mới xóa file cũ,
#"r" reading, "a" writing appending - ghi file mới, ghi thêm nhưng không xóa đi
# file.write("dunglai")
data = file.read() # đằng sau dấu chấm sẽ là một hành động gì đấy, một thuộc tính gì đấy. Đằng trước là một vật ... | true |
98f51d45bdf54323f99898dfd8841b43265b3192 | juhanurmonen/aikasarjat-liukuvat-tunnusluvut | /Aikasarjojen-kuvaaminen.py | UTF-8 | 4,776 | 3.09375 | 3 | [] | no_license |
# coding: utf-8
# Aikasarjojen esittämisestä Pythonilla
# Latasin ensin Valmetin viimeisen kolmen vuoden päätöskurssit ja indeksin OMH Helsinki 25 päätöskurssit vuodesta 1.1.2015 (ks. alla) osoistteesta http://www.nasdaqomxnordic.com.
# In[2]:
import pandas as pd
import matplotlib.pyplot as plt
get_ipython().run_... | true |
8fe8f4d19d39ef9437729f5527d142d24eac8fa1 | guochangjiang/seqtool | /seqtool/format/render.py | UTF-8 | 2,715 | 2.609375 | 3 | [
"MIT"
] | permissive | from seqtool.util import svg
from seqtool.util.rectangle import Rectangle
from seqtool.nucleotide import base_color
from seqtool import format
fm = svg.fm
class SvgBaseText(svg.SvgBase):
def __init__(self, ploc, pbas, scalex = 1., fontsize = svg.DEFAULT_FONTSIZE):
fw = svg.font_width(fontsize)
sel... | true |
c5bd998858106c15312341bf81a68420b8f259ad | tnakaicode/jburkardt-python | /subset/compnz_enum.py | UTF-8 | 3,782 | 2.703125 | 3 | [] | no_license | #! /usr/bin/env python3
#
import numpy as np
import matplotlib.pyplot as plt
import platform
import time
import sys
import os
import math
from mpl_toolkits.mplot3d import Axes3D
from sys import exit
sys.path.append(os.path.join("../"))
from base import plot2d, plotocc
from timestamp.timestamp import timestamp
from i... | true |
4ec7d7725a2e6de508bd32f2fd223c2dbea9b5d7 | PerryHuan9/LearnPython | /if.py | WINDOWS-1252 | 906 | 3.140625 | 3 | [] | no_license | # coding=gbk
cars=['audi','bwm','subaru','toyota']
for car in cars:
if car=='bwm':
print(car.upper())
else:
print(car.title())
print('audi' not in cars)
print('audi' in cars)
age=12
if age<4:
print('Your admisson cost is $0.')
elif age<18:
print('Your admission cost is $5.')
else:
print('Your admisson cost is... | true |
00e741b742ada3e9a214f2a385a1dac8d3b7c073 | Morgan10E/Cells | /feature_extractor.py | UTF-8 | 3,113 | 2.53125 | 3 | [] | no_license | from PIL import Image, ImageFilter
import math
import numpy as np
from scipy import ndimage
import sys
import csv
import subprocess
from os import listdir, path
from fft_extractor import fftExtractor
def CreateCountMap(csvFilename):
fileCountMap = {}
penIndex = -1
countIndex = -1
with open(csvFilename)... | true |
3be765adfadb36ee69c4943c84d78ee63b39a830 | Arthur-Miertschink/ExerciciosPhyton | /Lista1/Exercicios pt. 2/VolumeEAreaDaEsfera.py | UTF-8 | 374 | 4.3125 | 4 | [] | no_license | print('Vamos calcular o volume e a área da esfera')
pi = 3.14
raio = float(input('Digite o raio da esfera (em metros): '))
if(raio <= 0):
print('O raio está incorreto, tente novamente!')
else:
area = 4 * pi * (raio ** 2)
volume = (4/3) * pi * (raio ** 3)
print(f'A area e o volume da esfera são, res... | true |
71d33d95363c536e57338e0a04cbf99dca35a3cd | ryanh153/Morsels | /53_78/68_instance_tracker/tracker.py | UTF-8 | 779 | 3.3125 | 3 | [] | no_license | from weakref import WeakSet
def instance_tracker(*outer_args):
"""Return a class that can be inherited from and tracks all instances of that class
:param
outer_args:
If an argument is passed it will be the name of the attribute [str] the instances are stored on.
All other arguments will b... | true |
14e8b0ddf67f375b68393fd676159e46ff0cd506 | johnmusiu/Maintenance-Tracker | /migration.py | UTF-8 | 2,841 | 2.765625 | 3 | [] | no_license | """
defines db migrations
create tables
"""
from api.db_connect import DBConnect
from werkzeug.security import generate_password_hash
def migration():
try:
db = DBConnect()
cursor = db.connect()
if cursor is not False:
# drop tables if they exist
cursor.exec... | true |
5252c52f97b0c25b73f4de01c189270a438468c0 | GabDn/sistop-2019-2 | /proyectos/2/GarciaOrlando-RodriguezZuriel/PecesCircundantes.py | UTF-8 | 6,171 | 3.25 | 3 | [
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/python
# -*- coding: utf-8 -*-
import random
import threading
import time
#En esta variable se define en numero de peces que puede haber por cada corriente
pecesPorCorriente=2
#Se definen los multiplex que nos permiten controlar el flujo en cada direccion
multiplexReloj = threading.BoundedSemaphore... | true |
faa093c3c0d399b461a791fa05594cf2d30b7538 | miker123/Python-Web-Scripts | /printForms.py | UTF-8 | 375 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python
#Author: Mike R
#Date: Thursday, October 8th, 2015
#Code that prints all forms and the form fields in each in a given website.
import mechanize
#getting the website
website=raw_input("Please input a website to crawl the forms:")
br=mechanize.Browser()
#fetching the website
br.open(website)
#... | true |
0ec809efd6a892ebe1a47c03ada4de6fcae3c265 | mhsotoudeh/mir-course-project | /semanticscholar/semanticscholar/spiders/semanticscholar_spider.py | UTF-8 | 1,412 | 2.578125 | 3 | [] | no_license | import scrapy
from ..items import SemanticscholarItem
class SemanticScholarSpider(scrapy.Spider):
name = 'semanticscholar'
custom_settings = {'CLOSESPIDER_ITEMCOUNT': 5000}
f = open('start.txt', 'r')
start_urls = [url.strip() for url in f.readlines()]
f.close()
def parse(self, response):
... | true |
e367a1b2381a70a80e70ea781a6d3ef2e612f07b | Mahboub99/Orchestra | /utilities/staff_line_removal.py | UTF-8 | 9,344 | 2.65625 | 3 | [
"MIT"
] | permissive | import cv2
import numpy as np
import skimage.io as io
from collections import Counter
from skimage.filters import threshold_otsu
from skimage import color
from copy import deepcopy
from skimage import feature
import matplotlib.pyplot as plt
from skimage import measure
def staff_removal(in_img, thresh):
filterOne ... | true |
804a8fcccbda6562d57a6ab08f5e0c89b956a1b3 | Devanshu-singh-VR/OpenCV_mine | /OpenCV/24. detect shape.py | UTF-8 | 1,500 | 2.953125 | 3 | [
"MIT"
] | permissive | import cv2 as cv
import numpy as np
img = cv.imread('shape.png',1)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
_,thresh = cv.threshold(gray,240,255,cv.THRESH_BINARY)
contour,_ = cv.findContours(thresh,cv.RETR_TREE,cv.CHAIN_APPROX_NONE)
for count in contour:
approx = cv.approxPolyDP(count, 0.01*cv.arcLength... | true |
fa366e5fb959b95f92d6913feebe6ee1a93415f8 | YaroslavLtv/All_ITStep_Python | /Homeworks/hw16_Lytvyniuk/hw16_Lytvyniuk.py | UTF-8 | 3,400 | 4.34375 | 4 | [] | no_license | import random
random_list_1 = []
random_list_2 = []
third_list = []
for i in range(12):
random_list_1.append(random.randint(-10, 20))
random_list_2.append(random.randint(-99, 99))
print(f"First ist of random numbers: {random_list_1}\nSecond list of random numbers: {random_list_2}")
home_work = True
while home_... | true |
cc480ab2622281e5b578338d7638f0676b52050c | sbseo/leetcode | /Amazon/compareVersion.py | UTF-8 | 739 | 3.109375 | 3 | [] | no_license | class Solution:
def compareVersion(self, version1: str, version2: str) -> int:
num1, num2 = (map(int, v.split(".")) for v in (version1, version2))
num1, num2 = list(num1), list(num2)
d = len(num2) - len(num1)
num1 += [0]*d
num2 += [0]*-d
if... | true |
89a2e05fadca71de07802abc14204f62443c39fb | lucasmoeskops/codility | /nailing_planks/main.py | UTF-8 | 3,199 | 3.734375 | 4 | [] | no_license | """
You are given two non-empty arrays A and B consisting of N integers. These arrays
represent N planks. More precisely, A[K] is the start and B[K] the end of the K−th plank.
Next, you are given a non-empty array C consisting of M integers. This array represents M
nails. More precisely, C[I] is the position where y... | true |
59b6bb08a1a19665b97ae0ed973c5b2a26cdd492 | kbane0176/CS1 | /August20.py | UTF-8 | 134 | 3.265625 | 3 | [] | no_license | print("Today is Tuesday, August 20th")
print("Next Week is Week 3 of the First Quarter")
input("\n\nPress the enter key to exit.")
| true |
d6ee1f3c399fcbbc8421052aa6974f8dbf94491f | jborza/watch-doom-receiver | /util/frame_nr.py | UTF-8 | 685 | 3.453125 | 3 | [] | no_license | from PIL import Image, ImageDraw
# image size
imgx = 120
imgy = 120
image = Image.new("RGB", (imgx, imgy))
draw = ImageDraw.Draw(image)
def draw_frame(number):
#wrap around frames
if(number > 120):
number = number % 120
frame_txt = f'Frame {number:03}'
frame_txt = f'Frame {number:03}'
pr... | true |
2656f87a98363d12f322c3a3bfadf25800e23e74 | shirisha24/Dictionary | /middle num.py | UTF-8 | 396 | 3.484375 | 3 | [] | no_license | dict_nums=dict(x=list(range(11,20)))
dict1=dict(y=list(range(21,30)))
dict2=dict(z=list(range(31,40)))
print(dict_nums)
print(dict1)
print(dict2)
print(dict_nums["x"][4])
print(dict1["y"][4])
print(dict2["z"][4])
for k,v in dict_nums.items():
for a,b in dict1.items():
for c,d in dict2.items():
p... | true |
152ebc997b80cd965cfa1e3dd6dce1692b10aa92 | joyang93/2_highlight | /request/det_dlib.py | UTF-8 | 5,235 | 3.0625 | 3 | [] | no_license | import face_recognition
import cv2
import sys, os
# import numpy as np
sys.path.append(os.pardir)
def determine_dlib(file_name, start, end, picture_path, duration, fps = 30, frame_duration_suc = 10, frame_duration_fail = 30):
## using dlib
# codec
# This is a demo of running face recognition on a vid... | true |
7e86461b6e412b5d950843dea6485ba2e664d8ff | guillaume-gricourt/HmnRandomRead | /tests/main_tests.py | UTF-8 | 1,832 | 2.640625 | 3 | [
"MIT"
] | permissive | import gzip
import logging
import os
import subprocess
import unittest
from typing import List
class MainTests(unittest.TestCase):
dataset_path = os.path.join(os.path.dirname(__file__), "dataset")
exec_path = os.path.join(os.path.dirname(__file__), "HmnRandomRead")
# Gold input
toy_fa = os.path.join(d... | true |
88be1fcc5cb811720588743745801c1913fd9785 | raidenawkward/odeen | /src/py/odeen/predict/ui/console/cycle.py | UTF-8 | 1,395 | 3.46875 | 3 | [] | no_license | # coding = utf-8
class Cycle:
DEF_LIST = [
'-', '\\', '|', '/'
]
def __init__(self, l=DEF_LIST, interval=1, ticks=20):
import sys
import time
self._index = 0
self._list = l
self._out = sys.stdout
self._interval = interval
self._isWorking = ... | true |
83c564c3f789d80ac8fe539a26754abebe1bc0f6 | HanSolo7/online-python-aug-2016 | /Solutions/Fundamentals/csv.py | UTF-8 | 362 | 3.234375 | 3 | [] | no_license | import csv
# MAKE SURE YOU HAVE ACCESS TO THE FILE
with open('us-500.csv', 'rU') as csv_file:
reader = csv.reader(csv_file)
keys = reader.next()
for data in reader:
print "{} {}".format(data[0], data[1])
for idx in range(len(keys)):
print "{}: {}".format(keys[idx], data[idx])
... | true |
f97b1f6af3eb756fb766da3321fb1ed75f15aede | knaughten/mitgcm_python | /plot_utils/slices.py | UTF-8 | 27,276 | 3.015625 | 3 | [] | no_license | #############################################################
# Utilities specific to slice plots (lat-depth or lon-depth).
# Also general transect between two points, or data along
# ice shelf front (scroll down)
#############################################################
import numpy as np
from matplotlib.patches ... | true |
0de5f9c49c54bc97609b9e23fa8d474a47177806 | t-madeira-novus/Monofasicos | /funcoes.py | UTF-8 | 7,205 | 2.828125 | 3 | [] | no_license | import pandas as pd
import time
from tqdm import tqdm
def removeFirstOccur(string, char):
string2 = ''
length = len(string)
for i in range(length):
if(string[i] == char):
string2 = string[0:i] + string[i + 1:length]
break
return string2
def virgula_por_ponto(df, coluna... | true |
7a523fb4ab69db3c3d5df5d9412df7ba47734dc8 | WeAreHus/StudyRecord | /day-2018-09-02/LearnAI_xjh/learntens1.py | UTF-8 | 791 | 3.15625 | 3 | [] | no_license |
#-*-coding:utf-8-*-
import tensorflow as tf
sess = tf.Session()
# 创建变量 W 和 b 节点,并设置初始值
W = tf.Variable([.1], dtype=tf.float32)
b = tf.Variable([-.1], dtype=tf.float32)
# 创建 x 节点,用来输入实验中的输入数据
x = tf.placeholder(tf.float32)
# 创建线性模型
linear_model = W*x + b
# 创建 y 节点,用来输入实验中得到的输出数据,用于损失模型计算
y = tf.placeholder(tf.float32)... | true |
5fd2b15b6e504a7c060d70b0f6e4eb55ffebbde5 | danielcs88/fl_econ_news | /markdown_writer.py | UTF-8 | 704 | 3.296875 | 3 | [] | no_license | import feedparser
FEED_URL = "https://news.google.com/rss/search?q=%7Bflorida+economic%7D&hl=en-US&gl=US&ceid=US:en"
feed = feedparser.parse(FEED_URL)
feed.keys()
feed["entries"][0].published[:25]
def print_news():
feed = feedparser.parse(FEED_URL)
article = feed["entries"][0:10]
header = """# Florid... | true |
8279a20db395a3bf75aef217878678d5532ca4e7 | Bonifase/simple-board-game | /helpers.py | UTF-8 | 4,829 | 3.25 | 3 | [] | no_license | import os
import random
import time
from constants import (
NUM_ROWS,
NUM_COLS,
HIDDEN_CARD,
EMPTY_SPOT,
DELAY
)
if (NUM_ROWS * NUM_COLS) % 2 != 0:
raise ValueError('There must be even number of spots')
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
def print_title():
... | true |
316255e82d003c734a34553d7f3e910d7165884f | wcAlex/TensorFlow | /pluralsight/rnn_language_model/demos/python/CharacterPrediction_RNNs_Predictions.py | UTF-8 | 11,158 | 3.09375 | 3 | [] | no_license |
# coding: utf-8
# ### Character prediction using RNNs
# In[1]:
get_ipython().system(u'pip install --upgrade numpy')
get_ipython().system(u'pip install --upgrade tensorflow')
get_ipython().system(u'pip install --upgrade bs4')
# In[1]:
from __future__ import absolute_import
from __future__ import division
from __f... | true |
cd97968d1e0b8f48e46966e6941cc97695f9b755 | seanchen513/leetcode | /dfs/1376_time_needed_to_inform_all_employees.py | UTF-8 | 9,731 | 3.921875 | 4 | [] | no_license | """
1376. Time Needed to Inform All Employees
Medium
A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company has is the one with headID.
Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[he... | true |
846427cabe52ed0ce209aa62e5498a20c16b164a | AdamZhouSE/pythonHomework | /Code/CodeRecords/2559/60648/280674.py | UTF-8 | 326 | 2.90625 | 3 | [] | no_license | n=int(input())
for i in range(n):
s=input()
for j in range(len(s)):
count=0
for k in range(len(s)):
if j!=k:
if s[j]==s[k]:
print(0)
break
else:
continue
if j==len(s)-1:
pr... | true |
cd6bee2e3d73d66952cedbc3bce4e99091b7026d | haydnw/AirPi | /sensors/dht22.py | UTF-8 | 4,876 | 3.109375 | 3 | [
"BSD-3-Clause"
] | permissive | """ Read data from the DHT22 sensor.
A high-level Class to read data from the DHT22 sensor. An instance of
the Class can read *either* temperature *or* pressure; see __init__()
for more detail. Requires the low-level dhtreader.so (shared object) to
read the raw data from the sensor.
"""
import sensor
import dhtreader... | true |
3a256af4031b86c62c918d3ea8c98d2b4a113b80 | lwjNN/leetcode-python | /Python/leetcode/dfs_bfs/Solution_08_10.py | UTF-8 | 2,078 | 3.6875 | 4 | [] | no_license | """
编写函数,实现许多图片编辑软件都支持的「颜色填充」功能。
待填充的图像用二维数组 image 表示,元素为初始颜色值。初始坐标点的横坐标为 sr 纵坐标为 sc。需要填充的新颜色为 newColor 。
「周围区域」是指颜色相同且在上、下、左、右四个方向上存在相连情况的若干元素。
请用新颜色填充初始坐标点的周围区域,并返回填充后的图像。
示例:
输入:
image = [[1,1,1],[1,1,0],[1,0,1]]
sr = 1, sc = 1, newColor = 2
输出:[[2,2,2],[2,2,0],[2,0,1]]
解释:
初始坐标点位于图像的正中间,坐标 (sr,sc)=(1,1) 。
初始坐标... | true |
0abd58e0858b5f44b0bb7bc94a694ac568d366d4 | RegisDeVallis/CorpBot.py | /Cogs/Face.py | UTF-8 | 877 | 2.796875 | 3 | [
"MIT"
] | permissive | import asyncio
import discord
from discord.ext import commands
# This is the Face module. It sends faces.
class Face:
# Init with the bot reference, and a reference to the settings var
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def lenny(self, ctx, *, message : str = ... | true |
24be985ca64f1946c049c870b611a2ec6791d1fa | rishabhng/arbie | /Arbie/Variables/trades.py | UTF-8 | 939 | 2.921875 | 3 | [
"MIT"
] | permissive | """Trades contain variables for trading."""
from Arbie.Variables.pool import Pools
from Arbie.Variables.token import Tokens
class Trade(object):
def __init__(self, pools: Pools, path: Tokens, ratio=None, amount_in=None):
self.pools = pools
self.path = path
self.amount_in = amount_in
... | true |
e90da9535e34cf064b2c732b22fa7ed283860be9 | gabriellaec/desoft-analise-exercicios | /backup/user_044/ch83_2020_04_13_13_22_41_513035.py | UTF-8 | 241 | 2.8125 | 3 | [] | no_license | def medias_por_inicial(dic):
dn={}
for i,n in dic.items():
if i[0] not in dn:
dn[i[0]]=n
else:
for h,j in dn.items():
if i[0]==h:
dn[h]=(j+n)/2
return dn | true |
5e6bb4c2473d0f7d6f2e36a96612d182032acb60 | nicholasnigel/Forward-Algorithm-Hidden-Markov-Model- | /asg3.py | UTF-8 | 2,138 | 3.484375 | 3 | [] | no_license | # Main
# Get Input: - - - - - - - - - - - - - - - - - - - - - - - - - -
num_states = input()
pi = []
for i in range(num_states):
num = input()
pi.append(num)
# initialize the transition table first :
transition_table = [[] for x in range(num_states)]
for i in range(num_states):
for j in range(num_states... | true |
57c26a7e748fdc964b5ad1c73f644b3ea6685f29 | luizdefranca/Curso-Python-IgnoranciaZero | /Aulas Python/Conteúdo das Aulas/125/125.py | UTF-8 | 1,805 | 4.375 | 4 | [] | no_license | print("Propriedades e Descritores")
input()
print("Propriedades - Permitem gerenciar a criação")
print("e manipulação de atributos de uma da classe")
print("Semelhante aos métodos __getattr__, __setattr")
print("e __getattribute__ porem menos genéricos")
input()
print("Exemplo")
class Pessoa(object):
def __init_... | true |
4a72a9bdcb100ba0754f46d10a4b77c019b845fc | Oysteinvikane/DAT255_Drug_Discovery | /references/MOESM-src/13321_2017_226_MOESM2_ESM/Scripts/kNN_tune.py | UTF-8 | 3,882 | 2.625 | 3 | [] | no_license | from sklearn.neighbors import KNeighborsClassifier
import csv
import os
import numpy as np
from sklearn.metrics import auc,roc_auc_score,recall_score,precision_score,f1_score
from sklearn.metrics import matthews_corrcoef
from sklearn.metrics import accuracy_score
from sklearn import metrics
import time
import string
... | true |
b7cfd5bfb4716e514cb922192bdbf7c062b97f1e | oar-team/evalys | /evalys/visu/lifecycle.py | UTF-8 | 7,609 | 3.046875 | 3 | [
"BSD-3-Clause"
] | permissive | # coding: utf-8
import matplotlib.gridspec
import matplotlib.lines
import matplotlib.patches
import matplotlib.pyplot
import pandas
from . import core
from .. import utils
class LifecycleVisualization(core.Visualization):
"""
Visualization of the lifecycle of jobs in a jobset.
The `LifecycleVisualizati... | true |
a5841bb3556bc149e54af3ada803e39586df2b86 | lqktz/python_practice | /ex37.py | UTF-8 | 1,448 | 3.828125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# 关键字
print """
and : 与
del : 用于删除变量
a = 10
del a
b = [1, 2, 3, 4]
del b[2]
b就变为:[1, 2, 4]
or : 或
from : 导包,from ... import ...
not : 非
while : 循环
with ... as ... :
with open("/tmp/foo.txt") as file:
data = file.read()
pass :空语句,保证语句结构的完整性
if ... elif ... else ..... | true |
0be317f6a58b8ceffb639e544b1ae0ad99e1e666 | jizhi/jizhipy | /Basic/InArgs.py | UTF-8 | 692 | 3.359375 | 3 | [] | no_license |
def InArgs( local, *args ) :
'''
local:
must be given: locals()
*args:
dict(s)
will .update() local to *args
'''
# Example:
# class A( object ) :
#
# def __init__( self, a ) :
# self.inargs = {}
# InArgs(locals(), self.inargs, self.__dict__)
# print self.inargs
#
# def B( self, b ) : ... | true |
6fc8845e86ea743b60e1ade650b330e28e60d033 | francois-rozet/elen0016-2 | /2/python/models.py | UTF-8 | 9,846 | 2.859375 | 3 | [] | no_license | """
ELEN0016-2 - Computer vision
University of Liège
Academic year 2019-2020
Student project - Part 2
Sudoku digit recognition and performance assessment
"""
#############
# Libraries #
#############
import os
import cv2
import numpy as np
from sudoku import threshold
from keras.utils.np_utils import to_categorica... | true |
09ec9bba45ea7721b59157bf54da88c03c0a7be6 | alecordev/data-science | /src/matplotlib/animations/generated_animation.py | UTF-8 | 1,039 | 3.390625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Generate some random data
n = 100
x = np.random.rand(n)
y = np.random.rand(n)
# Create a pandas dataframe from the data
df = pd.DataFrame({"x": x, "y": y})
# Create a figure and axis
fig, ax = plt... | true |
b33af79e594518bc7f331b506c07e32799fd401d | BruceChen7/ToysCode | /Python/tinyHTTP/tinyhttp/response.py | UTF-8 | 5,310 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
response.py
~~~~~~~
This module is used to dispatch read/write event for http server
"""
import urllib
import os
import stat
import pystache
class HTTPResponse:
"""It's a class to represent a http response
"""
ServerString = "Server: toyhttp/0.1\r\n"
Encoding = {
"U... | true |
eb7733a3c37d29c422b3f0439d2e2ffe2843d1ca | duongnt52/project-web | /mlab.py | UTF-8 | 513 | 2.765625 | 3 | [] | no_license | import mongoengine
#mongodb://<dbuser>:<dbpassword>@ds337985.mlab.com:37985/c4e25-foods
# 1. Connect
host = "ds337985.mlab.com"
port = 37985
db_name = "c4e25-foods"
user_name = "admin"
password = "admin1"
# 1.2 Design file food.py
def connect():
mongoengine.connect(db_name, host=host, port=port, username=user_n... | true |
e0b56f81467c1ed892184e461f9af3f6e21fc618 | SylarK/Python_ | /Road/Classes OOP/Polymorphism/ex2.py | UTF-8 | 664 | 3.875 | 4 | [] | no_license | class Orc():
def __init__(self, name, age, element):
self.name = name
self.age = age
self.element = element
def sounds(self):
print('AWRRRG!')
def weapon(self):
print('Take the axe.')
class Human():
def __init__(self, name, age, element)... | true |
92905505575db97da1bb30666da250a61cc17687 | hyj1116/LeetCode-HYJ | /LeetCode Contest/2-Medium/1930. Unique Length-3 Palindromic Subsequences/1930. Unique Length-3 Palindromic Subsequences.py | UTF-8 | 638 | 3.6875 | 4 | [] | no_license | """
https://leetcode.com/problems/unique-length-3-palindromic-subsequences/discuss/1330178/Python-Straight-Forward-Solution
"""
import string
class Solution:
def countPalindromicSubsequence(self, s):
res = 0
for c in string.ascii_lowercase:
i, j = s.find(c), s.rfind(c)
if i ... | true |
f18852796c0eb802310b10f0f30f82b97796d33e | uiandwe/TIL | /back_end/python/tkinter/basic/1.py | UTF-8 | 259 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from tkinter import *
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
if __name__ == '__main__':
root = Tk()
app = Window(root)
root.mainloop()
| true |
c18443a0c5fd0f10e1800af635de91b9a091045c | ossskkar/SoftwareEngineering | /testing_exercises/02_parametrized_test/parametrized_test.py | UTF-8 | 517 | 3.875 | 4 | [] | no_license | from typing import Union
Number = Union[int, float]
class Calculator:
def sum(self, x: Number, y: Number) -> Number:
return x + y
import pytest
SUM_FIXTURES = [
(1, 2, 3),
(1, 5, 6),
(1, 4, 6),
(-5, 4, -1),
]
@pytest.mark.parametrize("x,y,expected_result", SUM_FIXTURES)
... | true |
a27fd5d2c19582d6dd820bfb9fb554cf52213a0b | vincentclaes/datascience | /projects/body_weight_predictor/lstm_nn/long_short_term_memory_network_predictor.py | UTF-8 | 8,372 | 3.3125 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from collections import defaultdict
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
tf.logging.set_verbosity(tf.logging.ERROR)
def lstm(df_raw, look_back=5, end_period=30, neurons = 4, show_plot=True):
#############... | true |
748fadb81d256fc6fc0b7f89a9511d64bb0a346f | JaylenZhang19/Leetcode | /39. Combination Sum.py | UTF-8 | 532 | 2.921875 | 3 | [] | no_license | class Solution:
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
n = len(candidates)
ret = []
def helper(index, com):
if sum(com) > target:
return
if index == n:
if sum(com) == target:
... | true |
1f4235876833bc477c057f003f7d137b592900e4 | calvinschmdt/PySlices | /PySlices/company.py | UTF-8 | 24,806 | 3.296875 | 3 | [
"MIT"
] | permissive | from datetime import datetime
from dateutil import relativedelta
from tabulate import tabulate
import numpy
class Company():
def __init__(self, company_name):
self.ledger = []
self.valuation = 0
self.company_name = company_name
def get_total_shares(self, classes = ['Common', 'Preferred', 'Option'... | true |
cb5ed347ef6ba2fee3fdd4f2fa0eb4719435c11e | uk-gov-mirror/alphagov.content-similarity-models | /recursive_retag_content_business_tax.py | UTF-8 | 11,904 | 2.765625 | 3 | [] | no_license |
class Node:
def __init__(self, entry, all_nodes):
self.base_path = entry['base_path']
self.content_id = entry['content_id']
self.title = entry['title']
if 'parent_content_id' in entry:
self.parent = all_nodes[entry['parent_content_id']]
self.parent.children.a... | true |
9f0a9e2f98a6ea7fab0dd44a10d815f592986ca2 | zhang29845987/tpshop-web | /script/login_case.py | UTF-8 | 1,317 | 2.5625 | 3 | [] | no_license | # 创建测试类
import json
import time
import unittest
from parameterized import parameterized
from config import BASE_DIR
from page.index_page import IndexProxy
from page.login_page import LoginProxy
from utils import DriverUtil
def data():
cs=[]
with open(BASE_DIR+"/data/shuju.json","r",encoding="utf8") as f:
... | true |
9074058482e310704325c208990bc0ba298ad2c4 | Sappadilla/SappyBird | /Sappy_bird/Pipe.py | UTF-8 | 779 | 3.078125 | 3 | [] | no_license | import pygame, random
class Pipe(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
#add random here to randomize the height
self.h = random.randrange(150,350)
self.image = pygame.Surface((20,self.h))
self.image.fill([0,255,0])
self.rect = self.imag... | true |
d39127a6308e6350edac668148f14af53ee3e186 | foggie-sims/foggie | /foggie/utils/prep_dataframe.py | UTF-8 | 10,901 | 2.9375 | 3 | [] | no_license | """
This is a utility function that accepts a dataset and other arguments
and returns a dataframe with the requested fields as columns.
This is useful to put datasets in the proper dataframe format,
correct units, log scales, etc. for shading by other code.
"""
import pandas as pd
import numpy as np
import yt
import ... | true |
83420a7b9885fcd43c5100209ed7451f8362c054 | webclinic017/project_muskat | /gui/widgets.py | UTF-8 | 3,472 | 2.90625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 1 19:33:25 2020
@author: DocZhi
"""
import numpy as np
import pyqtgraph as pg
from pyqtgraph import QtCore, QtGui
_color_up = "#26a69a"
_color_down = "#ef5350"
_color_neutral = "#fff176"
# _color_up = "g"
# _color_down = "r"
## Create a subclass of ... | true |
7bd66c27f69cd9161e9ac6a4ce444d9fb76f344d | SanyaBoroda4/Hillel_Homeworks | /LESSON_06(LISTS, TUPLES)/Lesson 06_4.py | UTF-8 | 103 | 3.265625 | 3 | [] | no_license | x = y = [1, 2, 3]
x[2] = 100
print(x)
print(y)
arr = [[]] * 2
print(arr)
arr[0].append(5)
print(arr) | true |
51ac7dbdee540bd9bafc2551603da23b6915917c | tamarastro/DESI_SV | /VI_merge_functions_v3.py | UTF-8 | 8,034 | 2.625 | 3 | [
"MIT"
] | permissive | # VI_merge_functions_v3
# File for VI merging functions for both notebook and command-line use.
#
import os, sys, glob
import fnmatch
import re
from astropy.table import Table, join, vstack
import pandas as pd
def choose_best_z(vi):
#make new column with best redshift estimate for each VI - take VI redshift if avail... | true |
83621414cd85682d10b7ac64a1d2174b2429857a | hulaoan/homework-arch-5 | /7/qianyukun/nbNetUtils.py | UTF-8 | 253 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
from inspect import currentframe
DEBUG = False
def get_linenumber():
cf = currentframe()
return str(cf.f_back.f_back.f_lineno)
def dbgPrint(msg):
if DEBUG:
print get_linenumber(),msg | true |
90fac33d911369e09f9700252d5c705b75b3d456 | huangruifeng/httpd | /htdocs/cgi_bin/updata.py | UTF-8 | 584 | 2.546875 | 3 | [] | no_license | #!/usr/bin/python
import MySQLdb
import os
conn=MySQLdb.connect('localhost','root','',"student_five")
cour=conn.cursor()
query_string =os.environ.get('QUERY_STRING')
str = str(query_string)
str = str+'&'
usr=str[str.find('=')+1:str.find('&')]
str = str[str.find('&')+1:]
pawd= str[str.find('=')+1:str.find('&')]
#co... | true |
0337721e352831e026f76fe49432e29cc9e2048a | jessamynsmith/django-csv-example | /csv_example/management/commands/import_csv.py | UTF-8 | 2,530 | 2.625 | 3 | [] | no_license | import csv
from decimal import Decimal, InvalidOperation
import os
import re
from django.core.management.base import BaseCommand
from csv_example import models as csv_example_models
def camel_case_to_snake_case(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
s2 = re.sub('([a-z0-9])([A-Z])', r'\1_\2', ... | true |
ff4df77a2dec1fa733e33dbaf7ce27df3c5f7502 | Untanky/bachelor-thesis | /backend/python/flask_app/controller.py | UTF-8 | 1,608 | 2.75 | 3 | [
"MIT"
] | permissive | import sys, os
from flask import request, make_response, jsonify
sys.path.append(os.path.realpath(os.path.dirname(__file__)+"/../dao/src"))
from Exception import IllegalArgumentException, UnknownElementException
from Post import Post
def post_from_request():
data = request.json
if 'id' in data.keys():
post = P... | true |
1af03f19a1acee4965731c33697306cb0042e2f1 | Addyvan/keras2cpp-terminal | /playground/rl_agent_prod/algolib/algo_base.py | UTF-8 | 4,494 | 2.640625 | 3 | [] | no_license | from .util import eprint
import sys
import os.path as path
sys.path.append(path.abspath(path.join(__file__ ,"./gamelib")))
import random
import math
import warnings
from sys import maxsize
import json
from .gamelib.util import get_command, debug_write, BANNER_TEXT, send_command
from .gamelib.algocore import AlgoCore
fr... | true |
850e8207d6df69795fc2dc05c409ffb51e21a276 | Guwudao/Python-demo | /FileSearch.py | UTF-8 | 4,726 | 2.671875 | 3 | [
"MIT"
] | permissive | import os
import shutil
import subprocess
path = "/Users/jackie/Desktop/PersonalInfo/中软资料"
# path = input("请输入文件夹路径: ")
# path = "/Users/jackie/Music/网易云音乐"
GIT_PATH = "/Users/jackie/Desktop/PersonalInfo"
#
# if not os.path.exists(path):
# exit()
def file_rename(old_name, new_name, index=0):
print(old_name)
... | true |
b48fde3ef5dcaeda99dcb15eeb57d6b8f5f17b4b | pytorch/pytorch | /torch/_weights_only_unpickler.py | UTF-8 | 10,716 | 2.5625 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause",
"LicenseRef-scancode-secret-labs-2011",
"LicenseRef-scancode-generic-cla",
"BSL-1.0",
"Apache-2.0"
] | permissive | # Unpickler restricted to loading only state dicts
# Restrict constructing types to a list defined in _get_allowed_globals()
# Restrict BUILD operation to `Tensor`, `Parameter` and `OrderedDict` types only
# Restrict APPEND/APPENDS to `list`
# In `GLOBALS` operation do not do class lookup by name, but rather rely on di... | true |
cce9dde646aa731ed78f573b5fb208475762161e | hyelim-kim1028/lab-python | /lec01/ex06.py | UTF-8 | 2,093 | 4.4375 | 4 | [] | no_license | #November 05, 2019
"""
문자열 (str) 타입
"""
u = '''
안녕하세요
Python
'''
# 큰 따옴표, 작은 따옴표 모두 사용가능 하고, 주석과는 다르다
d = """
안녕하세요,
Python
"""
"""
이건 주석입니다, 하지만 위에 아이는 문자열 입니다
"""
t = """
def my_function(x: int) -> int:
return x + 1
"""
print(t)
# 큰/작은 따옴표 3개를 사용한 문자열의 경우 내가 문자열을 만든 그대로 출력 (공백과 indentation 모두 그대로)... | true |
3c96d4c4a672bc519780ce182a4e9e6faa676f1c | YuanXianguo/Python-MOOC-2019 | /数据分析与展示/02、数据分析之展示-matplotlib/02pyplot绘图区域.py | UTF-8 | 277 | 3.328125 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.exp(-t) * np.cos(2 * np.pi * t)
def h(t):
return np.cos(2 * np.pi * t)
a = np.arange(0.0, 5.0, 0.02)
plt.subplot(211)
plt.plot(a, f(a))
plt.subplot(2, 1, 2)
plt.plot(a, h(a), 'r--')
plt.show()
| true |
01df8694606e17e7f850ef13aa80e6694b365296 | MatthewMagee20/Python_Labs | /Week2/DecimalBinaryConverter.py | UTF-8 | 1,141 | 4.09375 | 4 | [] | no_license | import sys
def decimalToBinary():
number = int(input("\nEnter a decimal number: "))
i = 1
result = 0
while number > 0:
remainder = int(number % 2) #modulus of number
result = result+(i*remainder)
number = int(number/2)
i = i*10
print("\nBinary: ",resu... | true |
947d566d50c63d9cb7d62e5a3910604df4d02555 | SCurtis95/Lab4 | /curt0061Library.py | UTF-8 | 1,132 | 4.46875 | 4 | [] | no_license |
def calculateAreaOfCircle():
import math
radius = input("Please enter a radius: ")
radiusInt = int(radius)
areaOfCircle = (math.pi * radiusInt ** 2)
aoC = str(areaOfCircle)
calcmpg = print("The area of the circle is " + aoC)
return calcmpg
def calculateMPG():
miles = input("Pleas... | true |
996747497f7a3c130f8c93a1da956e3b87b2329f | WealthCity/django-project | /retiresmartz/calculator/cashflows.py | UTF-8 | 4,296 | 3 | 3 | [] | no_license | from __future__ import unicode_literals
import datetime
from abc import abstractmethod, ABCMeta
from dateutil.relativedelta import relativedelta
from common.utils import months_between
from main.models import Inflation
from .base import FinancialResource
class CashFlow(FinancialResource):
__metaclass__ = ABCMe... | true |
94f08b06276e6737c523127fff28f7672ad294ce | Akshansh986/StockMarket | /src/Algo1.py | UTF-8 | 1,391 | 2.53125 | 3 | [] | no_license | from DataLoader import DataLoader
from Infrastructure import *
def start_trading(market, start_time, account):
while True:
market_opened = market.tick()
if not market_opened:
break
price = market.get_price()
if price is None:
continue
if market.get_... | true |
30296b4ec97d4dc476d2a092d116d74a33288ddc | joelranjithjebanesan7/Thirukural-api | /Project3/import_thirukural.py | UTF-8 | 670 | 2.65625 | 3 | [] | no_license | import csv
import sqlite3
def thirukural_db():
conn = sqlite3.connect("/home/joelrj/Project3/thirukural.db")
c = conn.cursor()
with open("/home/joelrj/Downloads/indianpincode.csv","r",encoding = 'latin-1') as csv_file:
csvReader = csv.DictReader(csv_file)
value_db = [(i['officename'],i... | true |
bf6bcc129b0349069f2d5bbe1cbd1209cb487db0 | richardbarran/django-photologue | /photologue/tests/test_photosize.py | UTF-8 | 1,084 | 2.671875 | 3 | [
"BSD-3-Clause"
] | permissive | from django.core.exceptions import ValidationError
from .factories import PhotoSizeFactory
from .helpers import PhotologueBaseTest
class PhotoSizeNameTest(PhotologueBaseTest):
def test_valid_name(self):
"""We are restricted in what names we can enter."""
photosize = PhotoSizeFactory()
p... | true |
c83b0ed0867aad285feeaf0c88cd67a6b6a8b277 | jay51/wallbreakers | /week1/valid_anagram.py | UTF-8 | 559 | 3.515625 | 4 | [] | no_license |
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(t) != len(s): return False
chars1 = {}
chars2 = {}
for char1, char2 in zip(s, t):
if char1 not in chars1:
chars1[char1] = 1
else:
chars1[char1] += 1
... | true |
c3e48d5b9adf9e0b09b1bcc4be0e9d55ab0c83f3 | eharacz/Stock-Dividend-Analysis | /dividend_analysis_function.py | UTF-8 | 1,351 | 3.296875 | 3 | [] | no_license | def analyze_dividend_performance(ticker):
### this function runs multiple functions to analyze stock dividend performance
try:
divy=historical_dividends(ticker)
pricy=historical_price(ticker)
historics= pd.merge(pricy, divy, how='outer')
historics=historics.sort_values(by='Date',... | true |
d150265b42cb453c7772fe489a12ffb4cd2ec365 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/point-mutations/98fd6117fbca484c96ff8ad571e24b1a.py | UTF-8 | 143 | 3.046875 | 3 | [] | no_license | class DNA:
def __init__(self, s):
self.s = s
def hamming_distance(self, s2):
return len([e for e in zip(self.s, s2) if e[0] != e[1]])
| true |
2d11d4b67f426d13e8b85464ca34075675dc09bf | msiemieniukmorawski/python | /Day_7/ex_import_2.py | UTF-8 | 433 | 2.890625 | 3 | [] | no_license | # trzeci sposób importowania
# importujemy wszystko z modułu
from dzien7.moj_modul.odwracacz import *
# tutaj możemy użyć bezpośrednio nazwy funkcji
odwrocony = odwroc_string("ewa")
print(odwrocony)
# uwaga przy tym sposobie może nastąpić konflikt nazw
# jeśli zaimportujemy w ten sposób kilka modułów i będą one mieć... | true |
2d3f39e38075476d64819cdf4fc62f749614d3fa | nsidc/qgreenland | /qgreenland/config/datasets/future_projections.py | UTF-8 | 3,616 | 2.53125 | 3 | [
"MIT"
] | permissive | from qgreenland.models.config.asset import HttpAsset
from qgreenland.models.config.dataset import Dataset
future_icesheet_coverage = Dataset(
id="future_icesheet_coverage",
assets=[
HttpAsset(
id="rcp_26",
urls=[
"https://arcticdata.io/metacat/d1/mn/v2/object/urn... | true |
0e04131a6be29e9f10da4bd2d8bda5b90b5d3c7e | SujaySSJ/MSDC | /CF(in memory).py | UTF-8 | 4,275 | 3.015625 | 3 | [] | no_license | import random
import sys
import pickle
import matplotlib.pyplot as plt
import time
#make changes to the following parameters as per each dataset
#total no of unique users in dataset
no_of_users=1100000
#total no of unique songs in dataset
no_of_songs=163208
#total no of tuples in dataset
no_of_ratings=1450934
#tota... | true |
fad8c98837d5b4b71d27ccf7afd0e3c9bc8b58d1 | tung491/algorithms | /problems/levenshtein_distance.py | UTF-8 | 1,757 | 3.5625 | 4 | [] | no_license | def levenshtein_distance1(str1, str2):
"""
Time: O(NM)
Space: O(NM)
:param str1:
:param str2:
:return:
"""
edits = [[x for x in range(len(str1) + 1)] for _ in range(len(str2) + 1)]
for i in range(1, len(str2) + 1):
edits[i][0] = i
for i2, c2 in enumerate(str2, start=1):
... | true |