content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
arr = [6, 54, 5, 125, 222, 113, 0]
def insertionSort(arr):
# Traverse through 1 to len(arr)
for x in range(1, len(arr)):
key = arr[x]
j = x-1
while j >= 0 and key < arr[j] :
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
inse... | arr = [6, 54, 5, 125, 222, 113, 0]
def insertion_sort(arr):
for x in range(1, len(arr)):
key = arr[x]
j = x - 1
while j >= 0 and key < arr[j]:
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
insertion_sort(arr)
for x in range(len(arr)):
print('% d' % arr[x]) |
def get_package_data():
return {
_ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc', 'data/*'],
_ASTROPY_PACKAGE_NAME_ + '.interpolation.tests': ['reference/*']
}
| def get_package_data():
return {_ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc', 'data/*'], _ASTROPY_PACKAGE_NAME_ + '.interpolation.tests': ['reference/*']} |
# the model gets created
# in this file specific layers can be defined and changed
# the default data contains 40 x 1200 x 3 data as defined by the input dataformat
# if the data for test and validation is change the first layer format can change
# model contains a sequential keras model that can be applied with differ... | model.add(conv2_d(8, kernel_size=(3, 3), activation='relu', input_shape=(40, 1200, 3)))
model.add(max_pooling2_d(pool_size=(2, 2)))
model.add(conv2_d(16, kernel_size=(3, 3), activation='relu'))
model.add(max_pooling2_d(pool_size=(2, 2)))
model.add(conv2_d(24, kernel_size=(3, 3), activation='sigmoid'))
model.add(max_poo... |
size_set = int(input())
set0 = set(map(int, input().split()))
iteration_number = int(input())
for i in range(iteration_number):
set1 = input().split()
if set1[0] == "pop":
set0.pop()
elif set1[0] == "remove":
set0.remove(int(set1[1]))
elif set1[0] == "discard":
set0.d... | size_set = int(input())
set0 = set(map(int, input().split()))
iteration_number = int(input())
for i in range(iteration_number):
set1 = input().split()
if set1[0] == 'pop':
set0.pop()
elif set1[0] == 'remove':
set0.remove(int(set1[1]))
elif set1[0] == 'discard':
set0.discard(int(s... |
class School(object):
def __init__(self):
self.school_roster = {}
def add_student(self, name, grade):
if self.school_roster.get(grade):
self.school_roster[grade].append(name)
else:
self.school_roster[grade] = [name]
def roster(self):
students = []
... | class School(object):
def __init__(self):
self.school_roster = {}
def add_student(self, name, grade):
if self.school_roster.get(grade):
self.school_roster[grade].append(name)
else:
self.school_roster[grade] = [name]
def roster(self):
students = []
... |
class A:
def __init__(self, content):
self._content = content
@property
def content(self):
if not hasattr(self, '_content'):
return "content not exists"
return self._content
@content.setter
def content(self, value):
self._content = value
@content.de... | class A:
def __init__(self, content):
self._content = content
@property
def content(self):
if not hasattr(self, '_content'):
return 'content not exists'
return self._content
@content.setter
def content(self, value):
self._content = value
@content.d... |
#
# PySNMP MIB module MICOM-56KCSU-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MICOM-56KCSU-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:12:11 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, value_size_constraint, constraints_intersection) ... |
'''
Hi, here's your problem today. This problem was recently asked by AirBNB:
Given a sorted array, A, with possibly duplicated elements, find the indices of the first and last occurrences of a target element, x. Return -1 if the target is not found.
Example:
Input: A = [1,3,3,5,7,8,9,9,9,15], target = 9
Output: [6,8... | """
Hi, here's your problem today. This problem was recently asked by AirBNB:
Given a sorted array, A, with possibly duplicated elements, find the indices of the first and last occurrences of a target element, x. Return -1 if the target is not found.
Example:
Input: A = [1,3,3,5,7,8,9,9,9,15], target = 9
Output: [6,8... |
# Write a Python program to get a string which is n (non-negative integer) copies of a given string.
def copies(string, number):
ans = ""
for i in range(number):
ans += string
return ans
s = input("Enter a string: ")
n = int(input("Enter number of copies to do: "))
print(copies(s, n))
| def copies(string, number):
ans = ''
for i in range(number):
ans += string
return ans
s = input('Enter a string: ')
n = int(input('Enter number of copies to do: '))
print(copies(s, n)) |
class spam:
def __init__(self):
self.msgtxt = "this is spam"
def msg(self):
print(self.msgtxt)
if __name__ == '__main__':
s = spam()
s.msg()
| class Spam:
def __init__(self):
self.msgtxt = 'this is spam'
def msg(self):
print(self.msgtxt)
if __name__ == '__main__':
s = spam()
s.msg() |
def run (autoTester):
b = b'bike'
s = bytes ('shop', 'utf8')
e = b''
bb = bytearray ([0, 1, 2, 3, 4])
bc = bytes ((5, 6, 7, 8, 9))
# __pragma__ ('opov')
bps = b + b'pump' + s
bps3 = 3 * bps + b'\0'
aBps3 = bps * 3 + b'\0'
l = [1, 2, 3] + [4, 5, 6]
# __pragma__ ('noopov')
... | def run(autoTester):
b = b'bike'
s = bytes('shop', 'utf8')
e = b''
bb = bytearray([0, 1, 2, 3, 4])
bc = bytes((5, 6, 7, 8, 9))
bps = b + b'pump' + s
bps3 = 3 * bps + b'\x00'
a_bps3 = bps * 3 + b'\x00'
l = [1, 2, 3] + [4, 5, 6]
def format_check(aBytes):
autoTester.check([... |
UNICORN_MESSAGE_ERROR = "..for the love it bears to fair maidens forgets its ferocity and wildness.. "
GENERIC_ERROR = "Ooooops, it works on my machine. Please try again later."
NOT_FOUND_ERROR = "Not found!"
SERVER_ERROR = "Server problem"
UNSUPPORTED_SERVICE_ERROR = "Unsupported service"
KEY_TEMPLATE_ERROR = "Attenti... | unicorn_message_error = '..for the love it bears to fair maidens forgets its ferocity and wildness.. '
generic_error = 'Ooooops, it works on my machine. Please try again later.'
not_found_error = 'Not found!'
server_error = 'Server problem'
unsupported_service_error = 'Unsupported service'
key_template_error = 'Attenti... |
class ViewSetView(object):
'''
A mixin for views to make them compatible with ``ViewSet``.
'''
# The ``viewset`` will be filled during the instantiation of the
# ``NamedView`` (i.e. ``NamedView.as_view()`` is called with the
# kwarg ``viewset``).
viewset = None
| class Viewsetview(object):
"""
A mixin for views to make them compatible with ``ViewSet``.
"""
viewset = None |
# RUN: %S/../test.sh %s
def func():
return 1
print(func()) # CHECK: 1
| def func():
return 1
print(func()) |
print ("hello world")
print ("hello" ,"world" , "epic" , sep="##" )
variable = input ("enter your name ")
print("hello" , variable, sep=", ")
variable = input ( "enter your age:")
print("damn" , variable, sep=", ")
variable = input("enter your age ")
variable = int(variable)
difference = 100 - variable
print ("y... | print('hello world')
print('hello', 'world', 'epic', sep='##')
variable = input('enter your name ')
print('hello', variable, sep=', ')
variable = input('enter your age:')
print('damn', variable, sep=', ')
variable = input('enter your age ')
variable = int(variable)
difference = 100 - variable
print('you have ', diff... |
nuke.pluginAddPath("renderFinished")
nuke.pluginAddPath("revealInFinder")
nuke.pluginAddPath("edgeNode")
nuke.pluginAddPath("autoBackup")
nuke.pluginAddPath("exrSplit") | nuke.pluginAddPath('renderFinished')
nuke.pluginAddPath('revealInFinder')
nuke.pluginAddPath('edgeNode')
nuke.pluginAddPath('autoBackup')
nuke.pluginAddPath('exrSplit') |
mot = {
'A': '5A',
'L': '6A',
'ST': '7A'
}
pot = ['DS', 'DC', 'START', 'USING']
print(mot)
print(pot)
inputList = []
with open("ainput.txt", "r") as f:
for ip in f:
inputList.append(ip.strip("\n").strip("\r"))
print(inputList)
symtab = open("SymbolTable.txt", "w")
a = (inputList.pop(0)).split("... | mot = {'A': '5A', 'L': '6A', 'ST': '7A'}
pot = ['DS', 'DC', 'START', 'USING']
print(mot)
print(pot)
input_list = []
with open('ainput.txt', 'r') as f:
for ip in f:
inputList.append(ip.strip('\n').strip('\r'))
print(inputList)
symtab = open('SymbolTable.txt', 'w')
a = inputList.pop(0).split(' ')
symtab.write... |
# https://www.codewars.com/kata/56dec885c54a926dcd001095
opposite = lambda n: -n
| opposite = lambda n: -n |
class py_solution:
def int_to_Roman(self, num):
val = [
1000, 900, 500, 400,
100, 90, 50, 40,
10, 9, 5, 4,
1
]
syb = [
"M", "CM", "D", "CD",
"C", "XC", "L", "XL",
"X", "IX", "V", "IV",
... | class Py_Solution:
def int_to__roman(self, num):
val = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
syb = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
roman_num = ''
i = 0
while num > 0:
for _ in range(num // val[i]):
... |
# Copyright 2016 Google Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
{
'includes': [
'../common.gypi',
],
'targets': [
{
'target_name': 'hls_builder',
... | {'includes': ['../common.gypi'], 'targets': [{'target_name': 'hls_builder', 'type': '<(component)', 'sources': ['base/hls_notifier.h', 'base/master_playlist.cc', 'base/master_playlist.h', 'base/media_playlist.cc', 'base/media_playlist.h', 'base/simple_hls_notifier.cc', 'base/simple_hls_notifier.h'], 'dependencies': ['.... |
#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2016, Ilya Etingof <ilya@glas.net>
# License: http://pysnmp.sf.net/license.html
#
# PySNMP MIB module SNMP-COMMUNITY-MIB (http://pysnmp.sf.net)
# ASN.1 source file:///usr/share/snmp/mibs/SNMP-COMMUNITY-MIB.txt
# Produced by pysmi-0.0.5 at Sat Sep 19 16:28... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint) ... |
def apply(df, model, rel_ev, rel_act, parameters=None):
if parameters is None:
parameters = {}
ret = {}
for persp in rel_ev:
df = rel_ev[persp]
df = df[df["event_activity_merge"].isin(rel_act[persp])]
df = df.groupby([persp, persp+"_2", "event_activity_merge"]).first()
... | def apply(df, model, rel_ev, rel_act, parameters=None):
if parameters is None:
parameters = {}
ret = {}
for persp in rel_ev:
df = rel_ev[persp]
df = df[df['event_activity_merge'].isin(rel_act[persp])]
df = df.groupby([persp, persp + '_2', 'event_activity_merge']).first()
... |
class ListReader():
def __init__(self, aList: list):
self.list = aList
def __enter__(self) -> list:
print("will print a list:")
return self.list
def __exit__(self, expType, expVal, expTrace):
print("end")
aList = [1, 2, 3, 4, 5, 6]
with ListReader(aList) as lr:
print(... | class Listreader:
def __init__(self, aList: list):
self.list = aList
def __enter__(self) -> list:
print('will print a list:')
return self.list
def __exit__(self, expType, expVal, expTrace):
print('end')
a_list = [1, 2, 3, 4, 5, 6]
with list_reader(aList) as lr:
print(l... |
class RateLimit:
def __init__(self):
self.rateLimitType = ""
self.interval = ""
self.intervalNum = 0
self.limit = 0
class ExchangeFilter:
def __init__(self):
self.filterType = ""
self.maxOrders = 0
class Symbol:
def __init__(self):
self.symbol =... | class Ratelimit:
def __init__(self):
self.rateLimitType = ''
self.interval = ''
self.intervalNum = 0
self.limit = 0
class Exchangefilter:
def __init__(self):
self.filterType = ''
self.maxOrders = 0
class Symbol:
def __init__(self):
self.symbol = '... |
def remove_middle(a, b, c):
cross = (a[0] - b[0]) * (c[1] - b[1]) - (a[1] - b[1]) * (c[0] - b[0])
dot = (a[0] - b[0]) * (c[0] - b[0]) + (a[1] - b[1]) * (c[1] - b[1])
return cross < 0 or cross == 0 and dot <= 0
def convex_hull(points):
spoints = sorted(points)
hull = []
for p in spoint... | def remove_middle(a, b, c):
cross = (a[0] - b[0]) * (c[1] - b[1]) - (a[1] - b[1]) * (c[0] - b[0])
dot = (a[0] - b[0]) * (c[0] - b[0]) + (a[1] - b[1]) * (c[1] - b[1])
return cross < 0 or (cross == 0 and dot <= 0)
def convex_hull(points):
spoints = sorted(points)
hull = []
for p in spoints + spoi... |
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'api',
'type': 'static_library',
'sources': [
'<@(schema_files)',
],
# TODO(j... | {'targets': [{'target_name': 'api', 'type': 'static_library', 'sources': ['<@(schema_files)'], 'msvs_disabled_warnings': [4267], 'includes': ['../../../../build/json_schema_bundle_compile.gypi', '../../../../build/json_schema_compile.gypi'], 'variables': {'chromium_code': 1, 'non_compiled_schema_files': ['adview.json',... |
#!/usr/bin/env python
# encoding: utf-8
class Solution:
def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
# adjacency matrix of the directed graph
self.graph = collections.defaultdict(list)
for to_node, from_node in prerequisites:
self.graph[from_node... | class Solution:
def can_finish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
self.graph = collections.defaultdict(list)
for (to_node, from_node) in prerequisites:
self.graph[from_node].append(to_node)
self.state = [0] * numCourses
for n in range(numCour... |
def file_from_tar(context, tar, member):
return tar.extractfile(member).read()
def static_file(context, path):
with open(path, 'rb') as fobj:
return fobj.read()
| def file_from_tar(context, tar, member):
return tar.extractfile(member).read()
def static_file(context, path):
with open(path, 'rb') as fobj:
return fobj.read() |
#Find the BITWISE NOT of the given number
a = int(input())
b = ~a
print(b)
| a = int(input())
b = ~a
print(b) |
#!/usr/bin/env python3
def merge_chars(string, block):
for i in range(0, len(string), block):
s = ''
for c in string[i:i+block]:
if c not in s:
s += c
print(s)
if __name__ == '__main__':
merge_chars(input(), int(input()))
| def merge_chars(string, block):
for i in range(0, len(string), block):
s = ''
for c in string[i:i + block]:
if c not in s:
s += c
print(s)
if __name__ == '__main__':
merge_chars(input(), int(input())) |
def solve():
direction = 0 # north = 0, east = 1, south = 2, west = 3
x = 0
y = 0
moves = [x for x in input().split(',')]
visited = []
for elem in moves:
elem = elem.strip()
turn = elem[0]
length = int(elem[1:])
if (turn == "R"):
direction = abs((direction + 1) % 4)
elif (turn == "L"):
direction ... | def solve():
direction = 0
x = 0
y = 0
moves = [x for x in input().split(',')]
visited = []
for elem in moves:
elem = elem.strip()
turn = elem[0]
length = int(elem[1:])
if turn == 'R':
direction = abs((direction + 1) % 4)
elif turn == 'L':
... |
live = 'yes'
def love():
live
| live = 'yes'
def love():
live |
# exercise-02 Length of Phrase
# Write the code that:
# 1. Prompts the user to enter a phrase:
# Please enter a word or phrase:
# 2. Print the following message:
# - What you entered is xx characters long
# 3. Return to step 1, unless the word 'quit' was entered.
while True:
input_word_phrase = input('P... | while True:
input_word_phrase = input('Please enter a word or phrase ')
if input_word_phrase == 'quit':
break
print(f'What you entered is {len(input_word_phrase)} characters long') |
KEY_PRESSES = {
'1ADGJMPTW* #': 1,
'BEHKNQUX0': 2,
'CFILORVY': 3,
'23456S8Z': 4,
'79': 5
}
def presses(phrase):
total = 0
for a in phrase.upper():
for k, v in KEY_PRESSES.iteritems():
if a in k:
total += v
break
return total
| key_presses = {'1ADGJMPTW* #': 1, 'BEHKNQUX0': 2, 'CFILORVY': 3, '23456S8Z': 4, '79': 5}
def presses(phrase):
total = 0
for a in phrase.upper():
for (k, v) in KEY_PRESSES.iteritems():
if a in k:
total += v
break
return total |
# 04 sKeyword Arguments
# def increment(number, by):
# return number + by
# result = increment(2, 1)
# print(result)
# It also works like this
def increment(number, by):
return number + by
print(increment(2, by=1))
# by=1 Its the keyword arguent, if a function as multiple arguments, the code can be more... | def increment(number, by):
return number + by
print(increment(2, by=1)) |
with open("day16.txt") as f:
data = f.readline()
data = data.split(",")
programs = [chr(i) for i in range(97, 113)]
for instruction in data:
type_ = instruction[0]
if type_ == "s":
length = int(instruction[1:])
programs = programs[-length:] + programs[:len(programs)-length]
if type_ == ... | with open('day16.txt') as f:
data = f.readline()
data = data.split(',')
programs = [chr(i) for i in range(97, 113)]
for instruction in data:
type_ = instruction[0]
if type_ == 's':
length = int(instruction[1:])
programs = programs[-length:] + programs[:len(programs) - length]
if type_ ==... |
#
# Simple class for dealing with Parameter.
# Parameter has a name, a value, an error and some bounds
# Names are also latex names.
class Parameter:
def __init__(self, name, value, err=0, bounds=None, Ltxname=None):
self.name = name
if Ltxname:
self.Ltxname = Ltxname
else:
... | class Parameter:
def __init__(self, name, value, err=0, bounds=None, Ltxname=None):
self.name = name
if Ltxname:
self.Ltxname = Ltxname
else:
self.Ltxname = name
self.value = value
self.error = err
if bounds == None:
self.bounds = ... |
def enter_text(text):
print(text)
input("Press Enter key.")
return(0)
def nostop(text):
enter_text(text)
return(0)
def message(text):
enter_text(text)
exit(0)
def error(text):
enter_text(text)
exit(9001)
def fatal(text):
error(text)
#return true if yes, false if no
def yes_n... | def enter_text(text):
print(text)
input('Press Enter key.')
return 0
def nostop(text):
enter_text(text)
return 0
def message(text):
enter_text(text)
exit(0)
def error(text):
enter_text(text)
exit(9001)
def fatal(text):
error(text)
def yes_no(prompt):
opt = 'x'
while ... |
lista = [1, 13, 15, 7]
lista_animal = ['cachorro', 'gato', 'elefante', 'arara']
#Ordenando a lista
lista.sort()
lista_animal.sort()
print(lista)
print(lista_animal)
#Revertendo a ordem da lista
lista_animal.reverse()
print(lista_animal) | lista = [1, 13, 15, 7]
lista_animal = ['cachorro', 'gato', 'elefante', 'arara']
lista.sort()
lista_animal.sort()
print(lista)
print(lista_animal)
lista_animal.reverse()
print(lista_animal) |
class xcconfig_item_base(object):
def __init__(self, line):
line_end = line.find('//');
if line_end > 0:
line = line[:line_end];
self.contents = line;
self.type = 'EMPTY';
def __repr__(self):
if self.isValid():
return '(%s : %s : %s)' % (... | class Xcconfig_Item_Base(object):
def __init__(self, line):
line_end = line.find('//')
if line_end > 0:
line = line[:line_end]
self.contents = line
self.type = 'EMPTY'
def __repr__(self):
if self.isValid():
return '(%s : %s : %s)' % (type(self), ... |
'''
Take name and two grades from many students
ONE LIST -> Nested list
Show a final grade from each student with the average grade
first show the final grade
Then ask if want to get the individual grade
'''
main_grade = list()
while True:
name = str(input('Name: '))
grade1 = float(input('First grade: '))
g... | """
Take name and two grades from many students
ONE LIST -> Nested list
Show a final grade from each student with the average grade
first show the final grade
Then ask if want to get the individual grade
"""
main_grade = list()
while True:
name = str(input('Name: '))
grade1 = float(input('First grade: '))
g... |
class Bag:
def __init__(self, bag_name):
self.name = bag_name
self.children_names = [bag_name]
self.children_counts = [1]
self.contained_bags = 0
def is_empty(self):
return len(self.children_names) == 0
def contains(self, bag_name):
return b... | class Bag:
def __init__(self, bag_name):
self.name = bag_name
self.children_names = [bag_name]
self.children_counts = [1]
self.contained_bags = 0
def is_empty(self):
return len(self.children_names) == 0
def contains(self, bag_name):
return bag_name in self.... |
# Networking settings
HOST = 'localhost'
PORT = 8000
TIMEOUT = 500
KEEP_ALIVE = False
# Validator settings
VALIDATOR_HOST = 'localhost'
VALIDATOR_PORT = 4004
# Database settings
DB_HOST = 'localhost'
DB_PORT = 28015
DB_NAME = 'marketplace'
# Runtime settings
DEBUG = True
# Secret keys
# WARNING! These defaults are ... | host = 'localhost'
port = 8000
timeout = 500
keep_alive = False
validator_host = 'localhost'
validator_port = 4004
db_host = 'localhost'
db_port = 28015
db_name = 'marketplace'
debug = True
secret_key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
aes_key = 'ffffffffffffffffffffffffffffffff'
batcher_private_key = '1111111111... |
ROLES = ["administrator", "developer", "newswriter", "repositories"]
# Scenario: Try to add a role that 'admin' already has.
try:
output = instance.execute(
["sudo", "criticctl", "addrole",
"--name", "admin",
"--role", "administrator"])
expected_output = "admin: user already has role ... | roles = ['administrator', 'developer', 'newswriter', 'repositories']
try:
output = instance.execute(['sudo', 'criticctl', 'addrole', '--name', 'admin', '--role', 'administrator'])
expected_output = "admin: user already has role 'administrator'"
if expected_output not in output.splitlines():
logger.e... |
'''
Created on Aug 15, 2009
@author: santiago
'''
| """
Created on Aug 15, 2009
@author: santiago
""" |
class KeyValueStorage:
def __init__(self, name, env, wtx, dupsort=False):
self.name = name.encode("utf-8")
self.env = env
self.main_db = self.env.open_db(self.name + b'_main_db', txn=wtx, dupsort=dupsort)
def put(self, key, value, wtx, dupdata=False):
return wtx.put( bytes(key), bytes(value), db=... | class Keyvaluestorage:
def __init__(self, name, env, wtx, dupsort=False):
self.name = name.encode('utf-8')
self.env = env
self.main_db = self.env.open_db(self.name + b'_main_db', txn=wtx, dupsort=dupsort)
def put(self, key, value, wtx, dupdata=False):
return wtx.put(bytes(key),... |
a = input()
print(a)
name = input("Enter your name: ")
print(f'Welcome {name}!')
age = input("Enter your age:")
print(age)
print("Hello " + input("Enter your name ")+"!")
None
weapons = None
print(weapons)
name = input("Enter your name")
# print(name)
print(f'Welcome {name} !')
print("... | a = input()
print(a)
name = input('Enter your name: ')
print(f'Welcome {name}!')
age = input('Enter your age:')
print(age)
print('Hello ' + input('Enter your name ') + '!')
None
weapons = None
print(weapons)
name = input('Enter your name')
print(f'Welcome {name} !')
print('Hello ' + input('Enter your name ') + '!')
Non... |
def scala_proto_register_toolchains():
native.register_toolchains("@io_bazel_rules_scala//scala_proto:default_toolchain")
def scala_proto_register_enable_all_options_toolchain():
native.register_toolchains("@io_bazel_rules_scala//scala_proto:enable_all_options_toolchain")
| def scala_proto_register_toolchains():
native.register_toolchains('@io_bazel_rules_scala//scala_proto:default_toolchain')
def scala_proto_register_enable_all_options_toolchain():
native.register_toolchains('@io_bazel_rules_scala//scala_proto:enable_all_options_toolchain') |
class Generator(nn.Module):
def __init__(self):
super().__init__()
self.noise_branch = nn.Sequential(
nn.ConvTranspose2d(noise_dim, d * 8, kernel_size=4, stride=1, padding=0, bias=False),
norm_layer(d * 8),
nn.ReLU(True)
)
self.label_branch = nn.S... | class Generator(nn.Module):
def __init__(self):
super().__init__()
self.noise_branch = nn.Sequential(nn.ConvTranspose2d(noise_dim, d * 8, kernel_size=4, stride=1, padding=0, bias=False), norm_layer(d * 8), nn.ReLU(True))
self.label_branch = nn.Sequential(nn.ConvTranspose2d(10, d * 8, 4, 1, ... |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | query_format = '?q={}'
dashboards_api_url = 'api/v1/dashboard/'
dashboards_api_url_with_query_format = DASHBOARDS_API_URL + QUERY_FORMAT
dashboard_api_url_format = DASHBOARDS_API_URL + '{}'
export_dashboards_api_url = DASHBOARDS_API_URL + 'export/'
export_dashboards_api_url_with_query_format = EXPORT_DASHBOARDS_API_URL... |
t = int(input())
answer = []
for a in range(t):
val = int(input())
if(val == 2):
answer.append(2)
elif(val%2 == 1):
answer.append(1)
else:
answer.append(0)
for b in answer:
print(str(b))
| t = int(input())
answer = []
for a in range(t):
val = int(input())
if val == 2:
answer.append(2)
elif val % 2 == 1:
answer.append(1)
else:
answer.append(0)
for b in answer:
print(str(b)) |
# Module version
py_version_info = (1, 0, 8)
js_version_info = (0, 1, 13)
# Module version accessible using vitessce.__version__
__version__ = '%s.%s.%s' % (
py_version_info[0], py_version_info[1], py_version_info[2])
| py_version_info = (1, 0, 8)
js_version_info = (0, 1, 13)
__version__ = '%s.%s.%s' % (py_version_info[0], py_version_info[1], py_version_info[2]) |
#isEqual(cad1: "abcd", cad2= "abcd") -> True
def isEqual(cad1,cad2):
diccCad = {}
for key in cad1:
if key in diccCad:
diccCad[key] += 1
else:
diccCad[key] = 1
for key in cad2:
if key in diccCad:
diccCad[key] -= 1
else:
return False
for (key) in diccCad:
if diccCad[key] !... | def is_equal(cad1, cad2):
dicc_cad = {}
for key in cad1:
if key in diccCad:
diccCad[key] += 1
else:
diccCad[key] = 1
for key in cad2:
if key in diccCad:
diccCad[key] -= 1
else:
return False
for key in diccCad:
if dic... |
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
}
SECRET_KEY = 1
INSTALLED_APPS = [
'django_counter_cache_field',
'tests',
]
DEBUG = False
SITE_ID = 1
| databases = {'default': {'ENGINE': 'django.db.backends.sqlite3'}}
secret_key = 1
installed_apps = ['django_counter_cache_field', 'tests']
debug = False
site_id = 1 |
description = 'setup for the status monitor'
group = 'special'
_reactorBlock = Block('Reactor', [
BlockRow(Field(name='Reactor power', dev='ReactorPower', width=6),
)
],
)
_shutterBlock = Block('Shutter', [
BlockRow(Field(name='Prim. shutter', dev='prim_shutt'),
Field(name='Sec.... | description = 'setup for the status monitor'
group = 'special'
_reactor_block = block('Reactor', [block_row(field(name='Reactor power', dev='ReactorPower', width=6))])
_shutter_block = block('Shutter', [block_row(field(name='Prim. shutter', dev='prim_shutt'), field(name='Sec. sutter', dev='sec_shutt'))])
_hover_block =... |
size = int(input())
matrix = []
for c in range(size):
col = [int(n) for n in input().split(' ')]
matrix.append(col)
primary_diagonal_sum = 0
for i in range(size):
primary_diagonal_sum += matrix[i][i]
print(primary_diagonal_sum)
| size = int(input())
matrix = []
for c in range(size):
col = [int(n) for n in input().split(' ')]
matrix.append(col)
primary_diagonal_sum = 0
for i in range(size):
primary_diagonal_sum += matrix[i][i]
print(primary_diagonal_sum) |
class DetectBaseNotImplementedError(NotImplementedError):
pass
class DetectBase:
def _notimplestr(self, param):
return (
"resource detect must have "
f"{param}\" property."
)
@property
def resource(self):
raise DetectBaseNotImplementedError(
... | class Detectbasenotimplementederror(NotImplementedError):
pass
class Detectbase:
def _notimplestr(self, param):
return f'resource detect must have {param}" property.'
@property
def resource(self):
raise detect_base_not_implemented_error(self._notimplestr('resource'))
@property
... |
#
# PySNMP MIB module CISCO-LWAPP-DOT11-CCX-CLIENT-DIAG-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-DOT11-CCX-CLIENT-DIAG-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:05:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
#... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint) ... |
userInput = input("Enter your Sentence: ").upper()
translated = ""
i = len(userInput)-1
while i >= 0:
translated += userInput[i]
i-=1
print(translated) | user_input = input('Enter your Sentence: ').upper()
translated = ''
i = len(userInput) - 1
while i >= 0:
translated += userInput[i]
i -= 1
print(translated) |
def part1(lines):
return 0
def part2(lines):
return 0
if __name__ == '__main__':
with open('input.txt', 'r') as f:
lines = f.read().splitlines()
print(part1(lines))
print(part2(lines))
| def part1(lines):
return 0
def part2(lines):
return 0
if __name__ == '__main__':
with open('input.txt', 'r') as f:
lines = f.read().splitlines()
print(part1(lines))
print(part2(lines)) |
class ValidatorLR0001:
value = None
def __get__(self, obj, objtype=None):
return self.value
def __set__(self, obj, value):
if value is not None:
if not isinstance(value, LR0001):
raise TypeError(f'Expected {value!r} to be LR0100 object')
self.value = va... | class Validatorlr0001:
value = None
def __get__(self, obj, objtype=None):
return self.value
def __set__(self, obj, value):
if value is not None:
if not isinstance(value, LR0001):
raise type_error(f'Expected {value!r} to be LR0100 object')
self.value = va... |
class Singleton:
_instance = None
def __new__(cls):
if not isinstance(cls._instance, cls):
cls._instance = super(Singleton, cls).__new__(cls)
return cls._instance
| class Singleton:
_instance = None
def __new__(cls):
if not isinstance(cls._instance, cls):
cls._instance = super(Singleton, cls).__new__(cls)
return cls._instance |
class Solution:
def numJewelsInStones(self, J: str, S: str) -> int:
d = {}
for letter in J:
d[letter] = 1
count = 0
for letter in S:
if letter in d:
count += 1
return count | class Solution:
def num_jewels_in_stones(self, J: str, S: str) -> int:
d = {}
for letter in J:
d[letter] = 1
count = 0
for letter in S:
if letter in d:
count += 1
return count |
{
'conditions': [
['OS=="win"', {
'variables': {
'MAGICK_ROOT%': 'C:\\Program Files\\ImageMagick-6.9.12-Q16\\',
# download the dll binary and check off for libraries and includes
'OSX_VER%': "0",
}
}],
['OS=="mac"', {
'variables': {
# matches 10.9.X , 10.1... | {'conditions': [['OS=="win"', {'variables': {'MAGICK_ROOT%': 'C:\\Program Files\\ImageMagick-6.9.12-Q16\\', 'OSX_VER%': '0'}}], ['OS=="mac"', {'variables': {'OSX_VER%': "<!(sw_vers | grep 'ProductVersion:' | grep -o '10.[0-9]*')"}}, {'variables': {'OSX_VER%': '0'}}]], 'targets': [{'target_name': 'imagemagick', 'sources... |
def main() -> None:
K = 10**4
def normalize(number: str) -> int:
parts = number.split(".")
if len(parts) == 1:
return int(parts[0]) * K
a, b = parts
return int(a) * K + int(b) * 10 ** (4 - len(b))
cx, cy, r = map(normalize, input().split())
def ... | def main() -> None:
k = 10 ** 4
def normalize(number: str) -> int:
parts = number.split('.')
if len(parts) == 1:
return int(parts[0]) * K
(a, b) = parts
return int(a) * K + int(b) * 10 ** (4 - len(b))
(cx, cy, r) = map(normalize, input().split())
def count_u... |
#
# PySNMP MIB module NBS-SFF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-SFF-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:17:37 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, 0... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) ... |
farmer = {
'kb': '''
Farmer(Mac)
Rabbit(Pete)
Mother(MrsMac, Mac)
Mother(MrsRabbit, Pete)
(Rabbit(r) & Farmer(f)) ==> Hates(f, r)
(Mother(m, c)) ==> Loves(m, c)
(Mother(m, r) & Rabbit(r)) ==> Rabbit(m)
(Farmer(f)) ==> Human(f)
(Mother(m, h) & Human(h)) ==> Human(m)
''',
# Note that this order of conjuncts
# would r... | farmer = {'kb': '\nFarmer(Mac)\nRabbit(Pete)\nMother(MrsMac, Mac)\nMother(MrsRabbit, Pete)\n(Rabbit(r) & Farmer(f)) ==> Hates(f, r)\n(Mother(m, c)) ==> Loves(m, c)\n(Mother(m, r) & Rabbit(r)) ==> Rabbit(m)\n(Farmer(f)) ==> Human(f)\n(Mother(m, h) & Human(h)) ==> Human(m)\n', 'queries': '\nHuman(x)\nHates(x, y)\n'}
weap... |
# Copyright 2010 Curtis McEnroe <programble@gmail.com>
# Licensed under the GNU GPLv3
class Scope:
def __init__(self, parent=None):
self.bindings = {}
self.parent = parent
def __getitem__(self, key):
# If bound in this scope, return that
if self.bindings.has_key(key):
... | class Scope:
def __init__(self, parent=None):
self.bindings = {}
self.parent = parent
def __getitem__(self, key):
if self.bindings.has_key(key):
return self.bindings[key]
elif self.parent:
return self.parent[key]
else:
raise name_erro... |
def soma(x: float, y: float) -> float:
return x + y
def main() -> None:
print(soma(10, 40))
print(soma(30, 30))
if __name__== '__main__':
main() | def soma(x: float, y: float) -> float:
return x + y
def main() -> None:
print(soma(10, 40))
print(soma(30, 30))
if __name__ == '__main__':
main() |
rol_enviar_notificaiones_servidor = "Server"
time_resend_mail = 300
minimo_nivel_bateria = 30 #3.0V | rol_enviar_notificaiones_servidor = 'Server'
time_resend_mail = 300
minimo_nivel_bateria = 30 |
STDIN_FILENO = 0
STDOUT_FILENO = 1
STDERR_FILENO = 2
DEFAULT_PORT = 0xdb9
DEFAULT_IP = '127.0.0.1'
DEFAULT_CONNECT_TIMEOUT = 10.
| stdin_fileno = 0
stdout_fileno = 1
stderr_fileno = 2
default_port = 3513
default_ip = '127.0.0.1'
default_connect_timeout = 10.0 |
s=input().split()
n1=str(s[0].replace('7','0'))
op=s[1]
n2=str(s[2].replace('7','0'))
res=str(int(n1)+int(n2)) if op=='+' else str(int(n1)*int(n2))
res=int(res.replace('7','0'))
print(res)
| s = input().split()
n1 = str(s[0].replace('7', '0'))
op = s[1]
n2 = str(s[2].replace('7', '0'))
res = str(int(n1) + int(n2)) if op == '+' else str(int(n1) * int(n2))
res = int(res.replace('7', '0'))
print(res) |
class MyMsp430Constants:
ACT_PXY_ADC = 0x40
ACT_PXY_DACDMA = 0x41
ACT_PXY_NMI = 0x42
ACT_PXY_PORT1 = 0x43
ACT_PXY_PORT2 = 0x44
ACT_PXY_TIMERA0 = 0x45
ACT_PXY_TIMERA1 = 0x46
ACT_PXY_TIMERB0 = 0x47
ACT_PXY_TIMERB1 = 0x48
ACT_PXY_UART0RX = 0x49
ACT_PXY_UART0TX = 0x4... | class Mymsp430Constants:
act_pxy_adc = 64
act_pxy_dacdma = 65
act_pxy_nmi = 66
act_pxy_port1 = 67
act_pxy_port2 = 68
act_pxy_timera0 = 69
act_pxy_timera1 = 70
act_pxy_timerb0 = 71
act_pxy_timerb1 = 72
act_pxy_uart0_rx = 73
act_pxy_uart0_tx = 74
act_pxy_uart1_rx = 75
a... |
# A Python program to demonstrate both packing and
# unpacking.
# A sample python function that takes three arguments
# and prints them
def fun1(a, b, c):
print(a, b, c)
# Another sample function.
# This is an example of PACKING. All arguments passed
# to fun2 are packed into tuple *args.
def fun2(*args):
... | def fun1(a, b, c):
print(a, b, c)
def fun2(*args):
args = list(args)
args[0] = 'Wikitechy'
args[1] = 'awesome'
fun1(*args)
fun2('Hello', 'beautiful', 'world!') |
# Coding Challenge 2
### Chelsea Lizardo
### NRS 528
#
#
#3 Ask the user for an input of their current age, and tell them how many years until they reach retirement (65 years old).
name = input("What is your name: ")
age = int(input("How old are you: "))
year = str((2021 - age)+65)
#print name input + " will b... | name = input('What is your name: ')
age = int(input('How old are you: '))
year = str(2021 - age + 65)
print(name + ' will be 65 years old in the year ' + year) |
__name__ = "bootstrap-scoped"
__version__ = "0.1.0"
__url__ = "https://github.com/achillesrasquinha/bootstrap-scoped"
__author__ = "Achilles Rasquinha"
__email__ = "achillesrasquinha@gmail.com"
__description__ = "Scope your Bootstrap assets in a jiffy!"
__license__ = "MIT"
__keywords__... | __name__ = 'bootstrap-scoped'
__version__ = '0.1.0'
__url__ = 'https://github.com/achillesrasquinha/bootstrap-scoped'
__author__ = 'Achilles Rasquinha'
__email__ = 'achillesrasquinha@gmail.com'
__description__ = 'Scope your Bootstrap assets in a jiffy!'
__license__ = 'MIT'
__keywords__ = ['bootstrap', 'scoped', 'css', ... |
def process_image(img):
# 1) Define source and destination points for perspective transform
dst_size = 5
source = np.float32([[200, 95],[300, 140],[10, 140],[118, 95]])
destination = np.float32([[165, 135],[165, 145],[155, 145],[155, 135]])
# 2) Apply perspective transform
warped = perspect_tran... | def process_image(img):
dst_size = 5
source = np.float32([[200, 95], [300, 140], [10, 140], [118, 95]])
destination = np.float32([[165, 135], [165, 145], [155, 145], [155, 135]])
warped = perspect_transform(img, source, destination)
rgb_nav_min = (170, 170, 170)
rgb_nav_max = (255, 255, 255)
... |
# -*- encoding: utf-8 -*-
def spam():
pass
def grok():
pass
blah = 42
__all__ = {'spam', 'grok'} | def spam():
pass
def grok():
pass
blah = 42
__all__ = {'spam', 'grok'} |
description = 'NOK5a using Beckhoff controllers'
group = 'lowlevel'
instrument_values = configdata('instrument.values')
showcase_values = configdata('cf_showcase.showcase_values')
optic_values = configdata('cf_optic.optic_values')
tango_base = instrument_values['tango_base']
code_base = instrument_values['code_base... | description = 'NOK5a using Beckhoff controllers'
group = 'lowlevel'
instrument_values = configdata('instrument.values')
showcase_values = configdata('cf_showcase.showcase_values')
optic_values = configdata('cf_optic.optic_values')
tango_base = instrument_values['tango_base']
code_base = instrument_values['code_base']
i... |
DATA_DIR = '/floyd/input'
PTB_DIR = '_ptb'
BROWN_DIR = '_brown'
GUTENBERG_DIR = '_gutenberg'
BIBLE_DIR = '_bible'
WIKITEXT2_DIR = '_wikitext2'
WIKITEXT103_DIR = '_wikitext103'
TRAIN = 'train'
TEST = 'test'
VAL = 'val'
MODEL_DIR = 'bin'
FLOYD = True
| data_dir = '/floyd/input'
ptb_dir = '_ptb'
brown_dir = '_brown'
gutenberg_dir = '_gutenberg'
bible_dir = '_bible'
wikitext2_dir = '_wikitext2'
wikitext103_dir = '_wikitext103'
train = 'train'
test = 'test'
val = 'val'
model_dir = 'bin'
floyd = True |
#!/usr/bin/env python
for n in range(2, 10):
print("== %d ==" % (n))
for x in range(2, n):
print("x = ", x)
if n % x == 0:
print(n, 'equals', x, '*', n//x)
break
else:
# loop fell through without finding a factor
print(n, 'is a prime number') | for n in range(2, 10):
print('== %d ==' % n)
for x in range(2, n):
print('x = ', x)
if n % x == 0:
print(n, 'equals', x, '*', n // x)
break
else:
print(n, 'is a prime number') |
class TvshowsData:
def __init__(self):
self.NetflixData=[]
self.HBOData = []
self.DisneyData = []
def add_NetflixData(self,data):
self.NetflixData.append(data)
def get_NetflixData(self):
return self.NetflixData
def add_HBOData(self,data):
self.H... | class Tvshowsdata:
def __init__(self):
self.NetflixData = []
self.HBOData = []
self.DisneyData = []
def add__netflix_data(self, data):
self.NetflixData.append(data)
def get__netflix_data(self):
return self.NetflixData
def add_hbo_data(self, data):
self... |
#!/usr/bin/env python
admin_server_listen_address = os.environ['ADMIN_SERVER_LISTEN_ADDRESS']
admin_server_listen_port = os.environ['ADMIN_SERVER_LISTEN_PORT']
admin_username = os.environ['ADMIN_USERNAME']
admin_password = os.environ['ADMIN_PASSWORD']
managed_server_name = os.environ['MANAGED_SERVER_NAME']
########... | admin_server_listen_address = os.environ['ADMIN_SERVER_LISTEN_ADDRESS']
admin_server_listen_port = os.environ['ADMIN_SERVER_LISTEN_PORT']
admin_username = os.environ['ADMIN_USERNAME']
admin_password = os.environ['ADMIN_PASSWORD']
managed_server_name = os.environ['MANAGED_SERVER_NAME']
def set_server_tunning_config(_se... |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( arr , n ) :
mpis = [ 0 ] * ( n )
for i in range ( n ) :
mpis [ i ] = arr [ i ]
for i in range (... | def f_gold(arr, n):
mpis = [0] * n
for i in range(n):
mpis[i] = arr[i]
for i in range(1, n):
for j in range(i):
if arr[i] > arr[j] and mpis[i] < mpis[j] * arr[i]:
mpis[i] = mpis[j] * arr[i]
return max(mpis)
if __name__ == '__main__':
param = [([1, 1, 4, 7,... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
CONTRASTA = [0.84, 0.37, 0, 1] # orange
CONTRASTB = [0.53, 0.53, 1, 1] # lightblue
CONTRASTC = [0.84, 1, 0, 1]
CONTRASTA = [0, 0.7, 0.8, 1]
CONTRASTB = [1, 1, 1, 0.5]
def show_detail(render, edges_coordinates, fn=None):
render.clear_canvas()
render_circle = render... | contrasta = [0.84, 0.37, 0, 1]
contrastb = [0.53, 0.53, 1, 1]
contrastc = [0.84, 1, 0, 1]
contrasta = [0, 0.7, 0.8, 1]
contrastb = [1, 1, 1, 0.5]
def show_detail(render, edges_coordinates, fn=None):
render.clear_canvas()
render_circle = render.circle
small = render.pix * 3.0
large = render.pix * 10.0
... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def mergeKLists(self, lists: 'List[ListNode]') -> 'ListNode':
res = []
for l in lists:
while l:
res.append(l.val)
... | class Solution:
def merge_k_lists(self, lists: 'List[ListNode]') -> 'ListNode':
res = []
for l in lists:
while l:
res.append(l.val)
l = l.next
return sorted(res) |
def find_sum(arr):
'''
using divide and conquer technique to recursively find the sum of a list of numbers
'''
result = 0
if len(arr) == 1 :
result = arr[0]
else:
result = arr.pop() + find_sum(arr)
return result
def count_list(arr):
'''
rec... | def find_sum(arr):
"""
using divide and conquer technique to recursively find the sum of a list of numbers
"""
result = 0
if len(arr) == 1:
result = arr[0]
else:
result = arr.pop() + find_sum(arr)
return result
def count_list(arr):
"""
recursive counter
... |
environment = 'test'
preservica_base_url = 'https://test_preservica_url'
input_stream_name = 'shared_services_output_test'
invalid_stream_name = 'message_invalid_test'
error_stream_name = 'message_error_test'
adaptor_aws_region = 'eu-west-2'
organisation_buckets = {
'44': 's3://some_bucket',
}
| environment = 'test'
preservica_base_url = 'https://test_preservica_url'
input_stream_name = 'shared_services_output_test'
invalid_stream_name = 'message_invalid_test'
error_stream_name = 'message_error_test'
adaptor_aws_region = 'eu-west-2'
organisation_buckets = {'44': 's3://some_bucket'} |
def soma_lista(x):
soma = 0
for c in x:
soma += c
return soma
print(soma_lista([1, 2, 3, 4, 5]))
| def soma_lista(x):
soma = 0
for c in x:
soma += c
return soma
print(soma_lista([1, 2, 3, 4, 5])) |
with open("input.txt") as f:
dat = f.readlines()
dat = [line.strip() for line in dat]
maxid = 0
for ele in dat:
hr = 127
lr = 0
hc = 7
lc = 0
chrs = [ c for c in ele]
chrsR = chrs[0:7]
chrsC = chrs[7:]
for c in chrsR:
if(c == 'F'):
hr = hr - ( hr - lr ) // 2 - 1
else:
lr =... | with open('input.txt') as f:
dat = f.readlines()
dat = [line.strip() for line in dat]
maxid = 0
for ele in dat:
hr = 127
lr = 0
hc = 7
lc = 0
chrs = [c for c in ele]
chrs_r = chrs[0:7]
chrs_c = chrs[7:]
for c in chrsR:
if c == 'F':
hr = hr - (hr - lr) // 2 - 1... |
#
# PySNMP MIB module NSCPS32-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NSCPS32-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:15:28 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, 0... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ... |
def popen(command, mode='r', bufsize=-1):
pass
class _wrap_close:
def close(self):
pass | def popen(command, mode='r', bufsize=-1):
pass
class _Wrap_Close:
def close(self):
pass |
[ ## this file was manually modified by jt
{
'functor' : {
'description' : ['Returns the exponent bits of the floating input as an integer value.',
'the other bits (sign and mantissa) are just masked.',
'\par',
'The sign \\\... | [{'functor': {'description': ['Returns the exponent bits of the floating input as an integer value.', 'the other bits (sign and mantissa) are just masked.', '\\par', 'The sign \\\\f$ \\\\pm \\\\f$, exponent e and mantissa m of a floating point entry a are related by', '\\\\f$a = \\\\pm m\\\\times 2^e\\\\f$, with m betw... |
a,b,c = [float(x) for x in input().split()]
delta = ((b**2)-(4*a*c))
if a != 0 and delta > 0:
sqrt_delta = (delta)**(1/2)
r1 = (-b + sqrt_delta)/(2*a)
r2 = (-b - sqrt_delta)/(2*a)
print("R1 = {0:.5f}".format(r1))
print("R2 = {0:.5f}".format(r2))
else:
print("Impossivel calcular")
| (a, b, c) = [float(x) for x in input().split()]
delta = b ** 2 - 4 * a * c
if a != 0 and delta > 0:
sqrt_delta = delta ** (1 / 2)
r1 = (-b + sqrt_delta) / (2 * a)
r2 = (-b - sqrt_delta) / (2 * a)
print('R1 = {0:.5f}'.format(r1))
print('R2 = {0:.5f}'.format(r2))
else:
print('Impossivel calcular') |
class Solution:
@staticmethod
def naive(nums,target):
dp = [0]*(target+1)
dp[0]=1
for i in range(1,target+1):
for n in nums:
if i-n>=0:
dp[i]+=dp[i-n]
return dp[target]
| class Solution:
@staticmethod
def naive(nums, target):
dp = [0] * (target + 1)
dp[0] = 1
for i in range(1, target + 1):
for n in nums:
if i - n >= 0:
dp[i] += dp[i - n]
return dp[target] |
mylist = [1,2,3]
print(mylist)
mylist.append(4)
print(mylist)
print(mylist.pop())
print(mylist)
mylist.reverse()
print(mylist)
newlist = mylist
mylist.reverse()
print(newlist)
print(mylist)
mylist = mylist*3
print(mylist)
mylist = mylist + newlist
print(mylist)
print(mylist[2:3])
print(mylist[4:5])
createlist = list([... | mylist = [1, 2, 3]
print(mylist)
mylist.append(4)
print(mylist)
print(mylist.pop())
print(mylist)
mylist.reverse()
print(mylist)
newlist = mylist
mylist.reverse()
print(newlist)
print(mylist)
mylist = mylist * 3
print(mylist)
mylist = mylist + newlist
print(mylist)
print(mylist[2:3])
print(mylist[4:5])
createlist = lis... |
class SimpleMean:
def solution(self, value1, value2):
mean = ((value1 * 3.5) + (value2 * 7.5)) / 11
return "MEDIA = " + "%.5f" % (mean) | class Simplemean:
def solution(self, value1, value2):
mean = (value1 * 3.5 + value2 * 7.5) / 11
return 'MEDIA = ' + '%.5f' % mean |
#Basic Data Types Challenge 3: Temperature Conversion App
print("Welcome to the Temperature Conversion App")
#Gather user input
temp_f = float(input("\nWhat is the given temperature in degrees Fahrenheit: "))
#Convert temps
temp_c = (5/9)*(temp_f - 32)
temp_k = temp_c + 273.15
#Round temps
temp_f = round(temp_f, 4... | print('Welcome to the Temperature Conversion App')
temp_f = float(input('\nWhat is the given temperature in degrees Fahrenheit: '))
temp_c = 5 / 9 * (temp_f - 32)
temp_k = temp_c + 273.15
temp_f = round(temp_f, 4)
temp_c = round(temp_c, 4)
temp_k = round(temp_k, 4)
print('\nDegrees Fahrenheit:\t' + str(temp_f))
print('... |
# compare class
# print class
# -*- coding:utf-8 -*-
def key_func(n):
return n.score
class TestClass:
def __init__(self, code, name, score):
self.code = code
self.name = name
self.score = score
# can be printed if define __str__
def __str__(self):
return '({}, {}, ... | def key_func(n):
return n.score
class Testclass:
def __init__(self, code, name, score):
self.code = code
self.name = name
self.score = score
def __str__(self):
return '({}, {}, {})'.format(self.code, self.name, self.score)
l = [test_class(1, 'Python', 100), test_class(2, '... |
# coding=utf8
ROOT_RULE = 'statement -> [mquery]'
GRAMMAR_DICTIONARY = {}
GRAMMAR_DICTIONARY["statement"] = ['(mquery ws)']
GRAMMAR_DICTIONARY["mquery"] = [
'(ws select_clause ws from_clause ws where_clause ws groupby_clause ws having_clause ws orderby_clause ws limit)',
'(ws select_clause ws from_clause ws ... | root_rule = 'statement -> [mquery]'
grammar_dictionary = {}
GRAMMAR_DICTIONARY['statement'] = ['(mquery ws)']
GRAMMAR_DICTIONARY['mquery'] = ['(ws select_clause ws from_clause ws where_clause ws groupby_clause ws having_clause ws orderby_clause ws limit)', '(ws select_clause ws from_clause ws where_clause ws groupby_cl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.