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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6c9001cb2d8425f8bd8e3a7c6ce2bf06a1ae25ec | Python | Thanakorn255/Python_Daily | /Day014.py | UTF-8 | 136 | 3.359375 | 3 | [] | no_license | print("*** Rabbit & Turtle ***")
d, Vr, Vt, Vf = [int(x) for x in input("Enter Input : ").split()]
ans = Vf*d/(Vt-Vr)
print('%.2f' %ans) | true |
ed6e10f18e6d3f64a0b0caeafc85b7281423d613 | Python | zhangymPerson/learning-notes | /programming_language/code-demo/set/py_set.py | UTF-8 | 1,630 | 3.65625 | 4 | [
"LicenseRef-scancode-mulanpsl-1.0-en",
"MulanPSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env python3
import json
def setCurd():
# 新建set
keys = set()
keys.add("a")
print("set = ", keys)
# 会自动去重
setOne = {1, 2, 'a', 'a', 'b', 'c', 'cc'}
print(setOne)
# 转json
# json.dumps(setOne)
jsonStr = json.dumps(list(setOne))
print(jsonStr)
# 新增
setOne.a... | true |
2ffc718207a4e5c8ddf0911885ebbfb645a7b7b2 | Python | em-nome-do-py/flask-with-sqlalchemy | /flask_with_sqlalchemy/app.py | UTF-8 | 2,380 | 2.578125 | 3 | [] | no_license | from flask import Flask, jsonify, request
from .models import database, User, Todo
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
database.init_app(app)
with app.app_context():
database.create_all()
@app.route('/users')
de... | true |
3aa97552d51bddfef19c4f72af95b389e68622ff | Python | krainLai/DL_Pytorch | /3.9 MLP.py | UTF-8 | 1,610 | 2.78125 | 3 | [] | no_license | #多层感知机的从0实现
import torch
import numpy as np
import d2lzh_pytorch as d2l
if __name__ =='__main__':
#加载mnist数据集
batch_size = 256
train_iter,test_iter = d2l.load_data_fashion_mnist(batch_size)
#fashion数据集的图像形状为28*28,类别数为10,本节依然使用28*28=784的向量表示每一张图像.
# 因此输入个数为784.实验中我们设置超参数隐藏层单元数为256
num_inputs,nu... | true |
9fc467378014f49636b1385a99e4c5154398f8bf | Python | jwo29/iot_project | /index.py | UTF-8 | 3,854 | 2.796875 | 3 | [] | no_license | #-*- coding: utf-8 -*-
from flask import Flask, request
from flask import render_template, json
import pymysql
import datetime
import time
import RPi.GPIO as GPIO
app = Flask(__name__)
db = pymysql.connect(
host='localhost',
user='root',
password='1234',
db='mydb', # mydb 데이터베이스의 detect 테이블을 이용함
... | true |
c0d7a189bc45230e74688c38d7ffc4d7d3dd582a | Python | 78Moonlight78/Showtor | /data/genre.py | UTF-8 | 393 | 2.5625 | 3 | [] | no_license | import sqlalchemy
from .db_session import SqlAlchemyBase
class Genre(SqlAlchemyBase):
"""
жанры
"""
__tablename__ = 'genres'
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True, autoincrement=True)
name = sqlalchemy.Column(sqlalchemy.String) # название жанра
is_visibl... | true |
20a9080488c8dd4022a2c42e4cf34a6cbba56902 | Python | visued/raspi-projects | /sensorPir_Relay8ch.py | UTF-8 | 1,960 | 3.046875 | 3 | [] | no_license | #!/usr/bin/python
import RPi.GPIO as GPIO
import time
#set pin sensor
sensor = 5
#set pin list
pinList = [2, 3, 4, 17, 27, 22, 10, 9]
#set time for sleep relay
SleepTimeL = 1
#set previous and current state sensor
previous_state = False
current_state = False
try:
while True:
#set board mode
GPIO.setmode(GPIO.... | true |
c5989e70fa714826a602afe54556b7a125f111ca | Python | crhuffer/GameUtilities | /EventProcessing.py | UTF-8 | 1,159 | 2.65625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 25 11:02:55 2018
@author: crhuffer
Process the data from the streaming API after it has been saved to .csv files
based on the type of event.
"""
# %% library imports
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import PlayerActivity
# %% ... | true |
a0d0cef40d0cfb9d291a18c99c5ebb63116bd3cc | Python | mdebski/munin-plugins | /xapi | UTF-8 | 3,412 | 2.546875 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf8 -*-
#
# Munin plugin to graph CPU load and memory usage on XenServer
#
# author: Maciej Dębski <winemore@staszic.waw.pl>
# Based on check_xapi.py nagios plugin by danievanzyl
import XenAPI
import parse_rrd
import sys
import time
from munin import MultiGraphs, Graph, Item
class Re... | true |
f9ba00df1746d194e15a29832379bbc68caeaa95 | Python | repinnick/teachmeskills | /day13/homework_sql.py | UTF-8 | 2,793 | 2.921875 | 3 | [] | no_license | import psycopg2
import pprint
while True:
sign = input("Какие действия вам необходимо совершить? \n"
"create, read, update, delete, stop: ")
if sign in ('create', 'read', 'update', 'delete', 'stop'):
connection = psycopg2.connect(
database="product",
user="postgres",
... | true |
f7911fcc912167fdc973f784d0e6a7e5847c086b | Python | VRumay/Data-Analysis-Notebooks | /Data Analysis - Zodiac and Serial Killers/scrapeBirthdays.py | UTF-8 | 7,880 | 3.046875 | 3 | [] | no_license | import urllib3
from googlesearch import search
import pandas as pd
import numpy as np
import pyreadr
import requests
from bs4 import BeautifulSoup
import wikipedia
import re
# Data from:
# https://github.com/lhehnke/serial-killers/
# Wallpaper from:
# https://wallpaperaccess.com/hd-stars
#-----
# Convert R studi... | true |
1c2e19d7737f55a93e5d45e28cd8fa246601f6ab | Python | koolhead17/python-learning | /string.py | UTF-8 | 307 | 3.359375 | 3 | [] | no_license | welcome = ("Hello World")
print(welcome)
print(type(welcome))
print(id(welcome))
print()
welcome = ('Hello World')
print(welcome)
print(type(welcome))
print(id(welcome))
print()
welcome = ("")
print(type(welcome))
print(id(welcome))
print()
welcome = ('')
print(welcome)
print(type(welcome))
print(id(welcome)) | true |
26e7752520cf8b924475fc403f1d5e445f4d6f1e | Python | ISPC2020/tscdprog2020_g4-julio-e-ivan | /Ejercicios/Ejercicio4.py | UTF-8 | 1,375 | 4.5 | 4 | [] | no_license | #Realizar un programa en el cual se declaren dos valores enteros por teclado utilizando el método init. Calcular después la suma, resta, multiplicación y división. Utilizar un método para cada una e imprimir los resultados obtenidos. Llamar a la clase Calculadora.
class calculadora:
def __init__(self):
pri... | true |
06995c7fc5b6d5f49c742825efc4893280f5cffc | Python | james-xi/gui-python-tkinter | /src/widgets-tk/radiobutton.py | UTF-8 | 1,467 | 3.46875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""."""
import tkinter as tk
class MainWindow(tk.Tk):
def __init__(self):
super().__init__()
self.title(string='Janela principal')
icon_png = tk.PhotoImage(file='../assets/icons/icon.png')
self.iconphoto(False, icon_png)
width = round(number=self.wi... | true |
97b22f8d2e5ced1475f04dcf0f982581bb190e9a | Python | botify-labs/simpleflow | /simpleflow/marker.py | UTF-8 | 256 | 2.78125 | 3 | [
"MIT"
] | permissive | from __future__ import annotations
class Marker:
def __init__(self, name, details):
self.name = name
self.details = details
def __repr__(self):
return f"<{self.__class__.__name__} {self.name!r} details={self.details!r}>"
| true |
6ef04320746d1e3301ba19d873269b966e92e1c0 | Python | Abuubkar/python | /projects/n-tier_application/DAL.py | UTF-8 | 445 | 2.640625 | 3 | [] | no_license | from BO import Bo
filein = "bill.in"
class Dal(object):
def read(self):
bo = Bo()
with open("bill.in", mode='r') as file:
bo._id, bo.watt, bo.unit, bo._bill = map(
float, file.readline().split(','))
return bo
def write(self, bo):
with open("bill.... | true |
073efd86c65c58674fd3f29e6e47c70fb0a3869e | Python | mdavis29/pythonBluePrints | /lstm_CNN_comment_classifier.py | UTF-8 | 3,325 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive |
import numpy as np
import pandas as pd
from keras.models import Model
from keras.layers import Dense, Embedding, Input
from keras.layers import LSTM, Bidirectional, GlobalMaxPooling1D, Dropout
from keras.preprocessing import text, sequence
from keras.callbacks import EarlyStopping, ModelCheckpoint
from sklearn.model_s... | true |
585dbc7cebbff370890b793a0d0eae504bd33397 | Python | wanglouxiaozi/python | /os/os.removedirs.py | UTF-8 | 409 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: UTF-8 -*-
import os, sys
def test():
try:
#列出目录
print "目录为: %s" % os.listdir(os.getcwd())
#移除
os.removedirs("test")
#列出移除后的目录
print "移除后目录为: %s" % os.listdir(os.getcwd())
except BaseException, Argument:
print "[Catch Error]%s" % str(Argument)
def __main():
te... | true |
9c20a88097f4209d8cf414fa8f7ff074ffc812d5 | Python | nadiavhansen/Python-Projects | /pythonProject2/sistemaLoja.py | UTF-8 | 458 | 3.25 | 3 | [] | no_license |
cpf = input("Digite o cpf: ")
nome = input("Digite o nome: ")
idade = input("Digite o idade: ")
def cadastro_cliente():
cadastroCliente = (f"{cpf}, {nome}, {idade}")
file = open("ClienteCadastro.txt")
file.append(cadastroCliente)
cadastro_cliente()
#
# cadastroCliente = ""
# cadastroClient... | true |
d6652da9efc0d524191b7d1a05caf4309cf3503c | Python | jdeleonferreira/python_exercism | /high-scores/high_scores.py | UTF-8 | 195 | 3.0625 | 3 | [] | no_license | def latest(scores):
return scores.pop()
def personal_best(scores):
return max(scores)
def personal_top_three(scores):
scores = sorted(scores, reverse=True)
return scores[0:3]
| true |
350b80ecb1a2c240750ed88f3c61b3bfa2b16501 | Python | Fundamental-Basic/Fundamental-Python | /jersey.py | UTF-8 | 621 | 3.109375 | 3 | [] | no_license | jersey = 1
ukuran = 'm'
if jersey == 1:
tim = 'persib'
if ukuran == 's':
harga = 100000
print( 'jersey', tim, 'ukuran', ukuran, 'haragnya', harga )
elif ukuran == 'm':
harga = 150000
print( 'jersey', tim, 'ukuran', ukuran, 'haragnya', harga )
elif ukuran == 'l':
... | true |
c32eeb609ec14ab358e0b13b5991c883282c28e7 | Python | unsortedtosorted/codeChallenges | /kClosest.py | UTF-8 | 367 | 3 | 3 | [] | no_license | class Solution(object):
def kClosest(self, points, K):
"""
:type points: List[List[int]]
:type K: int
:rtype: List[List[int]]
"""
def fun(p):
x = p[0]
y = p[1]
return x*x+y*y
points=so... | true |
a7264cd2838cbe5ae214b15eb6246595ac464c26 | Python | ErnestoSiemba/Python-for-Everybody | /Chapter 11 Exercise 1.py | UTF-8 | 280 | 3 | 3 | [] | no_license | import re
fname=input('Enter a File to process: ')
fhand=open('mbox.txt')
regex=input('Enter a regular expression: ')
count=0
for line in fhand:
line = line.rstrip()
if re.findall(regex, line):
count=count+1
print(fname, 'had', count, 'lines the matched', regex)
| true |
b40f29539aecd64b73063d8aae01dd23383b353f | Python | KertAles/Adventures-of-Gargamel | /catkin_ws/src/exercise8/exercise8/scripts/extract_qr | UTF-8 | 2,451 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import print_function
import roslib
# roslib.load_manifest('exercise4')
import sys
import rospy
import cv2
import numpy as np
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
from std_msgs.msg import ColorRGBA
import pyzbar.pyzbar as pyzbar
class The_QRer:
de... | true |
e813551fa3390610ac5e94702926474dda011008 | Python | xian-ran/seis_tools | /decon/decon.py | UTF-8 | 1,876 | 2.796875 | 3 | [] | no_license | import numpy as np
from scipy.linalg import toeplitz
from scipy.sparse.linalg import lsmr
from rf.deconvolve import _toeplitz_real_sym
import numpy as np
import numpy as np
import matplotlib.pyplot as plt
def damped_lstsq(a,b,damping=1.0,plot=False):
'''
Gm = d
G : discrete convolution matrix
m : ... | true |
a182815c0a6fb62f92d3f47be58a1cf8bc3ba9ec | Python | Soxrox12/soxrox12.github.io | /knock-knock.py | UTF-8 | 443 | 3.359375 | 3 | [] | no_license | def knock_knock():
print("Knock knock")
response1 = input('type here: ')
if response1 == "who's there":
print("Europe")
response2 = input('type here: ')
response2 = response2.lower()
if response2 == 'europe who' or 'europe who?':
print("I'm not a poo, you're a poo... | true |
e4375746516d5ac16b38e5a808ab604d4fb761bd | Python | savadev/leetcode-2 | /todo/338-countingBits.py | UTF-8 | 499 | 3.296875 | 3 | [] | no_license | from math import log
class Solution(object):
def countBits(self, num):
"""
:type num: int
:rtype: List[int]
"""
counter = 0
acc = {0:0, 1:1}
for n in range(1,num + 2):
prev = acc[n-1]
b = log(n,2) % 2
pri... | true |
d4585811dd285242b89af200e0ddaa901fef64ed | Python | loveKSHS2/similar_site_recommendation | /main2.py | UTF-8 | 7,866 | 2.53125 | 3 | [] | no_license | import os
from PIL import Image
import tensorflow as tf
import tensorflow_hub as hub
img_path = os.getcwd() + "/images" #이미지가 저장되어 있는 경로
#print(os.getcwd())
CHANNELS = 3 # number of image channels (
def build_graph(hub_module_url, target_image_path):
# Step 1) Prepare pre-trained model for extracting image featu... | true |
43ff08796bb52296eb1ab795560b9bd61deb5af7 | Python | limuxiao/PythonNote_Liy | /week04/测试tcp/TcpClient.py | UTF-8 | 1,025 | 3.125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import socket
class TcpClient(object):
"""
tcp 客户端类
"""
def __init__(self, ip, port):
self.__ip = ip
self.__port = port
self.__sock = None
pass
def start(self):
if self.__sock is None:
self.__sock = socket.socket(sock... | true |
6b8eb10ee75613e9c6e18f1ae1d5acd1766037c3 | Python | byhongyu/carnd-term1-project2 | /Project2.py | UTF-8 | 5,071 | 3.25 | 3 | [] | no_license | ## Step 0: Load Data
##################################################
# Load pickled data
import pickle
# TODO: Fill this in based on where you saved the training and testing data
training_file = 'traffic-signs-data/train.p'
validation_file = 'traffic-signs-data/valid.p'
testing_file = 'traffic-signs-data/test.p'
... | true |
fada7b06b4cd549f02679ef6f051c4c7069604c4 | Python | nigomezcr/Programming-Basics | /11-Plots/4-plot.py | UTF-8 | 931 | 3.203125 | 3 | [] | no_license | """
Description: Plots in python
"""
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-np.pi, np.pi, 0.1)
y1 = np.sin(x)
y2 = np.sin(2*x)
y3 = np.sin(3*x)
y4 = np.sin(4*x)
plt.title("Plot in python")
plt.xlabel('x')
plt.ylabel('$f(x)$')
plt.xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi])
plt.yticks([-... | true |
adabe80248baa65e52e8dc04b1f56f98a8b41032 | Python | Dekardt/OpengGL-2D-3D-Graphics | /3D-Graphics/DisplayMaster.py | UTF-8 | 1,793 | 3.140625 | 3 | [] | no_license | from OpenGL.GL import *
from OpenGL.GLU import gluPerspective
from OpenGL.GLUT import glutSwapBuffers
from LightSource import LightSource
from SceneObject import *
class DisplayMaster:
"""
A class for managing program window. It collects data, initializes window, draws figure, manages keyboard actions.
... | true |
e26022c708483730fa85a873f14008741d1df9d9 | Python | kipod/TelegramBot | /bot/config.py | UTF-8 | 792 | 2.546875 | 3 | [] | no_license | import os
import json
CONFIG_FILE_NAME = 'bot.conf'
class Configuration(object):
def __init__(self):
self.__bot_token = None
self.__bot_manager_token = None
if not os.path.exists(CONFIG_FILE_NAME):
return
with open(CONFIG_FILE_NAME, 'r') as file:
json_obj = ... | true |
bb5cd16264e2db033557eeee8d0603dc177108c4 | Python | nsmith0310/Programming-Challenges | /Python 3/Project_Euler/131-140/problem 137.py | UTF-8 | 170 | 2.8125 | 3 | [] | no_license | ###1120149658760
###https://oeis.org/A081018
from math import sqrt
i = 10
f=[0,2,15,104]
i = 3
while len(f)<=15:
f.append(8*f[-1]-8*f[-2]+f[-3])
print(f[-1])
| true |
58c3076503a4a33cc26633ed87cda9a0759a2c2f | Python | YW81/DAML | /lib/functions/triplet_loss.py | UTF-8 | 889 | 3.03125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import numpy as np
import chainer.functions as F
def triplet_loss(a,p,n,alpha=1.0):
"""Lifted struct loss function.
Args:
f_a (~chainer.Variable): Feature vectors as anchor examples.
All examples must be different classes each other.
f_p (~chainer.Variab... | true |
f0f5a67a40cded5abc5d6dc8f04281a02a94f8f8 | Python | johnnycs/dengue-prediction | /dengue_weather.py | UTF-8 | 1,816 | 2.890625 | 3 | [] | no_license | import pandas as pd
print "dengue weather"
def split_data(data):
train_mask = (data.index < "2011")
train = data[train_mask]
test_mask = (data.index > "2011")
test = data[test_mask]
return train, test
def remove_space(province):
if type(province) == str:
return province.replace(" ", "... | true |
4220c07975d44c5e45302ae0ce66328b3c5dd43c | Python | OSORIPD/wemix | /trader.py | UTF-8 | 1,329 | 2.671875 | 3 | [] | no_license | import simplejson as json
import time
import requests
import base64
import hashlib
import hmac
ACCESS_TOKEN = "4b72dfc3-11ec-4855-92d0-b870caeb74d7"
SECRET_KEY = "17ecd160-738a-4495-abc3-7b35420bc846"
API_NAME = "trader_v1"
def post_param(url, param):
'''signature를 반환함'''
# to json
json_param = json.dumps... | true |
8c5a6a4385c1960364bbf12bc3b8d242a04626da | Python | Yuki23329626/machine-learning | /1-hw/question-d.py | UTF-8 | 6,284 | 2.921875 | 3 | [] | no_license | import numpy as np
import random
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.model_selection import KFold
from sklearn.model_selection import LeaveOneOut
def linear_regression ( x_training, y_training, x_valid, y_valid, sum_training, sum_valid):
wlin = np.linalg.... | true |
b57d152db8ab81e297eb20259185698bb7f9878e | Python | rafaelpllopes/Selenium-Python | /aula 08/wait_aula_10_i.py | UTF-8 | 518 | 2.65625 | 3 | [] | no_license | from selenium.webdriver import Firefox
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.expected_conditions import (
title_contains,
title_is
)
url = 'https://selenium.dunossauro.live/aula_10_c.html'
browser = Firefox()
browser.... | true |
2cf3600175181c176e6b38a0755e9f2c4ff7fb1d | Python | PedroPadilhaPortella/Curso-Em-Video | /Curso de Python Mundo 2/057-adivinhacao2.py | UTF-8 | 686 | 4.09375 | 4 | [] | no_license | from random import randint
from time import sleep
aleatorio = randint(0, 10)
palpites = 0
acertou = False
print('Tente pensar no mesmo numero que eu, entre 0 e 10....')
while(not acertou):
numero = int(input("Sua Tentativa? "))
palpites += 1
if(numero > 10 or numero < 0):
print("Esse numero não ... | true |
518845218290590615462a5c68dd4895ee08cdb0 | Python | rafaelalmeida2909/Python-Data-Structures | /Doubly Linked List.py | UTF-8 | 7,173 | 4.09375 | 4 | [] | no_license | class Node:
"""Class to represent a node in Python3"""
def __init__(self, data):
self.data = data # Node value
self.next = None # Next node
self.prev = None # Previus node
class DoublyLinkedList:
"""Class to represent a doubly linked list in Python3"""
def __init__(self):
... | true |
82ee1c63b1dc8f343d512f5cefe25ccf23f8bb69 | Python | Aasthaengg/IBMdataset | /Python_codes/p03354/s257865865.py | UTF-8 | 884 | 3.34375 | 3 | [] | no_license | import sys
class UnionFind():
def __init__(self, n):
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.f... | true |
53992e1b60557b3327e6e94f2737d469949b3226 | Python | kailee-madden/Data-Science | /kmadden5-hw1-programming/kmadden5-hw1-1.py | UTF-8 | 641 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python3
import pandas
from pandas import Series, DataFrame
D = pandas.read_csv("Dataset-film-data.csv")
A = pandas.read_csv("Dataset-film-data.csv")
A.drop(["AVGRATING_WEBSITE_1", "AVGRATING_WEBSITE_2", "AVGRATING_WEBSITE_3", "AVGRATING_WEBSITE_4"],axis=1,inplace=True)
cols = list(D.columns)
cols.remov... | true |
1fbfebe9fda008741ffc416895fb1b5489e72f5e | Python | shaneebavaisiar/pythonDjangoLuminar | /pyhtoncollections/listprograms/nested_list2.py | UTF-8 | 391 | 3.265625 | 3 | [] | no_license | # lst=[[10,20],[21,22],[51,52],[53,54,55,56]]
# output=[10,20,21,22,51,52,53,54]
# =========================================================
lst=[[10,20],[21,22],[51,52],[53,54,55,56]]
# numlist=[]
# for sublst in lst:
# for n in sublst:
# numlist.append(n)
# print(numlist)
# or (list comprehension meth... | true |
3ceaa73d8a038fd66df01bcf4a8c32d90b5f6027 | Python | amankhoza/data-mining | /SearchEngine/utils.py | UTF-8 | 4,871 | 2.75 | 3 | [] | no_license | # coding: utf-8
import csv
import os
import sys
from functools import wraps
import time
from multiprocessing import Pool, Manager, cpu_count
MSG_START = "[START]"
MSG_SUCCESS = "[SUCCESS]"
MSG_FAILED = "[FAILED]"
def check_python_version():
python_version = sys.version_info
if python_version[0] < 3:
... | true |
d6cd34887085081d9af74894b09b26df657e4207 | Python | ysharc/sudoku-solver | /solution.py | UTF-8 | 8,303 | 3.671875 | 4 | [] | no_license | """
A sudoku solver agent
"""
def assign_value(values, box, value):
"""
Please use this function to update your values dictionary!
Assigns a value to a given box. If it updates the board record it.
"""
# Don't waste memory appending actions that don't actually change any values
if values[b... | true |
db8e9600b2d199f9ef0369e10b17834a2b5f5f3a | Python | minnjung/FCAT | /layers/pooling.py | UTF-8 | 1,890 | 2.578125 | 3 | [] | no_license | # Code taken from: https://github.com/filipradenovic/cnnimageretrieval-pytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
import MinkowskiEngine as ME
class MAC(nn.Module):
def __init__(self):
super().__init__()
self.f = ME.MinkowskiGlobalMaxPooling()
def forward(self... | true |
338a6be3f0399140b0039c810dc30c18349ac22d | Python | moisescantero/M01_python | /M01/main_suma100While.py | UTF-8 | 218 | 3.609375 | 4 | [] | no_license | """hacemos la suma de los 100 primeros números usando while"""
sumaTotal=0
contador=1
while contador<=100:
sumaTotal=sumaTotal+contador
contador=contador+1
print("Total:",sumaTotal)
| true |
fb8a0c9c54a2ddd2e369711944aeff42b94457c7 | Python | tristonarmstrong/ExtronLib-CDS | /extronlib/interface/FlexIOInterface.py | UTF-8 | 4,841 | 3.359375 | 3 | [] | no_license | class FlexIOInterface():
""" This class will provide a common interface for controlling and collecting data from Flex IO ports on Extron devices (extronlib.device). The user can instantiate the class directly or create a subclass to add, remove, or alter behavior for different types of devices.
---
Argume... | true |
8073894c2212a8da9dd3d7a27c11b17b0880ea5e | Python | Abhijitbuet/ML_Theory | /HierarchicalDendogram.py | UTF-8 | 527 | 2.71875 | 3 | [] | no_license | import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage
from matplotlib import pyplot as plt
randomMatrix = np.array([[.4173, .4893], [.0497, .3377], [.9027, 0.9001], [.9448, .3692], [.6, .2]])
linked = linkage(randomMatrix, 'complete')
labelList = ['1','2','3','4','5']
plt.figure(figsize... | true |
015e486d5e859b5c77031f878aefa4dbd7cf0474 | Python | alinajam/mosikidhoondh | /algorithm/cossim.py | UTF-8 | 443 | 2.921875 | 3 | [] | no_license | #CITE SOURCE
#helper function for find_artist (calculates similarity of genre lists)
import math
def counter_cosine_similarity(c1, c2):
terms = set(c1).union(c2)
dotprod = sum(c1.get(k, 0) * c2.get(k, 0) for k in terms)
magA = math.sqrt(sum(c1.get(k, 0)**2 for k in terms))
magB = math.sqrt(sum(c2.get(k... | true |
03cb4c9f0a633936fa6b84c13487641ee14993a4 | Python | jobaamos/gap-year-club-code | /AMOS45.py | UTF-8 | 175 | 3.515625 | 4 | [] | no_license | #python program that prints a list then delets the third item
sub_list=['physics','chemistry','maths','biology','civics']
print(sub_list)
del sub_list[2]
print(sub_list)
| true |
3aedf173fe007fd0a2187701095573c208e8d2d8 | Python | robingreig/raspi-git | /Pico/MicroPython/BlinkAnalogue.py | UTF-8 | 181 | 2.546875 | 3 | [] | no_license | import machine
import utime
led_onboard = machine.Pin(25, machine.Pin.OUT)
pott = machine.ADC(26)
while True:
led_onboard.toggle()
print(pott.read_u16())
utime.sleep(1) | true |
6fcc7777847c0e34a517503ce7ef44b2b4dc140c | Python | tmanjw/IBCS-Homework | /Waterloo Competition/Flipper.py | UTF-8 | 218 | 3.1875 | 3 | [] | no_license | line=input()
grid=[[1,2],[3,4]]
for i in line:
if i=="V":
for i in range(2):
grid[i] = [grid[i][1], grid[i][0]]
else:
grid = [grid[1], grid[0]]
for i in grid:
print(i[0],i[1]) | true |
81bc159c51f8db11875903296cd0e28d1fda3f0c | Python | gapigo/CEV_Aulas_Python | /Aulas/Aula 13/Aula 13c.py | UTF-8 | 232 | 3.671875 | 4 | [] | no_license | início = int(input('Digite o número que começa a contagem: '))
fim = int(input('Digite o número que a contagem termina: '))
passo = int(input('Digite o passo: '))
for c in range(início, fim + 1, passo):
print(c, end='\n')
| true |
ab47f601cd7b8b12e499d2fb01043356441b3789 | Python | chaozc/leetcode | /python/p017.py | UTF-8 | 627 | 3.375 | 3 | [] | no_license | import Queue
class Solution(object):
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
dic = {'1':'*','2':'abc','3':'def','4':'ghi','5':'jkl','6':'mno','7':'pqrs','8':'tuv','9':'wxyz'}
if digits == '':
return []
q = ... | true |
4179ffc29982dac5e2863bc629dea3e27b89b5d9 | Python | piara108/my-exercism-solutions | /python/raindrops/raindrops.py | UTF-8 | 232 | 3.1875 | 3 | [] | no_license | # Raindrops
def convert(number):
droplets = { 3: 'Pling', 5: 'Plang', 7: 'Plong'}
drops = ''
for x in [3, 5, 7]:
if number % x == 0:
drops += droplets[x]
return drops if drops else str(number)
| true |
fb1619c8c0279d1fe86486f3d21b47ad95d9edf9 | Python | N-Forshaw/Project-Euler | /Problem 6/Problem 6.py | UTF-8 | 1,191 | 4.3125 | 4 | [] | no_license | ### Project Euler
### Problem 6
# The sum of the squares of the first ten natural numbers is,
# 12+22+...+102=385
# The square of the sum of the first ten natural numbers is,
# (1+2+...+10)2=552=3025
# Hence the difference between the sum of the squares of the first ten natural numbers and the square of the... | true |
e64799ad72e4278ada788010db04edd0ea263192 | Python | lishuoleo/dynamic_risk_assessment | /ingestion.py | UTF-8 | 1,663 | 2.890625 | 3 | [
"MIT"
] | permissive | import pandas as pd
import numpy as np
import os
import json
from datetime import datetime
# Load config.json and get input and output paths
with open('config.json', 'r') as f:
config = json.load(f)
input_folder_path = os.path.join(os.getcwd(), config['input_folder_path'])
output_folder_path = os.path.join(os.get... | true |
107be64b79de123d229b6a9ed503504b6fe3486b | Python | TREVO786/pyjuque | /tests/test_Binance.py | UTF-8 | 2,290 | 2.765625 | 3 | [
"MIT"
] | permissive | # app/tests/test_basic.py
import os
import sys
import unittest
curr_path = os.path.abspath(__file__)
root_path = os.path.abspath(
os.path.join(curr_path, os.path.pardir, os.path.pardir))
sys.path.insert(1, root_path)
# Import all Created exchanges here
from pyjuque.Exchanges.Binance import Binance
from tests.utils ... | true |
be5f555b334173d6bfc1f0aedb6cabb8b6476cc5 | Python | liuyuan111/Bayes | /Simple_NB.py | UTF-8 | 4,152 | 3.15625 | 3 | [] | no_license |
# coding: utf-8
# In[1]:
# https://blog.csdn.net/moxigandashu/article/details/71480251?locationNum=16&fps=1
import numpy as np
# 构造loadDataSet函数用于生成实验样本
def loadDataSet():
postingList=[['my', 'dog', 'has', 'flea', 'problems', 'help', 'please'],
['maybe', 'not', 'take', 'him', 'to', 'dog', 'pa... | true |
7c39ff30464de5c312d47cb2c99a9e6d6ad1d19c | Python | XIAOQUANHE/pythontest | /yu_c/Chapter9_Error/P9_1.py | UTF-8 | 1,967 | 4.4375 | 4 | [] | no_license | # 1> AssertionError: 断言语句(assert)失败
# my_list = ["小甲鱼"]
# assert len(my_list) > 0
# print(my_list.pop())
#
# assert len(my_list) > 0
# 2> attributeError: 尝试访问未知的对象属性,当试图访问的对象属性不存在时抛出AttributeError异常:
# my_list = []
# my_list.fishc
# 3> IndexError: 索引超出序列的范围
# 在使用序列的时候就常常会遇到IndexError异常,原因是索引超出序列范围的内容:
# my_list = [1,... | true |
331c7f0c76b3d01a3cad23df4e507c741013a40d | Python | Gscsd8527/python | /python/python100/python_4.py | UTF-8 | 547 | 4.15625 | 4 | [] | no_license | # 以下实例为通过用户输入三角形三边长度,并计算三角形的面积:
import math
num1=int(input('请输入第一条边:'))
num2=int(input('请输入第二条边:'))
num3=int(input('请输入第三条边:'))
while 1:
if num3>num1+num2:
print('第三条边不正确,请重新输入:')
num3=int(input('请输入第三条边:'))
else:
break
# 用海伦公式算,求出半周长
s=(num1+num2+num3)/2
area=(s*(s-num1)*(s-num2)*(s-num... | true |
786d17be181bbc520546124b905b4e7e940f1528 | Python | LucaDorinAnton/Python-101 | /exercise files/05_file_and_console_IO.py | UTF-8 | 250 | 3.484375 | 3 | [] | no_license | #reading from the keyboard
#printing to the screen
#reading from a file
f = open("file.txt", "r+")
for line in f.readlines():
print("Hello!")
#writing to a file
f.close();
f = open("file.txt", "w")
f.write("Sup!")
#closing a file
f.close()
| true |
d4e33799ffa98e36a8fc51871341bbd777b4dc3b | Python | andreavs/manual_newton_fenics | /use_exact_field.py | UTF-8 | 7,376 | 2.890625 | 3 | [] | no_license | from fenics import *
from newton import Newton_manual
import math
"""
In this script we aim to solve the Poisson-Nernst-Planck equations, i.e. the
concentration dynamics of two ions, assuming they act by electrodiffusion.
Variables are
c1 - concentration of ion type 1
c2 - concentration of ion type 2
phi - the electri... | true |
8f24f1dc5ea62d7272345a3f7f7695b0b4f347f1 | Python | jeffanberg/Coding_Problems | /project_euler/problem43.py | UTF-8 | 1,176 | 4.25 | 4 | [] | no_license | '''
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of
each of the digits 0 to 9 in some order, but it also has a rather interesting
sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on.
In this way, we note the following:
d2d3d4=406 is divisible by 2
d... | true |
7aa2659cbabe2ae396ef1736ab5bb8309d19a551 | Python | tcfh2016/knowledge-map | /Techs/data-science/visualization/matplotlib/legend/use_legend.py | UTF-8 | 191 | 2.84375 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
s = pd.Series(np.random.randn(100), index=np.arange(100))
plt.plot(s, label='random100')
plt.legend(loc=0)
plt.show()
| true |
5bd30fbeb67ffbeb5f509020117b41f003ce3373 | Python | markchen1357/notebook-dvc | /dvc_nb/generate.py | UTF-8 | 719 | 2.734375 | 3 | [] | no_license | import json
import os
def generate(cells):
relative = os.path.dirname(__file__)
with open(os.path.join(relative,'format.json'), 'r') as f:
notebook = json.load(f)
cell_list = []
cell_dict = {}
cell_dict['cell_type'] = "code"
cell_dict['metadata'] = {}
cell_dict['outputs']... | true |
242722b079aeddbdb0fc1f0609494703adc06080 | Python | widdowquinn/pymetabc | /pymetabc/hashing.py | UTF-8 | 3,192 | 2.734375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""Functions to hash and quantify merged reads."""
import hashlib
from argparse import Namespace
from collections import Counter, defaultdict
from pathlib import Path
from typing import Any, Dict, Generator, List
import pandas as pd
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqR... | true |
f1ff1f3c016da20aa3393025892030e512273a84 | Python | AndreyGTHB/LocalLibrary | /catalog/forms.py | UTF-8 | 798 | 2.65625 | 3 | [] | no_license | import datetime
from django import forms
from django.core.exceptions import ValidationError
class BookRefreshForm(forms.Form):
errors_text = []
renewal_date = forms.DateField(label='Return date', help_text='Enter a date between now and 4 weeks.')
def clean_renewal_date(self):
data = self.cleane... | true |
cb2934fdccdd188770e7e2c7ba272ceb14946c8d | Python | jonag-code/python | /code_for_counterr_()_in_jonmodule.py | UTF-8 | 884 | 3.015625 | 3 | [] | no_license | ## For some reason this code, mainly contained in lines 27 to 35,
## compiles ~3 times slower than in 'jonmodule_example.py'. The
## relevant code imported from 'jonmodule.py' is also longer...
sub_string = '1911'
filename = 'pi_1000000.txt'
with open(filename) as f:
lines = f.readlines()
main_string = ''
#main... | true |
6072f39329936201665f15487e8f24ed6b673a66 | Python | sethschori/emailr | /emailr/models.py | UTF-8 | 4,867 | 2.96875 | 3 | [] | no_license | from datetime import datetime, time, timedelta
import pytz
from sqlalchemy import Boolean, Column, Integer, DateTime, ForeignKey, \
String, Time
from sqlalchemy.orm import relationship
from emailr.database import Base
class User(Base):
__tablename__ = 'user'
id = Column(Integer, primary_key=True)
ema... | true |
acef60df3b0a3fb40c5c360c484e6f0a7aa53794 | Python | ivanbryansk/Phyton | /main.py | UTF-8 | 1,726 | 3.5 | 4 | [] | no_license | # -*- coding: utf-8 -*-
print("Система расчёта штрафов в Германии")
carSpeed = 121
isTown = False
townSpeed = 100
fineFor1to10 = 10
fineFor11to15 = 20
fineFor16to20 = 30
fineFor21to25 = 70
fineFor26to30 = 80
fineFor31to40 = 120
fineFor41to50 = 160
fineFor51to60 = 240
fineFor61to70 = 440
fineFor70andMore = 600
if is... | true |
a5bee89080dab9a964d045825d9ad6a49aacf022 | Python | CQUDuanyu/GitRepo | /spider1.py | UTF-8 | 1,524 | 3.21875 | 3 | [] | no_license |
####################first version##################
# from urllib.request import urlopen
# from bs4 import BeautifulSoup
# html = urlopen("http://en.wikipedia.org/wiki/Kevin_Bacon")
# bsObj = BeautifulSoup(html)
# for link in bsObj.findAll("a"):
# if 'href' in link.attrs:
# print(link.attrs['href'])
##############... | true |
6ac66d46bc6dd57ddaa2e79bbde8719690efaad0 | Python | guidj/fashion-mnist | /py/fmnist/xmath.py | UTF-8 | 214 | 2.828125 | 3 | [] | no_license | import functools
from typing import Iterator, Union
class SeqOp(object):
@staticmethod
def multiply(sequence: Iterator[Union[int, float]]):
return functools.reduce(lambda x, y: x * y, sequence)
| true |
75bbab38401c5cab8b104890ab279228ff525746 | Python | viserion-999/SpEagle | /project/EXT.py | UTF-8 | 272 | 3.09375 | 3 | [] | no_license | import numpy as np
#feature 14: EXT
#extremity of the review
# 1 if ratings is {1,5}
# 0 otherwise
def EXT(rating_array):
extr_ratings = np.zeros((len(rating_array),))
extr_ratings[np.logical_or(rating_array == 5, rating_array == 1)] = 1
return extr_ratings | true |
56f78d3274a2f0881fda189958f63fe5118a5ab6 | Python | yoheia/yoheia | /aws/dynamodb/dynamodb_query.py | UTF-8 | 998 | 2.578125 | 3 | [] | no_license | import boto3
import json
import datetime
import time
import threading
from boto3.dynamodb.conditions import Key, Attr
import sys
args = sys.argv
id = args[1]
start_date = args[2]
end_date = args[3]
print(start_date)
print(end_date)
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('test_table')
i = 0
la... | true |
0fa4a902d737e81dc99ec30d3ae8439bd1b022f7 | Python | shubhangiranjan11/Hackaifelse | /if else15.py | UTF-8 | 213 | 2.859375 | 3 | [] | no_license | a=input("any number")
b=input("any number")
c=input("any number")
if a==b==c:
print("euilaetral traingle")
elif a==b or c==a or b==c:
print("isocelesec traingle")
else:
print("scalene traingle")
| true |
c8e63d13eda45192d7fde2a47e588300b64230b9 | Python | BaronJake/python4biologists | /chapt_9/chapt9_ bin.py | UTF-8 | 1,001 | 3.40625 | 3 | [] | no_license | """
Reads sequences from input/*.dna files and writes sequences to different directories based on sequence length
"""
import os
# create directories for different length sequences
bin_dict = dict()
for index in range(1, 11):
bin_dict[index] = f"output/{index}00-{index}99"
if not os.path.exists(bin_dict[index])... | true |
c9fb4c116bf17b7300ca65ca4fb7d04243027d10 | Python | JoseManuelG/Clasificaci-n-de-noticias | /kNN/knn-gui.py | UTF-8 | 8,589 | 2.765625 | 3 | [] | no_license | import sys
import dividir_noticias
import entrenar_modelo
import testear_modelo
import herramientas as ha
from PyQt5.QtWidgets import (QMainWindow, QPushButton,QTabWidget,
QWidget, QLCDNumber, QSlider,QVBoxLayout, QApplication, QSpinBox, QMessageBox)
from PyQt5.QtCore import Qt
class App(QM... | true |
e464bd88e0fb85d1ca187b9ed2a769620ab5d212 | Python | itcsoft/todo2 | /todoApp/views.py | UTF-8 | 1,346 | 2.75 | 3 | [] | no_license | from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponseNotFound
from .models import Todo
# Получение данных из БД
def homepage(request):
todos = Todo.objects.all()
return render(request, "index.html", {'todos':todos})
# Сохранение данных в БД
def create(request):
if... | true |
b7d7c51d4538aca23b4b957e8368186efcf6e6ce | Python | FNobrega/nova | /nova/view/tmp2.py | UTF-8 | 2,772 | 2.984375 | 3 | [] | no_license | # Libraries
# Functions
def moviment(object,directions,speed, x, y):
screenAjust = [(800-x)/2, (600-y)/2]
if directions == 1:
if object.position[1] < 310 - 32 - screenAjust[1]:
if(object.position[1] <= -300 - screenAjust[1] or object.position[1] >= -250 - screenAjust[1] or
... | true |
9a96d849c5977eeeb2fdbc571b1fa7f4175174d8 | Python | jinzaizhichi/akshare | /akshare/interest_rate/interbank_rate_em.py | UTF-8 | 4,385 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2022/5/24 20:13
Desc: 东方财富网-经济数据-银行间拆借利率
"""
import pandas as pd
import requests
from tqdm import tqdm
def rate_interbank(
market: str = "上海银行同业拆借市场",
symbol: str = "Shibor人民币",
indicator: str = "隔夜",
):
"""
东方财富-拆借利率一览-具体市场的具体品种的具体指标的拆借利率数据
... | true |
c3067f57849c44866a15231163e61b08281b69e3 | Python | emilianoNM/Clase2018Tecnicas | /Clase07022018/impresion_matrizAGS.py | UTF-8 | 352 | 3.90625 | 4 | [] | no_license | print("Impresion de una matriz")
matriz = []
columnas=int(raw_input("elige el numero de columnas: "))
fila=int(raw_input("dame el numero de filas: "))
for i in range(fila):
matriz.append([0]*columnas)
for l in range(fila):
for m in range(columnas):
matriz[l][m]=int(raw_input("Agrega el valor de %d,%d de la mat... | true |
b67c3de57be2ef17f721663d26eff5def80daf78 | Python | anirbanniara/bolt | /bolt/spark/array.py | UTF-8 | 29,549 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | from __future__ import print_function
from numpy import asarray, unravel_index, prod, mod, ndarray, ceil, where, \
r_, sort, argsort, array, random, arange, ones, expand_dims
from itertools import groupby
from bolt.base import BoltArray
from bolt.spark.stack import StackedArray
from bolt.spark.utils import zip_wit... | true |
197128c1ce48d1704163c50a450072e98125542f | Python | S-Yajima/UI_App_iOS_Python | /4_digital_ideology_裏表判定と陰影あり/dotmap.py | UTF-8 | 6,061 | 3.015625 | 3 | [] | no_license | from figure import *
from dot_data import *
import ui
from math import sqrt
# 世界地図のクラス
# ドット絵で地図を表現する
class MyMap(MyFigure):
# ドット一つの幅と高さ
dot_size = 5
# ドット一つの隙間
dot_gap = 1
# z軸のデフォルト座標
dot_z = 1
# ドットの色を表す二次元配列
# [['#bcbcff', '#ffc8c8', None,...],
# ['#bcbcff'... | true |
d92c27f0188a2179b455bbe115b7cab7bf6f08ad | Python | rayiniv/YouTubeSWEg | /app/tests.py | UTF-8 | 3,439 | 2.53125 | 3 | [] | no_license | # pylint: disable = invalid-name
# pylint: disable = missing-docstring
# pylint: disable = import-error
# pylint: disable = deprecated-method
from unittest import main, TestCase
from models import Video, Channel, Category, Playlist, Base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
imp... | true |
6c1df0c18d8f299b41c52b2a7a34cc62ffe018bc | Python | Mythetic/Python-Backend-Notes | /notes/Leetcode/241.为运算表达式设计优先级.py | UTF-8 | 1,191 | 3.578125 | 4 | [] | no_license | #
# @lc app=leetcode.cn id=241 lang=python
#
# [241] 为运算表达式设计优先级
#
# @lc code=start
class Solution(object):
def diffWaysToCompute(self, input):
"""
:type input: str
:rtype: List[int]
"""
# 如果只有数字,直接返回
if input.isdigit():
return [int(input)]... | true |
1f09c12c4e8c38d51edabd96c416c62c6970949b | Python | agolla0440/my_python_workbook | /MY_first_if_statement_assingment.py | UTF-8 | 325 | 3.640625 | 4 | [
"Apache-2.0"
] | permissive | is_sunny = False
is_snowing = False
if is_sunny:
print("It's a sunny day,drink plenty of water")
print("Have fun")
elif is_snowing:
print("It's snowing outside,make sure to wear your jacket")
print("Have fun")
else:
print("It's not too sunny or neither snowing,have a great day!")
print("Enjoy your d... | true |
b7a9b55e713cf4099b9a9c99b2698669aa788c38 | Python | sohamsamanta2000/M207_assignment1 | /euclid_algo_extended_ver.py | UTF-8 | 317 | 3.140625 | 3 | [] | no_license | def ext_gcd(a,b):
x, y= 0,1 #initial values
x1,y1= 1,0 #initial values
while a!=0:
q= b//a
r=b%a
x2=x-x1*q
y2=y-y1*q
b=a
a=r
x=x1
y=y1
x1=x2
y1=y2
gcd=b
return gcd, x, y
print( ext_gcd(10889992,66)) #example | true |
d8abce4d14c376826ee5ad5ad99c19f87ae355a8 | Python | AB07AB/PRO-C121-BACKGROUND-MATTERS | /PRO-C121: BACKGROUND MATTERS.py | UTF-8 | 1,112 | 2.546875 | 3 | [] | no_license | import cv2
import time
import numpy as np
fourcc = cv2.VideoWriter_fourcc(*"XVID")
output_file = cv2.VideoWriter("Output.avi",fourcc,20.0,(640,480))
cap = cv2.VideoCapture(0)
time.sleep(2)
bg = 0
for i in range(60):
ret,bg=cap.read()
bg=np.flip(bg,axis=1)
while(cap.isOpened()):
ret,img=cap.read()
if not... | true |
636b7c674e1698c8ddd8b048bec4c6830ac46bcc | Python | microease/Python-Tip-Note | /007ok.py | UTF-8 | 165 | 3.921875 | 4 | [] | no_license | # 已知矩形长a,宽b,输出其面积和周长,面积和周长以一个空格隔开。
# 例如:a = 3, b = 8
# 则输出:24 22
a = 3
b = 8
print(a*b,2*(a+b)) | true |
f459e25a0695b0a0fb620e33cea612dea8def4ef | Python | zckly/python-intro | /src/functions.py | UTF-8 | 2,723 | 3.96875 | 4 | [] | no_license | from collections import Counter
from itertools import izip, count
import operator
def write_to_file(lst, f):
"""
INPUT: list, open file object
OUTPUT: None
Write the list to the file with line numbers, starting at 1.
INPUT: ["a", "b", "c"]
FILE CONTENTS:
1 a
2 b
3 c
Hint: Use... | true |
c0b72af29a3a34a986bdf6f8b2b0c24b70a070f3 | Python | isthattyler/SearchProblemSolver | /src/Python/searchAI.py | UTF-8 | 5,702 | 3.421875 | 3 | [] | no_license | from problem1 import *
from problem2 import *
from problem3 import *
from bfsQueue import *
from dfsStack import *
from aPrioQueue import *
class Search:
def __init__(self):
self.problem = None
def setProblem(self, problem):
self.problem=problem
self.visited=None
def trace(self, ... | true |
cc7a5f699652a8e09f1a12024de2c39f7c759cf8 | Python | caimongs87/namtestgithubonline | /baitap.py | UTF-8 | 159 | 3.28125 | 3 | [] | no_license | # tinh giai thua cua 1 so cho trước
x = int(input("nhập 1 số để tính giai thừa: "))
gt=1
for i in range(1,x+1):
gt=gt*i
print(gt)
| true |
d3db7e030c780986243becaff0cca95b05aa2e23 | Python | HiroakiMikami/procon-workspace | /src/atcoder/abc094/a.py | UTF-8 | 116 | 3.078125 | 3 | [] | no_license | A, B, X = [ int(x) for x in input().split() ]
ans = A <= X and (A + B) >= X
print("YES" if ans else "NO")
print()
| true |
7578b5a23685e839816a85a7bdc649e9553f7a20 | Python | rit-git/snorkel-notebooks | /babble/parsing/spacy/parser.py | UTF-8 | 1,135 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | import sys
class Parser(object):
def __init__(self, name, encoding='utf-8'):
self.name = name
self.encoding = encoding
def to_unicode(self, text):
'''
Convert char encoding to unicode
:param text:
:return:
'''
if sys.version_info[0] < 3:
... | true |
dcb9ae7e719ad501aeb78bc2db3899d75b80272e | Python | Omkarkukiyan/ims-inventory_management_system- | /app/models.py | UTF-8 | 1,756 | 2.546875 | 3 | [] | no_license | from app import db
import datetime
from sqlalchemy import Integer
from flask_login import UserMixin
class User(UserMixin,db.Model):
__tablename__ = 'users'
id = db.Column(Integer, primary_key=True)
username = db.Column(db.String(64), index=False, unique=True, nullable=False)
email = db.Column(db.String... | true |
52e201336e2c32d0f43710be7da27a02be81e8a9 | Python | lubyluby/ChildrenPython | /ChildrenDemo/GamePy.py | UTF-8 | 995 | 3.328125 | 3 | [] | no_license | import pygame
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
green = (0,255,0)
def draw_a_boy(screen,x,y):
pygame.draw.ellipse(screen,black,[x,y-5,10,10])
pygame.draw.line(screen,red,[5+x,5+y],[5+x,15+y],2)
pygame.draw.line(screen,red,[5+x,5+y],[x-5,15+y],2)
pygame.draw.line(screen,red,[5+x... | true |
c9b0dfd3e262752298613d028905e6657a1884cf | Python | rhimanshu909/Webmap-Folium | /part9.py | UTF-8 | 1,312 | 2.734375 | 3 | [] | no_license | import folium
import pandas
data_frame = pandas.read_csv("Volcanoes_USA.csv")
map = folium.Map(location=[48.7767982,-121.810997])
lat = list(data_frame['LAT'])
lon = list(data_frame['LON'])
name = list(data_frame['NAME'])
loc = list(data_frame['LOCATION'])
status = list(data_frame['STATUS'])
elev = list(data_frame['E... | true |