content stringlengths 7 1.05M |
|---|
name = 'http'
__doc__ = "The http module provides access to methods concerning the http request and response"
def build(env,path):
self = env.get_new_module(path+'.'+name)
dbpy = env.get_module('dbpy')
#TODO:
#look... all this duplication of data in the request.
#eh.
#DOC:get_params
"""
The parsed... |
class Store:
def callStore(nestedList, store, inpCounter):
counter=[0]
i=nestedList
inList=[["("],["("]]
quit=False
while not quit:
repeat=True
while repeat:
repeat=False
i=nestedList
number=0
... |
SOCIAL_AUTH_TWITTER_KEY = 'LXgJdyaJRF0PeGlKakqg1HRF9'
SOCIAL_AUTH_TWITTER_SECRET = 'rjGbkkELyUhGt3GiEUUIW2A2S2yFtyB2GXmf23nDrgcqoQPZ5R'
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
|
class MyClassName:
__private = 123
non_private = __private * 2
mine = MyClassName()
mine.non_private
246
mine.__private
mine._MyClassName__private
123
|
"""
九成九的乘法表
"""
row=1
while row<=9:
col=1
while col<=row:
print("%d*%d=%d"%(col,row,row*col),end="\t")
col+=1
#print("%d"%row)
print("")
row+=1 |
# Eoin Lees
# Ascii Table
for i in range(0, 256):
print(f"{i:3} {i:08b} {chr(i)}") |
class Signal:
def __init__(self):
pass
def generate(self, df):
pass
|
# https://www.codingame.com/training/easy/brick-in-the-wall
def solution():
max_row_bricks = int(input())
num_bricks = int(input())
bricks = map(int, input().split())
work = 0
row, row_bricks = 1, 0
for brick in sorted(bricks, reverse=True):
work += ((row - 1) * 6.5 / 100) * 10 * bric... |
""" Prompts user to provide integer within a range """
def request_integer_in_range(prompt, lowest, highest):
"""
Purpose: prompts user for an integer, tests that an integer was
provided, and verifies the integer is within an acceptable range.
Inputs:
prompt (str): request to present to us... |
# -*- coding: utf-8 -*-
"""
sphinxcontrib.napoleon._upstream
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions to help compatibility with upstream sphinx.ext.napoleon.
:copyright: Copyright 2013-2018 by Rob Ruana, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
def _(message, *args):
"""
... |
#!/usr/bin/env python
str="../data/example-data-english.csv"
file = open(str, "r")
fileout = open(str+"B", "w")
for line in file:
array=line.split(",")
for i in range(len(array)-5):
#print (line.split(",")[i])
fileout.write(line.split(",")[i]+", ");
fileout.write(line.split(",")[i+1]+"\n... |
# vim: set et ts=4 sw=4 fileencoding=utf-8:
'''
tests
=====
'''
|
num_list = []
num = input('Please enter a number: ')
while num != 'done' and num != 'DONE':
try:
num_list.append(int(num))
num = input('Please enter a number: ')
except:
num = input("Not a number. Please enter a number Or 'done' to finish: ")
try:
print('Maximum number: ', max(num... |
num = int(input("Digite um número inteiro:"))
print("""Escolha para qual conversão você quer:
[ 1 ] para Binário
[ 2 ] para Octal
[ 3 ] para Hexadecimal""")
opç = int(input("Sua opção é:"))
if opç == 1:
print("A conversão de {} para Binario é {}" .format(num, bin(num)[2:]))
elif opç == 2:
print("A conversão de... |
#!/usr/bin/env python3
class Graph:
"""A collection of components and edges"""
def __init__(self, name):
self.name = name
self.nodes = {}
self.edges = {}
self.initializers = {}
def add_node(self, name, component):
'adds a node to the graph with name name.'
... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def convertBST(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
def dfs(node):
... |
summary_response = {
'data': {
'battery': {
'state': 'ONLINE',
'val': 2.0
},
'grid': {
'state': 'ONLINE',
'val': 40.0,
'something_else': 'not_included'
},
'house': {
'state': 'ONLINE',
'val': ... |
# -*- coding: utf-8 -*-
INVALID_URLS = [
'http://',
'http://.',
'http://..',
'http://../',
'http://?',
'http://??',
'http://??/',
'http://#',
'http://##',
'http://##/',
'http://foo.bar?q=Spaces should be encoded',
'//',
'//a',
'///a',
'///',
'http:///a',
... |
def merge(left, right):
result = []
i, j = 0, 0
while len(left) and j < len(right):
if left[i] <= right[j]:
result.append(left[i])
i += 1
else:
result.append(right[j])
j += 1
result += left[i:]
result += right[j:]
return result
... |
class OperationABC:
pass
class BaseTable(OperationABC):
def __init__(self, table, db):
self.table = table
self.database = db
class Selection(OperationABC):
def __init__(self, pred):
self.predicate = pred
|
# Question 6
num = float(input("Enter a number: "))
print("difference:", num-17)
if num > 17:
print("double of absolute value of difference:", abs(num - 17) * 2)
|
# Time: O(n + logc), c is the number of candies
# Space: O(1)
class Solution(object):
def distributeCandies(self, candies, num_people):
"""
:type candies: int
:type num_people: int
:rtype: List[int]
"""
# find max integer p s.t. sum(1 + 2 + ... + p) <= C
# =... |
class Notification(object):
def __init__(self, token, chat_id, logger):
super(Notification, self).__init__()
self.token = token
self.chat_id = chat_id
self.logger = logger
self.chat_id_list = chat_id.split()
def notify(self, user, message):
pass
def broadcas... |
# 250. Count Univalue Subtrees
# ttungl@gmail.com
# Given a binary tree, count the number of uni-value subtrees.
# A Uni-value subtree means all nodes of the subtree have the same value.
# For example:
# Given binary tree,
# 5
# / \
# 1 5
# / \ \
# 5 5... |
class Board():
def __init__(self, height, width, food, hazards, snakes):
self.height = height
self.width = width
self.food = food
self.hazards = hazards
self.snakes = snakes
|
# print(3 + 5)
# print(7 - 4)
# print(3 * 2)
# print(6 / 3)
# print(2 ** 3)
# PEDMAS LR
# ()
# **
# * /
# + -
print(3 * 3 + 3 / 3 - 3)
# Adding brackets around the addition increases priority
print(3 * (3 + 3) / 3 - 3) |
# write a function that takes a list of lists
# Each list has 5 numbers
# reverse each list in the big list but maintain the order of the lists
# e.g given [[1, 2, 3], [4, 5, 6], [7, 8]] return [[3, 2, 1], [6, 5, 4], [8, 7]]
# for more info on this quiz, go to this url: http://www.programmr.com/reverse-lists
def reve... |
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This data is in a separate file so that src/chrome/app/policy/PRESUBMIT.py
# can load it too without having to load pyautolib.
c... |
# Licensed under an MIT style license -- see LICENSE.md
__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
def psd_plot(
read_variable, default_analysis=None, plot_kwargs={}, extra_lines=[],
text="As an example, we now plot the PSDs stored in the file"
):
"""Return a string containing the function to ge... |
head = '''<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mob... |
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
while True:
a = random.randint(1, n - 1)
b = n - a
if '0' not in str(a) and '0' not in str(b):
return [a, b]
|
print("Welcome to MiOS")
yesValues = ["y", "yes", "true", "t"]
on = True
loggedIn = False
def yn(val):
return val.lower() in yesValues
while on:
account = input("Do you have an account? (y/n): ")
if yn(account):
print("Please login: ")
user = input("Enter your username: ")
userpassFi... |
class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
d = {")":"(","}":"{","]":"["}
inneed = ["(","[","{"]
list1 = []
input_lens = len(s)
if input_lens == 0:
return True
for i in range(input_lens): ... |
class Solution(object):
def numSquares(self, n):
"""
:type n: int
:rtype: int
"""
dp = [n] * (n + 1)
dp[0] = 0
for target in range(1, n+1):
for s in range(1, target + 1):
square = s * s
if target - square < 0:
... |
def createPageFile(title: str, description: str, rating: float):
pagestr = "{{-start-}}\n ${description}\n ====Rating===\n ${rating}\n{{-stop-}}"
f = open("%s" % (title), "w+")
pagestr = pagestr.replace("${description}", description)
pagestr = pagestr.replace("${rating}", str(rating))
f.write(pages... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ==================================================
# @Time : 2019-05-30 19:44
# @Author : ryuchen
# @File : constants.py
# @Desc :
# ==================================================
CUCKOO_GUEST_PORT = 8000
CUCKOO_GUEST_INIT = 0x001
CUCKOO_GUEST_RUNNING = 0x002
CUCKOO_G... |
class Config(object):
DEBUG = False
TESTING = False
UPLOAD_FOLDER = 'store'
class DevConfig(Config):
DEBUG = True
class TestConfig(Config):
TESTING = True
DEBUG = False
UPLOAD_FOLDER = 'test_store'
|
# clean code
def is_even(num):
return num % 2 == 0
print(is_even(51))
# *args **args
def super_func(*args):
return sum(args)
print(super_func(1,2,3,4,5)) #15
def another_super_func(**kwargs):
print(kwargs)
total = 0
for items in kwargs.values():
total += items
return total
print(another_super_f... |
class Fabric:
def __init__(self, width, height):
self._width = width
self._height = height
self._area = []
for row in range(0, height):
self._area.append([])
for column in range(0, width):
self._area[row].append(0)
def claim(self, piece):
... |
DAY = 11
def part1(data):
data = [ord(c) for c in data]
while not is_valid(data):
for j in range(len(data)-1, -1,-1):
data[j] = data[j]+1
if data[j] > ord("z"):
data[j] = ord("a")
else:
break
return "".join(chr(c) for c in data)
... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/12/27 10:32 AM
# @Author : Insomnia
# @Desc : 把数组排成最小的数字
# @File : RangeMinNum.py
# @Software: PyCharm
class Solution:
def rangeMinNum(self, arr):
num = [str(val) for val in arr]
num.sort()
num.reverse()
res = ''... |
# colorsystem.py is the full list of colors that can be used to easily create themes.
class Gray:
B0 = '#000000'
B10 = '#19232D'
B20 = '#293544'
B30 = '#37414F'
B40 = '#455364'
B50 = '#54687A'
B60 = '#60798B'
B70 = '#788D9C'
B80 = '#9DA9B5'
B90 = '#ACB1B6'
B100 = '#B9BDC1'
... |
# encoding: utf-8
##################################################
# This script shows an example of variable assignment. It explores the different options for storing vales into
# variables
##################################################
#
##################################################
# Author: Diego Pajari... |
"""
面试题50(一):字符串中第一个只出现一次的字符
题目:在字符串中找出第一个只出现一次的字符。如输入"abaccdeff",则输出
'b'。
"""
def first_not_repeat(s: str) -> str:
"""
Parameters
-----------
Returns
---------
Notes
------
"""
if not s:
return ""
dct = {}
for c in s:
if c in dct:
dc... |
data = []
with open("input.txt", "r") as file:
for line in file.readlines():
line = line.replace("\n", "")
data.append(line)
def countTrees(data, step_right, step_down):
check_index = step_right
count = 0
for i in range(step_down, len(data), step_down):
if data[i][check_index %... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"source": "01_noisyimagenette.ipynb",
"df": "01_noisyimagenette.ipynb",
"get_inverse_transform": "01_noisyimagenette.ipynb",
"lbl_dict": "01_noisyimagenette.ipynb",
"lbl_di... |
# Program to sort the array according to count of set bits in binary representation :)
def count_1(var):
count = 0
while var:
count += var % 2
var = var // 2
return count
arr = list(map(int, input("Enter the elements of array *With spaces b/w number* :").split()))
arr_new = [(arr[i], i) ... |
#!/usr/bin/python
# --------------------------------------
# Filters
# --------------------------------------
class FilterModule(object):
def filters(self):
return {
'assign_underlay_asn': self.assign_underlay_asn,
'get_local_asn': self.get_local_asn,
'filter_own_link... |
# max(iterable, *[, key, default])
list1 = [1, 2, 3, 2, 1, 2, 4, 3]
max_item = max(list1)
max_item = max(list1, key=lambda x: list1.count(x), default=1)
print('max_item: ', max_item)
# max_item: 2
print('default: ', max((), default=111))
# default: 111
lstobj = [
{'name': 'xiaoming', 'age': 18, 'gender': '... |
data = input()
elements = data.split(' ')
products = {}
for index in range(0, len(elements), 2):
key = elements[index]
quantity = int(elements[index + 1])
products[key] = quantity
searched_products = input().split(' ')
for item in searched_products:
if item in products.keys():
... |
#!/usr/bin/env python3
# Day 30: Check If a String Is a Valid Sequence from Root to Leaves Path in a
# Binary Tree
#
# Given a binary tree where each path going from the root to any leaf form a
# valid sequence, check if a given string is a valid sequence in such binary
# tree.
# We get the given string from the conc... |
class Solution(object):
def matrixReshape(self, nums, r, c):
"""
:type nums: List[List[int]]
:type r: int
:type c: int
:rtype: List[List[int]]
"""
if len(nums) * len(nums[0]) != r * c:
return nums
res = []
for i in range(len(nums)):... |
data = (
'yeoss', # 0x00
'yeong', # 0x01
'yeoj', # 0x02
'yeoc', # 0x03
'yeok', # 0x04
'yeot', # 0x05
'yeop', # 0x06
'yeoh', # 0x07
'ye', # 0x08
'yeg', # 0x09
'yegg', # 0x0a
'yegs', # 0x0b
'yen', # 0x0c
'yenj', # 0x0d
'yenh', # 0x0e
'yed', # 0x0f
'yel', # 0x10
'yelg', ... |
def test():
# if an assertion fails, the message will be displayed
# --> must have the correct arithmetic mean
assert numbers_one_mean == 4.0, "Are you calculating the arithmetic mean?"
# --> must have the first function call
assert "mean(numbers_one)" in __solution__, "Did you call the mean functio... |
class Category:
"""It should be able to instantiate objects based on different budget
categories like food, clothing, and entertainment. When objects are created,
they are passed in the name of the category.
Attributes:
category: A string of category of the category class
ledger: A list of al leger
... |
class EndLine (Exception):
pass
|
# Time: O(n)
# Space: O(n)
# freq table
class Solution(object):
def findLonely(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
cnt = collections.Counter(nums)
return [x for x in nums if cnt[x] == 1 and x-1 not in cnt and x+1 not in cnt]
|
# 7_lineNumbers.py
# A program that rewrites a file with line numbers
# Date: 10/6/2020
# Name: Ben Goldstone
def main():
readFileName = input("What is the name of the input file? ")
writeFileName = input("What do you want the name of your output file to be? ")
readFile = open(readFileName, "r")
writeFi... |
height = int(input())
for i in range(1,height+1):
for j in range(0,i+1):
print(end=" ")
for j in range(i,(2*height)-i+1):
print(j,end=" ")
print()
for i in range(1,height):
for j in range(0,height-i+1):
print(end=" ")
for j in range(height-i,height+i+1):
prin... |
class Solution:
def solve(self, nums):
if len(nums) <= 1:
return len(nums)
sign = lambda x: (x>0)-(x<0)
d = sign(nums[1]-nums[0])
streak = 1 if d == 0 else 2
ans = streak
for i in range(1,len(nums)-1):
if nums[i+1]-nums[i] == 0:
... |
def getFirst(pair):
return pair[0]
with open("../inputs/day4.txt","r") as f:
data=f.read()
# [1518-05-29 00:00] Guard #1151 begins shift
data=data.split("\n")
data.pop()
processedData=[]
for el in data:
piece=el.split("]")
piece[0]=piece[0].replace("[","")
piece[0]=piece[0].replace(... |
# There is a fence with n posts, each post can be painted with one of the k colors.
# You have to paint all the posts such that no more than two adjacent fence posts have the same color.
# Return the total number of ways you can paint the fence.
# Note:
# n and k are non-negative integers.
# Example:
# Input: n = 3, ... |
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 24 09:07:47 2018
@author: Lützenkirchen, Heberling, Jara
This module contains functions that are supossed to be used in one or more classes in order to remove redundancy.
"""
|
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
"""
Book: Hands-On MQTT Programming with Python
Author: Gaston C. Hillar - Twitter.com/gastonhillar
Publisher: Packt Publishing Ltd. - http://www.packtpub.com
"""
SURFBOARD_STATUS_IDLE = 0
SURFBOARD_STATUS_PADDLING = 1
SURFBOARD_STATUS_RIDING = 2
SURFBOARD_STATUS_RIDE_FINISHED = 3
SURFBOARD_STATUS_WIPED_OUT = 4
SURFBO... |
def parsinator(x):
s=dict()
for i in range(0,len(x)):
for j in range(0,len(x[i])):
if x[i][j]=='#':
s[j,i,0,0]=True
return (s,0,0,0,0,len(x)-1,len(x[i])-1,0,0)
banana = [(a,b,c,d) for a in [-1,0,1] for b in [-1,0,1] for c in [-1,0,1] for d in [-1,0,1] if (a,b,c,d... |
grafo3 = [{
"a": [
{
"aresta": "ac",
"incidencia": 1
},
{
"aresta": "ad",
"incidencia": 1
},
{
"aresta": "af",
"incidencia": 1
},
{
"aresta": "bd",
"incidencia": 0
},
{
"aresta": "be",
"incidencia": 0
},
{
"aresta": "cf",
"incidencia": 0
},
{
... |
#!/bin/python
def insertNewElement(ar, pos):
e = ar[pos]
idx = pos - 1
while idx >=0 and ar[idx] > e:
ar[idx+1] = ar[idx]
idx -= 1
ar[idx+1] = e
def insertionSort(ar):
if len(ar) <= 1:
return
for pos in range(1, len(ar)):
insertNewElement(ar, pos)
print('... |
Sys_User_Name = "EthanWayne"
Sys_Password = "123456"
User_Name = input("Please enter your name: ")
User_Password = input("Please enter your password: ")
if User_Name != Sys_User_Name and User_Password == Sys_Password:
print("Wrong user name...")
elif User_Name == Sys_User_Name and User_Password != Sys_Password:... |
def to_method(view, **base_kwargs):
"""Convert view function to instance method
"""
def _view(self, request, *args, **kwargs):
_kwargs = base_kwargs.copy()
_kwargs.update(kwargs)
return view(request, *args, **_kwargs)
return _view
|
while True:
valor = int(input("Valor (de 120 à 1001):"))
if valor>=120 and valor<1002:
break
qtd=0
while valor>2:
valor=valor/2
qtd+=1
print(qtd)
|
"""
T: O(N)
S: O(N)
Walk down the tree and calculate all created binary numbers. Calculating the
next number is as simple as shifting previous left(multiplying by two) and
adding additional digit to the end using OR.
"""
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
... |
#
# PySNMP MIB module IP-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/IP-MIB
# Produced by pysmi-0.0.7 at Sun Feb 14 00:17:37 2016
# On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose
# Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52)
#
( OctetString, I... |
fin = open("input_18.txt")
digits = '1234567890'
def end_of_operand(text):
if text[0] == '(':
plevel = 1
for i, char in enumerate(text[1:], 1):
if char == '(':
plevel += 1
elif char == ')':
plevel += -1
if plevel == 0:
... |
"""Constants for EQ3 Bluetooth Smart Radiator Valves."""
PRESET_PERMANENT_HOLD = "permanent_hold"
PRESET_NO_HOLD = "no_hold"
PRESET_OPEN = "open"
PRESET_CLOSED = "closed"
|
"""
Question:
Given an array of integers nums and integer k, return the total number of continuous subarrays whose sum equals to k.
nums = [1,-2,1,2,1,1] k =3
nums = [1,-2,1,2,1,1] k = 3
nums[i:j]
"""
def sub_array_sum(nums, k):
n = len(nums)
res = 0
for i in range(n-1):
cum_sum = nums[i]
... |
class DeleteDeniedException(Exception):
pass
class FileBrowser(object):
pass
|
"""This problem was asked by Google.
You are writing an AI for a 2D map game. You are somewhere in a 2D grid,
and there are coins strewn about over the map.
Given the position of all the coins and your current position,
find the closest coin to you in terms of Manhattan distance.
That is, you can move around up, d... |
'''
Fox and Snake
String Output
'''
n, m = list(map(int, input().split(' ')))
for i in range(n):
if i % 2 == 0:
print('#'*m)
elif (i+1) % 4 == 0:
print('#'+'.'*(m-1))
else:
print('.'*(m-1)+'#')
|
#
# @lc app=leetcode id=119 lang=python3
#
# [119] Pascal's Triangle II
#
# Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.
# Note that the row index starts from 0.
# In Pascal's triangle, each number is the sum of the two numbers directly above it.
# Example:
# Input:... |
#
# PySNMP MIB module Unisphere-Data-ATM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Unisphere-Data-ATM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:23:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... |
"""
1152. Analyze User Website Visit Pattern
Medium
We are given some website visits: the user with name username[i] visited the website website[i] at time timestamp[i].
A 3-sequence is a list of websites of length 3 sorted in ascending order by the time of their visits. (The websites in a 3-sequence are not necessa... |
filepath = "List of alternative rock artists - Wikipedia.html"
classifiedAs = "alternative rock"
file = open(filepath)
outputLines = []
for line in file:
if "</a></li>" in line:
outputLine = line.split("</a></li>")[0].split(">").pop() + " - " + classifiedAs
outputLines.append(outputLine)
... |
def flatten_dict(nested_dict, sep=None):
"""
flatten_dict flattens a dictionary,
The flattened keys are joined using a separater which is default to '__'.
:param nested_dict: input nested dictionary to be flattened.
:type nested_dict: dict
:param sep: seperator for the joined keys, defaults to... |
class Solution(object):
def romanToInt(self, s):
"""
:type s: str
:rtype: int
"""
values = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
res, prev = 0, 0
for c in reversed(s.upper()):
res += +values[c] if values[c] >= prev else ... |
N = int(input())
result = 0
for i in range(1, N + 1, 2):
t = 0
for j in range(1, i + 1):
if i % j == 0:
t += 1
if t == 8:
result += 1
print(result)
|
# -*- coding: utf-8 -*-
class Optimizer(object):
def __init__(self, parameters, lr=0.01):
self.parameters = parameters
self.lr = lr
def step(self):
raise NotImplementedError
def zero_grad(self):
for param in self.parameters:
param.zero_grad()
|
a = rtdpy.Ncstr(tau=1, n=2, dt=.001, time_end=10)
b = rtdpy.Pfr(tau=3, dt=.001, time_end=10)
c = rtdpy.Elist([a, b])
plt.plot(c.time, c.exitage)
plt.xlabel('Time')
plt.ylabel('Exit Age Function')
plt.title('Combined RTD Model') |
"""
Write a Python program to display the examination schedule. (extract the date from exam_st_date).
exam_st_date = (11, 12, 2014)
Sample Output : The examination will start from : 11 / 12 / 2014
"""
exam_st_date = (11, 12, 2014)
print("The examination will start from:",'{}/{}/{}'.format(exam_st_date[0],exam_st_date[1... |
#!/usr/bin/env python
#
# (c) Copyright Rosetta Commons Member Institutions.
# (c) This file is part of the Rosetta software suite and is made available under license.
# (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
# (c) For more information, see http://www.rosettacommons.or... |
tipos_de_classes = {
(1, 'Economica'),
(2, 'Executiva'),
(3, 'Primeira classe')
} |
#
# PySNMP MIB module JUNIPER-JS-IF-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-JS-IF-EXT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:59:34 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... |
#coding:utf8
class Config:
caption_data_path='caption.pth'# 经过预处理后的人工描述信息
img_path='/home/cy/caption_data/'
# img_path='/mnt/ht/aichallenger/raw/ai_challenger_caption_train_20170902/caption_train_images_20170902/'
img_feature_path = 'results.pth' # 所有图片的features,20w*2048的向量
scale_size = 300
im... |
while True:
n = int(input())
if n == 0:
break
arr = []
for i in range(n):
word = input()
arr.append(word)
flag = 0
for i in range(len(arr)):
for j in range(i+1, len(arr)):
if arr[j].startswith(arr[i]):
flag = 1
if flag ... |
#Make a class called Restaurant. The __init__() method for
#Restaurant should store two attributes: a restaurant_name and a cuisine_type.
#Make a method called describe_restaurant() that prints these two pieces of
#information, and a method called open_restaurant() that prints a message indicating
#that the restaurant ... |
#
# PySNMP MIB module HP-MEMPROC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-MEMPROC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:23:36 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... |
a = 0 # FIRST, set the initial value of the variable a to 0(zero).
while a < 10: # While the value of the variable a is less than 10 do the following:
a = a + 1 # Increase the value of the variable a by 1, as in: a = a + 1!
print(a) # Print to screen what the present value of the variable a... |
'''Fdb Genie Ops Object Outputs for IOSXE.'''
class FdbOutput(object):
ShowMacAddressTable = {
"mac_table": {
"vlans": {
'100': {
"mac_addresses": {
"ecbd.1d09.5689": {
"drop": {
... |
config = {
'SECRET_CAPTCHA_KEY': 'CHANGEME - 40 or 50 character long key here',
'METHOD': 'pbkdf2:sha256:100',
'CAPTCHA_LENGTH': 5,
'CAPTCHA_DIGITS': False
}
|
class Node:
def __init__(self, data=None, next_node=None):
self.data = data
self.next_node = next_node
def __str__(self):
return Node.pretty_string(self)
@staticmethod
def list_to_LL(L):
"""
Converts the given Python list into a linked list.
"""
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.