index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
9,600 | 92f59612b2697db155da1bdc625fdabc115867b0 | # 5. Write a program to implement polymorphism.
class Honda:
def __init__(self, name, color):
self.name = name
self.color = color
def display(self):
print("Honda car name is : ", self.name, " and color is : ", self.color)
class Audi:
def __init__(self, name, color):
sel... |
9,601 | 98940c898d58917e652fe1514ea758768b048dbc | import pygame
def play_file(name,loop=0,time=0.0):
try: #if image exists
file='data/audio/'+name
pygame.mixer.music.load(file)
pygame.mixer.music.play(loop, time)
except ZeroDivisionError: #if image doesn't exist
print('AudioLoading: failed to load ' + name)
try:
... |
9,602 | 028b38a07c71232eb42bedecd734cf7188550239 | from config import Config
def test_stf_3_2_1_pos(fixture):
seed = fixture.common.get_seed()
fixture.stf.open_stf_exercise('3-2-1', seed)
fixture.stf.open_solution_url(seed)
assert fixture.stf.get_solution() == Config.test_pass_text
fixture.common.back_to_main_page()
def test_stf_3_2_1_neg(fixtur... |
9,603 | bbff797fab4ac7dc7e6adb81c0eeda561f8ee147 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from unittest import TestCase
from pydsf.exceptions import DSFServiceError
from pydsf.service.response import parse_response
from pydsf.service.translations import translate_input_fields, translate_output_fields
class MockMessage(object):... |
9,604 | 14e247b7b586242bfc17507fece3c60b7b8a3025 |
"""
An wrapper around openid's fetcher to be used in django.
"""
from openid import fetchers
class UrlfetchFetcher(fetchers.HTTPFetcher):
def fetch(self, url, body=None, headers=None):
return fetchers.fetch(body, headers)
|
9,605 | 49887a3914fa0021a03d89721aa47cded95d54f6 | #!/usr/bin/env python
#python
import os
import math
import sys
import time
import re
import cPickle
import random
#eman
try:
import EMAN
except:
print "EMAN module did not get imported"
#scipy
import numpy
#appion
from appionlib import appionScript
from appionlib import appiondata
from appionlib import apDisplay
fro... |
9,606 | d3dcef6a1a6bcfc1161c4de46081703b8fe7016d | from docutils import nodes
from docutils.parsers.rst import directives, Directive
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.lexers.special import TextLexer
from pygments.formatters.html import HtmlFormatter
class Pygments(Directive):
""" Source code syntax hightli... |
9,607 | a550b9406e9dd301b863744bb28bc81fac0cd80c | from django.contrib import admin
from TestApp.models import Parcel
# Register your models here.
class ParcelAdmin(admin.ModelAdmin):
list_display = ['billno','shippername','rate']
admin.site.register(Parcel,ParcelAdmin)
|
9,608 | 6d1b882af2a027f2eecaa3a881dbcab1e3a3b92b | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the Spotlight Volume configuration plist plugin."""
import unittest
# pylint: disable=unused-import
from plaso.formatters import plist as plist_formatter
from plaso.parsers import plist
from plaso.parsers.plist_plugins import spotlight_volume
from tests.parsers.... |
9,609 | 98f234ca0cbec419466de0504fd8d5c68fd07627 | from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QLineEdit, QRadioButton, QPushButton, QTableWidgetItem, QTableWidget, QApplication, QMainWindow, QDateEdit, QLabel, QDialog, QTextEdit, QCheckBox
from PyQt5.QtCore import QDate, QTime, QDateTime, Qt
from OOPCourseWorkTwo.GUI.SingleAnswerQuestionDi... |
9,610 | 8cc0314d48f81ceead863245443548297e8188f8 | import time
from numpy import empty
from src.utils import normalize_input_sentence, evaluate, add_begin_and_trailing_tag, check_for_terminal_argument
from classes.BaseTagger import BaseTagger
from src.CONSTANT import POS_TAG_KEYNAME, WORD_KEYNAME, TRUETAG_KEYNAME, DEFAULT_TRAINING_FILENAME
import sys
import os
# TOD... |
9,611 | 05aa8eac846154024d25d639da565135e41403c2 | lista = [2, 3.2, 4, 52, 6.25]
s = sum(lista)
print(s) |
9,612 | 7369d5a463b0f41c17d5648739d4730256e611f9 | #!/usr/bin/python3
import RPi.GPIO as GPIO
import time
# motor_EN_A: Pin7 | motor_EN_B: Pin11
# motor_A: Pin8,Pin10 | motor_B: Pin13,Pin12
#Motor_A_EN = 7
Motor_B_EN = 11
#Motor_A_Pin1 = 8
#Motor_A_Pin2 = 10
Motor_B_Pin1 = 13
Motor_B_Pin2 = 12
Dir_forward = 0
Dir_backward = 1
#pwm_A = 0
pwm_B =... |
9,613 | 5685befae923fc336a2a5e0eb5e382c2e7d82d04 | numero_uno=int(input("ingresa el primer numero "))
numero_dos=int(input("ingresa el segundo numero "))
print(numero_uno)
print(numero_dos)
total=numero_uno +numero_dos
print("el total de la suma de : "+str(numero_uno)+" + "+str(numero_dos)+" es = a "+str(total)) |
9,614 | 704047cb7eb05db9fa5f7ae61763ddbc8942ff60 | from rest_framework import serializers
from notes import models
class CategorySerializer(serializers.ModelSerializer):
id = serializers.StringRelatedField()
class Meta:
model = models.Category
fields = (
'id',
'name',
'color',
)
# nested category in... |
9,615 | a93818440410bde004f0203f18112fa1b666959c | # coding: utf-8
"""
Negotiation API
The <b>Negotiations API</b> gives sellers the ability to proactively send discount offers to buyers who have shown an \"interest\" in their listings. <br><br>By sending buyers discount offers on listings where they have shown an interest, sellers can increase the velocity ... |
9,616 | 06b07045fcfafd174bb78ff5c3a36bed11e36e54 | import random
import string
import datetime
from app import db
from dateutil.parser import parse as date_parse
from flask_security import UserMixin, RoleMixin
roles_users = db.Table('roles_users',
db.Column('user_id', db.Integer(), db.ForeignKey('users.id')),
db.Column('role_id', db.Integer(), db.Forei... |
9,617 | 71dc429033b159f6ed806358f2286b4315e842d9 | def find_max(a, b):
if a>b:
return a
return b
def find_max_three(a, b, c):
return find_max(a, find_max(b, c)) |
9,618 | 912928cea0f96e601eecfcb6dba695ef26a3c6e2 | import itertools
import numpy as np
import pandas as pd
from scipy.sparse import coo_matrix
def merge_and_split(inputs, labels):
df = inputs.reset_index().merge(labels.reset_index(), on='utterance',
how='inner').set_index('utterance')
return df.feat, df.label
def list_to_... |
9,619 | 37748e3dd17f2bdf05bb28b4dfded12de97e37e4 | # Python program to count number of digits in a number.
# print len(str(input('Enter No.: ')))
num = input("Enter no.: ")
i = 1
while num / 10:
num = num / 10
i += 1
if num < 10:
break
print i
|
9,620 | ce1ef1ce538b8753af9e4b3e8e88f4cde9a2d860 | # - *- coding: utf- 8 - *-
import RPi.GPIO as io
import time
import math
io.setmode(io.BOARD)
hz = 50
dt = 1/hz
kr = 48
enc_res = 0.01636246
num_samples = 100
special_words = ['BackSpace', 'Tab', 'Enter', 'Cap', 'Shift2', 'Ctrl1',
'WIN1', 'Alt1', 'Alt2', 'WIN2', 'MClick', 'Ctrl2', 'Shift1', '\\']
L1... |
9,621 | 1ef40d4162ca1b1bd6a5a5010485c78eb9d8d736 | # coding=utf-8
import datetime
from django.http import JsonResponse
from django.shortcuts import render, redirect
from models import *
from hashlib import sha1
from user_decorators import user_login
from df_goods.models import GoodsInfo
# Create your views here.
def register(request):
context={'title':'注册','top':'0... |
9,622 | 3f3d7cdf7732b2a1568cd97574e1443225667327 | from urllib.request import urlopen
from json import loads
with urlopen('http://api.nbp.pl/api/exchangerates/tables/A/') as site:
data = loads(site.read().decode('utf-8'))
rates = data[0]['rates']
exchange = input('Jaką wartość chcesz wymienić na złotówki? ')
value, code = exchange.split(' ')
val... |
9,623 | fd904c70b350c650362c55ccb3b915371f24e267 | import logging
import os
import callbacks
import commands
import dice
import echo
import inline
import keyboards
import mybot
import myenigma
import poll
import rocketgram
import send
import unknown
# avoid to remove "unused" imports by optimizers
def fix_imports():
_ = callbacks
_ = commands
_ = echo
... |
9,624 | 7cfca56907f0bca7fd62e506414641f942527d1a | import os
TEMP_DIR = os.path.expanduser('~/Documents/MFA')
def make_safe(value):
if isinstance(value, bool):
return str(value).lower()
return str(value)
class MonophoneConfig(object):
'''
Configuration class for monophone training
Scale options defaults to::
['--transition-sca... |
9,625 | e8092faed22607f9c8f18a79709022037ff647bf | from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from sqlalchemy.sql.functions import current_date, current_user
from db.session import get_db
from db.models.jobs import Job
from schemas.jobs import JobCreate, ShowJob
from db.repository.jobs impo... |
9,626 | cda01bc7b0ebcfaf010bb87e7d9be34fd310d7a7 | import math
import torch
from torch import nn
from d2l import torch as d2l
def masked_softmax(X, valid_lens):
"""通过在最后一个轴上掩蔽元素来执行softmax操作"""
# X:3D张量,valid_lens:1D或2D张量
if valid_lens is None:
return nn.functional.softmax(X, dim=-1)
else:
shape = X.shape
if valid_lens.dim() == ... |
9,627 | 264da5a2ab7d5c311d8a59b06c81ea2156cefd76 | from flask import Flask, request, render_template
from utils import get_result
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route("/result", methods=["POST"])
def result():
form_data = request.form
sentence = form_data['sentence']
output = get_result... |
9,628 | 51bc2668a9f9f4425166f9e6da72b7a1c37baa01 | """Tasks for managing Debug Information Files from Apple App Store Connect.
Users can instruct Sentry to download dSYM from App Store Connect and put them into Sentry's
debug files. These tasks enable this functionality.
"""
import logging
import pathlib
import tempfile
from typing import List, Mapping, Tuple
impor... |
9,629 | 19cf34e7c38045a183c75703ec56c17f96ee2ac4 | from ROOT import *
import os
import sys
from optparse import Option, OptionValueError, OptionParser
Box = ["RawKLMnodeID","rawKLMlaneFlag","rawKLMtExtraRPC","rawKLMqExtraRPC","rawKLMtExtraScint","rawKLMqExtraScint","rawKLMsizeMultihit","rawKLM00channelMultiplicity","rawKLM00channelMultiplicityFine","rawKLM10channelMul... |
9,630 | 87e9c1d264523d02b287dedb44472fc08b488908 | from __future__ import division, print_function, absolute_import
"""
The dataset is stored in a CSV file, so we can use the TFLearn load_csv() function to
load the data from the CSV file into a python list.
We specify the 'target_column' argument to indicate that our labels (survived or not)
are located in the first... |
9,631 | 9a1b268386b4652bf50af0365892ef7338329727 | #header
import matplotlib.pyplot as pmf
import random
p = 0.5 # Probablility of success for original system
n = 18 # Number of trials
Y = [] # Contains binomial RVs
b = [0] * (n+1) # List of n + 1 zeroes
N = 100 # Number of experiments performed
for j in range(N):
# Bernoulli random variable
for i in ra... |
9,632 | 2ab303a2f36cdd64e2119856312dd5e38ee728d6 | #
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# ... |
9,633 | b220cacc2530ca62b5599a9c1894e979bcfd5109 | #!/usr/bin/env python3
#
# Display all tags in the specified file for neoview.
# Author: Andrew Pyatkov <mrbiggfoot@gmail.com>
# License: MIT
#
"""
Display all tags in the specified file for neoview.
Output: {file_name}\t{tag_address}\t{displayable_tag_info}
"""
import argparse
#import os
#import re
import subprocess
... |
9,634 | d13c6d71bb871496b0c6ad2451a2f561484e7c68 | # -*- coding: utf-8 -*-
import scrapy
class Heiyan2Spider(scrapy.Spider):
name = 'heiyan2'
allowed_domains = ['heiyan.com']
start_urls = ['http://heiyan.com/']
def parse(self, response):
pass
|
9,635 | 8fa78824a38a3b0c1f51aceacab671f987ea2705 | from .Buzzer import BuzzerController
from .Card import CardScanner
from .RFID import RFIDController
from .Servo import ServoController
__all__ = ["BuzzerController", "CardScanner", "RFIDController", "ServoController"]
|
9,636 | e01eced7c43aae354047fbf29028c601d1daae50 | import unittest
import gym
import torch
from all.environments import DuplicateEnvironment, GymEnvironment
def make_vec_env(num_envs=3):
env = [GymEnvironment('CartPole-v0') for i in range(num_envs)]
return env
class DuplicateEnvironmentTest(unittest.TestCase):
def test_env_name(self):
env = Dupl... |
9,637 | b75ebcd278ae92274bbbe8d1ce5cb3bb7fa14a2c | from nltk.tokenize import sent_tokenize
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
import networkx as nx
def summarize(text):
sentences_token = sent_tokenize(text)
#Feature Extraction
vectorizer = CountVectorizer(min_df=1,decode_error='replace')
sent_bow = v... |
9,638 | 18f355041a9982de56ad2eb51b665dd39a156f0a | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from django.db.models import Q
from django.contrib.auth import get_user_model
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK, HTTP_400_BAD_REQUEST
from rest_framework.views imp... |
9,639 | 10d3ee459a296c26429659a202833a9570cf9454 | #Create a 3x3 identity matrix
import numpy as np
vector = np.zeros((8,8))
vector[1::2,::2]=1
vector[::2,1::2]=1
print(vector)
'''
Output
[[0. 1. 0. 1. 0. 1. 0. 1.]
[1. 0. 1. 0. 1. 0. 1. 0.]
[0. 1. 0. 1. 0. 1. 0. 1.]
[1. 0. 1. 0. 1. 0. 1. 0.]
[0. 1. 0. 1. 0. 1. 0. 1.]
[1. 0. 1. 0. 1. 0. 1. 0.]
[0. 1. 0. 1. 0.... |
9,640 | e4b0dc2e3d9310bbe462e746e21080d309dfed84 | import sys
from PyQt4 import QtGui,QtCore
class Button(QtGui.QPushButton):
def __init__(self,*__args):
super().__init__(*__args)
self.setAcceptDrops(True) # 设置可以接受拖入事件
def dragEnterEvent(self, e):
"设置接受的类型"
#判断拖动的数据类型是否是:text/plain # 这两个一组表示一个类型
#查询方法是:e.mimeData().form... |
9,641 | 440c116327ee587b5a305953772523011ece5dda | """
This type stub file was generated by pyright.
"""
import editobj3.introsp as introsp
import editobj3.editor as editor
from owlready2 import *
from editobj3.observe import *
from typing import Any, Optional
__all__ = ["EditedInstances", "OntologyInstanceEditor"]
class EditedInstances(object):
def __init__(self, ... |
9,642 | 95584dfdb232be7f507dc9d29ed2f1d95fa2b653 | from random import randrange
import random
"""
both user and computer funcs:
"""
def check_ok(boat, taken_positions):
# input: boat, taken_positions
# this func checks if the boat outside the playground or the position of the boat is already in taken_position
# return: boat. boat will returned as [-1] or its... |
9,643 | 486362463dc07bdafea85de39a4a6d58cb8c8f26 | import json
from test.test_basic import BaseCase
class TestUserRegister(BaseCase):
"""
TestClass to test the register function.
"""
def test_successful_register(self):
# Given
payload = json.dumps({
"username": "userjw",
"password": "1q2w3e4r"
})
... |
9,644 | ddab4d014c000dd96bad932adac75e4eec065483 | import csv
from itertools import chain, combinations
import generation
import time
pi = []
wi = []
di = []
n = input("How many tasks do you want to schedule ? \n")
k=tuple(range(1,n+1))
#la fonction qui supprime un element dans l'ensemble des taches, elle facilite comment retrouver les sous taches de J
def ... |
9,645 | 106cca8af164fa4ae946f77b40c76e03accf171c | from tkinter import*
me=Tk()
me.geometry("354x460")
me.title("CALCULATOR")
melabel = Label(me,text="CALCULATE HERE",bg='PINK',font=("ARIAL",25))
melabel.pack(side=TOP)
me.config(background='BROWN')
displayStr=StringVar()
op=""
def but(a):
global op
op=op+str(a)
displayStr.set(op)
def eq():
... |
9,646 | 483a5e95a7bfca2cc6b1e7e81740620468fb5623 | print(" whats your name boi ?")
name = input();
if name == "arrya":
print("u are a boi");
elif name == "jon":
print("basterd")
elif name == "ned":
print("you are dead man")
elif name == "rob":
print("the king in the north")
else:
print("carry on")
|
9,647 | 93bfca1e756951faacd29871ad19afad374e25d6 | from p5 import *
capture = None
def setup():
global capture
createCanvas(390, 240)
capture = createCapture(VIDEO)
capture.size(320, 240)
def draw():
background(255)
image(capture, 0, 0, 320, 240)
run()
|
9,648 | a22d38f7e8122d6339d1beab3bf08fa41c36d61d | import math
def solve():
a = int(input())
b = int(input())
return math.sqrt(a*a + b * b)
print(solve()) |
9,649 | 6d0a945c9eaf6564a327928880df1f0aeed2e5d0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void findSubNode(Node root) {
}
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
... |
9,650 | 24a4b9246a9b15334bebc45c532a25bd81266918 | import collections
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if not root:
return True
... |
9,651 | 991b894c4c0fb9cb90aef0542227e001a3a3bb0d | #!/usr/bin/env python
"""
Usage:
generate-doc <layer-definition>
generate-doc --help
generate-doc --version
Options:
--help Show this screen.
--version Show version.
"""
from docopt import docopt
import openmaptiles
from openmaptiles.tileset import Layer
from openmaptiles.docs import ... |
9,652 | 9a0e24fbe9f51dc914d891e90196c2ff4e65f04a | #embaralhar sorteio
import random
a1 = input('Primeiro aluno: ')
a2 = input('Primeiro segundo: ')
a3 = input('Primeiro terceiro: ')
a4 = input('Primeiro quarto: ')
lista = [a1, a2, a3, a4]
random.shuffle(lista)
print('A ordem de apresentacao será')
print(lista) |
9,653 | 59c33383365d10c108253f7b5a210d40718913a2 | # pick three names
names = ["Mia", "Francis", "Eva"]
# propmpt user for his/her name
print("Please enter your name:")
user_name = input()
if user_name in names:
print("Hi there, {}!".format(user_name))
else:
print("Who goes there?")
|
9,654 | 4add80894036e0395a6e6eb13e8a2db0d963de8c | sum_value = 0
for _ in range(5):
sum_value += int(input())
print(sum_value) |
9,655 | 8ad9efbbb2d9e2a5f73ebbb999da3ed93e4c1974 | import time
import random
from BlockchainNetwork.MVB import *
from threading import Thread
coloredlogs.install()
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
log = logging.getLogger(__name__)
class MVBTest:
def __init__(self, initialNodeCnt):
sel... |
9,656 | cc97f70b9d41357f020ea9c59d8b149392a336cc | from django.apps import AppConfig
class WebApiAppConfig(AppConfig):
name = 'WebApiApp'
|
9,657 | 95e7e025660e71cbdf6a6a0812964fc26d4beec0 | import sqlite3
import argparse
import json
import index_db
from collections import defaultdict
def query_doc(cursor, lang, title):
cursor.execute(index_db.select_lang_title, (lang, title))
result = cursor.fetchone()
if not result:
return None
return {
'lang': result[0],
'doc_id... |
9,658 | 1f69bcd204c9be26756d964f4deb61296e40ff10 | # Import this.
|
9,659 | 61571ba9f647f430879b9fa5db884ec4c93c334f | import numpy as np
import urllib2
from io import StringIO
def demo_polyfit0():
x, y = np.loadtxt('stock.txt', unpack=True)
print '-'.join(map(str, np.polyfit(x, y, 1)))
def demo_polyfit1():
d = urllib2.urlopen("http://www.qlcoder.com/download/145622513871043.txt").read().decode("utf-8")
print d
... |
9,660 | af609f1558276bab96477d3a2c61d813b9dd3d82 | """
Program file: DataParser.py.
This program parses and returns a dataset for a plotting program
"""
from sys import exit
from csv import Sniffer, DictReader
class DataParser:
"""
Summary: parses a data file, and returns list of the filtered data.
Instances:
1. accepted_records
2. ignored_reco... |
9,661 | a1b85d140c45f082ceac54ad8aa9aa5c3659d5cf |
import ftplib
def ftp_download():
file_remote = 'ftp_upload.jpg'
file_local = '/home/pi/Desktop/Camera-Rasp-Arduino-sensors/test_download.jpg'
bufsize = 1024
fp = open(file_local, 'wb')
f.retrbinary('RETR ' + file_remote, fp.write, bufsize)
fp.close()
def ftp_upload():
file_remote = '... |
9,662 | c62ffcaa9095d772e51be086be349d200346bc22 | """ Utility functions and classes for SRP
Context : SRP
Module : Statsistics
Version : 1.0.0
Author : Stefano Covino
Date : 04/04/2013
E-mail : stefano.covino@brera.inaf.it
URL: : http://www.merate.mi.astro.it/utenti/covino
Usage : to be imported
Remarks : inputs are a 1D vectors to be cross-correlated. O... |
9,663 | a824bd7577134227f5c136f2a4382c056f1175be | import mxnet as mx
import numpy as np
import cv2
import random
class Even_iterator(mx.io.DataIter):
'''
data iterator, shuffle data but always make pairs as neighbors
for verification and triplet loss
'''
def __init__(self, lst_name, batch_size, aug_params=dict(), shuffle=False):
super(Eve... |
9,664 | 1178ad09638a4822461f7394e6cabb2db9516053 | #! /usr/bin/python
import Nodo,CLS,copy,sys
from excepcion import *
sys.setrecursionlimit(100000)
# Match
def match(nodo1,nodo2):
#print 'MATCH\n -',nodo1,'\n -',nodo2
# if isinstance(nodo1,Nodo.Nodo) and isinstance(nodo2,Nodo.Nodo):
# print ' -',nodo1.type,'\n -',nodo2.type
# Fin de recursion
if (not isinsta... |
9,665 | 179b07870d656fb24b73d8b0a1f76ffed08aa5c2 | import time
import DHT22
import pigpio
import Sensor
class MagicBoxDHT22(object):
def DHT22(self):
self.s.trigger()
time.sleep(0.2)
self.tempF=round(self.s.temperature()*1.8+32,2) -3.7 #+adjustment
self.humidity=round(self.s.humidity())
def __init__(self):
self.pi=pigp... |
9,666 | 78a96020abfd393438c2fce1dfd5fd159a23ca5a | #!/usr/bin/env python
################################################################################
#
# HDREEnable.py
#
# Version: 1.000
#
# Author: Gwynne Reddick
#
# Description:
#
#
# Usage:
#
# Last Update 16:49 08/12/10
#
################################################################################
# pa... |
9,667 | bb58b4384eaeec45be1af865012c618af05f5a0a | import os
from flask import Flask, request, jsonify, Response, abort
from sesamutils import sesam_logger, VariablesConfig
from sesamutils.flask import serve
required_env_vars = ["SUBDOMAIN"]
optional_env_vars = ["DEBUG", "LOG_LEVEL", ("API_ROOT","zendesk.com/api/v2/tickets/")] # Default values can be given t... |
9,668 | 08848e51d5564bad927607be3fa3c86f2c1212c5 | def favorite_book(name):
print(f"One of my favorite books is {name}...")
favorite_book("Alice in Wonderland")
|
9,669 | 8411acf6b27425357d212f5e220314daa019e023 | import numpy as np
import tensorflow as tf
def mfcc(data):
pass
def cut_frames(data):
pass |
9,670 | 24f6328d578b6145bf86d7b5378a081463936df3 | from __future__ import print_function
class StackQueue(object):
"""Queue implemented with two stacks"""
def __init__(self):
self.stack1 = []
self.stack2 = []
def enqueue(self, data):
self.stack1.append(data)
def dequeue(self):
if self.stack2:
return self.s... |
9,671 | 08712e050bd90408ed9d22bba9f62fafacd64d99 | from django.shortcuts import render
from django.contrib import messages
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
# Create your views here.
# def login(request):
# return render(request, 'login.html')
# def validar_login(request):
# usuario= request.POST['... |
9,672 | 4a711642af753ba2c82ce3351b052a4973e17e7d | import os
import RPi.GPIO as GPIO
import time
import neopixel
import board
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #Setup button pins
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(19, GPIO.I... |
9,673 | c967a63d03f9f836d97ae917dba2a7bfb7a54a0e | rule run_all:
shell:
'''
echo 'Hello World!'
'''
|
9,674 | 291cd789ac3ab7b794be8feafe0f608ad0c081d7 | from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox
class ChoiceTargetNumbers(QWidget):
"""Виджет с выбором номеров целей"""
def __init__(self, parent=None) -> None:
QWidget.__init__(self, parent)
# Нужные компоненты
label = QLabel(text="Выберите номера целей:")
... |
9,675 | 24595979199199ecc6bc6f3a26e0db418def8b78 | def __handle_import():
import sys
import os
cur_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
lib_path = os.path.join(cur_path, '../../build/lib/')
sys.path.append(lib_path)
proto_path = os.path.join(cur_path, '../../build/protobuf_python/')
sys.path.append(proto_path... |
9,676 | 4e77c7ac784ec235e9925004069131d16717e89a | from __future__ import absolute_import, division, print_function
from .core import Bag, Item, from_sequence, from_filenames
from ..context import set_options
|
9,677 | d5691403812cd3742f8e8b74d4ca613eca784ffd | class Rectangle():
def __init__(self,length,breadth):
self.length=length
self.breadth=breadth
def area(self):
return(self.length*self.breadth)
def perimeter(self):
return(2*(self.length+self.breadth))
r1=Rectangle(4,5)
r2=Rectangle(5,7)
a1=r1.area()
a2=r2.area()
p1=r1.perim... |
9,678 | 1328d62769ee2a0309021ff40fdbf78a2c5570c9 | def decorate():
print('hi')
@decorate
def decorated():
print('decorated')
decorate() |
9,679 | 565e994576a57f8bbdcb201f2439bd7e595fa53e | import pdb
from django.db.models import Count
from django.shortcuts import render_to_response, redirect
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.template import RequestContext
from models import *
from forms import *
from django.htt... |
9,680 | 1a7a2c2cfb2aa94401defd7a7a500f7dd2e7e0aa | # -*- coding: utf-8 -*-
from __future__ import absolute_import
import sh
import reqwire.helpers.cli
log_methods = (
'echo',
'error',
'fatal',
'info',
'warn',
'warning',
)
def test_emojize_win32(mocker):
mocker.patch('sys.platform', 'win32')
assert reqwire.helpers.cli.emojize(
... |
9,681 | 57f8584a8d058e5f9d4e0b7b75c7ec8dbbfef24a | # -*- coding:utf-8 -*-
# class TreeLinkNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# self.next = None
class Solution:
"""
给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。
注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。
"""
def GetNext(self, pNode):
... |
9,682 | 829b8cd0b648d39c07c20fd1c401bf717ed5b9c4 | from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper
from typing import Any, Optional
def wrap_oracle_errors() -> None: ...
class _UninitializedOperatorsDescriptor:
def __get__(self, instance: Any, cls: Optional[Any] = ...): ...
class DatabaseWrapper(BaseDatabaseWrapper):
vendo... |
9,683 | 421e7ed0cc5a8c8acc9b98fae4ee6cc784d9b068 | sair = True
while sair:
num = int(input("informe um numero inteiro:"))
if num <16:
fatorial = 1
x = num
while x>=1:
print(x,".")
fatorial = fatorial*x
x -= 1
print("Valor total do Fatorial do %d = %d "%(num,fatorial))
else:
... |
9,684 | 32eff306444966fab47815fcbae4aefb6769d29b | from lilaclib import *
def pre_build():
newver = _G.newver.removeprefix('amd-drm-fixes-')
for line in edit_file('PKGBUILD'):
if line.startswith('_tag'):
line = "_tag='amd-drm-fixes-" + newver + "'"
print(line)
newver2 = newver.replace("-",".")
update_pkgver_and_pkgrel(newver2)
def post_... |
9,685 | 5529813e10e4a30a60c28242be9d1a8822fb58af | """
It's annoying that we have to do it here but for something like Ant, we're not going to be able to
specify it easily inside of the rbf_hyper_parameters file. Because, for something like Ant, we have
2 COM dimensions, and Bipedal we have 1.
So, we're going to do something similar to shaping_functions.
The way it'... |
9,686 | 0b7d1564ecbd78086d59629a2058716f41b4b8c8 | import warnings
warnings.filterwarnings('ignore', category=FutureWarning)
from cv2 import cv2
from tqdm import tqdm
import os
import pickle
import numpy as np
import csv
import sys
from collections import defaultdict
from dataset_utils import *
sys.path.append("../training")
from dataset_tools import enclosing_square... |
9,687 | 3d59b8d6a34935ff332028443276f161430a981c | class A():
def m(self):
print("Class A")
class B():
def m(self):
print("Class B")
class C(B, A):
print("class C")
obj1 = C()
obj1.m()
print(C.mro()) # Method Resolution Order based on convention of "OBJECT" super class
|
9,688 | fdea48b6012b67327aea90e40eacbea5a1930d07 | print("This program calculates whether the year is a leap year or not")
year = input("Please enter the Year: ")
if year.isdecimal():
year=int(year)
if year%4==0 and year%100!=0 or year%400==0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
else:
... |
9,689 | f24516d8977b10b1ccece2f8eaec6e08ce0c2e16 | from functools import partial
import utils.functions as fn
import random as rd
import numpy as np
import time
class NeuralNetwork:
def __init__(self, input_size, hidden_size, output_size):
self.input_size = input_size
self.hidden_size = hidden_size
self.output_size = output_size
... |
9,690 | a903f9c5cae1c2eb2f40dc8ba29f0625a3d34224 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import xlrd
from enum import Enum
from sklearn import linear_model
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
import statsmodels.formula.api as smf
import statsmodels.api as sm
import statsmodels.formula.a... |
9,691 | a2fe62b6bbb6b753ef6aec6f44758b8aceeeafe6 | from __future__ import division
from collections import deque
import os
import warnings
import numpy as np
import keras.backend as K
import keras.layers as layers
import keras.optimizers as optimizers
from rl.core import Agent
from rl.util import *
def mean_q(y_true, y_pred):
return K.mean(K.max(y_pred, axis=-1... |
9,692 | f5c4057babc873099ae2a4d8c1aca960ab9fa30a | import numpy as np
from numpy import random
from sklearn.preprocessing import StandardScaler
from sklearn.cross_validation import train_test_split
from numpy.random import shuffle
import matplotlib.pyplot as plt
import numpy.linalg as la
import sklearn.preprocessing as proc
import csv
def get_accuracy(a, b, X_test, y_... |
9,693 | ee16b91ce1c12ce78d23ff655304aebc39cb1639 | from superwires import games, color
import random
SCORE = 0
## pizza_image= games.load_image("images/pizza.png")
## pizza = games.Sprite(image = pizza_image, x=SW/2, y=SH/2,
## dx =1, dy = 1)
## games.screen.add(pizza)
games.init(screen_width = 640, screen_height = 480, fps = ... |
9,694 | d28f5f95b375a1e075fdfcbc0350c90cf96f0212 | #python的运算符实例
#'+'加号
# 俩个对象相加(可以是俩个数字,也可以是俩个字符串(将俩个字符串连接))
a=7+8
print(a)
b="GOOD"+"Job"
print(b)
#'-'减号
#取一个数字的相反数或者实现俩个数字相减
c=-7
print(c)
print(19-1)
#'*'乘号
#如果是数字则进行乘法运算,字符串则复制若干次
d=4*7
print(d)
e="hello"*7
print(e)
#'/'除号
#表示俩个数字相除(Python 3.0中会直接输出正确的值)
f=7/2
print(f)
#'**'求幂运算
g=2**3
print(g)
#'<'小于号 返回一个布尔值
... |
9,695 | a6713a4edece14a88bd9c8ddd483ff8e16acdbcc | from unittest import TestCase
from attendance import Member
__author__ = 'colin'
class TestMember(TestCase):
def test_here(self):
member = Member("John", "Doe")
self.assertFalse(member.attended)
member.here()
self.assertTrue(member.attended) |
9,696 | 237f1f72ac3ef381f115a88025518f387825ff79 | # Jarvis interface class definition
import kernel.service
class interface(kernel.service.service):
def __init__(self, name):
self.name = name
|
9,697 | cf2973b94f1113013fe9baa946202ec75488f7d2 | #Exercise 2 - Write a Python class which has two methods get_String and print_String. get_String accept a string
#from the user and print_String print the string in upper case
#string will be an input to a get_string method and whatever you put in will print when you make the print screen method
class IOString():
... |
9,698 | 5b8d1bd026e97bb7508a500048f940abf0253471 | # def test_categories:
# ["5S", "5H", "5D", "4S", "4H", "4D", "3D", "3S"]
import unittest
from poker import Hand, makeCard, Rank, count_ranks, RankCount, max_straight
class TestHand(unittest.TestCase):
# def test_heap_multiples(self):
# heaped_multiples = Hand.heap_multiples({"J":4, "2":3})
# prin... |
9,699 | 86f365612e9f15e7658160ecab1d3d9970ca364e | # Autor : Kevin Oswaldo Palacios Jimenez
# Fecha de creacion: 16/09/19
# Se genera un bucle con for
# al no tener argumento print no genera ningun cambio
# mas que continuar a la siguiente linea
for i in range (1,11):
encabezado="Tabla del {}"
print(encabezado.format(i))
print()
# ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.