content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Fortnite:
CHARACTERS = {"Raven" :"https://lh5.googleusercontent.com/89tmMS73f0Xa6ki9DPQ1ww1foWMAztEFrTw_cNKiB6ttdbYTfySZwLoUJKMluR5vVW_Z3HvTdrkmP4Jv9Q82nCUg-0cFk1ydPHXGMIt1OQwEJ8KnCFt7DO1fwWioSKuuudPLe5_x",
"Dark Hound" :"https://brokenpanda.net/wp-content/uploads/Molten-Battle-Hound-Fortnite-Wal... | class Fortnite:
characters = {'Raven': 'https://lh5.googleusercontent.com/89tmMS73f0Xa6ki9DPQ1ww1foWMAztEFrTw_cNKiB6ttdbYTfySZwLoUJKMluR5vVW_Z3HvTdrkmP4Jv9Q82nCUg-0cFk1ydPHXGMIt1OQwEJ8KnCFt7DO1fwWioSKuuudPLe5_x', 'Dark Hound': 'https://brokenpanda.net/wp-content/uploads/Molten-Battle-Hound-Fortnite-Wallpapers-2020.... |
def col_groupby_pdf(data, col, metric_col, ascending=False):
'''Cumulative Distribution Function
Takes in a dataframe with at least 2 columns, and returns a
groupby table with PDF.
data | DataFrame | a pandas dataframe with the data
col | str | name of the column to be grouped by
metric_col |... | def col_groupby_pdf(data, col, metric_col, ascending=False):
"""Cumulative Distribution Function
Takes in a dataframe with at least 2 columns, and returns a
groupby table with PDF.
data | DataFrame | a pandas dataframe with the data
col | str | name of the column to be grouped by
metric_col | ... |
'''
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
The solution set must not contain duplicate triplets.
Example:
Given array nums = [-1, 0, 1, 2, -1, -4],
A solution set is:
[
[-1, 0, 1],
[... | """
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
The solution set must not contain duplicate triplets.
Example:
Given array nums = [-1, 0, 1, 2, -1, -4],
A solution set is:
[
[-1, 0, 1],
[... |
# Python - 3.4.3
test.describe('Example Test Cases')
test.assert_equals(dating_range(17), '15-20')
test.assert_equals(dating_range(40), '27-66')
test.assert_equals(dating_range(15), '14-16')
test.assert_equals(dating_range(35), '24-56')
test.assert_equals(dating_range(10), '9-11')
| test.describe('Example Test Cases')
test.assert_equals(dating_range(17), '15-20')
test.assert_equals(dating_range(40), '27-66')
test.assert_equals(dating_range(15), '14-16')
test.assert_equals(dating_range(35), '24-56')
test.assert_equals(dating_range(10), '9-11') |
color_pink = '#fff5f6'
color_white = '#ffffff'
color_gray = '#f0f0f0'
color_bright = '#E8E9EB'
button_color = color_white
button_style_classic = "background-color: " + button_color + "; border-style: outset; border-width: 2px; " \
"border-radius: 10px; " \
... | color_pink = '#fff5f6'
color_white = '#ffffff'
color_gray = '#f0f0f0'
color_bright = '#E8E9EB'
button_color = color_white
button_style_classic = 'background-color: ' + button_color + '; border-style: outset; border-width: 2px; border-radius: 10px; border-color: gray; font: 12px; min-width: 10em; padding: 6px; '
default... |
IS_WINDOWS = True
def lineJuggle_logic(n1, n2, operation, linePrefix):
delete_to_mark=min(n1,n2)
delete_from_mark=max(n1,n2)
if linePrefix == "+":
delete_to_mark, delete_from_mark = delete_from_mark, delete_to_mark
delete_to_mark=delete_to_mark-delete_from_mark # lower_line is now offset r... | is_windows = True
def line_juggle_logic(n1, n2, operation, linePrefix):
delete_to_mark = min(n1, n2)
delete_from_mark = max(n1, n2)
if linePrefix == '+':
(delete_to_mark, delete_from_mark) = (delete_from_mark, delete_to_mark)
delete_to_mark = delete_to_mark - delete_from_mark
else:
... |
VERSION = (0, 3, 5)
__version__ = '.'.join(map(str, VERSION))
class PaymentProviderException(Exception):
def __init__(self, message, *args, **kwargs):
super(PaymentProviderException, self).__init__(message, *args, **kwargs)
payment_providers = {}
def register_provider(name, provider):
payment_prov... | version = (0, 3, 5)
__version__ = '.'.join(map(str, VERSION))
class Paymentproviderexception(Exception):
def __init__(self, message, *args, **kwargs):
super(PaymentProviderException, self).__init__(message, *args, **kwargs)
payment_providers = {}
def register_provider(name, provider):
payment_provide... |
#!/usr/bin/env python3
class Util(object):
@classmethod
def has_key_recursion(cls, obj: dict, key: str) -> any:
"""Returns the value of the first key found in the dictionary. (No recursive search is performed.)
Args:
obj (dict): target
key (str): key
Returns:
... | class Util(object):
@classmethod
def has_key_recursion(cls, obj: dict, key: str) -> any:
"""Returns the value of the first key found in the dictionary. (No recursive search is performed.)
Args:
obj (dict): target
key (str): key
Returns:
dict: value ... |
def years(start, end):
""" Build a list of years in the recent past/future as strings."""
try:
too_far_in_past = start <= 1999
too_far_in_future = end >= 2020
if too_far_in_future or too_far_in_past:
raise ValueError
except ValueError:
raise
else:
en... | def years(start, end):
""" Build a list of years in the recent past/future as strings."""
try:
too_far_in_past = start <= 1999
too_far_in_future = end >= 2020
if too_far_in_future or too_far_in_past:
raise ValueError
except ValueError:
raise
else:
end ... |
k = 0
prevAvg = 0
firstRun = 0
def AvgFilter(x):
global k, prevAvg, firstRun
if firstRun == 0:
k = 1
prevAvg = 0
firstRun = 1
alpha = (k - 1) / k
avg = alpha + (1 - alpha)
prevAvg = avg
k = k + 1 | k = 0
prev_avg = 0
first_run = 0
def avg_filter(x):
global k, prevAvg, firstRun
if firstRun == 0:
k = 1
prev_avg = 0
first_run = 1
alpha = (k - 1) / k
avg = alpha + (1 - alpha)
prev_avg = avg
k = k + 1 |
# The name of the transpiler. This line is required. Do not change it.
transpiler_name = "adam"
"""
The following code is the translation of the code.
You can write your code here and modify the content of the variables.
Do not change the name of the variables.
"""
# All the symbols that the transpiler uses.
mayusc =... | transpiler_name = 'adam'
'\nThe following code is the translation of the code.\nYou can write your code here and modify the content of the variables.\nDo not change the name of the variables.\n'
mayusc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alphabet = mayusc + mayusc.lower() + '_'
digits = '0123456789'
alphanum = alphabet + di... |
#
# PySNMP MIB module BENU-TWAG-STATS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BENU-TWAG-STATS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:20:36 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint, constraints_union) ... |
# abc acb bac bca cab cba
inputs = [["abc","acb"],["abc","bac"],["abc","bca"],["abc","cab"],["abc","cba"],["abcd","abc"],["tacocat","catastrophy"]]
def checkPerm(inp):
cache = {}
for char in inp[0]:
if char in cache:
cache[char] += 1
else:
cache[char] = 1
for char in... | inputs = [['abc', 'acb'], ['abc', 'bac'], ['abc', 'bca'], ['abc', 'cab'], ['abc', 'cba'], ['abcd', 'abc'], ['tacocat', 'catastrophy']]
def check_perm(inp):
cache = {}
for char in inp[0]:
if char in cache:
cache[char] += 1
else:
cache[char] = 1
for char in inp[1]:
... |
notebook.width = 10
plt.rcParams['figure.figsize'] = (notebook.width, 2)
# only display [0, 20] timerange
notebook.crop = Segment(0, 20)
# plot annotation
annotation = Annotation()
annotation[Segment(1, 5)] = 'Carol'
annotation[Segment(6, 8)] = 'Bob'
annotation[Segment(12, 18)] = 'Carol'
annotation[Segment(7, 20)] =... | notebook.width = 10
plt.rcParams['figure.figsize'] = (notebook.width, 2)
notebook.crop = segment(0, 20)
annotation = annotation()
annotation[segment(1, 5)] = 'Carol'
annotation[segment(6, 8)] = 'Bob'
annotation[segment(12, 18)] = 'Carol'
annotation[segment(7, 20)] = 'Alice'
notebook.plot_annotation(annotation, legend=T... |
#
# PySNMP MIB module CISCO-802-TAP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-802-TAP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:32:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, constraints_intersection, value_size_constraint, value_range_constraint) ... |
# Code Demo for 06 Lecture
# Working with Repetition as Loops in Python
# CIS 135 - Code Demo File
# Sample Variable Declaration
userReply = "YES"
inputData = -99
counter = 10
# Sample Comparisons
print('True/False userReply == "YES")', userReply == "YES")
print('True/False inputData != -99)', inputData != -... | user_reply = 'YES'
input_data = -99
counter = 10
print('True/False userReply == "YES")', userReply == 'YES')
print('True/False inputData != -99)', inputData != -99)
print('True/False counter < 10)', counter < 10)
python_string_list = ['Chevy', 'Ford', 'Honda', 'Ferrari', 'Quit']
python_number_list = [100, 65, 82, 96, -... |
# Version 1: space: O(N * M)
class Solution:
"""
@param m: An integer m denotes the size of a backpack
@param A: Given n items with size A[i]
@param V: Given n items with value V[i]
@return: The maximum value
"""
def backPackII(self, m, A, V):
n = len(A)
dp = [[0 for _ in ran... | class Solution:
"""
@param m: An integer m denotes the size of a backpack
@param A: Given n items with size A[i]
@param V: Given n items with value V[i]
@return: The maximum value
"""
def back_pack_ii(self, m, A, V):
n = len(A)
dp = [[0 for _ in range(m + 1)] for __ in range... |
# Link to problem: https://leetcode.com/problems/n-queens/
# Problem :The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
#Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.
#Each solu... | class Solution:
def calc(self, cur_row, col, diag1, diag2, matrix, n):
for i in range(n):
if col[i]:
if cur_row - i not in diag1:
if cur_row + i not in diag2:
matrix[cur_row][i] = 'Q'
if cur_row == n - 1:
... |
input1 = """2 book at 12.49
1 music CD at 14.99
1 chocolate bar at 0.85"""
input2 = """1 imported box of chocolates at 10.00
1 imported bottle of perfume at 47.50"""
input3 = """1 imported bottle of perfume at 27.99
1 bottle of perfume at 18.99
1 packet of headache pills at 9.75
3 box of imported chocolates at 11.25"... | input1 = '2 book at 12.49\n1 music CD at 14.99\n1 chocolate bar at 0.85'
input2 = '1 imported box of chocolates at 10.00\n1 imported bottle of perfume at 47.50'
input3 = '1 imported bottle of perfume at 27.99\n1 bottle of perfume at 18.99\n1 packet of headache pills at 9.75\n3 box of imported chocolates at 11.25'
outpu... |
def kill_kth_bit(n, k):
"""
use bitwise AND
0 & 0 = 0
1 & 0 = 0
to clear the bit: perform a bitwise AND of the number with a reset bit
n = n & ~(1 << k)
OR
n &= ~(1 << k)
"""
return n & ~(1 << k - 1)
if __name__ == '__main__':
n = 37
k = 3
print(kill_kth_... | def kill_kth_bit(n, k):
"""
use bitwise AND
0 & 0 = 0
1 & 0 = 0
to clear the bit: perform a bitwise AND of the number with a reset bit
n = n & ~(1 << k)
OR
n &= ~(1 << k)
"""
return n & ~(1 << k - 1)
if __name__ == '__main__':
n = 37
k = 3
print(kill_kth_bi... |
class Queue:
def __init__(self):
self._head = None # first order in the list
self._tail = None # last order in the list
self.length = 0 # number of Orders in the list
self.volume = 0 # sum of Order quantity in the list AKA share volume
self.last = None # helper for iter... | class Queue:
def __init__(self):
self._head = None
self._tail = None
self.length = 0
self.volume = 0
self.last = None
def next_order(self):
"""Get the next order in the list.
Set self.last as the next order. If there is no next order, stop
... |
"""
Poetry Environment Repository
Designed to manage the virtual environment using Poetry and export a further repository to interact with it.
"""
def _symlink_venv(repository_ctx):
project_dir = repository_ctx.path(repository_ctx.attr.project).dirname
repository_ctx.symlink(repository_ctx.path(str(project_di... | """
Poetry Environment Repository
Designed to manage the virtual environment using Poetry and export a further repository to interact with it.
"""
def _symlink_venv(repository_ctx):
project_dir = repository_ctx.path(repository_ctx.attr.project).dirname
repository_ctx.symlink(repository_ctx.path(str(project_di... |
class MaskSensitiveDataException(Exception):
pass
class RequestException(Exception):
pass
class ResponseParsingException(Exception):
pass
| class Masksensitivedataexception(Exception):
pass
class Requestexception(Exception):
pass
class Responseparsingexception(Exception):
pass |
def findRoots(A, B, C):
D = B**2 - 4*A*C
if D >= 0:
r1 = (-B-D**(0.5))/(2*A)
if D == 0:
R = [r1]
else:
r2 = (-B+D**(0.5))/(2*A)
if A > 0:
R = [r1, r2]
else:
R = [r2, r1]
else:
R = [-1]
return ... | def find_roots(A, B, C):
d = B ** 2 - 4 * A * C
if D >= 0:
r1 = (-B - D ** 0.5) / (2 * A)
if D == 0:
r = [r1]
else:
r2 = (-B + D ** 0.5) / (2 * A)
if A > 0:
r = [r1, r2]
else:
r = [r2, r1]
else:
r... |
def rc(num, low, high):
if num >= low and num <= high:
print(f'num = {num} is between {low} and {high}')
rc(5,2,7) | def rc(num, low, high):
if num >= low and num <= high:
print(f'num = {num} is between {low} and {high}')
rc(5, 2, 7) |
class Solution(object):
def validWordSquare(self, words):
"""
:type words: List[str]
:rtype: bool
"""
n = len(words)
for i in range(n):
for j, ch in enumerate(words[i]):
# compare with ith col
if j >= n or i >= len(words[j])... | class Solution(object):
def valid_word_square(self, words):
"""
:type words: List[str]
:rtype: bool
"""
n = len(words)
for i in range(n):
for (j, ch) in enumerate(words[i]):
if j >= n or i >= len(words[j]) or ch != words[j][i]:
... |
"""
Configuration for docs
"""
# source_link = "https://github.com/[org_name]/hoa_alliance"
# docs_base_url = "https://[org_name].github.io/hoa_alliance"
# headline = "App that does everything"
# sub_heading = "Yes, you got that right the first time, everything"
def get_context(context):
context.brand_html = "Hoa Al... | """
Configuration for docs
"""
def get_context(context):
context.brand_html = 'Hoa Alliance' |
# Fill fields with your data
login = ''
passwd = ''
host = ''
| login = ''
passwd = ''
host = '' |
PUZZLE_INPUT = input("> ")
# PART 1
def phase(input_signal, base_pat=(0,1,0,-1)):
if isinstance(input_signal, int): input_signal = str(input_signal)
numbers = [int(x) for x in input_signal] # 12345 -> 1, 2, 3, 4, 5
new_numbers = []
for n in range(1, len(input_signal)+1):
number_total = 0
... | puzzle_input = input('> ')
def phase(input_signal, base_pat=(0, 1, 0, -1)):
if isinstance(input_signal, int):
input_signal = str(input_signal)
numbers = [int(x) for x in input_signal]
new_numbers = []
for n in range(1, len(input_signal) + 1):
number_total = 0
for i in range(0, l... |
__author__ = 'schlitzer'
__all__ = [
'Connection',
'Hash',
'HyperLogLog',
'Key',
'List',
'Publish',
'Scripting',
'Set',
'SSet',
'String',
'Subscribe',
'Transaction'
]
class BaseCommand(object):
def __init__(self):
self._cluster = False
def execute(self... | __author__ = 'schlitzer'
__all__ = ['Connection', 'Hash', 'HyperLogLog', 'Key', 'List', 'Publish', 'Scripting', 'Set', 'SSet', 'String', 'Subscribe', 'Transaction']
class Basecommand(object):
def __init__(self):
self._cluster = False
def execute(self, *args, **kwargs):
raise NotImplemented
c... |
#tablas de 1 al 10
print ("numero de tabla de a l 10")
n= int(input("ingresa tu numero de tabla"))
print (n,(" * 1 es ="),(n*1))
print (n,(" * 2 es ="),(n*2))
print (n,(" * 3 es ="),(n*3))
print (n,(" * 4 es ="),(n*4))
print (n,(" * 5 es ="),(n*5))
print (n,(" * 6 es ="),(n*6))
print (n,(" * 7 es ="),(n*7))
print (n... | print('numero de tabla de a l 10')
n = int(input('ingresa tu numero de tabla'))
print(n, ' * 1 es =', n * 1)
print(n, ' * 2 es =', n * 2)
print(n, ' * 3 es =', n * 3)
print(n, ' * 4 es =', n * 4)
print(n, ' * 5 es =', n * 5)
print(n, ' * 6 es =', n * 6)
print(n, ' * 7 es =', n * 7)
print(n, ' * 8 es =', n * 8)
print(n... |
#
# MIT License
#
# Copyright (c) 2021 David Walters
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, mer... | file = open('cpc-screen-addr.bin', 'wb')
c = 0
for y in range(0, 200, 1):
base = 49152
a = base + int(y / 8) * 80 + int(y % 8) * 2048
print('output #' + str(c) + ': y = ' + str(y) + ', address = ' + str(hex(a)))
b = a.to_bytes(2, byteorder='little')
file.write(b)
c = c + 1
file.close() |
''' For Dataset1:
This is list of models and parameters where model with parameter 0.p is represented
by 'modelp'
'''
dataset = 'Dataset'
metrics_dict = ['PD', 'TEuc', 'TEMD','param', 'random']
feat_dict = ['top_log_Betti','top_log_simplex']
model_dict = ['ER03', 'ER06', 'ER1', 'ER15', 'ER2', 'ER25', 'GR1', 'GR175', ... | """ For Dataset1:
This is list of models and parameters where model with parameter 0.p is represented
by 'modelp'
"""
dataset = 'Dataset'
metrics_dict = ['PD', 'TEuc', 'TEMD', 'param', 'random']
feat_dict = ['top_log_Betti', 'top_log_simplex']
model_dict = ['ER03', 'ER06', 'ER1', 'ER15', 'ER2', 'ER25', 'GR1', 'GR175', ... |
#
# @lc app=leetcode id=40 lang=python3
#
# [40] Combination Sum II
#
# @lc code=start
class Solution:
def combinationSum2(self, candidates: list[int], target: int) -> list[list[int]]:
dp = [set({()})] + [set() for _ in range(target)]
for c in sorted(candidates):
for i in range(target,... | class Solution:
def combination_sum2(self, candidates: list[int], target: int) -> list[list[int]]:
dp = [set({()})] + [set() for _ in range(target)]
for c in sorted(candidates):
for i in range(target, c - 1, -1):
for prev in dp[i - c]:
dp[i].add(prev ... |
"""
66 / 66 test cases passed.
Runtime: 140 ms
Memory Usage: 36 MB
"""
class Solution:
def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
indegree = [0] * n
for edge in edges:
indegree[edge[1]] = True
ans = []
for i, d in enumerate(indegree)... | """
66 / 66 test cases passed.
Runtime: 140 ms
Memory Usage: 36 MB
"""
class Solution:
def find_smallest_set_of_vertices(self, n: int, edges: List[List[int]]) -> List[int]:
indegree = [0] * n
for edge in edges:
indegree[edge[1]] = True
ans = []
for (i, d) in enumerate(i... |
techTreeDict = {
"Elite Genitour": ["Berbers"],
"Supremacy": ["Spanish"],
"Battle Elephant": ["Vietnamese", "Burmese", "Khmer", "Malay"],
"Perfusion": ["Goths"],
"Thalassocracy": ["Malay"],
"Supplies": [
"Turks",
"Vietnamese",
"Burmese",
"Incas",
"Indians"... | tech_tree_dict = {'Elite Genitour': ['Berbers'], 'Supremacy': ['Spanish'], 'Battle Elephant': ['Vietnamese', 'Burmese', 'Khmer', 'Malay'], 'Perfusion': ['Goths'], 'Thalassocracy': ['Malay'], 'Supplies': ['Turks', 'Vietnamese', 'Burmese', 'Incas', 'Indians', 'Japanese', 'Poles', 'Magyars', 'Ethiopians', 'Teutons', 'Brit... |
def sublister(q,modulo=1):
i=0
j=0
while True:
yield j % q
i+=1
if i % modulo==0:j+=1
# def lister(q):
# lea=q
# border=lea
# gen=[sublister(q)]
# i=0
# while True:
# ac=[zw.__next__() for zw in gen]
# yield ac
# i+=1
# if i==border:
# q-=1
# if q<=0:brea... | def sublister(q, modulo=1):
i = 0
j = 0
while True:
yield (j % q)
i += 1
if i % modulo == 0:
j += 1
def lister3(q, modulo=1):
"""all numbers from 0 to q with modulo"""
i = 0
j = 0
while True:
yield i
j += 1
if not j % modulo:
... |
#!/usr/bin/env python
"""
--------------------------------
project: code
created: 02/07/2018 14:00
---------------------------------
"""
| """
--------------------------------
project: code
created: 02/07/2018 14:00
---------------------------------
""" |
# One Iteration, Linear Space (Stack) Sol.
# IB : Rain Water Trapped
# Author : @amitrajitbose
#
#
class Solution:
# @param A : tuple of integers
# @return an integer
def trap(self, A):
st = []
i = 0
ans = 0
while i<len(A):
while st and A[i]>A[st[-1]]:
top = st.pop(-1)
... | class Solution:
def trap(self, A):
st = []
i = 0
ans = 0
while i < len(A):
while st and A[i] > A[st[-1]]:
top = st.pop(-1)
if not st:
break
dist = i - st[-1] - 1
bounded_height = min(A[i]... |
def vogal(x):
if x in "aAeEiIoOuU":
return True
else:
return False
| def vogal(x):
if x in 'aAeEiIoOuU':
return True
else:
return False |
class Vehicle:
def __init__(self, id = None, license_plate = None, brand = None, model = None, id_user = None, id_vehicle_type = None):
self._id = id
self._license_plate = license_plate
self._brand = brand
self._model = model
self._id_user = id_user
self._id_vehicle_t... | class Vehicle:
def __init__(self, id=None, license_plate=None, brand=None, model=None, id_user=None, id_vehicle_type=None):
self._id = id
self._license_plate = license_plate
self._brand = brand
self._model = model
self._id_user = id_user
self._id_vehicle_type = id_ve... |
time_pitch=1.0
sim_len_sec=10.0
NE=300
Nsominh=200
Ndndinh=200
Ninput=300
Ndistractor=0
| time_pitch = 1.0
sim_len_sec = 10.0
ne = 300
nsominh = 200
ndndinh = 200
ninput = 300
ndistractor = 0 |
x = 0
while x < 10:
print(x)
x = x + 1
x = "horse"
print(x)
print(5 + "horse") | x = 0
while x < 10:
print(x)
x = x + 1
x = 'horse'
print(x)
print(5 + 'horse') |
#
# PySNMP MIB module IBM-ELAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IBM-ELAN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:50:53 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ... |
class Person:
def __init__(self, name, age, height_in_cm):
self.name = name
self.age = age
self.height_in_cm = height_in_cm
def speak(self):
print(f'Hello! My name is {self.name}. I am {self.age} years old.')
def greet(self, person):
if person.name == 'Rogers':
... | class Person:
def __init__(self, name, age, height_in_cm):
self.name = name
self.age = age
self.height_in_cm = height_in_cm
def speak(self):
print(f'Hello! My name is {self.name}. I am {self.age} years old.')
def greet(self, person):
if person.name == 'Rogers':
... |
numbers_count = int(input())
p1 = 0
p2 = 0
p3 = 0
p4 = 0
p5 = 0
for i in range(numbers_count):
current_number = int(input())
if current_number < 200:
p1 += 1
elif 200 <= current_number <= 399:
p2 += 1
elif 400 <= current_number <= 599:
p3 += 1
elif 600 <= current_number <= ... | numbers_count = int(input())
p1 = 0
p2 = 0
p3 = 0
p4 = 0
p5 = 0
for i in range(numbers_count):
current_number = int(input())
if current_number < 200:
p1 += 1
elif 200 <= current_number <= 399:
p2 += 1
elif 400 <= current_number <= 599:
p3 += 1
elif 600 <= current_number <= 79... |
""" Assignment 3"""
customer_id = 101
type(customer_id) #int
customer_name = 'John'
type(customer_name) #str
bill_amount = 675.45
type(bill_amount) #float
x = 5.3 + 0.9j
type(x) #complex
print(customer_id,customer_name,bill_amount)
print(x.real)
print(x.imag+3)
Flag = True
type(Flag)
| """ Assignment 3"""
customer_id = 101
type(customer_id)
customer_name = 'John'
type(customer_name)
bill_amount = 675.45
type(bill_amount)
x = 5.3 + 0.9j
type(x)
print(customer_id, customer_name, bill_amount)
print(x.real)
print(x.imag + 3)
flag = True
type(Flag) |
def fib():
x = y = 1
c=2
while len(str(y)) < 1000:
x , y = y , y+x
c += 1
return c
print(fib()) | def fib():
x = y = 1
c = 2
while len(str(y)) < 1000:
(x, y) = (y, y + x)
c += 1
return c
print(fib()) |
def rotate_left(point_a, point_b, sin, cos):
x1, y1 = point_a
x2, y2 = point_b
x_rot = (x2 * cos) - (y2 * sin) + (x1 * (1 - cos)) + (y1 * sin)
y_rot = (x2 * sin) + (y2 * cos) + (y1 * (1 - cos)) - (x1 * sin)
return x_rot, y_rot
def rotate_right(point_a, point_b, sin, cos):
x1, y1 = point_a
... | def rotate_left(point_a, point_b, sin, cos):
(x1, y1) = point_a
(x2, y2) = point_b
x_rot = x2 * cos - y2 * sin + x1 * (1 - cos) + y1 * sin
y_rot = x2 * sin + y2 * cos + y1 * (1 - cos) - x1 * sin
return (x_rot, y_rot)
def rotate_right(point_a, point_b, sin, cos):
(x1, y1) = point_a
(x2, y2) ... |
def square(x):
return x*x
def minus_one(x):
return x - 1
| def square(x):
return x * x
def minus_one(x):
return x - 1 |
temperatures_arr = [21, 23, 26, 22, 25, 20, 19, 23]
i = 0
max = 0
while i < 8:
temp = temperatures_arr[i]
i = i + 1
if temp > max:
max = temp
print(max)
| temperatures_arr = [21, 23, 26, 22, 25, 20, 19, 23]
i = 0
max = 0
while i < 8:
temp = temperatures_arr[i]
i = i + 1
if temp > max:
max = temp
print(max) |
'''
A number where one digit is the sum of the other digits is called a digit sum number or DS-number for short. For example, 352, 3003 and 32812 are DS-numbers.
We define to be the sum of all DS-numbers of digits or less.
You are given and .
Find . Give your answer modulo .
'''
n=1
s=0
while(n<50):
cn=n
... | """
A number where one digit is the sum of the other digits is called a digit sum number or DS-number for short. For example, 352, 3003 and 32812 are DS-numbers.
We define to be the sum of all DS-numbers of digits or less.
You are given and .
Find . Give your answer modulo .
"""
n = 1
s = 0
while n < 50:
cn... |
# code
def solve(num):
count = 0
num = str(num)
revNum = int(num[::-1])
nextNum = int(num) + revNum
count += 1
if (count > 5):
return -1
if poli:
return nextNum
else:
return solve(nextNum)
def poli(nextNum):
if nextNum == int(str(nextNum)[::-1]):
re... | def solve(num):
count = 0
num = str(num)
rev_num = int(num[::-1])
next_num = int(num) + revNum
count += 1
if count > 5:
return -1
if poli:
return nextNum
else:
return solve(nextNum)
def poli(nextNum):
if nextNum == int(str(nextNum)[::-1]):
return True... |
"""
HTTPies: Api-testing made portable from the terminal.
"""
__version__ = '1.0'
__author__ = 'Flip Vernooij'
__licence__ = 'BSD'
| """
HTTPies: Api-testing made portable from the terminal.
"""
__version__ = '1.0'
__author__ = 'Flip Vernooij'
__licence__ = 'BSD' |
'''
Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error.
If the score is between 0.0 and 1.0, print a grade using the following table:
Score Grade
>= 0.9 A
>= 0.8 B
>= 0.7 C
>= 0.6 D
< 0.6 F
If the user enters a value out of range, print a suitable error message a... | """
Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error.
If the score is between 0.0 and 1.0, print a grade using the following table:
Score Grade
>= 0.9 A
>= 0.8 B
>= 0.7 C
>= 0.6 D
< 0.6 F
If the user enters a value out of range, print a suitable error message a... |
indices = []
a = 2
for i, c in enumerate(format(a, '02b')):
if c == "1":
indices.append(i)
print(indices)
| indices = []
a = 2
for (i, c) in enumerate(format(a, '02b')):
if c == '1':
indices.append(i)
print(indices) |
"""
registry = {
'NLP_SERVICE_ADDRESS': "ipc:///tmp/nlp-service.sock",
'ANN_SERVICE_ADDRESS': "ipc:///tmp/ann-service.sock",
'RECOMMEND_SERVICE_ADDRESS': "ipc:///tmp/recommend-service.sock",
'DIALOG_SERVICE_ADDRESS': "ipc:///tmp/dialog-service.sock",
'INTENT_SERVICE_ADDRESS': "ipc:///tmp/intent-serv... | """
registry = {
'NLP_SERVICE_ADDRESS': "ipc:///tmp/nlp-service.sock",
'ANN_SERVICE_ADDRESS': "ipc:///tmp/ann-service.sock",
'RECOMMEND_SERVICE_ADDRESS': "ipc:///tmp/recommend-service.sock",
'DIALOG_SERVICE_ADDRESS': "ipc:///tmp/dialog-service.sock",
'INTENT_SERVICE_ADDRESS': "ipc:///tmp/intent-serv... |
def mod_value(mod, value):
def apply_mod(x):
return x % mod
return apply_mod
def mod_add(mod, a, b):
return (a + b) % mod
def mod_multiply(mod, a, b):
return (a * b) % mod
def mod_metabolism(mod, base):
def metabolism(a):
return (base * a) % mod
return metabolism
def f_add(mo... | def mod_value(mod, value):
def apply_mod(x):
return x % mod
return apply_mod
def mod_add(mod, a, b):
return (a + b) % mod
def mod_multiply(mod, a, b):
return a * b % mod
def mod_metabolism(mod, base):
def metabolism(a):
return base * a % mod
return metabolism
def f_add(mod,... |
__all__ = ["m1m1"]
def m1m1():
pass
def m1m2():
pass | __all__ = ['m1m1']
def m1m1():
pass
def m1m2():
pass |
lista=[]
def teste(n1):
for i in (range(n1+1)):
var=2**i
lista.append(var)
return lista
tt= teste(5)
print(tt)
| lista = []
def teste(n1):
for i in range(n1 + 1):
var = 2 ** i
lista.append(var)
return lista
tt = teste(5)
print(tt) |
##########################DATA LABEL PROPERTIES###############################
cameraInfo = {"Pelco" : 11.34, "Andor" : 8.1}
qualityParameters = ["Good","Very Good", "Amazing"],[0.1,0.05,0.01],["Bad"]
qualityN = {"N":3}
columnLocations = {"calX":3,"calTime":0,"pullP1X":1,"pullP2X":3,"FWHM":1}
alphabet = ["a","b","c","... | camera_info = {'Pelco': 11.34, 'Andor': 8.1}
quality_parameters = (['Good', 'Very Good', 'Amazing'], [0.1, 0.05, 0.01], ['Bad'])
quality_n = {'N': 3}
column_locations = {'calX': 3, 'calTime': 0, 'pullP1X': 1, 'pullP2X': 3, 'FWHM': 1}
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',... |
n = int(input())
c = 0
c += n // 100
n %= 100
c += n // 20
n %= 20
c += n // 10
n %= 10
c += n // 5
n %= 5
c += n // 1
n %= 1
print(c) | n = int(input())
c = 0
c += n // 100
n %= 100
c += n // 20
n %= 20
c += n // 10
n %= 10
c += n // 5
n %= 5
c += n // 1
n %= 1
print(c) |
# --------------------------------------------------------
# Multi-Epitope-Ligand Cartography (MELC) phase-contrast image based segmentation pipeline
#
#
# Written by Filip Mivalt
# --------------------------------------------------------
"""
A package containing fucntions and classes for data handling.
The pa... | """
A package containing fucntions and classes for data handling.
The package performs many tasks employing different sub-packages.
Sub-packages
----------
Dataset:
- Contains classes representing data such as MELC Run providing us with ready-to-use images
Files:
- Set of func... |
arr = []
arr.append(0)
arr.append(1)
i = 0
while len(arr) != 61:
if i == 0:
arr.append(2)
else:
x = str(arr[i])
x = x[::-1]
y = str(arr[i+1])
y = y[::-1]
arr.append(int(x)+int(y))
i += 1
while True:
try:
x = int(input())
pr... | arr = []
arr.append(0)
arr.append(1)
i = 0
while len(arr) != 61:
if i == 0:
arr.append(2)
else:
x = str(arr[i])
x = x[::-1]
y = str(arr[i + 1])
y = y[::-1]
arr.append(int(x) + int(y))
i += 1
while True:
try:
x = int(input())
print(arr[x])
... |
BENGALI_FONT = [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x00
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x01
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x02
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 0x03
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], ... | bengali_font = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0,... |
# Pybashrc file. Create your command-line accessible python functions here.
def _hidden_print_function(*args):
"""This function will be ignored by pybashrc, and will not be available from the
command line.
However, other functions can still use it.
"""
print(*args)
def test_pybashrc(first_argumen... | def _hidden_print_function(*args):
"""This function will be ignored by pybashrc, and will not be available from the
command line.
However, other functions can still use it.
"""
print(*args)
def test_pybashrc(first_argument: str, second_argument: str='second_argument'):
"""Default test function... |
key="find"
with open("mt7_7.txt","r",encoding="utf-8") as tf:
for i,line in enumerate(tf):
if line.find(key) >=0:
a=line.find(key)
print(a)
print(i+1, ":",line)
| key = 'find'
with open('mt7_7.txt', 'r', encoding='utf-8') as tf:
for (i, line) in enumerate(tf):
if line.find(key) >= 0:
a = line.find(key)
print(a)
print(i + 1, ':', line) |
EXAMPLE_ARR = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
def flipRows(arr):
""" left(r) to left
top to bottom
right(r) to right
bottom to top
>>> flipRows(EXAMPLE_ARR)
[[7, 8, 9], [4, 5, 6], [1, 2, 3]]
>>> flipRows(flipRows(EXAMPLE_ARR)) == EXAM... | example_arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
def flip_rows(arr):
""" left(r) to left
top to bottom
right(r) to right
bottom to top
>>> flipRows(EXAMPLE_ARR)
[[7, 8, 9], [4, 5, 6], [1, 2, 3]]
>>> flipRows(flipRows(EXAMPLE_ARR)) == EXAMPLE_ARR
True
"""
r... |
d = 1
n = 2
for i in range(2,101):
c = 2*(i//3) if i%3 == 0 else 1
t = d
d = n
n = c*d + t
print(sum([int(i) for i in str(n)])) | d = 1
n = 2
for i in range(2, 101):
c = 2 * (i // 3) if i % 3 == 0 else 1
t = d
d = n
n = c * d + t
print(sum([int(i) for i in str(n)])) |
"""
Problem Statement
=================
Given the number n, find the nth fibanacci number.
The fibonacci series is 0, 1, 1, 2, 3 ...
And follows the formula Fn = Fn-1 + Fn-2
Complexity
----------
* Recursive Solution: O(2^n)
* Dynamic Programming: O(n)
"""
def fibonacci_recursive(n):
if n == 0 or n == 1:
... | """
Problem Statement
=================
Given the number n, find the nth fibanacci number.
The fibonacci series is 0, 1, 1, 2, 3 ...
And follows the formula Fn = Fn-1 + Fn-2
Complexity
----------
* Recursive Solution: O(2^n)
* Dynamic Programming: O(n)
"""
def fibonacci_recursive(n):
if n == 0 or n == 1:
... |
#!/usr/bin/python
message = '!yadhtriB yppaH'[::-1]
print(message)
#prints Happy Birthday!
| message = '!yadhtriB yppaH'[::-1]
print(message) |
"""
TLD List defined things.
"""
api = "https://tld-list.com/xaja/dac"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML,"
" like Gecko) Ubuntu Chromium/69.0.3497.81 Chrome/69.0.3497.81 "
"Safari/537.36",
"Origin": "https://tld-list.com",
"Referer": "https://tld-li... | """
TLD List defined things.
"""
api = 'https://tld-list.com/xaja/dac'
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/69.0.3497.81 Chrome/69.0.3497.81 Safari/537.36', 'Origin': 'https://tld-list.com', 'Referer': 'https://tld-list.com/', 'Accept': '*/*', ... |
class fftcomp:
"""
This operation will plot the Fourier transform of given time series.
The time series and FFT are shown interactively so the user can select
a desired time slot and get the FFT from that region.
Parameters
----------
start : str
Starting date to retrieve data fr... | class Fftcomp:
"""
This operation will plot the Fourier transform of given time series.
The time series and FFT are shown interactively so the user can select
a desired time slot and get the FFT from that region.
Parameters
----------
start : str
Starting date to retrieve data from.
... |
def add_two_num(a, b):
# a and b are the parameters of add_two_num()
'''This function compute the sum of two numbers(a and b).
'''
return a + b # the result which function will return
print(add_two_num(3, 5)) # 3 and 5 are the arguments of add_two_num()
x = 10
y = 20
print(add_two_num(x, y)) # x and y... | def add_two_num(a, b):
"""This function compute the sum of two numbers(a and b).
"""
return a + b
print(add_two_num(3, 5))
x = 10
y = 20
print(add_two_num(x, y)) |
#Statement:Determine the sum of all elements in the sequence, ending with the number 0.
seq = int(input("enter numbers: "))
sum = seq
while seq > 0:
seq = int(input("enter number: "))
sum+= seq
if seq == 0:
break
print(sum) | seq = int(input('enter numbers: '))
sum = seq
while seq > 0:
seq = int(input('enter number: '))
sum += seq
if seq == 0:
break
print(sum) |
# The next lines will make the Pixel Turtle and its heading invisible
# and will clear the screen for light show
hidePixel()
hideHeading()
clear()
# First we move to the top left corner
moveTo(0, 0)
right(2)
for i in range(0, 8):
for j in range(0, 15):
if j % 2 == 0:
setColor(red)
else... | hide_pixel()
hide_heading()
clear()
move_to(0, 0)
right(2)
for i in range(0, 8):
for j in range(0, 15):
if j % 2 == 0:
set_color(red)
else:
set_color(cyan)
forward()
if i % 2 == 0:
right(2)
forward()
right(2)
else:
left(2)
... |
# if every sentences has these anotated words then label anotation with 0
# NOT_ANNOTATED = ["not", "no", "normal", "without", "negative for", "stable", "intact", "unchanged", "no evidence", "no acute", "no suspicious", "clear", "free of", "removal", "removed"]
NOT_ANNOTATED = ["not", "negative for", "no evidence", "no... | not_annotated = ['not', 'negative for', 'no evidence', 'no suspicious', 'free of', 'removal', 'removed']
not_found = ['no indexing', 'technical quality of image unsatisfactory']
synonyms = {'middle lobe': 'midlobe/mid lobe', 'middle': 'mid', 'lobe': 'lung', 'lung': 'lobe', 'pulmonary disease, chronic obstructive': 'cop... |
__author__ = 'jbowman'
# https://pythonspot.com/poylmorphism/
class Bear(object):
def sound(self):
print("Groarrr")
class Dog(object):
def sound(self):
print("Ruffff")
def makeSound(animalType):
animalType.sound()
bearObj = Bear()
dogObj = Dog()
makeSound(bearObj)
makeSound(dogObj)
cl... | __author__ = 'jbowman'
class Bear(object):
def sound(self):
print('Groarrr')
class Dog(object):
def sound(self):
print('Ruffff')
def make_sound(animalType):
animalType.sound()
bear_obj = bear()
dog_obj = dog()
make_sound(bearObj)
make_sound(dogObj)
class Document:
def __init__(sel... |
tanmuLink = '''
<link rel="stylesheet" href="/static/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/static/css/bootstrapValidator.min.css"/>
''' | tanmu_link = '\n \n <link rel="stylesheet" href="/static/css/bootstrap.min.css"/>\n <link rel="stylesheet" href="/static/css/bootstrapValidator.min.css"/>\n\n' |
# Metadata options:
# ---------------------------------
META_COMMENTS_MAP = 'comments-map'
META_KNITTY_COMMENTS_EXT = 'knitty-comments-ext'
META_KNITTY_LANG = 'knitty-lang'
PANDOC_CODECELL_CLASSES = ('code', 'cell')
| meta_comments_map = 'comments-map'
meta_knitty_comments_ext = 'knitty-comments-ext'
meta_knitty_lang = 'knitty-lang'
pandoc_codecell_classes = ('code', 'cell') |
sv1 = {0: 1, 1: 1, 2: 3}
sv2 = {0: 4, 1: 5, 2: 6}
def sparse_add(sv1, sv2):
"""dict, dict -> dict
Returns a new dictionary that is the sum of the other two.
>>>sparse_add(sv1, sv2)
{0: 5, 1: 6, 2: 9}
"""
newdict = {}
keys = set(sv1.keys()) | set(sv2.keys())
for key in keys:
x... | sv1 = {0: 1, 1: 1, 2: 3}
sv2 = {0: 4, 1: 5, 2: 6}
def sparse_add(sv1, sv2):
"""dict, dict -> dict
Returns a new dictionary that is the sum of the other two.
>>>sparse_add(sv1, sv2)
{0: 5, 1: 6, 2: 9}
"""
newdict = {}
keys = set(sv1.keys()) | set(sv2.keys())
for key in keys:
x ... |
load("//sqlc:def.bzl", _sqlc_package = "sqlc_package")
load("//sqlc:def.bzl", _SQLCRelease = "SQLCRelease")
sqlc_package = _sqlc_package
SQLCRelease = _SQLCRelease
| load('//sqlc:def.bzl', _sqlc_package='sqlc_package')
load('//sqlc:def.bzl', _SQLCRelease='SQLCRelease')
sqlc_package = _sqlc_package
sqlc_release = _SQLCRelease |
def COP(T_c):
return 0.35*((45+273.15)/(45-T_c))
def T_from_COP(COP):
return 45 - ((45+273.15)/(COP/0.35)) | def cop(T_c):
return 0.35 * ((45 + 273.15) / (45 - T_c))
def t_from_cop(COP):
return 45 - (45 + 273.15) / (COP / 0.35) |
class OpenOptException(BaseException):
def __init__(self, msg):
self.msg = msg
def __str__(self):
return self.msg
#pass
#def ooassert(cond, msg):
# assert cond, msg
def oowarn(msg):
s = oowarn.s + msg
print(s)
return s
oowarn.s = 'OpenOpt Warning: '
errSet = set()
def ... | class Openoptexception(BaseException):
def __init__(self, msg):
self.msg = msg
def __str__(self):
return self.msg
def oowarn(msg):
s = oowarn.s + msg
print(s)
return s
oowarn.s = 'OpenOpt Warning: '
err_set = set()
def ooerr(msg):
s = ooerr.s + msg
if msg not in errSet:
... |
def fatorial(x, show=False):
f = 1
for c in range(x, 0, -1):
if show:
print(c, end='')
if c>1:
print(f' x ', end='')
else:
print(' = ', end='')
f *= c
return f
print(fatorial(5, show=True))
| def fatorial(x, show=False):
f = 1
for c in range(x, 0, -1):
if show:
print(c, end='')
if c > 1:
print(f' x ', end='')
else:
print(' = ', end='')
f *= c
return f
print(fatorial(5, show=True)) |
##parameters=file='', **kw
##
try:
upload = file.read()
except AttributeError:
return context.setStatus(True)
else:
if upload:
return context.setStatus(True, text=upload)
else:
return context.setStatus(True)
| try:
upload = file.read()
except AttributeError:
return context.setStatus(True)
else:
if upload:
return context.setStatus(True, text=upload)
else:
return context.setStatus(True) |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Created by Roger on 2019/11/13
def pprint_tensor(x, name):
print("tensor %s: %s with %s" % (name, x.size(), type(x)))
print(x)
if __name__ == "__main__":
pass
| def pprint_tensor(x, name):
print('tensor %s: %s with %s' % (name, x.size(), type(x)))
print(x)
if __name__ == '__main__':
pass |
def normalize(name):
name = name.capitalize()
return name
L1 = ['adam', 'LISA', 'barT']
L2 = list(map(normalize, L1))
print(L2)
| def normalize(name):
name = name.capitalize()
return name
l1 = ['adam', 'LISA', 'barT']
l2 = list(map(normalize, L1))
print(L2) |
# Dabeeruddin Syed # Doubly linked list # Bi-directional linked list
class LinkedNode(object):
# Each node has its value and a pointer that points to next node in the Linked List
def __init__(self, value, next = None, previous = None):
self.value = value;
self.next = next;
self.previous... | class Linkednode(object):
def __init__(self, value, next=None, previous=None):
self.value = value
self.next = next
self.previous = previous
class Doublylinkedlist(object):
def __init__(self):
self.head = None
def insert_at_start(self, value):
if self.head == None:... |
class ModelRepository(object):
def __init__(self, *args, **kwargs):
self.obj = None
def __call__(self, func):
def authorize_and_call(*args, **kwargs):
obj = args[0]
if obj is None or obj._repository is None:
raise Exception(
'This obje... | class Modelrepository(object):
def __init__(self, *args, **kwargs):
self.obj = None
def __call__(self, func):
def authorize_and_call(*args, **kwargs):
obj = args[0]
if obj is None or obj._repository is None:
raise exception('This object is not connected... |
src =Split('''
''')
component =aos_component('lib_mico_ble_firmware', src)
BT_CHIP = aos_global_config.get('BT_CHIP')
BT_CHIP_REVISION = aos_global_config.get('BT_CHIP_REVISION')
BT_CHIP_XTAL_FREQUENCY = aos_global_config.get('BT_CHIP_XTAL_FREQUENCY')
if BT_CHIP_XTAL_FREQUENCY == None:
src.add_sources( BT_CHIP+BT... | src = split(' \n')
component = aos_component('lib_mico_ble_firmware', src)
bt_chip = aos_global_config.get('BT_CHIP')
bt_chip_revision = aos_global_config.get('BT_CHIP_REVISION')
bt_chip_xtal_frequency = aos_global_config.get('BT_CHIP_XTAL_FREQUENCY')
if BT_CHIP_XTAL_FREQUENCY == None:
src.add_sources(BT_CHIP + BT_... |
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
# if not s:
# return 0
# if len(s) == 1:
# return 1
# count = 0
# s0 = set()
# max_ = 0
# for letter in s:
# if letter not in s0:
# count += 1
... | class Solution:
def length_of_longest_substring(self, s: str) -> int:
if not s:
return 0
if len(s) == 1:
return 1
(p, q) = (0, 1)
ans = 1
while q < len(s):
while q < len(s) and len(s[p:q + 1]) == len(set(s[p:q + 1])):
q += ... |
"""
Problem Description:
The numbers 1,2,3.. are known as Natural numbers. Calculate the sum of all the natural numbers from 1 to N, where N will be the input.
Input:
A positive integer N
Output:
Output will be sum of numbers from 1 to N
Constraints:
1<N<1000
Sample Input:
5
Sample Output:
15
"""
n = int(input())... | """
Problem Description:
The numbers 1,2,3.. are known as Natural numbers. Calculate the sum of all the natural numbers from 1 to N, where N will be the input.
Input:
A positive integer N
Output:
Output will be sum of numbers from 1 to N
Constraints:
1<N<1000
Sample Input:
5
Sample Output:
15
"""
n = int(input())
... |
class GatewayError(RuntimeError):
def __init__(self, error_code, error_message):
super().__init__(error_message)
self.error_code = error_code
self.error_message = error_message
| class Gatewayerror(RuntimeError):
def __init__(self, error_code, error_message):
super().__init__(error_message)
self.error_code = error_code
self.error_message = error_message |
""" Dunder methods is a fancy name for 'under under method under under' or __method__()
They are built-in functions that add functionality to python code and also unlock new features on objects """
class Garage:
""" Stores cars in a garage object """
def __init__(self):
self.cars = []
def __len_... | """ Dunder methods is a fancy name for 'under under method under under' or __method__()
They are built-in functions that add functionality to python code and also unlock new features on objects """
class Garage:
""" Stores cars in a garage object """
def __init__(self):
self.cars = []
def __len__... |
#!/usr/bin/env python3
"""
dictmask masks dictionary data based on mask
"""
def dictmask(data, mask, missing_keep=False):
"""dictmask masks dictionary data based on mask"""
if not isinstance(data, dict):
raise ValueError("First argument with data should be dictionary")
if not isinstance(mask, di... | """
dictmask masks dictionary data based on mask
"""
def dictmask(data, mask, missing_keep=False):
"""dictmask masks dictionary data based on mask"""
if not isinstance(data, dict):
raise value_error('First argument with data should be dictionary')
if not isinstance(mask, dict):
raise value_... |
filename = "test_file.txt"
fh = open(filename, "r")
print(dir(fh))
for line in fh.readlines():
print(line, end="") | filename = 'test_file.txt'
fh = open(filename, 'r')
print(dir(fh))
for line in fh.readlines():
print(line, end='') |
def max_profit_memo(price_list, count, cache):
# base case
if count in [0, 1]:
return price_list[count]
if count in cache:
return cache[count]
if count < len(price_list):
profit = price_list[count]
else:
profit = 0
# recursive case
for i in ... | def max_profit_memo(price_list, count, cache):
if count in [0, 1]:
return price_list[count]
if count in cache:
return cache[count]
if count < len(price_list):
profit = price_list[count]
else:
profit = 0
for i in range(1, count // 2 + 1):
profit = max(profit, m... |
def merge(array, left, right):
i = j = k = 0
while i < len(left) and j < len(right):
if left[i][0] <= right[j][0]:
array[k] = left[i]
k += 1
i += 1
else:
array[k] = right[j]
k += 1
j += 1
if len(left) > i:
arra... | def merge(array, left, right):
i = j = k = 0
while i < len(left) and j < len(right):
if left[i][0] <= right[j][0]:
array[k] = left[i]
k += 1
i += 1
else:
array[k] = right[j]
k += 1
j += 1
if len(left) > i:
array[... |
# rule definitions for a level (ex. level 4 is rule_full)
RULE_FULL,RULE_PASSIVE,RULE_PHASE,RULE_FAULT,RULE_HINT = 0,1,2,3,4
# rule index that make up the above level rules (ex. hints are present)
RULEI_ANY, RULEI_SIDE, RULEI_PHASE, RULEI_FAULT, RULEI_HINTDELAY, RULEI_HINTREWARD = 0,1,2,3,4,5
rules = { # [rule_any,... | (rule_full, rule_passive, rule_phase, rule_fault, rule_hint) = (0, 1, 2, 3, 4)
(rulei_any, rulei_side, rulei_phase, rulei_fault, rulei_hintdelay, rulei_hintreward) = (0, 1, 2, 3, 4, 5)
rules = {RULE_FULL: [True, True, True, False, False, False], RULE_PASSIVE: [False, False, False, True, True, False], RULE_PHASE: [True,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.