content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def restrict_level(mobs, level):
for mob, priority in mobs:
if level < mob.level:
continue
yield (mob, priority)
def restrict_terrain(mobs, terrain):
for mob, priority in mobs:
if terrain not in mob.terrains:
continue
yield (mob, priority)
def restri... | def restrict_level(mobs, level):
for (mob, priority) in mobs:
if level < mob.level:
continue
yield (mob, priority)
def restrict_terrain(mobs, terrain):
for (mob, priority) in mobs:
if terrain not in mob.terrains:
continue
yield (mob, priority)
def restri... |
# noinspection PyBroadException
def computegrade(score):
try:
score = float(input("Enter the score"))
if score >= 0.9:
print("Grade A")
elif score >= 0.8:
print("Grade B")
elif score >= 0.7:
print("Grade C")
elif score >= 0.6:
p... | def computegrade(score):
try:
score = float(input('Enter the score'))
if score >= 0.9:
print('Grade A')
elif score >= 0.8:
print('Grade B')
elif score >= 0.7:
print('Grade C')
elif score >= 0.6:
print('Grade D')
elif sco... |
cases = int(input())
for case in range(cases):
k,p = [int(x) for x in input().split(' ')]
print(k,int(p+(p*(p+1))/2))
| cases = int(input())
for case in range(cases):
(k, p) = [int(x) for x in input().split(' ')]
print(k, int(p + p * (p + 1) / 2)) |
test_cases = int(input().strip())
def get_days_of_month(month):
if month == 2:
return 28
if month in [1, 3, 5, 7, 8, 10, 12]:
return 31
return 30
for i in range(1, test_cases + 1):
month1, day1, month2, day2 = map(int, input().strip().split())
if month1 == month2:
print(... | test_cases = int(input().strip())
def get_days_of_month(month):
if month == 2:
return 28
if month in [1, 3, 5, 7, 8, 10, 12]:
return 31
return 30
for i in range(1, test_cases + 1):
(month1, day1, month2, day2) = map(int, input().strip().split())
if month1 == month2:
print('#... |
#
# PySNMP MIB module CISCO-DOT11-QOS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-DOT11-QOS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:38:30 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')
(value_range_constraint, constraints_intersection, constraints_union, single_value_constraint, value_size_constraint) ... |
def fibonacci(n):
a = 1
b = 1
while b <= n:
yield b
a, b = b, a + b
print("Numbers:", list(fibonacci(40)))
print("Sum:", sum(filter(lambda x: x % 2 == 0, fibonacci(4e6)))) | def fibonacci(n):
a = 1
b = 1
while b <= n:
yield b
(a, b) = (b, a + b)
print('Numbers:', list(fibonacci(40)))
print('Sum:', sum(filter(lambda x: x % 2 == 0, fibonacci(4000000.0)))) |
class NeureCtr:
def __init__(self, content_label):
self._uuid = content_label
self._relevants = {}
@property
def uuid(self):
return self._uuid
@property
def relevants(self):
return self._relevants
@relevants.setter
def relevants(self, value):
if valu... | class Neurectr:
def __init__(self, content_label):
self._uuid = content_label
self._relevants = {}
@property
def uuid(self):
return self._uuid
@property
def relevants(self):
return self._relevants
@relevants.setter
def relevants(self, value):
if va... |
def boxplot(x_data, y_data, base_color="#539caf", median_color="#297083", x_label="", y_label="", title=""):
_, ax = plt.subplots()
# Draw boxplots, specifying desired style
ax.boxplot(y_data
# patch_artist must be True to control box fill
, patch_artist = True
... | def boxplot(x_data, y_data, base_color='#539caf', median_color='#297083', x_label='', y_label='', title=''):
(_, ax) = plt.subplots()
ax.boxplot(y_data, patch_artist=True, medianprops={'color': median_color}, boxprops={'color': base_color, 'facecolor': base_color}, whiskerprops={'color': base_color}, capprops={... |
def lambda_handler(event, context):
# TODO implement
return {
'statusCode': 200,
'body': 'Hello from Lambda!'
}
| def lambda_handler(event, context):
return {'statusCode': 200, 'body': 'Hello from Lambda!'} |
#
# PySNMP MIB module WLSX-SYSTEMEXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WLSX-SYSTEMEXT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:30:06 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (wlsx_enterprise_mib_modules,) = mibBuilder.importSymbols('ARUBA-MIB', 'wlsxEnterpriseMibModules')
(aruba_switch_role, aruba_active_state, aruba_card_type) = mibBuilder.importSymbols('ARUBA-TC', 'ArubaSwitchRole', 'ArubaActiveState', 'ArubaCardType')
(object_identifier, integer, octet_string) = mibBuilder.importSymbols... |
with open('input', 'r') as f:
lengths = [ord(x) for x in f.read()] + [17, 31, 73, 47, 23]
inp = [x for x in range(0, 256)]
curr_position = 0
skip_size = 0
for i in range(64):
for length in lengths:
start_sublist = []
if curr_position + length >= len(inp):
start_sublist = inp[0:curr_... | with open('input', 'r') as f:
lengths = [ord(x) for x in f.read()] + [17, 31, 73, 47, 23]
inp = [x for x in range(0, 256)]
curr_position = 0
skip_size = 0
for i in range(64):
for length in lengths:
start_sublist = []
if curr_position + length >= len(inp):
start_sublist = inp[0:curr_p... |
products = {'gucci boots': 10000, 'channel': 20000, 'adidas boots': 8000,
'nike sport-suit': 23000, 'gucci sport-suit': 24000,
'Lonsdale suit': 8000, 'nike boots': 9000,
'dior chest': 10000, 'raben waist': 15000,
'wedding dress': 500000}
user = 'user'
password = 'user123... | products = {'gucci boots': 10000, 'channel': 20000, 'adidas boots': 8000, 'nike sport-suit': 23000, 'gucci sport-suit': 24000, 'Lonsdale suit': 8000, 'nike boots': 9000, 'dior chest': 10000, 'raben waist': 15000, 'wedding dress': 500000}
user = 'user'
password = 'user123456'
def check_login(login, password):
if le... |
#!/usr/bin/env python
__author__ = "bt3"
class Queue(object):
def __init__(self):
self.in_stack = []
self.out_stack = []
def _transfer(self):
while self.in_stack:
self.out_stack.append(self.in_stack.pop())
def enqueue(self, item):
return self.in_stack.append... | __author__ = 'bt3'
class Queue(object):
def __init__(self):
self.in_stack = []
self.out_stack = []
def _transfer(self):
while self.in_stack:
self.out_stack.append(self.in_stack.pop())
def enqueue(self, item):
return self.in_stack.append(item)
def dequeue(... |
print("----------------------------------------------")
print(" Even/Odd Number Identifier")
print("----------------------------------------------")
play_again = 'Y'
while play_again == 'Y':
user_num = input("Enter any whole number: ")
user_int = int(user_num)
if user_int % 2 == 0:
print("... | print('----------------------------------------------')
print(' Even/Odd Number Identifier')
print('----------------------------------------------')
play_again = 'Y'
while play_again == 'Y':
user_num = input('Enter any whole number: ')
user_int = int(user_num)
if user_int % 2 == 0:
print('Th... |
# 1. Exemplo de um trecho de codigo sem o uso da interupcao de repeticoes.
num = soma = 0
while num != 90:
num = int(input("Digite um numero: "))
soma += num
soma -= 90
print(f"A soma dos valores e' igual a {soma}.")
print("FIM!")
# 2. Com a interupcao de repeticoes while.
n = s = 0
while True:
n = int(inp... | num = soma = 0
while num != 90:
num = int(input('Digite um numero: '))
soma += num
soma -= 90
print(f"A soma dos valores e' igual a {soma}.")
print('FIM!')
n = s = 0
while True:
n = int(input('Digite um numero: '))
if n == 90:
break
s += n
print(f"A soma dos valores e' igual a: {s}.")
print(... |
M_PI = 3.14159265358979323846
EPSILON = 1.0e-38
MAX_TRANSIENTS = 4
BASE_N = 44 # The base number of segments of tract. | m_pi = 3.141592653589793
epsilon = 1e-38
max_transients = 4
base_n = 44 |
#!/usr/bin/env python3
# Create a function named remove_middle which has three parameters named
# lst, start, and end. The function should return a list where all elements
# in lst with an index between start and end(inclusive) have been removed.
def remove_middle(lst, start, end):
return lst[:start] + lst[end+1:]
... | def remove_middle(lst, start, end):
return lst[:start] + lst[end + 1:]
print(remove_middle([9, 7, 3, 10, 2, 4], 1, 2)) |
user_input = input("Type a two digit number: ")
first_digit = user_input[0]
second_digit = user_input[1]
print(int(first_digit) + int(second_digit)) | user_input = input('Type a two digit number: ')
first_digit = user_input[0]
second_digit = user_input[1]
print(int(first_digit) + int(second_digit)) |
def steps(number):
'''
The Collatz Conjecture or 3x+1 problem.
Given a number n, return the number of steps required to reach 1.
:param number:
:return:
'''
# The Collatz Conjecture is only concerned with strictly positive integers,
# so your solution should raise a ValueError with a me... | def steps(number):
"""
The Collatz Conjecture or 3x+1 problem.
Given a number n, return the number of steps required to reach 1.
:param number:
:return:
"""
if number <= 0:
raise value_error('.+')
steps_total = 0
while number != 1:
if number % 2 == 0:
numb... |
class Word:
def __init__(self):
self.hanzi = ''
self.pinyin = ''
self.english = ''
self.strokes = []
self.mnemonics = ''
self.audio = ''
self.notes = ''
def __str__(self):
format_str = '{} ({}) - {}\n'
return format_str.format(self.hanzi, ... | class Word:
def __init__(self):
self.hanzi = ''
self.pinyin = ''
self.english = ''
self.strokes = []
self.mnemonics = ''
self.audio = ''
self.notes = ''
def __str__(self):
format_str = '{} ({}) - {}\n'
return format_str.format(self.hanzi,... |
########################################
# QUESTION
########################################
# The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in th... | def duplicate_encode(word):
x = list(word.lower())
u = []
for k in x:
if x.count(k) == 1:
u.append('(')
elif x.count(k) > 1:
u.append(')')
j = ''
for k in u:
j += k
return j |
try:
None < 0
def NoneAndDictComparable(v):
return v
except TypeError:
# comparator to allow comparisons against None and dict
# comparisons (these were allowed in Python 2, but aren't allowed
# in Python 3 any more)
class NoneAndDictComparable(object):
def __init__(self, value)... | try:
None < 0
def none_and_dict_comparable(v):
return v
except TypeError:
class Noneanddictcomparable(object):
def __init__(self, value):
self.value = value
def __cmp__(self, other):
if not isinstance(other, self.__class__):
raise type_erro... |
class Transect:
def __init__(self, name="Transect", files=[]):
self.name = name
self.files = files
@property
def numFiles(self):
return len(self.files)
@property
def firstLastText(self):
first = self.files[0]
last = self.files[-1]
return f"{first.nam... | class Transect:
def __init__(self, name='Transect', files=[]):
self.name = name
self.files = files
@property
def num_files(self):
return len(self.files)
@property
def first_last_text(self):
first = self.files[0]
last = self.files[-1]
return f'{first... |
def fib(n):
if n == 0 or n == 1:
return 1
else:
answer = fib(n-1) + fib(n-2)
return answer
def memoise(f):
memo = {}
def g(n):
if n in memo:
return memo[n]
else:
answer = f(n)
memo[n] = answer
return answer
re... | def fib(n):
if n == 0 or n == 1:
return 1
else:
answer = fib(n - 1) + fib(n - 2)
return answer
def memoise(f):
memo = {}
def g(n):
if n in memo:
return memo[n]
else:
answer = f(n)
memo[n] = answer
return answer
... |
f = open('input.txt')
time = int(f.readline()[:-1])
busses = [[int(bus), i] for i, bus in enumerate(f.readline()[:-1].split(',')) if bus != 'x']
product = 1
for bus in busses:
product *= bus[0]
res = 0
for bus in busses:
l = product / bus[0] % bus[0]
k = 1
tmp = l
while l % bus[0] != 1:
... | f = open('input.txt')
time = int(f.readline()[:-1])
busses = [[int(bus), i] for (i, bus) in enumerate(f.readline()[:-1].split(',')) if bus != 'x']
product = 1
for bus in busses:
product *= bus[0]
res = 0
for bus in busses:
l = product / bus[0] % bus[0]
k = 1
tmp = l
while l % bus[0] != 1:
k ... |
#
# PySNMP MIB module ALCATEL-IND1-IPX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-IPX-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:18:07 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (routing_ind1_ipx,) = mibBuilder.importSymbols('ALCATEL-IND1-BASE', 'routingIND1Ipx')
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constra... |
def importEXPH(fdata):
ENCHVM = dict()
MOTORI = dict()
cline = 3
while cline < len(fdata):
coduhe = fdata[cline][0:5].strip()
nome = fdata[cline][5:18].strip()
if fdata[cline][17:43].strip():
# Enchimento de Volume Morto
iniench = fdata[cline][17:26].strip... | def import_exph(fdata):
enchvm = dict()
motori = dict()
cline = 3
while cline < len(fdata):
coduhe = fdata[cline][0:5].strip()
nome = fdata[cline][5:18].strip()
if fdata[cline][17:43].strip():
iniench = fdata[cline][17:26].strip()
durmeses = fdata[cline][2... |
with open('Chal08.txt','r') as f:
sum = 0
for i in f.readlines():
i = i.strip().split(' | ')
output = i[1].split()
for i in output:
if len(i) == 2 or len(i) == 4 or len(i) == 3 or len(i) == 7:
sum += 1
print(sum)
| with open('Chal08.txt', 'r') as f:
sum = 0
for i in f.readlines():
i = i.strip().split(' | ')
output = i[1].split()
for i in output:
if len(i) == 2 or len(i) == 4 or len(i) == 3 or (len(i) == 7):
sum += 1
print(sum) |
#!/usr/bin/python
# This file is used as a global config file while PCBmodE is running.
# DO NOT EDIT THIS FILE
cfg = {} # PCBmodE configuration
brd = {} # board data
stl = {} # style data
pth = {} # path database
msg = {} # message database
stk = {} # stackup data
| cfg = {}
brd = {}
stl = {}
pth = {}
msg = {}
stk = {} |
class JSONDL(object):
def __init__(self, jsondl_url=None, jsondl_data=None):
pass
def __attrMethod(self, method):
class MethodCaller(object):
#TODO: This implementation is horrible improve both code and apijson
def __init__(self, ssp_instance, method):
... | class Jsondl(object):
def __init__(self, jsondl_url=None, jsondl_data=None):
pass
def __attr_method(self, method):
class Methodcaller(object):
def __init__(self, ssp_instance, method):
self.ssp_instance = ssp_instance
api_instance = self.ssp_instan... |
f = open("input", "r").read()
f = f[:-1] # remove trailing char
floor = 0
position = 1
entered_basement = False
for i in f:
if i == '(':
floor = floor + 1
else:
floor = floor - 1
if (floor < 0) and (entered_basement == False):
print('entering basement on move ' + str(position))
... | f = open('input', 'r').read()
f = f[:-1]
floor = 0
position = 1
entered_basement = False
for i in f:
if i == '(':
floor = floor + 1
else:
floor = floor - 1
if floor < 0 and entered_basement == False:
print('entering basement on move ' + str(position))
entered_basement = True
... |
def generate_instance_identity_document(instance):
return {
"instanceId": instance.id,
}
| def generate_instance_identity_document(instance):
return {'instanceId': instance.id} |
# iterating over a list
print('-- list --')
a = [1,2,3,4,5]
for x in a:
print(x)
# iterating over a tuple
print('-- tuple --')
a = ('cats','dogs','squirrels')
for x in a:
print(x)
# iterating over a dictionary
# sort order in python is undefined, so need to sort the results
# explictly before comparing output... | print('-- list --')
a = [1, 2, 3, 4, 5]
for x in a:
print(x)
print('-- tuple --')
a = ('cats', 'dogs', 'squirrels')
for x in a:
print(x)
print('-- dict keys --')
a = {'a': 1, 'b': 2, 'c': 3}
keys = []
for x in a.keys():
keys.append(x)
keys.sort()
for k in keys:
print(k)
print('-- dict values --')
values... |
# Se define la clase "piso" con 4 atributos
class piso():
numero = 0
escalera = ''
ventanas = 0
cuartos = 0
# Se le da la funcion "timbre" a cada piso
def timbre(self):
print("ding dong")
# __init__ se usa para "llenar" los 4 atributos preestablecidos
def __init__(s... | class Piso:
numero = 0
escalera = ''
ventanas = 0
cuartos = 0
def timbre(self):
print('ding dong')
def __init__(self, numero, ventanas, escaleras, cuartos):
self.numero = numero
self.ventanas = ventanas
self.escaleras = escaleras
self.cuartos = cuartos
... |
'''
Blockchain Backup version.
Copyright 2020-2022 DeNova
Last modified: 2022-02-01
'''
CURRENT_VERSION = '1.3.5'
| """
Blockchain Backup version.
Copyright 2020-2022 DeNova
Last modified: 2022-02-01
"""
current_version = '1.3.5' |
for i in range(1, 5):
print(" "*(4-i), end="")
for j in range(1, 2*i):
print("*", end="")
print()
for i in range(1, 4):
print(" "*(i), end="")
for j in range(7-2*i):
print("*", end="")
print()
| for i in range(1, 5):
print(' ' * (4 - i), end='')
for j in range(1, 2 * i):
print('*', end='')
print()
for i in range(1, 4):
print(' ' * i, end='')
for j in range(7 - 2 * i):
print('*', end='')
print() |
class Lint:
def __init__(self, file):
pass
| class Lint:
def __init__(self, file):
pass |
def sort(keys):
_sort(keys, 0, len(keys)-1, 0)
def _sort(keys, lo, hi, start):
if hi <= lo:
return
lt = lo
gt = hi
v = get_r(keys[lt], start)
i = lt + 1
while i <= gt:
c = get_r(keys[i], start)
if c < v:
keys[lt], keys[i] = keys[i], keys[lt]
... | def sort(keys):
_sort(keys, 0, len(keys) - 1, 0)
def _sort(keys, lo, hi, start):
if hi <= lo:
return
lt = lo
gt = hi
v = get_r(keys[lt], start)
i = lt + 1
while i <= gt:
c = get_r(keys[i], start)
if c < v:
(keys[lt], keys[i]) = (keys[i], keys[lt])
... |
c = get_config()
# Add users here that are allowed admin access to JupyterHub.
c.Authenticator.admin_users = ["instructor1"]
# Add users here that are allowed to login to JupyterHub.
c.Authenticator.whitelist = [
"instructor1", "instructor2", "student1", "student2", "student3"
]
| c = get_config()
c.Authenticator.admin_users = ['instructor1']
c.Authenticator.whitelist = ['instructor1', 'instructor2', 'student1', 'student2', 'student3'] |
# -*- coding: utf-8 -*-
HOST = '0.0.0.0'
PORT = 4999
DEBUG = 'true'
APP_NAME = 'DingDing'
DOMAIN = 'https://oapi.dingtalk.com/'
| host = '0.0.0.0'
port = 4999
debug = 'true'
app_name = 'DingDing'
domain = 'https://oapi.dingtalk.com/' |
class Movie:
def __init__(self, movie_id, category, title, genres, year, minutes, language, actors, director, imdb):
self.id = movie_id
self.category = category
self.title = title
self.genres = genres
self.year = year
self.minutes = minutes
self.language = lan... | class Movie:
def __init__(self, movie_id, category, title, genres, year, minutes, language, actors, director, imdb):
self.id = movie_id
self.category = category
self.title = title
self.genres = genres
self.year = year
self.minutes = minutes
self.language = la... |
#!/usr/bin/env python3
operations = {
'a': lambda a, b : a+b,
's': lambda a, b : a-b,
'm': lambda a, b : a*b,
'd': lambda a, b : a/b,
}
data = [
['a', 4, 5],
['d', 0, 3],
['m', 4, 8],
['s', 1, 4],
]
[el.append(operations[el[0]](el[1], el[2])) for el in... | operations = {'a': lambda a, b: a + b, 's': lambda a, b: a - b, 'm': lambda a, b: a * b, 'd': lambda a, b: a / b}
data = [['a', 4, 5], ['d', 0, 3], ['m', 4, 8], ['s', 1, 4]]
[el.append(operations[el[0]](el[1], el[2])) for el in data]
[print(el) for el in data] |
# -*- coding: utf-8 -*-
__version__ = '3.0.0'
__description__ = 'Password generator to generate a password based\
on the specified pattern.'
__author__ = 'rgb-24bit'
__author_email__ = 'rgb-24bit@foxmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2018 - 2019 rgb-24bit'
| __version__ = '3.0.0'
__description__ = 'Password generator to generate a password basedon the specified pattern.'
__author__ = 'rgb-24bit'
__author_email__ = 'rgb-24bit@foxmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2018 - 2019 rgb-24bit' |
def post_register_types(root_module):
root_module.add_include('"ns3/propagation-module.h"')
| def post_register_types(root_module):
root_module.add_include('"ns3/propagation-module.h"') |
class Cache(dict):
def __init__(self):
self['test_key'] = 'test_value'
| class Cache(dict):
def __init__(self):
self['test_key'] = 'test_value' |
def friends(n):
arr = [0 for i in range(n + 1)]
i = 0
while n+1 != 0:
if i <= 2:
arr[i] = i
else:
arr[i] = arr[i - 1] + (i - 1) * arr[i - 2]
i += 1
n -= 1
return arr[n]
if __name__ == '__main__':
## n = 1
## n... | def friends(n):
arr = [0 for i in range(n + 1)]
i = 0
while n + 1 != 0:
if i <= 2:
arr[i] = i
else:
arr[i] = arr[i - 1] + (i - 1) * arr[i - 2]
i += 1
n -= 1
return arr[n]
if __name__ == '__main__':
n = 10
print(friends(n)) |
'''https://leetcode.com/problems/n-queens/'''
class Solution:
def solveNQueens(self, n: int) -> List[List[str]]:
board = [['.' for _ in range(n)] for _ in range(n)]
ans = []
def placeQ(row, col):
board[row][col] = 'Q'
def removeQ(row, col):
board... | """https://leetcode.com/problems/n-queens/"""
class Solution:
def solve_n_queens(self, n: int) -> List[List[str]]:
board = [['.' for _ in range(n)] for _ in range(n)]
ans = []
def place_q(row, col):
board[row][col] = 'Q'
def remove_q(row, col):
board[row][... |
# Review:
# Create a function called greet().
# Write 3 print statements inside the function.
# Call the greet() function and run your code.
name = input("What's your name? ")
location = input("Where are you from? ")
def greet(name, location):
print(f"Hello Mr.{name}")
print(f"{location} is a nice place!")
... | name = input("What's your name? ")
location = input('Where are you from? ')
def greet(name, location):
print(f'Hello Mr.{name}')
print(f'{location} is a nice place!')
greet(name, location)
greet(location=location, name=name) |
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use ... | class Testdataframedrop:
def test_drop(self, df):
df.drop(['Carrier', 'DestCityName'], axis=1)
df.drop(columns=['Carrier', 'DestCityName'])
df.drop(['1', '2'])
df.drop(['1', '2'], axis=0)
df.drop(index=['1', '2'])
def test_drop_all_columns(self, df):
all_columns... |
# Basic Structure for Stack using Linked List
class Node:
def __init__(self,data):
self.data = data
self.next = None
class Stack:
def __init__(self):
self.head = None
def is_empty(self):
if self.head == None:
return True
else:
return False
... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Stack:
def __init__(self):
self.head = None
def is_empty(self):
if self.head == None:
return True
else:
return False
def push(self, data):
if not sel... |
# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you 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/... | def encode_field(value, encode_function=str):
"""
Encodes a field value using encode_function
:param value:
:param encode_function:
:return:
"""
if value is None:
return None
return encode_function(value)
def decode_field(value, decode_function):
"""
Decodes a field v... |
class Node(object):
def __init__(self, *contents):
self.contents = contents
def __repr__(self):
return "<{0} {1}>".format(self.__class__.__name__,
', '.join(map(repr, self.contents)))
def __eq__(self, other):
same_class = (isinstance(other, self.__... | class Node(object):
def __init__(self, *contents):
self.contents = contents
def __repr__(self):
return '<{0} {1}>'.format(self.__class__.__name__, ', '.join(map(repr, self.contents)))
def __eq__(self, other):
same_class = isinstance(other, self.__class__) or isinstance(self, other... |
SEED_LIMIT = 20
MAX_PAGES_PER_SITE = 35
MAX_LOGICAL_DEPTH = 3
MAX_PHYSICAL_DEPTH = 3
TOTAL_MAX_PAGES = 500 | seed_limit = 20
max_pages_per_site = 35
max_logical_depth = 3
max_physical_depth = 3
total_max_pages = 500 |
formdata = {
'deposittype': "",
'dates': {},
'dissertation': {
'degreename': {
'Doctor of Musical Arts (DMA)',
'Doctor of Education (EDD)',
'Doctor of Philosophy (PhD)'
},
'degreetype': {
'dissertation': 'Dissertation',
... | formdata = {'deposittype': '', 'dates': {}, 'dissertation': {'degreename': {'Doctor of Musical Arts (DMA)', 'Doctor of Education (EDD)', 'Doctor of Philosophy (PhD)'}, 'degreetype': {'dissertation': 'Dissertation', 'essay': 'Doctoral Essay', 'treatise': 'Doctoral Treatise', 'lecture': 'Lecture Recital Essay'}, 'degrees... |
# Copyright (c) 2018 Gennadii Donchyts. All rights reserved.
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
# Contributors:
# * 2018-08-01: Fedor Baart (f.baart@gmail.com) - added cmocean
# * 2019-01-18: Justin Braaten (jstnbraaten@gmail.com) - ... | cmocean = {'Thermal': {'7': ['042333', '2c3395', '744992', 'b15f82', 'eb7958', 'fbb43d', 'e8fa5b']}, 'Haline': {'7': ['2a186c', '14439c', '206e8b', '3c9387', '5ab978', 'aad85c', 'fdef9a']}, 'Solar': {'7': ['331418', '682325', '973b1c', 'b66413', 'cb921a', 'dac62f', 'e1fd4b']}, 'Ice': {'7': ['040613', '292851', '3f4b96'... |
valor = input().split(" ")
a, b, c = valor
maiorAB = ((int(a) + int(b)) + abs(int(a) - int(b)))/2
maiorAC = ((int(a) + int(c)) + abs(int(a) - int(c)))/2
maior = ((maiorAB + maiorAC) + abs(maiorAB - maiorAC))/2
print("%d eh o maior" % maior) | valor = input().split(' ')
(a, b, c) = valor
maior_ab = (int(a) + int(b) + abs(int(a) - int(b))) / 2
maior_ac = (int(a) + int(c) + abs(int(a) - int(c))) / 2
maior = (maiorAB + maiorAC + abs(maiorAB - maiorAC)) / 2
print('%d eh o maior' % maior) |
class Solution:
def productExceptSelf(self, nums: list[int]) -> list[int]:
products, it = [1] * len(nums), 1
for i in range(len(nums) - 1, -1, -1):
products[i] = it
it *= nums[i]
it = 1
for i in range(len(products)):
products[i] *= it
i... | class Solution:
def product_except_self(self, nums: list[int]) -> list[int]:
(products, it) = ([1] * len(nums), 1)
for i in range(len(nums) - 1, -1, -1):
products[i] = it
it *= nums[i]
it = 1
for i in range(len(products)):
products[i] *= it
... |
#
# PySNMP MIB module APEX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APEX-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:23:23 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, 09:23:1... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, constraints_union, value_size_constraint, value_range_constraint) ... |
class ResultObject:
def __init__(self, title: str, animeid: str):
self.title = title
self.animeid = animeid
class MediaInfoObject:
def __init__(self,
title: str,
year: int,
other_names: str,
season: str,
status... | class Resultobject:
def __init__(self, title: str, animeid: str):
self.title = title
self.animeid = animeid
class Mediainfoobject:
def __init__(self, title: str, year: int, other_names: str, season: str, status: str, genres: list, episodes: int, image_url: str, summary: str):
self.tit... |
#!/usr/bin/env python3
processors = 0
with open('/proc/cpuinfo') as cpufile:
for line in cpufile:
if line.find('core id') != -1:
processors += 1
print("No. of processors are : %d " %processors)
| processors = 0
with open('/proc/cpuinfo') as cpufile:
for line in cpufile:
if line.find('core id') != -1:
processors += 1
print('No. of processors are : %d ' % processors) |
files = {
'amy':{'num_1':5, 'num_2':2},
'bob':{'num_1':6, 'num_2':8},
'candy':{'num_1':9, 'num_2':6},
'doby':{'num_1':1, 'num_2':5},
'john':{'num_1':7, 'num_2':1},
}
for name,num in files.items():
print('\nName: ' + name)
favo_num = num['num_1'] + num['num_2']
print("Numb... | files = {'amy': {'num_1': 5, 'num_2': 2}, 'bob': {'num_1': 6, 'num_2': 8}, 'candy': {'num_1': 9, 'num_2': 6}, 'doby': {'num_1': 1, 'num_2': 5}, 'john': {'num_1': 7, 'num_2': 1}}
for (name, num) in files.items():
print('\nName: ' + name)
favo_num = num['num_1'] + num['num_2']
print('Number is ' + str(favo_nu... |
class Solution:
def getLastMoment(self, n: int, left: List[int], right: List[int]) -> int:
left=sorted(left)
right=sorted(right)
answer=0
if len(right)>0:
answer=max(answer, n-right[0])
if len(left)>0:
answer=max(answer, left[-1])
retu... | class Solution:
def get_last_moment(self, n: int, left: List[int], right: List[int]) -> int:
left = sorted(left)
right = sorted(right)
answer = 0
if len(right) > 0:
answer = max(answer, n - right[0])
if len(left) > 0:
answer = max(answer, left[-1])
... |
# -*- coding: utf-8 -*-
description = 'Sampletable complete'
includes = ['system']
group = 'lowlevel'
devices = dict(
stt_step = device('nicos.devices.generic.VirtualMotor',
unit = 'deg',
abslimits = (-100, 130),
speed = 4,
lowlevel = True,
),
stt_enc = device('nicos.dev... | description = 'Sampletable complete'
includes = ['system']
group = 'lowlevel'
devices = dict(stt_step=device('nicos.devices.generic.VirtualMotor', unit='deg', abslimits=(-100, 130), speed=4, lowlevel=True), stt_enc=device('nicos.devices.generic.VirtualCoder', motor='stt_step', unit='deg', lowlevel=True), stt=device('ni... |
# Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is:
# 2^31-1 (c++ int) or 2^63-1 (C++ long long int).
#
# As we know, the result of a^b grows really fast with increasing b.
#
# Let's do some calculations on very large integers.
#
# Task
# Read four numbers, a... | a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(pow(a, b) + pow(c, d)) |
{
'targets': [
{
'target_name': 'webaudio',
'sources': [
'main.cpp',
"<!@(node -p \"require('fs').readdirSync('./lib/src').map(f=>'lib/src/'+f).join(' ')\")"
],
'include_dirs': [
"<!(node -e \"require('nan')\")",
'<(module_root_dir)/lib/include',
'<(... | {'targets': [{'target_name': 'webaudio', 'sources': ['main.cpp', '<!@(node -p "require(\'fs\').readdirSync(\'./lib/src\').map(f=>\'lib/src/\'+f).join(\' \')")'], 'include_dirs': ['<!(node -e "require(\'nan\')")', '<(module_root_dir)/lib/include', '<(module_root_dir)/labsound/include', '<(module_root_dir)/labsound/third... |
def isPalind_string(str):
temp = str
if str[::-1] == temp:
return True
else:
return False
| def is_palind_string(str):
temp = str
if str[::-1] == temp:
return True
else:
return False |
class Degree:
def __init__(self,
title,
subject,
institution,
year):
self.title = title;
self.subject = subject;
self.institution = institution;
self.year = year;
bs = Degree(title = "B.S.",
subject = ... | class Degree:
def __init__(self, title, subject, institution, year):
self.title = title
self.subject = subject
self.institution = institution
self.year = year
bs = degree(title='B.S.', subject='Mathematics & Physics', institution='University of Arizona', year=2016)
ms = degree(title... |
class Pet:
def __init__(self, name):
self.name = 'unknown'
self._age = 10
def speak(self):
self.bark()
def _reset_age(self):
self._age = 10
class Dog(Pet):
def __init__(self):
Pet.__init__(self,'')
def bark(self):
print ('barking')
def se... | class Pet:
def __init__(self, name):
self.name = 'unknown'
self._age = 10
def speak(self):
self.bark()
def _reset_age(self):
self._age = 10
class Dog(Pet):
def __init__(self):
Pet.__init__(self, '')
def bark(self):
print('barking')
def set_a... |
__author__ = "Gawen Arab, Wes Mason"
__copyright__ = "Copyright 2012, Gawen Arab"
__credits__ = ["Gawen Arab", "Wes Mason"]
__license__ = "Apache License, Version 2.0"
__version__ = "1.0.2"
__maintainer__ = "Gawen Arab"
__email__ = "g@wenarab.com"
__status__ = "Production"
| __author__ = 'Gawen Arab, Wes Mason'
__copyright__ = 'Copyright 2012, Gawen Arab'
__credits__ = ['Gawen Arab', 'Wes Mason']
__license__ = 'Apache License, Version 2.0'
__version__ = '1.0.2'
__maintainer__ = 'Gawen Arab'
__email__ = 'g@wenarab.com'
__status__ = 'Production' |
sLabNew = {
"cdc": "cdc",
"cnic": "cnic",
"melb": "vidrl",
"vidrl": "vidrl",
"niid": "niid",
"nimr": "crick",
"crick": "crick",
}
sLabOld = {
"cdc": "cdc",
"cnic": "cnic",
"melb": "melb",
"vidrl": "melb",
"niid": "niid",
"nimr": "nimr",
"crick": "nimr",
}... | s_lab_new = {'cdc': 'cdc', 'cnic': 'cnic', 'melb': 'vidrl', 'vidrl': 'vidrl', 'niid': 'niid', 'nimr': 'crick', 'crick': 'crick'}
s_lab_old = {'cdc': 'cdc', 'cnic': 'cnic', 'melb': 'melb', 'vidrl': 'melb', 'niid': 'niid', 'nimr': 'nimr', 'crick': 'nimr'}
s_lab_display_name = {'cdc': 'CDC', 'cnic': 'CNIC', 'nimr': 'Crick... |
# -*- coding: utf-8 -*-
host = "127.0.0.1";
port = 3306;
user = "root";
pwd = "root";
db = "test";
charset = "utf8";
if __name__ == '__main__':
pass;
#end | host = '127.0.0.1'
port = 3306
user = 'root'
pwd = 'root'
db = 'test'
charset = 'utf8'
if __name__ == '__main__':
pass |
# 2020.03.25
# Problem Statement:
# https://leetcode.com/problems/sort-list/
# I hate linked list!
# https://leetcode.com/problems/sort-list/discuss/46714/Java-merge-sort-solution
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.... | class Solution:
def sort_list(self, head: ListNode) -> ListNode:
if not head or not head.next:
return head
(second_half, ptr, prev) = (head, head, None)
while ptr and ptr.next:
prev = second_half
second_half = second_half.next
ptr = ptr.next.n... |
# GYP file to build pdfviewer.
#
# To build on Linux:
# ./gyp_skia pdfviewer.gyp && make pdfviewer
#
{
'includes': [
'apptype_console.gypi',
],
'targets': [
{
'target_name': 'libpdfviewer',
'type': 'static_library',
'sources': [
'../experimental/PdfViewer/SkPdfBasics.cpp',
... | {'includes': ['apptype_console.gypi'], 'targets': [{'target_name': 'libpdfviewer', 'type': 'static_library', 'sources': ['../experimental/PdfViewer/SkPdfBasics.cpp', '../experimental/PdfViewer/SkPdfFont.cpp', '../experimental/PdfViewer/SkPdfRenderer.cpp', '../experimental/PdfViewer/SkPdfUtils.cpp', '../experimental/Pdf... |
class Utilities:
# Thanks, Wikipedia!
def inverse(self, a, n):
t = 0
r = n
newt = 1
newr = a
while newr != 0:
quot = r / newr
t, newt = newt, t - quot * newt
r, newr = newr, r - quot * newr
if (r > 1):
return "a not... | class Utilities:
def inverse(self, a, n):
t = 0
r = n
newt = 1
newr = a
while newr != 0:
quot = r / newr
(t, newt) = (newt, t - quot * newt)
(r, newr) = (newr, r - quot * newr)
if r > 1:
return 'a not invertible'
... |
# dataset settings
dataset_type = 'ImageNetC'
data_prefix = '/home/sjtu/scratch/zltan/datasets/imagenet-c'
corruption = 'snow'
severity = 5
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='Normalize... | dataset_type = 'ImageNetC'
data_prefix = '/home/sjtu/scratch/zltan/datasets/imagenet-c'
corruption = 'snow'
severity = 5
img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [dict(type='LoadImageFromFile'), dict(type='Normalize', **img_norm_cfg), dict(type='Imag... |
description = "neutronguide, leadblock"
group = 'lowlevel'
includes = ['nok_ref', 'zz_absoluts']
instrument_values = configdata('instrument.values')
showcase_values = configdata('cf_showcase.showcase_values')
tango_base = instrument_values['tango_base']
code_base = instrument_values['code_base']
devices = dict(
... | description = 'neutronguide, leadblock'
group = 'lowlevel'
includes = ['nok_ref', 'zz_absoluts']
instrument_values = configdata('instrument.values')
showcase_values = configdata('cf_showcase.showcase_values')
tango_base = instrument_values['tango_base']
code_base = instrument_values['code_base']
devices = dict(shutter_... |
__author__ = 'Haarm-Pieter Duiker'
__copyright__ = 'Copyright (C) 2016 - Duiker Research Corp'
__license__ = ''
__maintainer__ = 'Haarm-Pieter Duiker'
__email__ = 'support@duikerresearch.org'
__status__ = 'Production'
__major_version__ = '1'
__minor_version__ = '0'
__change_version__ = '0'
__version__ = '.'.join((__ma... | __author__ = 'Haarm-Pieter Duiker'
__copyright__ = 'Copyright (C) 2016 - Duiker Research Corp'
__license__ = ''
__maintainer__ = 'Haarm-Pieter Duiker'
__email__ = 'support@duikerresearch.org'
__status__ = 'Production'
__major_version__ = '1'
__minor_version__ = '0'
__change_version__ = '0'
__version__ = '.'.join((__maj... |
n = int(input("Quantos elementos vai ter o verto? "))
vet = [0 for x in range(n)]
for i in range(n):
vet[i] = int(input("Digite um numero: "))
soma = 0
pares = 0
for i in range(n):
if vet[i] % 2 == 0:
soma = soma + vet[i]
pares = pares + 1
if pares == 0:
print("NENHUM NUMERO PAR")
else:... | n = int(input('Quantos elementos vai ter o verto? '))
vet = [0 for x in range(n)]
for i in range(n):
vet[i] = int(input('Digite um numero: '))
soma = 0
pares = 0
for i in range(n):
if vet[i] % 2 == 0:
soma = soma + vet[i]
pares = pares + 1
if pares == 0:
print('NENHUM NUMERO PAR')
else:
... |
# Script to redirect from long-obsolete URLs to current static-blog ones
redirects = {
"2010/11/From-Baselayout-to-Systemd-setup-on-Exherbo": "2010/11/05/from-baselayout-to-systemd-setup-on-exherbo.html",
"2010/11/Moar-free-time": "2010/11/12/moar-free-time.html",
"2010/12/Commandline-pulseaudio-mixer-tool": "2010/... | redirects = {'2010/11/From-Baselayout-to-Systemd-setup-on-Exherbo': '2010/11/05/from-baselayout-to-systemd-setup-on-exherbo.html', '2010/11/Moar-free-time': '2010/11/12/moar-free-time.html', '2010/12/Commandline-pulseaudio-mixer-tool': '2010/12/25/commandline-pulseaudio-mixer-tool.html', '2010/12/Further-improvements-o... |
def test_setup_legacy_bus0(gpio, smbus, sn3218):
gpio.RPI_REVISION = 1
sn3218.channel_gamma(0, [int(pow(255, float(i - 1) / 255)) for i in range(256)])
assert smbus.SMBus.called_once_with(0)
sn3218.enable()
def test_setup_legacy_bus1(gpio, smbus, sn3218):
gpio.RPI_REVISION = 3
sn3218.channel_g... | def test_setup_legacy_bus0(gpio, smbus, sn3218):
gpio.RPI_REVISION = 1
sn3218.channel_gamma(0, [int(pow(255, float(i - 1) / 255)) for i in range(256)])
assert smbus.SMBus.called_once_with(0)
sn3218.enable()
def test_setup_legacy_bus1(gpio, smbus, sn3218):
gpio.RPI_REVISION = 3
sn3218.channel_ga... |
colors = ['darkred', 'darkmagenta', 'darkolivegreen',
'darkorange',
'darkorchid',
'darkseagreen',
'darksalmon',
'darkslateblue',
'crimson', 'antiquewhite',
'aqua', 'aquamarine', 'azure',
'beige', 'bisque', 'blanchedalmond',
'blue','blueviolet', 'brown',
'burlywood', 'cadetblue', 'chartreuse',
'chocol... | colors = ['darkred', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkseagreen', 'darksalmon', 'darkslateblue', 'crimson', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral'] |
def del_rep():
n=int(input("Enter the no of elements"))
print("Enter the list elements")
l=[]
for i in range(n):
l.append(input())
print(l)
for i in l:
c=int(l.count(i))
for j in l:
if(i==j) and c >1:
l.remove(j)
c-=1
... | def del_rep():
n = int(input('Enter the no of elements'))
print('Enter the list elements')
l = []
for i in range(n):
l.append(input())
print(l)
for i in l:
c = int(l.count(i))
for j in l:
if i == j and c > 1:
l.remove(j)
c -= 1
... |
class Ecosystem:
def __init__(self, deer_0=1.5, wolves_0=1.5, deer_growth=2/3, deer_predation=4/3, wolves_predation=1.0, wolves_decay=1.0, dt=0.0):
self.initialDeer = deer_0
self.initialWolves = wolves_0
self.currentDeer = deer_0
self.currentWolves = wolves_0
self.maxWolves =... | class Ecosystem:
def __init__(self, deer_0=1.5, wolves_0=1.5, deer_growth=2 / 3, deer_predation=4 / 3, wolves_predation=1.0, wolves_decay=1.0, dt=0.0):
self.initialDeer = deer_0
self.initialWolves = wolves_0
self.currentDeer = deer_0
self.currentWolves = wolves_0
self.maxWol... |
class Seating:
def __init__(self, layout: str):
self.seats = [list(line) for line in layout.splitlines()]
self.width = len(self.seats[0])
self.height = len(self.seats)
def nr_neigbors(self, row: int, col: int) -> int:
count = 0
for i in range(max(row - 1, 0), min(row+2, ... | class Seating:
def __init__(self, layout: str):
self.seats = [list(line) for line in layout.splitlines()]
self.width = len(self.seats[0])
self.height = len(self.seats)
def nr_neigbors(self, row: int, col: int) -> int:
count = 0
for i in range(max(row - 1, 0), min(row + ... |
string = [1, 2, 'ASD', 4, (1, 2, 3), '1', 'PY']
def get_string_list(lst):
if type(lst) == str:
return True
else:
return False
only_string = filter(get_string_list, string)
print(list(only_string))
| string = [1, 2, 'ASD', 4, (1, 2, 3), '1', 'PY']
def get_string_list(lst):
if type(lst) == str:
return True
else:
return False
only_string = filter(get_string_list, string)
print(list(only_string)) |
_base_ = [
'../_base_/models/ocrnet_hr18.py', '../_base_/datasets/cityscapes_bs2x.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k_lr2x.py'
]
| _base_ = ['../_base_/models/ocrnet_hr18.py', '../_base_/datasets/cityscapes_bs2x.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k_lr2x.py'] |
# Python allows empty class
class EmptyClass:
pass
# Create an instance of the class
obj_1 = EmptyClass()
# Attrubutes can be added to an object dynamically
obj_1.attribute1 = "The attribute 1"
obj_1.attribute2 = "The attribute 2"
print(obj_1.attribute1 + ' - ' + obj_1.attribute2)
# The __dict__ has all the infor... | class Emptyclass:
pass
obj_1 = empty_class()
obj_1.attribute1 = 'The attribute 1'
obj_1.attribute2 = 'The attribute 2'
print(obj_1.attribute1 + ' - ' + obj_1.attribute2)
print('The __dict__:')
print(obj_1.__dict__)
del obj_1.attribute2
print(obj_1.__dict__)
print() |
# This sample tests type annotations on variables.
array1 = [1, 2, 3]
# This should generate an error because the LHS can't
# have a declared type.
array1[2] = 4 # type: int
dict1 = {}
# This should generate an error because the LHS can't
# have a declared type.
dict1["hello"] = 4 # type: int
def... | array1 = [1, 2, 3]
array1[2] = 4
dict1 = {}
dict1['hello'] = 4
def foo():
a: int = 3
b: float = 4.5
c: str = ''
d: int = (yield 42) |
threePow19 = 1162261467 # 3**19
class Solution:
def isPowerOfThree(self, n: int) -> bool:
return n>0 and not (threePow19 % n)
| three_pow19 = 1162261467
class Solution:
def is_power_of_three(self, n: int) -> bool:
return n > 0 and (not threePow19 % n) |
__all__ = ["CLUSTER_ARGS", "EXAMPLE_DIRS", "EXTRA_ARGS"]
################################################################################
# Arguments used on the cluster
# Any set to None are ignored and only used for getting the key names in _update_cluster_args
CLUSTER_ARGS = {
'submit_cluster': None,
'submi... | __all__ = ['CLUSTER_ARGS', 'EXAMPLE_DIRS', 'EXTRA_ARGS']
cluster_args = {'submit_cluster': None, 'submit_qtype': 'SGE', 'submit_array': None, 'submit_pe_lsf': None, 'submit_pe_sge': 'smp', 'submit_queue': None}
example_dirs = ['contact-example', 'homologs', 'ideal-helices', 'import-data', 'nmr.remodel', 'nmr.truncate',... |
expected_output = {
'eigrp_instance': {
'100': {
'vrf': {
'default': {
'address_family': {
'ipv6': {
'name': 'test',
'named_mode': True,
'eigrp_interf... | expected_output = {'eigrp_instance': {'100': {'vrf': {'default': {'address_family': {'ipv6': {'name': 'test', 'named_mode': True, 'eigrp_interface': {'GigabitEthernet0/0/0/1.90': {'eigrp_nbr': {'fe80::5c00:ff:fe02:7': {'peer_handle': 1, 'hold': 12, 'uptime': '01:36:14', 'srtt': 0.011, 'rto': 200, 'q_cnt': 0, 'last_seq_... |
size=int(input("enter size="))
numbers=[]
for i in range(1,size+1):
a=int(input("enter a="))
numbers.append(a)
count=numbers.count(4)
print(numbers)
print("numbers of 4s in list=",count)
| size = int(input('enter size='))
numbers = []
for i in range(1, size + 1):
a = int(input('enter a='))
numbers.append(a)
count = numbers.count(4)
print(numbers)
print('numbers of 4s in list=', count) |
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
# Author: illuz <iilluzen[at]gmail.com>
# File: AC_mod_1.py
# Create Date: 2015-08-17 00:44:30
# Usage: AC_mod_1.py
# Descripton:
class Solution:
# @param {integer} num
# @return {integer}
def addDigits(self, num):
return num % 9... | class Solution:
def add_digits(self, num):
return num % 9 or (num and 9) |
# An object that will hold the type of current input with its respective value
class Token:
# type_ -> a type of token (from the list in constants)
# value -> the actual value
# pos_start -> Position of start of token (optional)
# pos_end -> Position of end of token (optional)
def __init__(self, typ... | class Token:
def __init__(self, type_, value=None, pos_start=None, pos_end=None):
self.type = type_
self.value = value
if pos_start:
self.pos_start = pos_start.copy()
self.pos_end = pos_start.copy()
self.pos_end.advance()
if pos_end:
s... |
class Student:
# class initialization method
def __init__(self, name, birthday, courses):
# class public attributes
self.full_name = name
self.first_name = name.split(' ')[0]
self.birthday = birthday
self.courses = courses
self.attendance = []
# class public ... | class Student:
def __init__(self, name, birthday, courses):
self.full_name = name
self.first_name = name.split(' ')[0]
self.birthday = birthday
self.courses = courses
self.attendance = []
def is_colleague(self, other):
course_intersection = self.courses.intersec... |
PV = int(input('Primeiro valor:'))
SV = int(input('Segundo valor:'))
TV = int(input('Terceiro valor:'))
menor = PV
if SV < PV and SV < TV:
menor = SV
if TV < PV and TV < SV:
menor = TV
maior = PV
if SV > PV and SV > TV:
maior = SV
if TV > PV and TV > SV:
maior = TV
print(f'O menor valor digitado foi {m... | pv = int(input('Primeiro valor:'))
sv = int(input('Segundo valor:'))
tv = int(input('Terceiro valor:'))
menor = PV
if SV < PV and SV < TV:
menor = SV
if TV < PV and TV < SV:
menor = TV
maior = PV
if SV > PV and SV > TV:
maior = SV
if TV > PV and TV > SV:
maior = TV
print(f'O menor valor digitado foi {me... |
a=int(input("Enter a number "))
while(a>0):
print(a)
a=a-1
| a = int(input('Enter a number '))
while a > 0:
print(a)
a = a - 1 |
conf_file = open("./online_exam_bot.config","r")
lines = conf_file.readlines()
data = []
conf = {}
i = 0
for line in lines:
if i <= 10:
extracted = line.split("'")
data.append(extracted)
if i != 5:
conf[data[i][1]] = data[i][3]
else:
pass
i += 1
| conf_file = open('./online_exam_bot.config', 'r')
lines = conf_file.readlines()
data = []
conf = {}
i = 0
for line in lines:
if i <= 10:
extracted = line.split("'")
data.append(extracted)
if i != 5:
conf[data[i][1]] = data[i][3]
else:
pass
i += 1 |
def encryptRailFence(text, key):
rail = [['\n' for i in range(len(text))]
for j in range(key)]
dir_down = False
row, col = 0, 0
for i in range(len(text)):
if (row == 0) or (row == key - 1):
dir_down = not dir_down
rail[row][col] = text[i]
c... | def encrypt_rail_fence(text, key):
rail = [['\n' for i in range(len(text))] for j in range(key)]
dir_down = False
(row, col) = (0, 0)
for i in range(len(text)):
if row == 0 or row == key - 1:
dir_down = not dir_down
rail[row][col] = text[i]
col += 1
if dir_dow... |
def func():
print("Hello")
def func2():
print("world")
l = [1,2,3,func, lambda x: x+1]
print(l)
print(l[3]())
print(l[4](2))
l2 = [func, func2]
for i in l2:
i() | def func():
print('Hello')
def func2():
print('world')
l = [1, 2, 3, func, lambda x: x + 1]
print(l)
print(l[3]())
print(l[4](2))
l2 = [func, func2]
for i in l2:
i() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.