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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
40bb2f72a4ff7e12382e1410f8dd136b5e149e9c | Python | roopa-13/Edge_detection | /EdgeDetection.py | UTF-8 | 1,762 | 3.421875 | 3 | [] | no_license | import cv2
img = cv2.imread("task1.png", cv2.IMREAD_GRAYSCALE)
img = img.astype(float)/255
imgx_new = img.copy()
imgy_new = img.copy()
sobel_x = [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
sobel_y = [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]
width, height = img.shape[:2]
# Convolution of the image with the sobel-x... | true |
2b4eaa19df1d002511832a2347e641fb5a53d5e7 | Python | EarthenSky/Python-Practice | /misc&projects/ex(1-1).py | UTF-8 | 220 | 3.9375 | 4 | [] | no_license | # global variable parameters
name = "Gabe Stang"
grade = 11
class_period = 5
# str() casts the integer variables into strings
print name + " is in grade " + str(grade) + " and has programming in block " + str(class_period)
| true |
fa61921224dc3f953fc0e766f1aa06334f6b47bf | Python | duanzhihua/cs188 | /Project2/multiAgents.py | UTF-8 | 17,323 | 3.4375 | 3 | [] | no_license | # multiAgents.py
# --------------
# Licensing Information: You are free to use or extend these projects for
# educational purposes provided that (1) you do not distribute or publish
# solutions, (2) you retain this notice, and (3) you provide clear
# attribution to UC Berkeley, including a link to http://ai.berkeley.e... | true |
f9725e3748e7008128a41bcd420acb3e5844d9b7 | Python | wghreg/pystudy | /op_shell.py | UTF-8 | 549 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# author: wgh
# Date: 2018/7/31 0031 下午 17:30
import subprocess
'''
Python和Shell的交互,可以通过subprocess这个内置模块实现,它能帮助我们直接执行Shell命令,并且获取返回的结果。
模块还支持控制Shell进程的输入输出等... 但如果是比较复杂的Shell脚本,还是推荐直接用Shell编写,然后Python调用实现起来更加方便
'''
date = subprocess.getstatusoutput('date')
time = subproc... | true |
bed84092a34948b1c1f509966c0bdc853465bd87 | Python | tectronics/snapi-bot | /plugins/weather.py | UTF-8 | 3,743 | 2.578125 | 3 | [] | no_license | # coding: utf-8
# weather.py
# Initial Copyright (с) esprit
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distri... | true |
123c8ac24fe7693c9a97742e901ecde68e96e64a | Python | Iliy-klos/Teaching | /8th mod.py | UTF-8 | 1,055 | 3.640625 | 4 | [] | no_license | i = 0
g = 0
l = 0
c = 0
n = 0
# Удаление отриц. чисел
x = [1, 3, 5, -1, 3, -2]
for i in range(len(x)-1):
if x[i] < 0:
del x[i]
print(x)
# Посчитать отрицательные числа
y = [[1, -1, 0], [2, 5, -9], [-2, -3, 0]]
for g, l in enumerate(y):
for c, k in enumerate(l):
if k < 0:
n += 1
prin... | true |
e26510fe38199fe708b4762b750faf59d37f4c4b | Python | guru-14/CodeChef | /October Long Challenge 2019/Missing Number (MSNG).py | UTF-8 | 4,364 | 3.015625 | 3 | [] | no_license | MAX = 10 ** 12
def toDecimal(s, base):
p = 0
num = 0
for i in range(len(s) - 1, -1, -1):
if s[i] >= "0" and s[i] <= "9":
num += (base ** p) * (ord(s[i]) - ord("0"))
else:
num += (base ** p) * ((ord(s[i]) - ord("A")) + 10)
p += 1
if num > MAX:
... | true |
684fbd81ad0f753688b49567808134d056667625 | Python | nipy/nipype | /nipype/interfaces/utility/tests/test_csv.py | UTF-8 | 1,149 | 2.546875 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
from nipype.interfaces import utility
def test_csvReader(tmpdir):
header = "files,labels,erosion\n"
lines = ["foo,hello,300.1\n", "bar,world,5\n", "baz,goodbye,0.3\n"]
for x in range(2):
... | true |
240849cf832671f5376fe3905a5f6ae06864843b | Python | chromium/chromium | /chrome/updater/app/server/win/generate_user_system_idl.py | UTF-8 | 4,387 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | # Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""A tool for generating IDL files from a template, with distinct user and
system identities for interfaces that are decorated with `BEGIN_INTERFACE` and
`END_INTERFACE`.
`BEGIN_I... | true |
7a06adbf4d079fbe49057e2bb9f606d0e270a4ab | Python | dongfeif/lkker-document-tag | /src/FileLoader.py | UTF-8 | 2,345 | 2.984375 | 3 | [] | no_license | import os
import zipfile
import json
class FileLoader(object):
# 文件解压的路径
un_zip_dir = os.getcwd() + '/tmp/'
files = []
images = []
texts = []
def __init__(self, path):
self.path = path
def read(self, path=''):
if path == '':
path = self.path
# self.path... | true |
457ed055d555b6c60075bfbab500b2fa26f7d1db | Python | smml1996/search_engine | /scripts/preprocess/index_file_splitter.py | UTF-8 | 350 | 2.953125 | 3 | [] | no_license | import pandas as pd
data = pd.read_csv("index_file.txt", sep='\t')
# drop by Name
data = data.drop(['url', 'title'], axis=1)
count_row = data.shape[0]
half = int(count_row/2)
df1 = data.iloc[:half]
df1.to_csv ('df1.csv', index = False, header=True, sep='\t')
df2 = data.iloc[half:]
df2.to_csv ('df2.csv', index = Fal... | true |
caf0d0915814af894c2812b06b1c2c4d5023b085 | Python | yma010/hangman-py-project | /test.py | UTF-8 | 1,830 | 4.21875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 18:49:10 2019
@author: Marvin
"""
def score(word, f):
"""
word, a string of length > 1 of alphabetical
characters (upper and lowercase)
f, a function that takes in two int arguments and returns an int
Returns the score of word as... | true |
73531bc0328e9f59381dbd37f86e15c78011f3bc | Python | Jcnovoa1/tallerIntegradorPythonUNLZ | /GuiaEjercicios/Ejercicio3.3.py | UTF-8 | 1,120 | 4.84375 | 5 | [] | no_license | """
Ejercicio 3.3.
Escribir una función que encuentre los números primos comprendidos entre
dos números enteros ingresados por teclado.
"""
#Listas Números Primos
primos = []
#Determina si el Numero es Primo
def esPrimo(numPrimo):
if numPrimo < 1:
return False
elif numPrimo == 2:
return True
... | true |
af8c4b2ae00a48d58a7048003c73702559850c32 | Python | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_2_neat/16_0_2_vovapolu_clfB.py | UTF-8 | 435 | 3.140625 | 3 | [] | no_license | fin = open('input.txt', 'rb')
fout = open('output.txt', 'wb')
n = int(fin.readline()[:-1])
for i in xrange(n):
s = fin.readline()[:-1]
cur_ans = 0
j = 0
while True:
while j < len(s) and s[j] == '+':
j += 1
if j > 0 and j < len(s):
cur_ans += 1
if j == len(s):
break
while j... | true |
2d52ae4511f204cb9313784e746847eb5825b28b | Python | gidoj/ore | /ore.py | UTF-8 | 15,966 | 2.8125 | 3 | [] | no_license | import sys, readline, inspect, subprocess
from pathlib import Path
from io import StringIO
from collections import OrderedDict
# self defined modules
from orecompleter import OreCompleter
from flag import Flag
from textstyler import Styler
class Ore(object):
intro = "Welcome. Type ? or help for documentation, ??... | true |
ef3ab8e8208e836765db86b7cebc24ef12d8e428 | Python | jvanderz22/march-madness-bracket-picker | /scripts/kenpom_scraping/scraper.py | UTF-8 | 1,238 | 2.796875 | 3 | [] | no_license | from selenium import webdriver
from contextlib import contextmanager
import os
import json
class KenpomScraper:
def __init__(self):
self.email = os.getenv('KENPOM_EMAIL')
self.password = os.getenv("KENPOM_PASSWORD")
self.home_address = 'http://kenpom.com'
self.tournament_name = "Me... | true |
af5a0f802bafb57082741c4fc1ad5fd68f52e1c5 | Python | innightm/LearningTasks | /3.py | UTF-8 | 403 | 3.796875 | 4 | [] | no_license | import random
mas = []
sum = 0
# Генерируем массив из 10 чисел от 1 до 10:
mas = [random.randint(1,10) for i in range(1,10)]
print(mas)
# Проходим в цикле по массиву и все четные числа суммируем:
for i in mas:
if (i%2) == 0:
sum += i
print(sum)
input ("\nДля выхода, нажмите Ввод...")
| true |
8af9f2e5af1095a739eab92655053abb45a7a6a0 | Python | boyuezhong/2018---2019-Equipe-5 | /aval/src/score.py | UTF-8 | 19,944 | 2.640625 | 3 | [] | no_license | #! /usr/bin/env python3
"""
Contains all classes, methods and functions refering to a score.
"""
import contextlib
import os
import tempfile as tmp
import numpy as np
from modeller import * # Load standard Modeller classes
from modeller.automodel import * # Load the automodel class
import src.checking... | true |
55da50b34029da661e6f7f72439330705660f04a | Python | kimjuhee12/Multimodal-Emotion-Recognition | /emotion_recognition/utils.py | UTF-8 | 4,307 | 2.578125 | 3 | [] | no_license | import wave
import struct
import numpy as np
def loadwav(filename):
waveFile = wave.open(filename,'rb')
nchannel = waveFile.getnchannels()
length = waveFile.getnframes()
nBytes = nchannel * length
format = "<" +str(nBytes) + "h"
waveData = waveFile.readframes(length)
data_a = struct.unpack... | true |
68572abb0bfd0a15b347edeb3f877e423c1e2aa0 | Python | riegojerey/file_organizer | /organizer.py | UTF-8 | 361 | 2.59375 | 3 | [] | no_license | import shutil, time, os
from holy_dik import path_extension
input_path = 'C:\\Users\\R. Terte\\Desktop\\Organizer'
for file_path in os.listdir(input_path):
real_path = os.path.join(input_path, file_path)
file_name, ext_name = os.path.splitext(real_path)
if ext_name.lower() in path_extension:
shuti... | true |
3c179593d5a47e2fd0706cfa298b1f43e3100b07 | Python | benkiel/fontParts | /Lib/fontParts/test/test_point.py | UTF-8 | 1,301 | 2.9375 | 3 | [
"MIT"
] | permissive | import unittest
from fontParts.base import FontPartsError
class TestPoint(unittest.TestCase):
def getPoint_generic(self):
contour, unrequested = self.objectGenerator("contour")
unrequested.append(contour)
contour.appendPoint((0, 0), "move")
contour.appendPoint((101, 202), "line")
... | true |
e8feeb2c862eb0d98938296901760d57460c1f82 | Python | eggtgg/bai12_MinhTriHo_final | /b12_1_sinhlist.py | UTF-8 | 371 | 2.96875 | 3 | [] | no_license | import random
import numpy as np
n=random.randrange(50,1001)
print(n,' Là giải độc đắc của chương trình xổ số hôm nay!','\n')
a=list(np.random.randint(-1000,1000, size=n))
print('Chúc mừng các giải khuyến khích!')
print(a,'\n')
b=list(np.random.uniform(-1000,1000, size=n))
print('Chúc các bạn may mắn lần sau!')
print(b... | true |
7722ed0fc8fb3e514eeb239452bc1f1e705bfcb3 | Python | ederson-lehugeur/fullstack-nanodegree-vm | /vagrant/lesson_4/project.py | UTF-8 | 7,110 | 2.671875 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Base, Restaurant, MenuItem
from flask import Flask, render_template, request, redirect, url_for, flash, jsonify
app = Flask(__name__)
engine = create_engine('sqlite:///restaurantmenu.db')
Ba... | true |
a29a9894017e358730dd72f6c061b2bb2ac3a451 | Python | xbfool/smscd | /smsd/src/common/timer.py | UTF-8 | 551 | 3.484375 | 3 | [] | no_license | # coding=utf-8
#!/usr/bin/env python
import time
class Timer:
def __init__(self):
self.tmBegin = time.time()
def elapse(self):
tmEnd = time.time()
return int((tmEnd - self.tmBegin)*10**3)
def elapseUs(self):
tmEnd = time.time()
return int((tmEnd - self.tmBegin)*10**6)
def elapseS(self):
tmEnd... | true |
341dc0a835aae747d8f7cd6e21b9911083276283 | Python | jh-lau/leetcode_in_python | /02-算法思想/数学/223.矩形面积(M).py | UTF-8 | 1,091 | 4.03125 | 4 | [] | no_license | """
@Author : Liujianhan
@Date : 20/6/26 20:39
@FileName : 223.矩形面积(M).py
@ProjectName : leetcode_in_python
@Description : 在二维平面上计算出两个由直线构成的矩形重叠后形成的总面积。
每个矩形由其左下顶点和右上顶点坐标表示,如图所示。
示例:
输入: -3, 0, 3, 4, 0, -1, 9, 2
输出: 45
说明: 假设矩形面积不会超出 int 的范围。
"""
class Solution:
... | true |
1acdf5cd7ab91c2ee8b00f02d564c073fac0e46e | Python | pedrocambui/exercicios_e_desafios | /python/cursoemvideo/ex094.py | UTF-8 | 1,178 | 3.71875 | 4 | [] | no_license | pessoas = dict()
lista = list()
total = 0
while True:
pessoas.clear()
pessoas['nome'] = str(input('Nome: ')).strip()
while True:
pessoas['sexo'] = str(input('Sexo [M/F]: ')).upper().strip()[0]
if pessoas['sexo'] in 'MF':
break
print('ERRO! Por favor, digite apenas M ou F.... | true |
82edb534cafd815e28e99f175bff12a9ab42a314 | Python | Spansky/slides | /03-python-examples/req_ex.py | UTF-8 | 248 | 2.625 | 3 | [] | no_license | import requests
try:
res = requests.get("https://google.com", timeout=5)
except:
print("No connection.")
try:
res = requests.get("https://www.baidu.com", timeout=5)
except:
print("No connection.")
print(res.ok)
print(res.content)
| true |
22c003d8dda86be26b8da752da79e8c39b47a7af | Python | silnrsi/langtags | /lib/langtag/__init__.py | UTF-8 | 21,661 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
'''Langtags processing module
SYNOPSIS:
from langtag import lookup, langtag
t = lookup('en-Latn')
l = langtag('en-Latn')
'''
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions... | true |
a0f2a5217d3f3218f19020ebe4d2692214d4fb08 | Python | sushmita119/pythonProgramming | /programmingInPython/leetcode 3.py | UTF-8 | 121 | 2.9375 | 3 | [] | no_license | s ="pwwkew"
c=0
l=[]
for i in range(len(s)):
if s[i] not in l:
l.append(s[i])
c+=1
print(c)
print(l)
| true |
a2f1ec34a268ef5bfcbfd5a5b4b256eb000b83d9 | Python | Sequd/python | /Steps/Neuro/Parceptron1.py | UTF-8 | 903 | 3.0625 | 3 | [] | no_license | import numpy as np
def parceptron_learn_step1():
# x = np.array([[1, 60], [1, 50], [1, 75]])
w = np.array([[-5], [-1], [5], [0]])
x = np.array([[1], [0], [1], [1]])
step1 = w.T.dot(x)
print(step1)
# print(step1.mean(axis=0))
w = np.array([[5], [0], [-1], [-5]])
x = np.array([[1], [1],... | true |
a75da87ba39fe8417f4d066b871229b47a9fc1d6 | Python | kmust-why/Python | /project/python堡垒机/project/paramiko_test1.py | UTF-8 | 1,127 | 2.9375 | 3 | [
"MIT"
] | permissive | import paramiko
#1、创建一个ssh链接的实例
ssh = paramiko.SSHClient()
#2、制定当前ssh实例采用默认的受信列表,并且对不受信的计算机进行通过
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#3、远程登陆到指定的服务器
ssh.connect(
hostname='172.93.39.34',#要连接的主机的ip
port=29192,#端口
username='root',#远程登陆的主机的用户名
password='8W8XkW9sTM9h',#远程登陆的主机的用户名
)
#4、... | true |
0e90495f3d90c828285a004a2c249721c69f3ada | Python | aoifemcdonagh/C4.5_ML-DM | /Node.py | UTF-8 | 2,158 | 3.921875 | 4 | [] | no_license | """
Author: Aoife McDonagh
ID Number: 13411348
Class: 4BP
Class for Nodes in a decision tree.
"""
class Node:
"""
Function to initialise a node
Parameters:
@data: All data points underneath this node.
@parent_node: Node which is directly above this node object
@subnodes: A list of subnodes belongin... | true |
f9212807ef9ad385872bad5e2071520ff19c527c | Python | cgwu/python-demo | /syntax-demo/urllib_demo.py | UTF-8 | 677 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
https://blog.csdn.net/kittyboy0001/article/details/21552693
'''
from urllib.parse import urljoin, urldefrag, urlsplit
url = 'schema://net_loc/path;params?query#fragment'
pure_url, frag = urldefrag(url)
print(url)
print(pure_url)
print(frag)
ret = urlsplit(url)
print(ret... | true |
c9cf5118ea157c19b4a17b2647d54082285423b9 | Python | noguzdogan/Alistirmalar_I | /Alistirma7.py | UTF-8 | 385 | 3.890625 | 4 | [] | no_license | total = 0
print("İlk iki rakamı son rakama eşit olan 3 basamaklı sayılar:\n")
for x in range(100,999):
iyi_uyu = str(x)
ilk = iyi_uyu[0]
orta = iyi_uyu[1]
son = iyi_uyu[2]
inttop = int(ilk) + int(orta)
if (inttop == int(son)):
print(x,end="\t")
total += 1
print("\nBu k... | true |
6ef316fe0cb6c5bed071dc6372b6d0c23108134b | Python | coolerking/tubplayer | /tubplayer.py | UTF-8 | 3,919 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Tubディレクトリ上にあるデータを順番にMQTTブローカ(IBM Watson IoT Platform)へ
データがなくなるまで送信する。
Usage:
tubplayer.py [--conf=CONFIG_PATH] [--tub=TUB_DIR] [--interval=INTERVAL_SECS]
Options:
--config=CONFIG_PATH 設定ファイルパス。
--tub=TUB_DIR 送信するイメージファイルのパス。
--interval=INTERVAL_SECS publ... | true |
2f591c30bb781937a3762cf58474a2795e0650d9 | Python | maxmhuggins/Assorted_Scripts | /PChem/Final Report/Morse Potential/MorsePotential.py | UTF-8 | 4,381 | 2.984375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 10 01:50:38 2019
@author: maxhu
"""
#============================================================================#
import numpy as np
import matplotlib.pyplot as plt
#=======================================#
width = 10 #width for figures
size = 12 #fontsize for... | true |
1891eafe2fc62d8246258b9fa0247c7afaba1edc | Python | DIAOZHAFENG/simplework | /DealWithTables/db_inconnect.py | UTF-8 | 1,331 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import json
import pymssql
from DBUtils.PooledDB import PooledDB
with open('db_settings', 'r') as sf:
s = json.load(sf)
class MSSQL:
# 连接池对象
__pool = None
def __init__(self):
# 数据库构造函数,从连接池中取出连接,并生成操作游标
self._conn = MSSQL.__getConn()
self._cursor = sel... | true |
a1e683049125120dd2ad87196780063be184909d | Python | YuriiKhomych/ITEA_AC | /Serhii_Hidenko/l_16_web_api/hw/blog/api/utils.py | UTF-8 | 2,881 | 2.8125 | 3 | [] | no_license | from blog import db
from blog.posts.models import Post, Tag
def save_changes(data: object):
"""
Add data to db session and commit it
:param data: Oblect to save
:type data: object
"""
db.session.add(data)
db.session.commit()
def get_all_posts() -> list:
"""
Get all posts
:re... | true |
6469f6d98ca21773cb1955a204ec35424922cded | Python | santiago0072002/Python_stuff | /hackerrankBirthdayCakecandles.py | UTF-8 | 700 | 4.53125 | 5 | [] | no_license | #You are in charge of the cake for a child's birthday.
# You have decided the cake will have one candle for each year of their total age.
# They will only be able to blow out the tallest of the candles. Count how many candles are tallest.
def birthdayCakeCandles(candles): # this is why I love Pytho... | true |
aa3de57dfb6f23802faf0d18529c221e520ae0f0 | Python | Nikituk-hacker/Python | /Tkinter/Квадрат.py | UTF-8 | 163 | 3.796875 | 4 | [] | no_license | import turtle
pen = turtle.Turtle()
angle = 90
pen.forward(100)
pen.left(angle)
pen.forward(100)
pen.left(angle)
pen.forward(100)
pen.left(angle)
pen.forward(100)
| true |
38d758d6d4760335b79fbe22af7beef1ec8f22fa | Python | pulakk/LSTM_RNN_Tensorflow | /fixed size input rnn/lib/load.py | UTF-8 | 878 | 2.734375 | 3 | [] | no_license | import numpy as np
def loadf(seq_len, label_dim, tt_ratio = 0.8):
# init
gen = '{0:0'+str(seq_len)+'b}'
# param is train to test data ratio
features = [[float(char) for char in gen.format(i)] for i in range(2**seq_len)]
labels = [np.eye(label_dim)[bin(i).count("1")%label_dim] for i in range(2**seq_len)]
... | true |
a10c273c477f1c8f52007754c999aa4f817853a2 | Python | sashakrasnov/datacamp | /11-analyzing-police-activity-with-pandas/4-analyzing-the-effect-of-weather-on-policing/01-plotting-the-temperature.py | UTF-8 | 1,042 | 4.96875 | 5 | [] | no_license | '''
Plotting the temperature
In this exercise, you'll examine the temperature columns from the weather dataset to assess whether the data seems trustworthy. First you'll print the summary statistics, and then you'll visualize the data using a box plot.
When deciding whether the values seem reasonable, keep in mind th... | true |
aa8caaf1d5f7da6395592eefc37f65cfbdcb8cfd | Python | lnsongxf/OG-USA | /Python/microtaxest/getmicrodata.py | UTF-8 | 3,944 | 2.921875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | '''
------------------------------------------------------------------------
This program extracts tax rate and income data from the microsimulation
model (tax-calculator) and saves it as csv files.
------------------------------------------------------------------------
'''
from taxcalc import *
import pandas a... | true |
2d63fb116129b92692dcd5a6f52a2a0fb0f09fcd | Python | linpeng109/py_20191122 | /py_chardect.py | UTF-8 | 282 | 2.640625 | 3 | [] | no_license | import chardet
def dectect(filename):
file = open(filename, 'rb')
data = file.read()
return chardet.detect(data)
if __name__ == '__main__':
# filename = '20191127HCS.txt'
filename = '20191127AAS.txt'
result = dectect(filename=filename)
print(result)
| true |
1f21d2cd389d44cb4cb16c954fd205793d0c249d | Python | anthony-yeo/CPE-123 | /something.py | UTF-8 | 1,590 | 3.3125 | 3 | [] | no_license | from sys import *
def main():
filename = ''
flag = ''
calculate_sum = False
try:
if(len(argv) == 2):
filename = argv[1]
elif(len(argv) == 3):
if(argv[2] == '-s'):
filename = argv[1]
flag = argv[2]
calculate_sum = T... | true |
0f2e2479ac3c1cf7206cc2392b638287e54caf47 | Python | slp520/Python-zixue | /adcd.py | UTF-8 | 26 | 2.5625 | 3 | [] | no_license | a=2
b=8
a,b=b,a
print(a,b) | true |
48bc1f6a446e47291f6c2023bc65d2ab7f042e36 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_201/2591.py | UTF-8 | 849 | 3.46875 | 3 | [] | no_license | FILE = 'C-small-1-attempt1.in'
def stall(k, n):
lst = [n]
while k > 1:
big = max(lst)
lst.remove(big)
if big%2 == 0:
lst += [int(big/2), int(big/2-1)]
else:
lst += [int(big//2), int(big//2)]
k -= 1
#print(lst)
re... | true |
b398a4a0024da2ddf26f2ff8e5330a389ebeadac | Python | dave31415/kay | /seasonality.py | UTF-8 | 1,240 | 3.46875 | 3 | [] | no_license | from collections import defaultdict, Counter
def average_by_weekday(dates, y):
"""
:param dates: list or Series of dates
:param y: list or Series of some time-series numerical value
:return: dictionary of weekday averages
and global average, keyed by 'all'
"""
assert len(dates) ==... | true |
e2b43ba36fa291fafb7ce5013649d6b960ece1bd | Python | twitter-forks/model-analysis | /tensorflow_model_analysis/notebook/colab/util.py | UTF-8 | 3,751 | 2.5625 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"MIT"
] | permissive | # Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | true |
bc7cde888c9ec290bf37b8c5a185734c621e90af | Python | cyeh015/cmflow | /cmflow/test_geom_3dface_utils.py | UTF-8 | 3,541 | 2.625 | 3 | [] | no_license | from geom_3dface_utils import *
import unittest
class TestFace(unittest.TestCase):
"""docstring for TestFace"""
def test_load(self):
fault = Face3D()
fault.read('test_geom_3dface_utils_ex.ts')
self.assertEqual(len(fault.points),8286)
self.assertEqual(len(fault.triangles),15857... | true |
7260aea26cbd36a32537619d76cc2203b3cf0dea | Python | iamclearmind/webAppBackend | /spe/strategies/LMR1_1.py | UTF-8 | 4,252 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 28 00:41:00 2020
@author: prateek
"""
import backtrader as bt
from backtrader.indicators import SMA
from spe.cust_ind import hhpc
from spe.cust_ind import pchannel
class LMR1_1(bt.Strategy) :
params = (
('trade_size',1),
('benchmark_name', 'NSEI'),
('t... | true |
b5cabe3b2e431d92b2226b37fbb21a71732794fc | Python | VdovichenkoSergey/QAutomation_python_pytest | /home_work_6/task_3.py | UTF-8 | 697 | 3.328125 | 3 | [] | no_license | from itertools import groupby
'''Записывает в новый файл все слова в алфавитном порядке из другого файла с
текстом. Каждое слово на новой строке.
Рядом со словом укажите сколько раз оно встречалось в тексте'''
with open('task3_output.txt', 'r') as file_output:
with open('task3_input.txt', 'w') as file_input:
... | true |
227fc0e978da7762261b33f04ec98c01493d4e1b | Python | acoomans/kanjinetworks | /kanjinetworks/extract/extractor.py | UTF-8 | 2,837 | 2.609375 | 3 | [
"MIT"
] | permissive | import codecs
import os
import re
from cStringIO import StringIO
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
# http://www.slideshare.net/KanjiNetworks/etymological-dictiona... | true |
997cbc8bb3503fd0b1a0f7d65192cd865db47f61 | Python | rldotai/varcompfa | /varcompfa/algos/discrete_actions_categorical_q_learning.py | UTF-8 | 9,680 | 3.46875 | 3 | [] | no_license | """
Categorical Q-Learning with discrete actions for distributional RL.
"""
import numpy as np
from .algo_base import LearningAlgorithm
class DiscreteCategoricalQ(LearningAlgorithm):
"""Discrete Categorical Q Learning (AKA C51) for linear function approximation.
Implemented following [A Distributional Perspec... | true |
13467c7f28014e00eff6240f97e91ff98318b465 | Python | yushuang823/python-learn-new | /pythonsuanfa/18.py | UTF-8 | 588 | 4.0625 | 4 | [] | no_license | """
一个数如果恰好等于它的因子之和,这个数就称为"完数"。例如6=1+2+3.编程找出1000以内的所有完数。
> 请参照程序Python 练习实例14。
"""
# * 1)遍历i从2到1000的数;
# * 2)对这个数i从1到a-1进行除,然后将所有能整除a的数进行相加得sum,
# * 3)如果sum==a,则说明a为完数,否则,不是。
if __name__ == '__main__':
n = 1000
s = []
for i in range(2, n + 1):
for j in range(1, i):
if i % j == 0:
... | true |
eac462f1c7a358a229a4fa6ec511ec9b5198409b | Python | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 5/ejercicios-clase-05-1bim-JamilErasmo/Ejemplo05.py | UTF-8 | 140 | 2.734375 | 3 | [] | no_license | ciudad = input("Ingrese el nombre de la ciudad: ")
if ciudad != "Loja":
print("Acceso correcto")
else:
print("Acceso Incorrecto") | true |
0b197f5e46509ebf441a1b25af4ba013fa021b6b | Python | mazh661/distonslessons | /HomeWork3/task1.py | UTF-8 | 135 | 3.3125 | 3 | [] | no_license | a = [int(s) for s in input().split()]
x = a[0]
y = a[1]
z = a[2]
sumi=x+y-z
if sumi>=0:
print(sumi)
else:
print("Impossible")
| true |
8b9145c1f82a81298264ed383ade2896a53895b3 | Python | chenzhaohuai/Python | /Learn/baike_spider/html_parser.py | UTF-8 | 709 | 2.578125 | 3 | [] | no_license | from bs4 import BeautifulSoup
class HtmlParser(object):
def _get_new_urls(self, page_url, soup):
links = soup.find_all('a', href=re.compiler(r"/view/\d+\.htm"))
for link in links:
new_url = link['href']
new_full_url =
def _get_new_datas(self, page_url, so... | true |
225cddf0a62a1c7d631d326a94b82f236fab2295 | Python | mao-liu/bricklayer | /bricklayer/catalog/crawler.py | UTF-8 | 7,086 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | """
delta_tables crawlers
two functions supported
- restore delta tables from delta_log location
- update existing delta table from delta_log location
```
"""
import typing
import logging
from pathlib import Path
from pyspark.sql import SparkSession
from . import dbricks_catalog
class Crawler():
... | true |
3662a4a676a34198bd20972cfa960ec168cf6755 | Python | LinDeshuang/dg-pro1 | /firstapp/app/toolfunc.py | UTF-8 | 1,428 | 2.75 | 3 | [] | no_license | import hashlib
import io
import os
import random
import string
from PIL import Image, ImageDraw, ImageFont
from django.conf import settings
# md5摘要密码
from firstapp.settings import BASE_DIR
def md5HashPwd(text):
md5 = hashlib.md5()
md5.update((text + settings.SECRET_KEY).encode('utf-8'))
return md5.hexdi... | true |
00d1d9e230c6fdfb3f10aff8accf4faf1284541c | Python | fabiohsmachado/bn_learning_milp | /score_files.py | UTF-8 | 1,115 | 2.984375 | 3 | [
"MIT"
] | permissive | #!/bin/python
#Read a list of datasets and score their variables using Gobnilp's scorer
import sys, os
from subprocess import call
def ScoreDatasetFile(pathToScorer, pathToDataset, ess, palim):
print "Scoring the dataset", pathToDataset ;
scoreFileName = os.path.splitext(pathToDataset)[0] + ".scores";
scoreCommand... | true |
61614d6ee9240e836fd7a005a7c9cf933c5ec123 | Python | AIsCocover/python | /python-road/012/012.py | UTF-8 | 1,208 | 4 | 4 | [] | no_license | #! E:\codeprojects\python\pythonEveryDay\012
# 第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入
# 敏感词语,则用 星号 * 替换,例如当用户输入「北京是个好城市」,则变成「**是个好城市」。
import re
def read_file(filename) : # 读取文件
content = []
with open(filename,'r') as file :
for line in file.readli... | true |
b48eba215a419aba6cea1ddf04b02379f4efbca0 | Python | mblange/python | /csurfer.py | UTF-8 | 2,228 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python
#####################
# defeat anti-csrf tokens
#####################
try:
import requests
import lxml.html as lh
from io import StringIO
import argparse
except ImportError, e:
print "Exception: {}".format(str(e))
exit(1)
ap = argparse.ArgumentParser(description='"Intru... | true |
4ba7741764f02bd8469c42f89fcdfd9d685f64b5 | Python | lbu0413/python-study | /SWEA-PYTHON-BASIC-2/6302.py | UTF-8 | 369 | 3.5625 | 4 | [] | no_license | # 리스트 내포 기능을 이용해 [12, 24, 35, 70, 88, 120, 155]에서
# 첫번째, 다섯번째, 여섯번째 항목을 제거한 후 리스트를 출력하는 프로그램을 작성하십시오.
# 입력없음
# 출력
# [24, 35, 70, 155]
n = [12, 24, 35, 70, 88, 120, 155]
m = [i for i in n if n.index(i) != 0 and n.index(i) != 4 and n.index(i) != 5]
print(m)
| true |
fb0b9b8ca0293e306a08800714f5bc063148a526 | Python | epistemologist/Project-Euler-Solutions | /euler243.py | UTF-8 | 218 | 2.78125 | 3 | [] | no_license | def euler243():
from sympy.ntheory import totient
d = 10
while True:
if d%100==0: print d
if totient(d)*94744<15499*(d-1):
print d
break
d+=1
print euler243() | true |
8474a47128a1180be451feda9d77f5ff94a59a29 | Python | bclarke98/eftracker | /saver.py | UTF-8 | 1,584 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import os
import sys
import json
import requests
from multiprocessing import Pool
from scraper import mkdir
def download_icons():
mkdir('img')
try:
icons = {}
with open('dat/iconcache.json', 'r') as j:
icons = json.loads(j.read())
amtdl = 0
fo... | true |
d0124ecb56c0e71da710addc113735c4de90f4a9 | Python | JiSuHyun2689/PS-python | /study/string/10809.py | UTF-8 | 336 | 3.375 | 3 | [] | no_license | from sys import stdin
import string
word_list = list(stdin.readline().strip("\n"))
for alphabet in string.ascii_lowercase:
if alphabet not in word_list:
print(-1)
else:
print(word_list.index(alphabet))
# alphabet = "abcdefghijklmnopqrstuvwxyz"
# for i in alphabet:
# print(str(word_list).f... | true |
4e1c3ba2e04a544d7abee26435be27908b2d71e9 | Python | maaayanglin/MyLeetcode | /My_Answers/leetcode09_Palindrome_Number/pySolution01.py | UTF-8 | 471 | 3.078125 | 3 | [] | no_license | # 执行用时 :92 ms, 在所有 Python3 提交中击败了90.14%的用户
# 内存消耗 :13.1 MB, 在所有 Python3 提交中击败了91.76%的用户
class Solution:
def isPalindrome(self, x: int) -> bool:
try:
if x<0:
return False
rev = int(''.join(list(reversed(str(x)))))
if rev == x:
return True
... | true |
52b19a78507e0d1962419321c4c62b6d7749f2d8 | Python | existeundelta/tattle | /recon/getimgur.py | UTF-8 | 2,447 | 2.984375 | 3 | [] | no_license | import os
import json
import logging
from pathlib import Path
from urllib.request import urlopen, Request
from time import time
from queue import Queue
from threading import Thread
import multiprocessing
POOLSIZE = multiprocessing.cpu_count()
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - ... | true |
f8bbcd5f79228f31996adfa57262dc84f5dc3241 | Python | hxsylzpf/Machine-Learning-Privacy | /data/optdigits.py | UTF-8 | 2,092 | 2.609375 | 3 | [] | no_license | #from converter import writeAttributes
def makeDict():
files = {}
files['datafile'] = "optdigits.tra"
files['testfile'] = 'optdigits.tes'
return files
def getFiles(c, filename, files):
config = open(c, 'r')
for line in config:
if line.split(',')[0] == filename:
... | true |
6fb42ea89c91a5e8947430b94d880d355bab64f9 | Python | magic149162/Project_Euler | /21_amicable_numbers.py | UTF-8 | 1,406 | 3.8125 | 4 | [] | no_license | #https://projecteuler.net/problem=21
#Evaluate the sum of all the amicable numbers under 10000
#solution 1: less time but more lines
'''def d(x):
d = set()
if x == 1:
return d
for i in xrange(1,int(x**0.5+1)):
m = x % i
n = x / i
if m == 0 :
d.add(i)
d.add(n)
d.remove(x)
return sum(d)
ami = []
... | true |
907fb6d156d97bd2ba8346beb935254bb699431d | Python | carines/openclassroom_python | /4 _frameworks/res/Client.py | UTF-8 | 5,398 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# Externe
from socket import *
from select import select
from threading import Thread
from tkinter import *
# Interne
from res.Listener import Listener
from res.Sender import Sender
from res.settings import *
########## CLASSE CLIENT #########... | true |
b5003bae61d930d452370a12022313611595216b | Python | Athulya-Unnikrishnan/DjangoProjectBasics | /LaanguageFundamentals/exceptionHandling/lessthanzeroexception.py | UTF-8 | 238 | 3.9375 | 4 | [] | no_license |
try:
num = int(input("Enter a number"))
print(num)
if(num<0):
raise Exception("number less than 0")
except Exception as e:
print("Enter a number greater than 0")
num=int(input("Enter a number"))
print(num) | true |
9a9d64cbfd29ec3ffa784c460b8485054c64c350 | Python | SMSteen/Python_Assignments | /OOP_assignments/modular_store/store.py | UTF-8 | 3,619 | 4.34375 | 4 | [] | no_license | ''' OOP Assignment 9 - Store
Build a store to contain our products by making a store class and putting our products into an array.
ATTRIBUTES: products (array of products objects); location (store address); owner (store owner's name)
METHODS:
add_product: add a product to the store's product list
... | true |
228505b0b141f39bfcf8c3dd653f99db3d95f68e | Python | AutuanLiu/ML-Docker-Env | /examples/sklearn_test.py | UTF-8 | 881 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name:PolynomialRegression
Description : 多项式回归
数据使用随机生成的数据
http://sklearn.apachecn.org/cn/0.19.0/modules/linear_model.html#polynomial-regression
Email : autuanliu@163.com
Date:2017/12/17
"""
im... | true |
603ca587b797970db66224baafe2634da0e5382a | Python | paulrefalo/Python-2---4 | /python2/DatabaseHints_Homework/src/testClassFactory.py | UTF-8 | 1,296 | 2.90625 | 3 | [] | no_license | import unittest
from database import login_info
import mysql.connector
from classFactory import build_row
class DBTest(unittest.TestCase):
# mysql -h sql -u <username> -p <username>
def setUp(self):
S = build_row("animal", "id name family weight")
self.a = S([8, "Dennis", "Dragon", 1000... | true |
bc9504a086695545481ff45e9fded11177d7aad8 | Python | RaghavGoyal/Raghav-root | /python/code/LessonsDump/6-ExternalLibraries/Pendulum/basicdates_start.py | UTF-8 | 434 | 2.71875 | 3 | [] | no_license | # Python Essential Libraries by Joe Marini course example
# Example file for Pendulum library
from datetime import datetime
import time
import pendulum
# TODO: create a new datetime using pendulum
# TODO: convert the time to another time zone
# TODO: create a new datetime using the now() function
# TODO: Use the... | true |
0657cb2e83e1a65bfb8b3fcaf6a68df47f0c4060 | Python | Rolv-Arild/MatteProsjekt | /Body.py | UTF-8 | 4,043 | 2.984375 | 3 | [] | no_license | import functools
import numpy as np
from numpy.core.multiarray import ndarray
from RungeKuttaFehlberg import RungeKuttaFehlberg54
G = 6.67408e-11 # m^3 / kg s^2
class Body:
mass: float
radius: float
coord: ndarray
velocity: ndarray
angular_velocity: ndarray
def __init__(self, mass: float,... | true |
74a95e1cf03d5e00225b697fe56c5dc0dfb78932 | Python | Bhavana1801/challenges_accepted | /python/assert.py | UTF-8 | 114 | 3.015625 | 3 | [] | no_license | chars=['apple']
def display(elem):
assert type(elem) is int,'hurray!'
print chars[elem]
elem = 'i'
display(elem) | true |
747e6bbaa7a9e6463ebeddcd0a97689b4309ca18 | Python | Wineson/DPSSIM | /enemy.py | UTF-8 | 3,046 | 2.734375 | 3 | [] | no_license | import read_data as rd
import activeeffects as a
import copy
#Enemy with stats
class Enemy:
def __init__ (self, enemy, level):
enemydict = rd.read_enemy_data()
self.name = enemydict[enemy].name
self.level = int(level)
self.element = "None"
self.units = 0
self.defence... | true |
5338c033aa255d4568452760de7f9125c6304ebb | Python | muldvang/filch | /filch/modules/dropbox_module.py | UTF-8 | 1,692 | 2.875 | 3 | [
"MIT"
] | permissive | import socket
import os
import time
from threading import Thread, Event
def run(callback):
status = fetch_status()
callback(render(status))
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(os.path.expanduser('~/.dropbox/iface_socket'))
event = Event()
updater_thread = Thread(tar... | true |
a883fca824b29809e4c3f65242a9f6eae9b5341f | Python | alvaronaschez/amazon | /leetcode/amazon/sorting_and_searching/merge_intervals.py | UTF-8 | 1,024 | 3.6875 | 4 | [] | no_license | """
https://leetcode.com/explore/interview/card/amazon/79/sorting-and-searching/2993/
Merge Intervals
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into... | true |
3fc823846fd9ca91e7441320b36b35a69b02172b | Python | EdgarPozas/inventario-objetos | /algorithm/algorithm.py | UTF-8 | 2,374 | 2.609375 | 3 | [] | no_license | import random
ends={}
def listSub(originalTarget,target,dataSet,path):
if dataSet==[]:
k=abs(originalTarget-sum(path))
if not k in ends.keys():
ends[k]=[]
ls=list(path)
ls.sort()
if not ls in ends[k]:
ends[k].append(ls)
return
for i ... | true |
f78c66d317861d41c3c6d616d208039b11f6e21f | Python | sarim-zafar/Library-Of-Pybel | /library_of_babel.py | UTF-8 | 10,184 | 3.171875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import string
import random
import sys
length_of_page = 3239
loc_mult = pow(90, length_of_page)
title_mult = pow(90, 25)
help_text = '''
--checkout <addr> - Checks out a page of a book. Also displays the page's title.
--fcheckout <file> Does exactly the search does, but with address in the f... | true |
cd25e61033f014b3037022613359d3ffe93ee186 | Python | KseniaYurko/DAC-ADC | /DAC/sin.py | UTF-8 | 636 | 2.765625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import RPi.GPIO as GPIO
import time
N = [26, 19, 13, 6, 5, 11, 9, 10]
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(N, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
def num2dac(val):
binary = bin(val)[2:].zfill(8)
binary = binary.replace("0b", '')
binary ... | true |
d675db539df0b92d905a0b24ead3e77e1c538844 | Python | Jean-Bi/100DaysOfCodePython | /Day 24/snake_game/main.py | UTF-8 | 2,606 | 3.890625 | 4 | [
"MIT"
] | permissive | # Imports the Screen class from the turtle module
from turtle import Screen
# Imports the Snake class from the snake module
from snake import Snake
# Imports the Food class from the food module
from food import Food
# Imports the Scoreboard class from the scoreboard module
from scoreboard import Scoreboard
# Import... | true |
d1727884564c47f936f830e56a1b8a4672d907d8 | Python | kennycaiguo/Heima-Python-2018 | /00-2017/就业班/01练习/数据结构和算法/面试题优化.py | UTF-8 | 800 | 3.640625 | 4 | [] | no_license | #coding=utf-8
#如果 a+b+c=1000,且 a^2+b^2=c^2(a,b,c 为自然数),如何求出所有a、b、c可能的组合?
import time
startTime = time.time()
print(startTime)
for a in range(0,1001):
for b in range(0,1001):
c = 1000 - a -b
if a**2 + b**2 == c**2:
print("a,b,c:%d,%d,%d"%(a,b,c))
endTime = time.time()
print(endTime)
print... | true |
89a74062685dd09b0c9080b69df40be4a1044731 | Python | li-yonghao/ClusteringAlgorithm | /tool/PCA.py | UTF-8 | 914 | 2.78125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import numpy as np
def pca(dataSet, dim = 10) :
mean_val = np.mean(dataSet, axis=0)
cent_mat = dataSet - mean_val
cov_mat = np.cov(cent_mat, rowvar = 0)
eig_val, eig_vec = np.linalg.eig(cov_mat)
eig_val_index = np.argsort(eig_val) # 从小到大排序
# -1 切片函数step是负数,意思是倒着切,取大的
... | true |
bdfba213399ef8b067b17472fd6f4cbc96cb7b27 | Python | MahshidZ/ArchivIT | /DjangoWebApplication/documentViewerApp/scanned_image_processing/image_processing/util_archiveIT.py | UTF-8 | 2,332 | 2.8125 | 3 | [] | no_license | import scipy.signal as signal
import scipy
import numpy as np
import matplotlib.pyplot as plt
from pylab import imread, mean, imsave
from PIL import Image
import scipy.misc as misc
import math
#import mahotas
def gauss2D(shape=(3,3),sigma=0.5):
"""
2D gaussian mask - should give the same result as MATLAB's
... | true |
c5c848ce2c9594258e458da3c414f8df9281da33 | Python | micah-olivas/CS168 | /Miniproject_9/mp9_part1.py | UTF-8 | 1,545 | 3 | 3 | [] | no_license | import cvxpy as cvx
import numpy as np
from PIL import Image as im
from matplotlib import pyplot as plt
## part a
x = []
with open('wonderland-tree.txt') as infile:
for line in infile:
x.extend(map(int, list(line.strip())))
x = np.array(x)
n = x.size
print("n = {}".format(n))
k = sum(x == 1)
print("k = {}"... | true |
3c477778ec034ff56c1abd48ebdd73f21003f7da | Python | renatasarmet/algorithms | /URI/strings/led.py | UTF-8 | 519 | 3.28125 | 3 | [] | no_license | # https://www.urionlinejudge.com.br/judge/pt/problems/view/1168
n = int(input())
for i in range(0,n):
v = input()
total = 0
for digito in v:
if digito == '0':
total += 6
elif digito == '1':
total += 2
elif digito == '2':
total += 5
elif digito == '3':
total += 5
elif digito == '4':
total +... | true |
0db165233e8fa6e28fd118fe1eebe642f55bf285 | Python | wangdaniel0205/stockauto | /RecordUtil.py | UTF-8 | 3,145 | 2.765625 | 3 | [] | no_license | import pandas as pd
import numpy as np
from DataUtil import DataUtil
from datetime import datetime
import time, calendar
def make_new_record(fileName):
dataUtil = DataUtil()
cols = ['date', 'balance', 'profit'] + dataUtil.read_stock_list()
df = pd.DataFrame(columns=cols)
df.to_csv(fileName,index=F... | true |
b554439a563479c44108cf3603cec888d93228df | Python | mehranaman/Intro-to-computing-data-structures-and-algos- | /Assignments/Grid.py | UTF-8 | 1,692 | 3.5625 | 4 | [] | no_license | # File: Grid.py
# Description:Maximum product of four adjacent numbers in a grid.
# Student Name: Naman Mehra
# Student UT EID: nm26465
# Partner Name:NA
# Partner UT EID: NA
# Course Name: CS 303E
# Unique Number: 51850
# Date Created: April 21st, 2017
# Date Last Modified: April 22nd, 2017
def... | true |
d84732c6a09ae10697cc8f4c9272f854f52ebfc2 | Python | percevalve/botany18_pycon | /athanase.py | UTF-8 | 2,857 | 2.875 | 3 | [
"MIT"
] | permissive | # This bot looks one move ahead, and if possible it will make a move to
# block its opponent winning. Otherwise, it picks a move at random.
import copy,os
import random
from botany_connectfour import game
from collections import defaultdict, namedtuple
def get_next_move(board, token):
available_moves = game.ava... | true |
bef54d939577ea74868c99e5ab1aed0d498858b7 | Python | yasosurya33/yaso | /Check number in between.py | UTF-8 | 152 | 3.265625 | 3 | [] | no_license | s=int(input())
a,b=input().split()
lab=0
for i in range(int(a)+1,int(b)):
if i==s:
lab=1
if lab==1:
print("yes")
else:
print("no")
| true |
7ddf2e8f9328853456c60e53bef850fac08d5f40 | Python | a-wvv/reimagined-octo-tribble | /second_page.py | UTF-8 | 963 | 2.921875 | 3 | [] | no_license | from base_page import BasePage
from locators import SecondPageLocators
from random import sample
class SecondPage(BasePage):
def fill_movie_list(self):
def get_list_movies(movies):
mov_rand = sample(movies, 3)
s = f'''{movies[0]} {movies[1]} {movies[2]} {movies[3]} {movies[4]}
{mov... | true |
313aa50b0fd2ceff29bba3cbc700f43079ac9f90 | Python | ravaligayathri/Projects | /CPGIslands.py | UTF-8 | 6,961 | 3.328125 | 3 | [] | no_license | # Author : Ravali Kuppachi
import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import ast
#matplotlib inline
# create state space and initial state probabilities
states = ['a', 'c', 'g' , 't']
pi = [0.25, 0.25 , 0.25 , 0.25]
state_space = pd.Series(pi, index=states, name='sta... | true |
d9567dea280b62f89f1acd25c7ff794fee2e1f54 | Python | alpha-256/Neural-Matrix-Research | /1/V00/oneLiner.py | UTF-8 | 1,398 | 3.640625 | 4 | [
"Unlicense"
] | permissive |
from random import randint
from random import choice
from pprint import pprint
"""
I = input Cell
O = Output Cell
G = Green Cell (Increase signal per step from I Cell)
R = Red Cell (Decrease Signal per step from I Cell)
"""
def ayy(layer_count, size):
layer_matrix = [[choice(["G", "R"]) for _ in ... | true |
e8dbf29c82f23a5b788038dca78e089890dc3fe7 | Python | PeterZs/VectorSkinning | /src/raytri/raytri.py | UTF-8 | 14,151 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | from math import *
from numpy import *
import os
'''
gcc raytri.c raytri_wrapper.cpp -lstdc++ -fkeep-inline-functions \
-dynamiclib -o libraytri.dylib \
-g -O3 -Wall -Wshadow -Woverloaded-virtual -Winit-self -Wno-sign-compare
'''
try:
import ctypes
except:
print '''
ERROR: ctypes not installed properl... | true |
b365b5a2edcf4bf7eb10ceb56e2638fd59145ad9 | Python | Okiii-lh/python_learn | /常用数据结构/queue.py | GB18030 | 613 | 3.359375 | 3 | [] | no_license | """
@File : queue.py
@Contact : 13132515202@163.com
@Modify Time @Author @Version @Description
------------ ------- -------- -----------
2020/2/12 19:44 LiuHe 1.0 ʵֶ
"""
class Queue:
"""
ʵֶ
п
г
"""
def __init__(self):
... | true |