content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class BaseProxyResponseHandler: def __init__(self): pass def merge_result(self, response_entity_list): pass
class Baseproxyresponsehandler: def __init__(self): pass def merge_result(self, response_entity_list): pass
__author__ = 'hs634' def distributeCandy( score): candies = [1 for i in range(len(score))] for i in range(1, len(score)): if score[i] > score[i-1]: candies[i] = candies[i-1] + 1 for i in range(len(score)-2, -1, -1): if score[i+1] < score[i] and candies[i+1] >= candies[i]: ...
__author__ = 'hs634' def distribute_candy(score): candies = [1 for i in range(len(score))] for i in range(1, len(score)): if score[i] > score[i - 1]: candies[i] = candies[i - 1] + 1 for i in range(len(score) - 2, -1, -1): if score[i + 1] < score[i] and candies[i + 1] >= candies[...
def bar(): for i in range(10): yield i for z in bar(): print(z)
def bar(): for i in range(10): yield i for z in bar(): print(z)
#Exercise 1 #Print out "b is larger than a. # b-a=x" or "a and b are equal. # a = b = x". # x shows the result of "b-a" or the value of "a" and "b". a = 450 b = 76 c = 23 if a > b: print ("a is larger than B.", "a-b=", a-b) elif a == b: print("a and b are equal.", "a = b =", a) else: print("a is smaller th...
a = 450 b = 76 c = 23 if a > b: print('a is larger than B.', 'a-b=', a - b) elif a == b: print('a and b are equal.', 'a = b =', a) else: print('a is smaller than b') num = int(input('Enter a number: ')) if num >= 0: if num == 0: print('Zero') else: print('Positive number') else: ...
class Interface: def __init__(self, L=0.0, n=1.0): self.n = n self.L = L class SphericalInterface(Interface): def __init__(self, R: float, L=0.0, n=1.0): super(SphericalInterface, self).__init__(L=L, n=n) self.R = R class FlatInterface(SphericalInterface): def __init__(se...
class Interface: def __init__(self, L=0.0, n=1.0): self.n = n self.L = L class Sphericalinterface(Interface): def __init__(self, R: float, L=0.0, n=1.0): super(SphericalInterface, self).__init__(L=L, n=n) self.R = R class Flatinterface(SphericalInterface): def __init__(s...
DUMMY_TAGS = ["one", "two", "three"] DUMMY_DEVICES_IDS = ["123", "abc"] DUMMY_USER_IDS = "321" USERS_SQS = [ { "id": "61b0ef77749934fad94f121a", "name": "Administrator Users Locked Out", "view": { "colExcludedAdapters": [{"exclude": [], "fieldPath": ""}], "colFilte...
dummy_tags = ['one', 'two', 'three'] dummy_devices_ids = ['123', 'abc'] dummy_user_ids = '321' users_sqs = [{'id': '61b0ef77749934fad94f121a', 'name': 'Administrator Users Locked Out', 'view': {'colExcludedAdapters': [{'exclude': [], 'fieldPath': ''}], 'colFilters': [], 'fields': ['adapters', 'specific_data.data.image'...
__author__ = 'jbowman' # https://pythonspot.com/method-overloading/ class Human: name = '' def __init__(self, name=None): self.name = name def sayHello(self): if self.name is not None: print('Hello ' + self.name) else: print('Hello') obj = Human() obj.s...
__author__ = 'jbowman' class Human: name = '' def __init__(self, name=None): self.name = name def say_hello(self): if self.name is not None: print('Hello ' + self.name) else: print('Hello') obj = human() obj.sayHello() obj2 = human('Jerry') obj2.sayHello()
for _ in range(int(input())): n=int(input()) goal=input() team_1=team_2=0 a=b=n for i in range(2*n): if i%2==0: a-=1 if goal[i]=='1':team_1+=1 else : b-=1 if goal[i]=='1':team_2+=1 if team_1>team_2: if t...
for _ in range(int(input())): n = int(input()) goal = input() team_1 = team_2 = 0 a = b = n for i in range(2 * n): if i % 2 == 0: a -= 1 if goal[i] == '1': team_1 += 1 else: b -= 1 if goal[i] == '1': team...
##Task ##The provided code stub reads and integer,n , from STDIN. Print Half pyramid pattern with number of rows <=n n=int(input("Enter the number of rows")) for row in range(1, n+1): for column in range(1, row + 1): print(column, end=' ') print("")
n = int(input('Enter the number of rows')) for row in range(1, n + 1): for column in range(1, row + 1): print(column, end=' ') print('')
class Test: count=0 def __init__(self): Test.count=Test.count+1 @classmethod def noOfObjects(cls): print('the no. of objects created for test class:',cls.count) t1=Test() t2=Test() Test.noOfObjects() t3=Test() t4=Test() t5=Test() Test.noOfObjects()
class Test: count = 0 def __init__(self): Test.count = Test.count + 1 @classmethod def no_of_objects(cls): print('the no. of objects created for test class:', cls.count) t1 = test() t2 = test() Test.noOfObjects() t3 = test() t4 = test() t5 = test() Test.noOfObjects()
# # PySNMP MIB module CISCO-SSG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SSG-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:12:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, constraints_intersection, value_size_constraint, single_value_constraint) ...
List = ["Name","Lang","Tech",12] tup = [] for x in List: tup.append(x) # print(x) print(tup)
list = ['Name', 'Lang', 'Tech', 12] tup = [] for x in List: tup.append(x) print(tup)
# Enter your code here. Read input from STDIN. Print output to STDOUT class Trade: def __init__(self, TradeDate,Instrument,SidelsBuy,Quantity,Price): self.TradeDate = TradeDate self.Instrument = Instrument self.SidelsBuy = SidelsBuy self.Quantity = Quantity self.Pric...
class Trade: def __init__(self, TradeDate, Instrument, SidelsBuy, Quantity, Price): self.TradeDate = TradeDate self.Instrument = Instrument self.SidelsBuy = SidelsBuy self.Quantity = Quantity self.Price = Price def total_financeiro(trades): total_by_trade = [] for i...
def main(): num = 2520 con = 0 while True: for i in range(2,21): if not num % i == 0: num += 1 con = 0 break else: con += 1 if con == 19: break print("Finished:" + str(num)) ...
def main(): num = 2520 con = 0 while True: for i in range(2, 21): if not num % i == 0: num += 1 con = 0 break else: con += 1 if con == 19: break print('Finished:' + str(num)) if __name__ =...
def f(): try: # Looks like this returns from the function, but it needs to go to the finally block return finally: pass f()
def f(): try: return finally: pass f()
##!FAIL: UnsupportedTopLevelNodeError[Expr]@3:0 42 + 3 def f(x, y): return 2 * (x + y) assert f(1, 2) == 6
42 + 3 def f(x, y): return 2 * (x + y) assert f(1, 2) == 6
class Observation: def __init__(self, timestep, coil_speed, current_coil_type, current_coating_target, coil_switch_next_tick, next_coil_type, next_coating_target, coil_length, zinc_bath_coating, zinc_coating, nozzle_pressure): self.timestep = timestep self.coil_speed = coil_speed self.cu...
class Observation: def __init__(self, timestep, coil_speed, current_coil_type, current_coating_target, coil_switch_next_tick, next_coil_type, next_coating_target, coil_length, zinc_bath_coating, zinc_coating, nozzle_pressure): self.timestep = timestep self.coil_speed = coil_speed self.curre...
# We cant find a seeded random number, but there is method that changes the ip such that 0x15 is passed to decrypt arg = 0x1337d00d s1 = 'Q}|u'+'`sfg'+'~sf{'+'}|a3' s2 = 'Congratulations!' for i in range(16): key = ord(s1[i])^ord(s2[i]) print("Key:"+str(0x1337d00d-key))
arg = 322424845 s1 = 'Q}|u' + '`sfg' + '~sf{' + '}|a3' s2 = 'Congratulations!' for i in range(16): key = ord(s1[i]) ^ ord(s2[i]) print('Key:' + str(322424845 - key))
#!/usr/bin/env python count2 = 1 count3 = 5 print(7*"*") for i in range(3,8,2): print(count2*" "+count3*"*"+count2*" ") count2 += 1 count3 -= 2 for i in range(3,8,2): count1 = int((7-i)/2) print(count1*" "+i*"*"+count1*" ")
count2 = 1 count3 = 5 print(7 * '*') for i in range(3, 8, 2): print(count2 * ' ' + count3 * '*' + count2 * ' ') count2 += 1 count3 -= 2 for i in range(3, 8, 2): count1 = int((7 - i) / 2) print(count1 * ' ' + i * '*' + count1 * ' ')
help(sorted) # it will show the function documentation # see that sorted has 4 arguments: iterable, cmp=None, key=None, reverse=False full = [11.25, 18.0, 20.0, 10.75, 9.50] # we want to pass only "reverse" parameter full_sorted = sorted(full, reverse = True) print(full_sorted)
help(sorted) full = [11.25, 18.0, 20.0, 10.75, 9.5] full_sorted = sorted(full, reverse=True) print(full_sorted)
s1 = input() s2 = input() sum = 0 for i in range(len(s1) - 1): if s1[i: i+2] in s2: sum += 1 print(sum)
s1 = input() s2 = input() sum = 0 for i in range(len(s1) - 1): if s1[i:i + 2] in s2: sum += 1 print(sum)
class ExitCode: def __init__(self, code: int): self.__code = code def is_error(self): return self.__code < 0 def is_play_again(self): return self.__code == 1 def value(self): return self.__code def equals(self, other): return self.value() == other.value() ...
class Exitcode: def __init__(self, code: int): self.__code = code def is_error(self): return self.__code < 0 def is_play_again(self): return self.__code == 1 def value(self): return self.__code def equals(self, other): return self.value() == other.value()...
class Converter: def __init__(self, number): self.number = number def toBinary(self): binary = "" while self.number > 0: binary += str(self.number % 2) self.number //= 2 return binary[::-1] def toDecimal(self): decimal = 0 max_power = len(str(self.number)) - 1 for i in str(self.number): d...
class Converter: def __init__(self, number): self.number = number def to_binary(self): binary = '' while self.number > 0: binary += str(self.number % 2) self.number //= 2 return binary[::-1] def to_decimal(self): decimal = 0 max_powe...
# Full formatting strings. sentence = 'On a scale of {0:d} to {1:d}, I give {2:s} a {3:d}.' sentence = sentence.format(1, 5, 'Monty Python', 6) print(sentence) # Simplify by removing field names (indexes). sentence = 'On a scale of {:d} to {:d}, I give {:s} a {:d}.' sentence = sentence.format(1, 5, 'Monty Python', 6) ...
sentence = 'On a scale of {0:d} to {1:d}, I give {2:s} a {3:d}.' sentence = sentence.format(1, 5, 'Monty Python', 6) print(sentence) sentence = 'On a scale of {:d} to {:d}, I give {:s} a {:d}.' sentence = sentence.format(1, 5, 'Monty Python', 6) print(sentence) sentence = 'On a scale of {:} to {:}, I give {:} a {:}.' s...
def fib(x): if x == 0: return 0 elif x == 1: return 1 return fib(x-1) + fib(x-2) print(fib(40))
def fib(x): if x == 0: return 0 elif x == 1: return 1 return fib(x - 1) + fib(x - 2) print(fib(40))
values = input().split(" ") a = float(values[0]) b = float(values[1]) c = float(values[2]) triangulo = (a * c)/2 circulo = 3.14159 * (c * c) trapezio = ((a + b) * c)/2 quadrado = b * b retangulo = a * b print("TRIANGULO: %1.3f" %(triangulo)) print("CIRCULO: %1.3f" %(circulo)) print("TRAPEZIO: %1.3f" %(trapezio)) pri...
values = input().split(' ') a = float(values[0]) b = float(values[1]) c = float(values[2]) triangulo = a * c / 2 circulo = 3.14159 * (c * c) trapezio = (a + b) * c / 2 quadrado = b * b retangulo = a * b print('TRIANGULO: %1.3f' % triangulo) print('CIRCULO: %1.3f' % circulo) print('TRAPEZIO: %1.3f' % trapezio) print('QU...
class Solution: def countSmaller(self, nums): counts = [] for i in range(0, len(nums)): right = nums[i: len(nums)] right.sort() counts.append(right.index(nums[i])) return counts
class Solution: def count_smaller(self, nums): counts = [] for i in range(0, len(nums)): right = nums[i:len(nums)] right.sort() counts.append(right.index(nums[i])) return counts
R = float(input()) PI = 3.14159 sphear = float((4/3) * PI * R**3) print("VOLUME = %.3f" % sphear)
r = float(input()) pi = 3.14159 sphear = float(4 / 3 * PI * R ** 3) print('VOLUME = %.3f' % sphear)
def rsum(n): for i in range (n,1,-1): return n + rsum(n-1) return n print(rsum(5))
def rsum(n): for i in range(n, 1, -1): return n + rsum(n - 1) return n print(rsum(5))
# Content autogenerated. Do not edit. syscalls_mipso32 = { "_llseek": 4140, "_newselect": 4142, "_sysctl": 4153, "accept": 4168, "accept4": 4334, "access": 4033, "acct": 4051, "add_key": 4280, "adjtimex": 4124, "alarm": 4027, "bdflush": 4134, "bind": 4169, "bpf": 435...
syscalls_mipso32 = {'_llseek': 4140, '_newselect': 4142, '_sysctl': 4153, 'accept': 4168, 'accept4': 4334, 'access': 4033, 'acct': 4051, 'add_key': 4280, 'adjtimex': 4124, 'alarm': 4027, 'bdflush': 4134, 'bind': 4169, 'bpf': 4355, 'brk': 4045, 'cachectl': 4148, 'cacheflush': 4147, 'capget': 4204, 'capset': 4205, 'chdir...
# # Copyright 2013 Pixar # # Licensed under the Apache License, Version 2.0 (the "Apache License") # with the following modification; you may not use this file except in # compliance with the Apache License and the following modification to it: # Section 6. Trademarks. is deleted and replaced with: # # 6. T...
class Topoerror(Exception): def __init__(self, message): Exception.__init__(self, message) class Osdtypeerror(Exception): def __init__(self, message): Exception.__init__(self, message) class Boundarymode: """Subdivision boundary rules for :class:`osd.Topology` construction.""" none =...
class Solution: def poorPigs(self, buckets: int, minutesToDie: int, minutesToTest: int) -> int: pigs, product = 0, 1 while product < buckets: product *= minutesToTest // minutesToDie + 1 pigs += 1 return pigs # TESTS for buckets, minutesToDie, minutesToTest, expecte...
class Solution: def poor_pigs(self, buckets: int, minutesToDie: int, minutesToTest: int) -> int: (pigs, product) = (0, 1) while product < buckets: product *= minutesToTest // minutesToDie + 1 pigs += 1 return pigs for (buckets, minutes_to_die, minutes_to_test, expect...
''' Common abstract mixins for database modules that provide name field, notes, and year date handling. ''' default_app_config = 'derrida.common.apps.CommonConfig'
""" Common abstract mixins for database modules that provide name field, notes, and year date handling. """ default_app_config = 'derrida.common.apps.CommonConfig'
class Building(): def __init__(self,floor,floorNumber): self.totalFloorNumber = floorNumber self.totalVoice = floor.totalVoice self.totalMass = floor.mass
class Building: def __init__(self, floor, floorNumber): self.totalFloorNumber = floorNumber self.totalVoice = floor.totalVoice self.totalMass = floor.mass
class Solution: def maxKilledEnemies(self, grid: List[List[str]]) -> int: if not grid: return 0 m, n = len(grid), len(grid[0]) v1 = [[0]*n for _ in range(m)] # left to right v2 = [[0]*n for _ in range(m)] # right to left v3 = [[0]*n for _ in range(m)] # top to bottom ...
class Solution: def max_killed_enemies(self, grid: List[List[str]]) -> int: if not grid: return 0 (m, n) = (len(grid), len(grid[0])) v1 = [[0] * n for _ in range(m)] v2 = [[0] * n for _ in range(m)] v3 = [[0] * n for _ in range(m)] v4 = [[0] * n for _ in ...
class Player: def __init__(self, saved: bool): if saved is True: # Runs if there is a save file to load from pass else: # Runs if this is a new game pass
class Player: def __init__(self, saved: bool): if saved is True: pass else: pass
# Equalizing an image histogram # Load the image into an array: image image = plt.imread('640px-Unequalized_Hawkes_Bay_NZ.jpg') # Flatten the image into 1 dimension: pixels pixels = image.flatten() # Generate a cumulative histogram cdf, bins, patches = plt.hist(pixels, bins=256, range=(0,256), normed=True, ...
image = plt.imread('640px-Unequalized_Hawkes_Bay_NZ.jpg') pixels = image.flatten() (cdf, bins, patches) = plt.hist(pixels, bins=256, range=(0, 256), normed=True, cumulative=True) new_pixels = np.interp(pixels, bins[:-1], cdf * 255) new_image = new_pixels.reshape(image.shape) plt.subplot(2, 1, 1) plt.title('Equalized im...
#Enum file class RedditAPI: FIELDS = ["REDDIT_CLIENT_ID", "REDDIT_CLIENT_SECRET", "REDDIT_USER_AGENT", "REDDIT_USERNAME", "REDDIT_PASSWORD"] CLIENT_ID = "REDDIT_CLIENT_ID" CLIENT_SECRET = "REDDIT_CLIENT_SECRET" USER_AGENT = "REDDIT_USER_AGENT" USERNAM...
class Redditapi: fields = ['REDDIT_CLIENT_ID', 'REDDIT_CLIENT_SECRET', 'REDDIT_USER_AGENT', 'REDDIT_USERNAME', 'REDDIT_PASSWORD'] client_id = 'REDDIT_CLIENT_ID' client_secret = 'REDDIT_CLIENT_SECRET' user_agent = 'REDDIT_USER_AGENT' username = 'REDDIT_USERNAME' password = 'REDDIT_PASSWORD'
#-*- coding: utf-8 -*- class CAManagerInitializeException(Exception): pass class RelayStreamingException(Exception): pass
class Camanagerinitializeexception(Exception): pass class Relaystreamingexception(Exception): pass
def get_power(integer, power): if power>0: ret_val=integer for i in range(power-1): ret_val=ret_val*integer else: ret_val=1 return ret_val def get_factorial(integer): if integer==0: ret_val=1 else: ret_val=integer for i in range(1,integer...
def get_power(integer, power): if power > 0: ret_val = integer for i in range(power - 1): ret_val = ret_val * integer else: ret_val = 1 return ret_val def get_factorial(integer): if integer == 0: ret_val = 1 else: ret_val = integer for i i...
def f(a): print(a.size) class C1: size = 1 class C2: def __init__(self, size): self.size = size class MyClass: def __init__(self, size): self.size = size def __len__(self): return self.size def f(obj): if "__len__" not in dir(obj): raise TypeError # do t...
def f(a): print(a.size) class C1: size = 1 class C2: def __init__(self, size): self.size = size class Myclass: def __init__(self, size): self.size = size def __len__(self): return self.size def f(obj): if '__len__' not in dir(obj): raise TypeError f(my_clas...
def add_auth_to_response(_response, _request): response = _response response['User'] = str(_request.user) response['Auth'] = str(_request.auth) return response
def add_auth_to_response(_response, _request): response = _response response['User'] = str(_request.user) response['Auth'] = str(_request.auth) return response
# 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 ( str ) : result = 0 for i in range ( len ( str ) ) : if ( ( i == ord ( str [ i ] ) - ord ( 'a' ) ) o...
def f_gold(str): result = 0 for i in range(len(str)): if i == ord(str[i]) - ord('a') or i == ord(str[i]) - ord('A'): result += 1 return result if __name__ == '__main__': param = [('lLkhFeZGcb',), ('ABcED',), ('geeksforgeeks',), ('Alphabetical',), ('abababab',), ('bcdefgxyz',), ('cBza...
class hat: # properties color = "" style = "" # actions def __init__(self, color, style): self.color = str(color) self.style = str(style) def getcolor(self): return self.color def setcolor(self, color): if (type(color) is str): self.color = colo...
class Hat: color = '' style = '' def __init__(self, color, style): self.color = str(color) self.style = str(style) def getcolor(self): return self.color def setcolor(self, color): if type(color) is str: self.color = color else: print...
# =============== loggging mechanism ====================== def logger(*args, func=None, msg): global log_file if func: if len(args) > 1: output = str(func(args)) elif len(args) == 1: output = str(func(args[0])) else: func() else: output...
def logger(*args, func=None, msg): global log_file if func: if len(args) > 1: output = str(func(args)) elif len(args) == 1: output = str(func(args[0])) else: func() else: output = '-No output-' log = jdate('Y/m/d H:i:s') + '\t' + str(ms...
class Solution: def longestDecomposition(self, text: str) -> int: n = len(text) if n <= 1: return n for i in range(n // 2): if text[:i + 1] == text[-(i + 1):]: return 2 + self.longestDecomposition(text[(i + 1):-(i + 1)]) return 1
class Solution: def longest_decomposition(self, text: str) -> int: n = len(text) if n <= 1: return n for i in range(n // 2): if text[:i + 1] == text[-(i + 1):]: return 2 + self.longestDecomposition(text[i + 1:-(i + 1)]) return 1
def test_ref_task(run_poe_subproc, projects, esc_prefix): # This should be exactly the same as calling the echo task directly result = run_poe_subproc("also_echo", "foo", "!") assert ( result.capture == f"Poe => echo POE_ROOT:{projects['example']} Password1, task_args: foo !\n" ) ass...
def test_ref_task(run_poe_subproc, projects, esc_prefix): result = run_poe_subproc('also_echo', 'foo', '!') assert result.capture == f"Poe => echo POE_ROOT:{projects['example']} Password1, task_args: foo !\n" assert result.stdout == f"POE_ROOT:{projects['example']} Password1, task_args: foo !\n" assert ...
# # MIT License # # (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the...
""" This is a series of instructions used to configure a local copy of sshd so that it may trust the upstream vault client instance. This setup procedure involves pulling the public_key from the vault service, injecting a value into sshd config, and then optionally reloading the sshd service to pick up the new values. ...
class Dimension: def __init__(self, x, y, height, width): self.x = x self.y = y self.height = height self.width = width
class Dimension: def __init__(self, x, y, height, width): self.x = x self.y = y self.height = height self.width = width
{ 'targets': [ { 'target_name': 'weakref', 'sources': [ 'src/weakref.cc' ] } ] }
{'targets': [{'target_name': 'weakref', 'sources': ['src/weakref.cc']}]}
# -*- coding: utf-8 -*- ''' Contract Context ''' __virtualname__ = 'ctx_update' def pre(hub, ctx): ''' ''' assert ctx.args == [hub, True] # Let's replace the context arguments ctx.args[1] = False assert ctx.args == [hub, False] def call_test_call(hub, ctx): ''' ''' assert ctx.ar...
""" Contract Context """ __virtualname__ = 'ctx_update' def pre(hub, ctx): """ """ assert ctx.args == [hub, True] ctx.args[1] = False assert ctx.args == [hub, False] def call_test_call(hub, ctx): """ """ assert ctx.args == [hub, False] return 'contract executed' def post(hub, ctx)...
# Link: https://leetcode.com/problems/validate-stack-sequences/ # Time: O(N) # Space: O(N) # def validate_stack_sequences(pushed, popped): # stack, i = [], 0 # while stack or popped: # if i < len(pushed): # stack.append(pushed[i]) # elif stack[-1] != popped[0]: # return...
def validate_stack_sequences(pushed, popped): (stack, i) = ([], 0) for element in pushed: stack.append(element) while stack and stack[-1] == popped[i]: i += 1 stack.pop() return not stack def main(): pushed = [1, 2, 3, 4, 5] popped = [4, 5, 3, 2, 1] print...
# Natural Language Toolkit: code_give def give(t): return t.label() == 'VP' and len(t) > 2 and t[1].label() == 'NP'\ and (t[2].label() == 'PP-DTV' or t[2].label() == 'NP')\ and ('give' in t[0].leaves() or 'gave' in t[0].leaves()) def sent(t): return ' '.join(token for token in t.leaves() ...
def give(t): return t.label() == 'VP' and len(t) > 2 and (t[1].label() == 'NP') and (t[2].label() == 'PP-DTV' or t[2].label() == 'NP') and ('give' in t[0].leaves() or 'gave' in t[0].leaves()) def sent(t): return ' '.join((token for token in t.leaves() if token[0] not in '*-0')) def print_node(t, width): o...
# Python Program To Accept A Group Of String Seprated By Commas ''' Function Name : Accept A Group Of String Function Date : 26 Aug 2020 Function Author : Prasad Dangare Input : Charactor Output : Charactor ''' lst = [x for x in input('Enter String:').split(',')] print('You ...
""" Function Name : Accept A Group Of String Function Date : 26 Aug 2020 Function Author : Prasad Dangare Input : Charactor Output : Charactor """ lst = [x for x in input('Enter String:').split(',')] print('You Entered :\n', lst)
age = input('What your age?: ') if int(age) >= 18: print('You are old enough to vote!') print('Have you registered to vote yet?') else: print('Sorry, you are to young to vote.') print('Please register to vote as soon as you turn 18!')
age = input('What your age?: ') if int(age) >= 18: print('You are old enough to vote!') print('Have you registered to vote yet?') else: print('Sorry, you are to young to vote.') print('Please register to vote as soon as you turn 18!')
__all__ = [ 'stage, stageElements' ] __version__ = "0.0.1"
__all__ = ['stage, stageElements'] __version__ = '0.0.1'
class timetable: def __init__(self, start, stop, frequency, bunch, delay, cancellation): self.start = start self.stop = stop self.frequency = frequency self.bunch = bunch self.delay = delay self.cancellation = cancellation
class Timetable: def __init__(self, start, stop, frequency, bunch, delay, cancellation): self.start = start self.stop = stop self.frequency = frequency self.bunch = bunch self.delay = delay self.cancellation = cancellation
class Coffee: ingredient = ['water', 'milk', 'coffee beans', 'cups', ''] espresso = [250, 0, 16, 1, -4] latte = [350, 75, 20, 1, -7] cappuccino = [200, 100, 12, 1, -6] def __init__(self, waters, milks, coffee_bean, cup, moneys): self.water = waters self.milk = milks self.cof...
class Coffee: ingredient = ['water', 'milk', 'coffee beans', 'cups', ''] espresso = [250, 0, 16, 1, -4] latte = [350, 75, 20, 1, -7] cappuccino = [200, 100, 12, 1, -6] def __init__(self, waters, milks, coffee_bean, cup, moneys): self.water = waters self.milk = milks self.cof...
# # Solution to Project Euler problem 56 # Copyright (c) Project Nayuki. All rights reserved. # # https://www.nayuki.io/page/project-euler-solutions # https://github.com/nayuki/Project-Euler-solutions # def compute(): ans = max(sum(int(c) for c in str(a**b)) for a in range(100) for b in range(100)) return str(...
def compute(): ans = max((sum((int(c) for c in str(a ** b))) for a in range(100) for b in range(100))) return str(ans) if __name__ == '__main__': print(compute())
#!/usr/bin/env python3 class AppnameXlator(): def __init__(self, file_path_apps_json=None): self.appname_to_id = {} self.id_to_appname = {} def get_appname_id(self, appname, add_app=True): try: return self.appname_to_id[appname] except KeyError: app_id =...
class Appnamexlator: def __init__(self, file_path_apps_json=None): self.appname_to_id = {} self.id_to_appname = {} def get_appname_id(self, appname, add_app=True): try: return self.appname_to_id[appname] except KeyError: app_id = len(self.appname_to_id) ...
# status: testado com exemplos da prova def walk(pacman, side): if pacman[0] % 2: if pacman[1] == 0: return pacman[0] + 1, pacman[1] return pacman[0], pacman[1] - 1 else: if pacman[1] + 1 == side: return pacman[0] + 1, pacman[1] return pacman[0], pacman[...
def walk(pacman, side): if pacman[0] % 2: if pacman[1] == 0: return (pacman[0] + 1, pacman[1]) return (pacman[0], pacman[1] - 1) else: if pacman[1] + 1 == side: return (pacman[0] + 1, pacman[1]) return (pacman[0], pacman[1] + 1) if __name__ == '__main__': ...
#!/usr/bin/python # This file defines the output and input pins for the T-Shirt Launcher # Define our relay outputs # Each output is triggered via a ULN2803 Darlington Driver TSHIRT1=4 TSHIRT2=17 TSHIRT3=22 TSHIRT4=18 # Define our LED outputs # LED status for each barrel LED1=2 LED2=14 LED3=3 LED4=15 # Either for e...
tshirt1 = 4 tshirt2 = 17 tshirt3 = 22 tshirt4 = 18 led1 = 2 led2 = 14 led3 = 3 led4 = 15 led5 = 24 button1 = 27 button2 = 23 valve_sleep_time = 0.16
name = input("Enter your name: ") with open('guest.txt', 'a') as f: f.write(f'{name}\n')
name = input('Enter your name: ') with open('guest.txt', 'a') as f: f.write(f'{name}\n')
def add_two_numbers_in_list(arr, k): for i in arr: n = k-i if (n in arr): return [i, n] result = add_two_numbers_in_list([10, 15, 3, 7], 17) print(result)
def add_two_numbers_in_list(arr, k): for i in arr: n = k - i if n in arr: return [i, n] result = add_two_numbers_in_list([10, 15, 3, 7], 17) print(result)
"Key poviders" DotnetLibraryInfo = provider( doc = "DotnetLibraryInfo is a provider that exposes a compiled assembly along with it's full transitive dependencies.", fields = { "label": "Label of the rule used to create this DotnetLibraryInfo.", "name": "Name of the assembly (label.name if not p...
"""Key poviders""" dotnet_library_info = provider(doc="DotnetLibraryInfo is a provider that exposes a compiled assembly along with it's full transitive dependencies.", fields={'label': 'Label of the rule used to create this DotnetLibraryInfo.', 'name': 'Name of the assembly (label.name if not provided).', 'version': 'V...
def hotpo(n): def even_odd(m): return [3*m+1, m/2][m%2==0] c = 0 while n!=1: n = even_odd(n) c+=1 return c
def hotpo(n): def even_odd(m): return [3 * m + 1, m / 2][m % 2 == 0] c = 0 while n != 1: n = even_odd(n) c += 1 return c
jpg1 = 0 jpg1 = 0 def setup(): global jpg1, jpg2 size(500, 500) background(100) smooth() jpg1 = loadImage('milos1.png') jpg2 = loadImage('milos2.png') def draw(): global jpg1, jpg2 myTintBO = map(mouseX, 0, width, 0, 255) myTintVP = map(m...
jpg1 = 0 jpg1 = 0 def setup(): global jpg1, jpg2 size(500, 500) background(100) smooth() jpg1 = load_image('milos1.png') jpg2 = load_image('milos2.png') def draw(): global jpg1, jpg2 my_tint_bo = map(mouseX, 0, width, 0, 255) my_tint_vp = map(mouseX, 0, width, 255, 0) tint(255,...
letter_side_a = input("Enter one side of letter: ") letter_side_b = input("Enter second side of letter: ") envelope_side_a = input("Enter one side of envelope: ") envelope_side_b = input("Enter second side of envelope: ") if (letter_side_a < letter_side_b): temp = letter_side_b letter_side_b = letter_side_a le...
letter_side_a = input('Enter one side of letter: ') letter_side_b = input('Enter second side of letter: ') envelope_side_a = input('Enter one side of envelope: ') envelope_side_b = input('Enter second side of envelope: ') if letter_side_a < letter_side_b: temp = letter_side_b letter_side_b = letter_side_a l...
# Flask Secrets SECRET_KEY = 'This-is-the-supa-dupa-secret-key'
secret_key = 'This-is-the-supa-dupa-secret-key'
# Builtins stub used for some float/complex test cases. class object: def __init__(self): pass class type: pass class function: pass class int: pass class float: pass class complex: pass class str: pass
class Object: def __init__(self): pass class Type: pass class Function: pass class Int: pass class Float: pass class Complex: pass class Str: pass
SECRET_KEY = 'None' ROOT_URLCONF = 'healthcheck.contrib.django.status_endpoint.urls' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'mydatabase', } }
secret_key = 'None' root_urlconf = 'healthcheck.contrib.django.status_endpoint.urls' databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'mydatabase'}}
#!/usr/local/bin/python CGI_BIN = '../cgi-bin' HTDOCS = '../htdocs' LOG_ROOT = '/home/bamca/logs' ENV = 'unset' IMG_DIR_ACC = '/pic/set/acc' IMG_DIR_ADD = '/pic/man/add' IMG_DIR_ADS = '/pic/pub/ads' IMG_DIR_ART ...
cgi_bin = '../cgi-bin' htdocs = '../htdocs' log_root = '/home/bamca/logs' env = 'unset' img_dir_acc = '/pic/set/acc' img_dir_add = '/pic/man/add' img_dir_ads = '/pic/pub/ads' img_dir_art = '/pic/gfx' img_dir_blister = '/pic/pub/blister' img_dir_book = '/pic/pub/book' img_dir_box = '/pic/pub/box' img_dir_cat = '/pic/pub...
INPUT_A = 277 INPUT_B = 349 def gen_value(start, factor, multiple=1): current = (start * factor) % 2147483647 while current % multiple != 0: current = (current * factor) % 2147483647 while True: yield current current = (current * factor) % 2147483647 while current % multipl...
input_a = 277 input_b = 349 def gen_value(start, factor, multiple=1): current = start * factor % 2147483647 while current % multiple != 0: current = current * factor % 2147483647 while True: yield current current = current * factor % 2147483647 while current % multiple != 0:...
def isIPv4Address(inputString): str_split = inputString.split(".") count = 0 if len(str_split) != 4: return False for i in range(0, 4): if str_split[i] == "" or str_split[i] == "00" or str_split[i] == "01": return False if re.search("[a-zA-Z]", str_split[i]): ...
def is_i_pv4_address(inputString): str_split = inputString.split('.') count = 0 if len(str_split) != 4: return False for i in range(0, 4): if str_split[i] == '' or str_split[i] == '00' or str_split[i] == '01': return False if re.search('[a-zA-Z]', str_split[i]): ...
m = [[int(input()) for i in range(10)] for j in range(10)] soma = 0 for i in range(10): for j in range(10): if j > i: soma += m[i][j] print(soma)
m = [[int(input()) for i in range(10)] for j in range(10)] soma = 0 for i in range(10): for j in range(10): if j > i: soma += m[i][j] print(soma)
# These are the "raw" inputs to the IGGTools database construction subcommands. # See https://github.com/czbiohub/iggtools/wiki#inputs iggdb2 = "s3://jason.shi-bucket/IGGdb2.0" genomes2species = f"{iggdb2}/genomes2species.tab" alt_species_ids = f"{iggdb2}/alt_species_ids.tsv" uhgg_genomes = "s3://jason.shi-bucket/IGGd...
iggdb2 = 's3://jason.shi-bucket/IGGdb2.0' genomes2species = f'{iggdb2}/genomes2species.tab' alt_species_ids = f'{iggdb2}/alt_species_ids.tsv' uhgg_genomes = 's3://jason.shi-bucket/IGGdb2.0/clean_set' igg = 's3://microbiome-igg/gtdb_r202' marker_set = 'phyeco'
class a: def __init__(self): self. x=10 def m1(self): print("public variable and method") def m2(self): print(self.x) self. m1() t=a() t. m2() t.x t.m2() print() class A: def __init__(self): self. __x=20 def __m1(self): print("private variable...
class A: def __init__(self): self.x = 10 def m1(self): print('public variable and method') def m2(self): print(self.x) self.m1() t = a() t.m2() t.x t.m2() print() class A: def __init__(self): self.__x = 20 def __m1(self): print('private variable ...
class PeekingIterator: def __init__(self, iterator): def get_elements_in_iterator(iterator): ret = [] while iterator.hasNext(): ret.append(iterator.next()) return ret self.sublist = get_elements_in_iterator(iterator) self.point...
class Peekingiterator: def __init__(self, iterator): def get_elements_in_iterator(iterator): ret = [] while iterator.hasNext(): ret.append(iterator.next()) return ret self.sublist = get_elements_in_iterator(iterator) self.pointer = -1 ...
def get_text(): return input("Please enter your text: ") def show_count(count): print(F'Number of words: {count}')
def get_text(): return input('Please enter your text: ') def show_count(count): print(f'Number of words: {count}')
def help(text): if text == "!help": return "help" else: return "error"
def help(text): if text == '!help': return 'help' else: return 'error'
prevs = [int(input()) for _ in range(25)] stack = [prevs[i] for i in range(25)] stack_sum = sum(stack) target = 26796446 found = False start_stack = 0 def is_sum(a): for i, x in enumerate(prevs): for y in prevs[i+1:]: if x + y == a: return True i = 0 while True: try: ...
prevs = [int(input()) for _ in range(25)] stack = [prevs[i] for i in range(25)] stack_sum = sum(stack) target = 26796446 found = False start_stack = 0 def is_sum(a): for (i, x) in enumerate(prevs): for y in prevs[i + 1:]: if x + y == a: return True i = 0 while True: try: ...
# Given a string of words, you need to find the highest scoring word. # Each letter of a word scores points according to its position i the alphabet: a = 1, b = 2, c = 3 etc. # You need to return the highest scoring word as a string. # If two words score the same, return the word that appears earliest in the original s...
def high(x): words = x.split() words_score = [sum((ord(x) - 96 for x in word)) for word in words] return words[max(range(len(words_score)), key=words_score.__getitem__)] def first_high(x): words = x.split() index = 0 score = 0 for word in words: x = sum((ord(x) - 96 for x in word)) ...
def execute(args, extra_args, controller): if len(args) == 0 and len(extra_args) == 1: new_extra_args = dict(extra_args) new_extra_args['--all'] = [] extra_args = new_extra_args search_conditions = controller.get_search_conditions(args, extra_args) repo_list = controller.get_repos(...
def execute(args, extra_args, controller): if len(args) == 0 and len(extra_args) == 1: new_extra_args = dict(extra_args) new_extra_args['--all'] = [] extra_args = new_extra_args search_conditions = controller.get_search_conditions(args, extra_args) repo_list = controller.get_repos(se...
class formatCodes: HEADER = "\033[95m" OKBLUE = "\033[94m" OKGREEN = "\033[92m" WARNING = "\033[93m" FAIL = "\033[91m" ENDC = "\033[0m" BOLD = "\033[1m" UNDERLINE = "\033[4m" def tprint(Style, Text, end="\n"): print(Style + Text + "\033[0m", end=end) def clear(): print("\03...
class Formatcodes: header = '\x1b[95m' okblue = '\x1b[94m' okgreen = '\x1b[92m' warning = '\x1b[93m' fail = '\x1b[91m' endc = '\x1b[0m' bold = '\x1b[1m' underline = '\x1b[4m' def tprint(Style, Text, end='\n'): print(Style + Text + '\x1b[0m', end=end) def clear(): print('\x1bc',...
def factorial(number): if number == 1: # BASE CASE return 1 else: # RECURSIVE CASE return number * factorial(number - 1) print(factorial(5))
def factorial(number): if number == 1: return 1 else: return number * factorial(number - 1) print(factorial(5))
while(1): a = 1 print(a) while(1): a = 222 print(a) b = "ppppppppppppppppppppppppppppppppppppppp" print(b)
while 1: a = 1 print(a) while 1: a = 222 print(a) b = 'ppppppppppppppppppppppppppppppppppppppp' print(b)
class SFError(Exception): pass class SFValueError(ValueError, SFError): pass
class Sferror(Exception): pass class Sfvalueerror(ValueError, SFError): pass
# coding=utf-8 DEFAULT_LOCALE = 'en_US' PROVIDERS = ['address', 'company', 'credit_card', 'internet', 'misc', 'date_time', 'job', 'person', 'phone_number', 'profile', 'ssn'] AVAILABLE_LOCALES = {'fi_FI', 'uk_UA', 'ar_AA', 'et_EE', 'fil_PH', 'dk_DK', 'en_CA', 'nl_NL', 'el_CY', 'hr_HR', 'en_NZ', 'de', 'ka_GE', 'en_PH'...
default_locale = 'en_US' providers = ['address', 'company', 'credit_card', 'internet', 'misc', 'date_time', 'job', 'person', 'phone_number', 'profile', 'ssn'] available_locales = {'fi_FI', 'uk_UA', 'ar_AA', 'et_EE', 'fil_PH', 'dk_DK', 'en_CA', 'nl_NL', 'el_CY', 'hr_HR', 'en_NZ', 'de', 'ka_GE', 'en_PH', 'he_IL', 'en_US'...
class ArtifactoryException(Exception): pass class UserAlreadyExistsException(ArtifactoryException): pass class GroupAlreadyExistsException(ArtifactoryException): pass class RepositoryAlreadyExistsException(ArtifactoryException): pass class PermissionAlreadyExistsException(Artifac...
class Artifactoryexception(Exception): pass class Useralreadyexistsexception(ArtifactoryException): pass class Groupalreadyexistsexception(ArtifactoryException): pass class Repositoryalreadyexistsexception(ArtifactoryException): pass class Permissionalreadyexistsexception(ArtifactoryException): ...
x = { 'ban': 10, 'band': 5, 'bar': 14, 'can': 32, 'candy': 7 } ''' def make_tree(words): fill = {} for key, value in words.items(): node = fill for c in key: if c not in node: node[c] = {} node = node[c] node[f'${key}'] = value ...
x = {'ban': 10, 'band': 5, 'bar': 14, 'can': 32, 'candy': 7} "\ndef make_tree(words):\n fill = {}\n for key, value in words.items():\n node = fill\n for c in key:\n if c not in node:\n node[c] = {}\n node = node[c]\n node[f'${key}'] = value\n ...
def intersect_list(firstList, secondList): result, secondList_copy = [], secondList[:] for element in firstList: if (element in secondList_copy): result.append(element) secondList_copy.remove(element) return result print(intersect_list([1,2,3,4,5],[8,9,7,3,0]))
def intersect_list(firstList, secondList): (result, second_list_copy) = ([], secondList[:]) for element in firstList: if element in secondList_copy: result.append(element) secondList_copy.remove(element) return result print(intersect_list([1, 2, 3, 4, 5], [8, 9, 7, 3, 0]))
int.from_bytes(b'y\xcc\xa6\xbb', byteorder='big') # Default byte ordering # 2043455163 int.from_bytes(b'y\xcc\xa6\xbb', byteorder='little') # 3148270713
int.from_bytes(b'y\xcc\xa6\xbb', byteorder='big') int.from_bytes(b'y\xcc\xa6\xbb', byteorder='little')
#!/usr/bin/python3 file = open('results.log', 'r').read() print("Black wins:", file.count("Black wins")) print("White wins:", file.count("White wins")) print("Games drawn:", file.count("Game drawn"))
file = open('results.log', 'r').read() print('Black wins:', file.count('Black wins')) print('White wins:', file.count('White wins')) print('Games drawn:', file.count('Game drawn'))
MAX_PAGINATION = 5000 PAGINATION_ALL = { 'nbperpage': MAX_PAGINATION, 'pagenum': 1, } SEARCH_TYPE_CLIENTS = 'Client' SEARCH_TYPE_DOCUMENTS = 'Document' SEARCH_TYPE_PRODUCTS = 'Catalogue' SEARCH_TYPE_PEOPLES = 'Peoples' PRODUCT_TYPE_ITEM = 'item' PRODUCT_TYPE_SERVICE = 'service' CLIENT_TYPE_CORPORATION = 'co...
max_pagination = 5000 pagination_all = {'nbperpage': MAX_PAGINATION, 'pagenum': 1} search_type_clients = 'Client' search_type_documents = 'Document' search_type_products = 'Catalogue' search_type_peoples = 'Peoples' product_type_item = 'item' product_type_service = 'service' client_type_corporation = 'corporation' clie...
def dim_1(answer, dictionary, word) : answer.append(word) for w in dictionary : dim_2(answer, dictionary, word + w) return answer def dim_2(answer, dictionary, word) : answer.append(word) for w in dictionary : dim_3(answer, dictionary, word + w) def dim_3(answer, dictionary, word) : ...
def dim_1(answer, dictionary, word): answer.append(word) for w in dictionary: dim_2(answer, dictionary, word + w) return answer def dim_2(answer, dictionary, word): answer.append(word) for w in dictionary: dim_3(answer, dictionary, word + w) def dim_3(answer, dictionary, word): ...
UPDATE_TYPES = { "message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_member" }
update_types = {'message', 'edited_message', 'channel_post', 'edited_channel_post', 'inline_query', 'chosen_inline_result', 'callback_query', 'shipping_query', 'pre_checkout_query', 'poll', 'poll_answer', 'my_chat_member', 'chat_member'}
money = 2 apple_price = 4 if money >= apple_price: print('Anda dapat membeli apel') # Ketika kondisi di atas adalah False, cetak 'Uang Anda tidak mencukupi' else: print("Uang Anda tidak mencukupi")
money = 2 apple_price = 4 if money >= apple_price: print('Anda dapat membeli apel') else: print('Uang Anda tidak mencukupi')
b = 20 c = 30 fji = 23 fko = 26
b = 20 c = 30 fji = 23 fko = 26
def solve(input): n = 0 for l in input.split("\n"): _, _, out = l.partition(" | ") n += sum(1 for w in out.split() if len(w) in {2, 3, 4, 7}) return n
def solve(input): n = 0 for l in input.split('\n'): (_, _, out) = l.partition(' | ') n += sum((1 for w in out.split() if len(w) in {2, 3, 4, 7})) return n
#!/usr/bin/env python # -*- coding: utf-8 -*- spinMultiplicity = 2 energy = { 'CCSD(T)-F12/cc-pVTZ-F12': MolproLog('p08_f12.out'), } frequencies = GaussianLog('g-Q1-freq.log') rotors = [HinderedRotor(scanLog=ScanLog('scan_0.log'), pivots=[14,15], top=[15,16], symmetry=1, fit='best'), HinderedRotor(scan...
spin_multiplicity = 2 energy = {'CCSD(T)-F12/cc-pVTZ-F12': molpro_log('p08_f12.out')} frequencies = gaussian_log('g-Q1-freq.log') rotors = [hindered_rotor(scanLog=scan_log('scan_0.log'), pivots=[14, 15], top=[15, 16], symmetry=1, fit='best'), hindered_rotor(scanLog=scan_log('scan_1.log'), pivots=[1, 14], top=[14, 15, 1...