content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@npm//@bazel/protractor:package.bzl", "npm_bazel_protractor_dependencies") load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies") load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories") load("@io_bazel_r...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@npm//@bazel/protractor:package.bzl', 'npm_bazel_protractor_dependencies') load('@npm//@bazel/karma:package.bzl', 'npm_bazel_karma_dependencies') load('@io_bazel_rules_webtesting//web:repositories.bzl', 'web_test_repositories') load('@io_bazel_r...
pares = open('pares.txt', 'w') impares = open('impares.txt', 'w') for t in range(0, 1000): if t % 2 == 0: pares.write(f"{t}\n") else: impares.write(f"{t}\n") pares.close() impares.close()
pares = open('pares.txt', 'w') impares = open('impares.txt', 'w') for t in range(0, 1000): if t % 2 == 0: pares.write(f'{t}\n') else: impares.write(f'{t}\n') pares.close() impares.close()
def luasSegitiga2(a,t): luas = a * t / 2 print('Luas segitiga dengan alas ',alas,'dan tinggi ',tinggi,' adalah ',luas) alas=10 tinggi=20 luasSegitiga2(alas,tinggi)
def luas_segitiga2(a, t): luas = a * t / 2 print('Luas segitiga dengan alas ', alas, 'dan tinggi ', tinggi, ' adalah ', luas) alas = 10 tinggi = 20 luas_segitiga2(alas, tinggi)
CONFIGURATION = "css" WIDTH = 30 HEIGHT = 30
configuration = 'css' width = 30 height = 30
#!/usr/bin/env python def solution(S): stack = [] for char in S: if char == ')': if len(stack) > 0: stack.pop() else: return 0 if char == '(': stack.append(char) if len(stack) != 0: return 0 return 1 def te...
def solution(S): stack = [] for char in S: if char == ')': if len(stack) > 0: stack.pop() else: return 0 if char == '(': stack.append(char) if len(stack) != 0: return 0 return 1 def test(): s = '(()(())())' ...
''' https://www.codingame.com/training/easy/equivalent-resistance-circuit-building ''' # Dictionary that stores the value of each resistance name ohms = {} # Read the inputs n = int(input()) for i in range(n): inputs = input().split() name = inputs[0] value = int(inputs[1]) # Pop...
""" https://www.codingame.com/training/easy/equivalent-resistance-circuit-building """ ohms = {} n = int(input()) for i in range(n): inputs = input().split() name = inputs[0] value = int(inputs[1]) ohms[name] = value circuit = [ohms[e] if e in ohms else e for e in input().split()] opening_characters =...
class Error(Exception): pass class NotFound(Error): pass class Corruption(Error): pass class NotSupported(Error): pass class InvalidArgument(Error): pass class RocksIOError(Error): pass class MergeInProgress(Error): pass class Incomplete(Error): pass
class Error(Exception): pass class Notfound(Error): pass class Corruption(Error): pass class Notsupported(Error): pass class Invalidargument(Error): pass class Rocksioerror(Error): pass class Mergeinprogress(Error): pass class Incomplete(Error): pass
test = { 'name': 'q0_3', 'points': 1, 'suites': [ { 'cases': [{'code': '>>> np.all(flavor_ratings_sorted.take(0).column("Rating list") == [1, 2, 4, 5]) == True\nTrue', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardo...
test = {'name': 'q0_3', 'points': 1, 'suites': [{'cases': [{'code': '>>> np.all(flavor_ratings_sorted.take(0).column("Rating list") == [1, 2, 4, 5]) == True\nTrue', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
num_waves = 2 num_eqn = 4 num_aux = 2 # Conserved quantities pressure = 0 x_velocity = 1 y_velocity = 2 z_velocity = 3 # Auxiliary variables impedance = 0 sound_speed = 1
num_waves = 2 num_eqn = 4 num_aux = 2 pressure = 0 x_velocity = 1 y_velocity = 2 z_velocity = 3 impedance = 0 sound_speed = 1
# reverse given string # Sample output: # string this reverse def reverse_sentence(sentence): words = sentence.split(" ") reverse = ' '.join(reversed(words)) return reverse sentence = "reverse this string" print (reverse_sentence(sentence))
def reverse_sentence(sentence): words = sentence.split(' ') reverse = ' '.join(reversed(words)) return reverse sentence = 'reverse this string' print(reverse_sentence(sentence))
class HashTable(object): def __init__(self,size): self.size = size self.slots = [None] * self.size self.data = [None] * self.size def put(self,key,data): hashValue = self.hashFunc(key,len(self.slots)) if self.slots[hashValue] == ...
class Hashtable(object): def __init__(self, size): self.size = size self.slots = [None] * self.size self.data = [None] * self.size def put(self, key, data): hash_value = self.hashFunc(key, len(self.slots)) if self.slots[hashValue] == None: self.slots[hashVal...
class PriorityQueue(object): def __init__(self): self.qlist = [] def isEmpty(self): return len(self) == 0 def __len__(self): return len(self.qlist) def enqueue(self, data, priority): entry = _PriorityQEntry(data, priority) self.qlist.append(entry) de...
class Priorityqueue(object): def __init__(self): self.qlist = [] def is_empty(self): return len(self) == 0 def __len__(self): return len(self.qlist) def enqueue(self, data, priority): entry = __priority_q_entry(data, priority) self.qlist.append(entry) def...
if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) total = list() [total.append(i) for i in arr if i not in total] total.sort() print(total[-2])
if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) total = list() [total.append(i) for i in arr if i not in total] total.sort() print(total[-2])
# %% [markdown] ''' Logistic Regression Classifier Random forest Classifier Decision Tree Classifier PCA Logistic Regression Classifier Random forest Classifier Decision Tree Classifier Normalization Modeling With PCA Without PCA ''' all_metrics.append(["Logistic Regression", rou...
""" Logistic Regression Classifier Random forest Classifier Decision Tree Classifier PCA Logistic Regression Classifier Random forest Classifier Decision Tree Classifier Normalization Modeling With PCA Without PCA """ all_metrics.append(['Logistic Regression', round(sensitivity, 2), round(specific...
# ldap/util.py # Written by Jeff Kaleshi def get_permissions(query): permissions = [] for item in query: permission = item[3:item.find(',')] if permission != 'ACMPaid' and permission != 'ACMNotPaid': permissions.append(permission) return permissions def get_paid_status(query):...
def get_permissions(query): permissions = [] for item in query: permission = item[3:item.find(',')] if permission != 'ACMPaid' and permission != 'ACMNotPaid': permissions.append(permission) return permissions def get_paid_status(query): result = False permissions = get_p...
NAME = 'Jane P. Roult' # Communication Definitions BAUDRATE = 115200 COMMAND_COMM_LOCATION = "/dev/robot/arduino" # For sending commands SENSORS_COMM_LOCATION = "/dev/robot/sensors" # For receiving sensor telemetry # Physical Definitions WHEEL_BASE_MM = 153.0 # Blue Wheels with geared steppers: STEPS_PER_CM = 132....
name = 'Jane P. Roult' baudrate = 115200 command_comm_location = '/dev/robot/arduino' sensors_comm_location = '/dev/robot/sensors' wheel_base_mm = 153.0 steps_per_cm = 132.0 steps_per_mm = STEPS_PER_CM / 10.0
def calculate( time, realtime ): starting = time[6] hhs = int(time[:2]) mms = int(time[3:5]) ending = time[15] hhe = int(time[9:11]) mme = int(time[12:15]) if time[6]== 'A': if time[15] == 'A': if hhs!=12: sum=0 sum = sum + (hh*60)+mm ...
def calculate(time, realtime): starting = time[6] hhs = int(time[:2]) mms = int(time[3:5]) ending = time[15] hhe = int(time[9:11]) mme = int(time[12:15]) if time[6] == 'A': if time[15] == 'A': if hhs != 12: sum = 0 sum = sum + hh * 60 + mm ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def findLeaves(self, root: TreeNode) -> List[List[int]]: if not root: return [] ...
class Solution: def find_leaves(self, root: TreeNode) -> List[List[int]]: if not root: return [] res = [] while not self.isLeaf(root): res.append(self.getNextLeaves(root)) res.append([root.val]) return res def is_leaf(self, root) -> bool: ...
sheep_size = [5,7,300,90,24,50,75] print("Hello, my name is Duy Anh and these are my sheep sizes") print(sheep_size) biggest_sheep = max(sheep_size) print() print("Now my biggest sheep has size",biggest_sheep,"let's shear it")
sheep_size = [5, 7, 300, 90, 24, 50, 75] print('Hello, my name is Duy Anh and these are my sheep sizes') print(sheep_size) biggest_sheep = max(sheep_size) print() print('Now my biggest sheep has size', biggest_sheep, "let's shear it")
# https://app.codesignal.com/arcade/code-arcade/loop-tunnel/7BFPq6TpsNjzgcpXy/ def leastFactorial(n): # What's the highest factorial number that is bigger than n? i, fact = (1, 1) # Keep increasing a cumulative factorial until n can't no longer contain # it. If n becomes 1, then n was a factorial, if n ...
def least_factorial(n): (i, fact) = (1, 1) while n / fact > 1: fact *= i i += 1 return fact
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: node = parent = None def deleteNode(self, root: TreeNode, key: int) -> TreeNode: # search for the node and its parent self.findNodeAndParent(root, key) if s...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: node = parent = None def delete_node(self, root: TreeNode, key: int) -> TreeNode: self.findNodeAndParent(root, key) if self.node == root and (not root.left) and (...
student = { "firstName": "Prasad", "lastName": "Honrao", "age": 37 } try: #try to get wrong value from dictionary last_name = student["last_name"] except KeyError as error: print("Exception thrown!") print(error) print("Done!")
student = {'firstName': 'Prasad', 'lastName': 'Honrao', 'age': 37} try: last_name = student['last_name'] except KeyError as error: print('Exception thrown!') print(error) print('Done!')
class BaseAbort(object): def __init__(self, reason): self.reason = reason class PythonAbort(BaseAbort): def __init__(self, reason, pycode, lineno): super(PythonAbort, self).__init__(reason) self.pycode = pycode self.lineno = lineno def visit(self, visitor): return v...
class Baseabort(object): def __init__(self, reason): self.reason = reason class Pythonabort(BaseAbort): def __init__(self, reason, pycode, lineno): super(PythonAbort, self).__init__(reason) self.pycode = pycode self.lineno = lineno def visit(self, visitor): return...
coco_file = 'yolo/darknet/coco.names' yolo_cfg_file = 'yolo/darknet/yolov3-tiny.cfg' yolo_weights_file = 'yolo/darknet/yolov3-tiny.weights' img_size = (320,320) conf_threshold = 0.5 nms_threshold = 0.3
coco_file = 'yolo/darknet/coco.names' yolo_cfg_file = 'yolo/darknet/yolov3-tiny.cfg' yolo_weights_file = 'yolo/darknet/yolov3-tiny.weights' img_size = (320, 320) conf_threshold = 0.5 nms_threshold = 0.3
with open("log.txt", "r") as f: line = f.read() count = int(line) + 1 with open("log.txt", "w") as f: f.write(str(count))
with open('log.txt', 'r') as f: line = f.read() count = int(line) + 1 with open('log.txt', 'w') as f: f.write(str(count))
__title__ = 'grabstats' __description__ = 'Scrape NBA stats from Basketball-Reference' __url__ = 'https://github.com/kndo/grabstats' __version__ = '0.1.0' __author__ = 'Khanh Do' __author_email__ = 'dokhanh@gmail.com' __license__ = 'MIT License'
__title__ = 'grabstats' __description__ = 'Scrape NBA stats from Basketball-Reference' __url__ = 'https://github.com/kndo/grabstats' __version__ = '0.1.0' __author__ = 'Khanh Do' __author_email__ = 'dokhanh@gmail.com' __license__ = 'MIT License'
expected_output = { "ping": { "address": "2001:db8:223c:2c16::2", "data-bytes": 56, "result": [ { "bytes": 16, "from": "2001:db8:223c:2c16::2", "hlim": 64, "icmp-seq": 0, "time": "973.514", ...
expected_output = {'ping': {'address': '2001:db8:223c:2c16::2', 'data-bytes': 56, 'result': [{'bytes': 16, 'from': '2001:db8:223c:2c16::2', 'hlim': 64, 'icmp-seq': 0, 'time': '973.514'}, {'bytes': 16, 'from': '2001:db8:223c:2c16::2', 'hlim': 64, 'icmp-seq': 1, 'time': '0.993'}, {'bytes': 16, 'from': '2001:db8:223c:2c16...
#player class #constructor: player = white or black class Player: def __init__(self, player, username): self.player = player self.username = username def move(self, move): return def print(self): print(self.player) print(self.username) if __name__ == "__main__"...
class Player: def __init__(self, player, username): self.player = player self.username = username def move(self, move): return def print(self): print(self.player) print(self.username) if __name__ == '__main__': a = player('white', 'adarsh') a.print()
def joke(): return (u'Wenn ist das Nunst\u00fcck git und Slotermeyer? Ja! ... ' u'Beiherhund das Oder die Flipperwaldt gersput.')
def joke(): return u'Wenn ist das Nunstück git und Slotermeyer? Ja! ... Beiherhund das Oder die Flipperwaldt gersput.'
class HashSetString: _ARR_DEFAULT_LENGTH = 211 def __init__(self, arr_len=_ARR_DEFAULT_LENGTH): self._arr = [None,] * arr_len self._count = 0 def _hash_str_00(self, value): hashv = 0 for c in value: hashv = (hashv * 27 + ord(c)) % len(self._arr) return ha...
class Hashsetstring: _arr_default_length = 211 def __init__(self, arr_len=_ARR_DEFAULT_LENGTH): self._arr = [None] * arr_len self._count = 0 def _hash_str_00(self, value): hashv = 0 for c in value: hashv = (hashv * 27 + ord(c)) % len(self._arr) return ha...
class Solution: def validIPAddress(self, IP: str) -> str: res = 'Neither' if IP.count(".") == 3: for value in IP.split("."): temp_value = re.sub(r'[^0-9]', '', value) if not temp_value or not str(int(temp_value)) == value or...
class Solution: def valid_ip_address(self, IP: str) -> str: res = 'Neither' if IP.count('.') == 3: for value in IP.split('.'): temp_value = re.sub('[^0-9]', '', value) if not temp_value or not str(int(temp_value)) == value or int(temp_value) < 0 or (int(t...
# Escape the ' caracter story_description = 'It\'s a touching story' print(story_description) # Escape the \ caracter story_description = "It\\'s a touching story" print(story_description) # Break Line story_description = 'It\'s a \n touching \n story'
story_description = "It's a touching story" print(story_description) story_description = "It\\'s a touching story" print(story_description) story_description = "It's a \n touching \n story"
a = source() b = k if(a == w): b = c elif(a==y): b = d sink(b)
a = source() b = k if a == w: b = c elif a == y: b = d sink(b)
FORMER_TEAM_NAME_MAP = { 'AFC Bournemouth': 'AFC Bournemouth', 'Accrington FC': 'Accrington FC', 'Arsenal FC': 'Arsenal FC', 'Aston Villa': 'Aston Villa', 'Barnsley FC': 'Barnsley FC', 'Birmingham City': 'Birmingham City', 'Birmingham FC': 'Birmingham City', 'Blackburn Rovers': 'Blackbur...
former_team_name_map = {'AFC Bournemouth': 'AFC Bournemouth', 'Accrington FC': 'Accrington FC', 'Arsenal FC': 'Arsenal FC', 'Aston Villa': 'Aston Villa', 'Barnsley FC': 'Barnsley FC', 'Birmingham City': 'Birmingham City', 'Birmingham FC': 'Birmingham City', 'Blackburn Rovers': 'Blackburn Rovers', 'Blackpool FC': 'Black...
class RouteWithTooSmallCapacity(Exception): pass class RebalanceFailure(Exception): pass class NoRouteError(Exception): pass class DryRunException(Exception): pass class PaymentTimeOut(Exception): pass class TooExpensive(Exception): pass
class Routewithtoosmallcapacity(Exception): pass class Rebalancefailure(Exception): pass class Norouteerror(Exception): pass class Dryrunexception(Exception): pass class Paymenttimeout(Exception): pass class Tooexpensive(Exception): pass
QWORD = 8 DWORD = 4 WORD = 2 BYTE = 1
qword = 8 dword = 4 word = 2 byte = 1
# -*- coding: utf-8 -*- # # IceCream - Never use print() to debug again # # Ansgar Grunseid # grunseid.com # grunseid@gmail.com # # License: MIT # __title__ = 'icecream' __license__ = 'MIT' __version__ = '2.1.1' __author__ = 'Ansgar Grunseid' __contact__ = 'grunseid@gmail.com' __url__ = 'https://github.com/gruns/icec...
__title__ = 'icecream' __license__ = 'MIT' __version__ = '2.1.1' __author__ = 'Ansgar Grunseid' __contact__ = 'grunseid@gmail.com' __url__ = 'https://github.com/gruns/icecream' __description__ = 'Never use print() to debug again; inspect variables, expressions, and program execution with a single, simple function call....
all_datasets = { 'macdebug': 'macdebug', '128leftonly': 'ords062', '128w': 'ords064sc9', '128valsame': 'ords064sc9', }
all_datasets = {'macdebug': 'macdebug', '128leftonly': 'ords062', '128w': 'ords064sc9', '128valsame': 'ords064sc9'}
ternary = [0, 1, 2] ternary[0] = "true" ternary[1] = "maybe" ternary[2] = "false" x = 34 y = 34 if x > y: print(ternary[0]) elif x < y: print(ternary[2]) else: print(ternary[1])
ternary = [0, 1, 2] ternary[0] = 'true' ternary[1] = 'maybe' ternary[2] = 'false' x = 34 y = 34 if x > y: print(ternary[0]) elif x < y: print(ternary[2]) else: print(ternary[1])
# # PySNMP MIB module FDDI-SMT73-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/FDDI-SMT73-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:12:32 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52) # ...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint, constraints_union) ...
# Division print(5 / 8) # Addition print(7 + 10)
print(5 / 8) print(7 + 10)
# Password validation # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators AUTH_USER_MODEL = 'users.User' AUTHENTICATION_BACKENDS = [ 'pg_rest_api.backends.PGBackend', 'django.contrib.auth.backends.ModelBackend' ] AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.au...
auth_user_model = 'users.User' authentication_backends = ['pg_rest_api.backends.PGBackend', 'django.contrib.auth.backends.ModelBackend'] auth_password_validators = [{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValida...
def get_fp_addsub(f): return f["addpd"] + f["addsd"] + f["addss"] + f["addps"] + f["subpd"] + f["subsd"] + f["subss"] + f["subps"] def get_fp_muldiv(f): return f["mulpd"] + f["mulsd"] + f["mulss"] + f["mulps"] + f["divpd"] + f["divsd"] + f["divss"] + f["divps"]
def get_fp_addsub(f): return f['addpd'] + f['addsd'] + f['addss'] + f['addps'] + f['subpd'] + f['subsd'] + f['subss'] + f['subps'] def get_fp_muldiv(f): return f['mulpd'] + f['mulsd'] + f['mulss'] + f['mulps'] + f['divpd'] + f['divsd'] + f['divss'] + f['divps']
#!/usr/bin/python3 ## author: jinchoiseoul@gmail.com def parse_io(inp, out): ''' io means input/output for testcases; It splitlines them and strip the elements @param inp: multi-lined str @param out: multi-lined str @return (inp::[str], out::[str]) ''' inp = [i.strip() for i...
def parse_io(inp, out): """ io means input/output for testcases; It splitlines them and strip the elements @param inp: multi-lined str @param out: multi-lined str @return (inp::[str], out::[str]) """ inp = [i.strip() for i in inp.splitlines() if i.strip()] out = [o.strip()...
N = int(input()) A = [0]*N for i in N: A[i] = int(input())
n = int(input()) a = [0] * N for i in N: A[i] = int(input())
class BaseMeta(type): def __new__(cls, name, bases, namespace): return super().__new__(cls, name, bases, namespace) class MyMeta(BaseMeta): def __new__(cls, name, bases, namespace): return super().__new__(cls, name, bases, namespace)
class Basemeta(type): def __new__(cls, name, bases, namespace): return super().__new__(cls, name, bases, namespace) class Mymeta(BaseMeta): def __new__(cls, name, bases, namespace): return super().__new__(cls, name, bases, namespace)
f = open("Writetofile.txt", "a") f.write("Lipika\n") f.write("Ugain\n") f.write("Shivam\n") f.write("Sanjeev\n") print("Data written to the file using append mode") f.close()
f = open('Writetofile.txt', 'a') f.write('Lipika\n') f.write('Ugain\n') f.write('Shivam\n') f.write('Sanjeev\n') print('Data written to the file using append mode') f.close()
T = int(input()) def calc_op(l): cnt = 0 for i in range(len(l)): if l[i] % 2 == 0: cnt += l[i]//2 else: cnt += l[i]//2+1 return cnt for _ in range(T): N = int(input()) l = list(map(int, input().split()))[1:-1] if len(l) == 1: if l[0]%2 == 0: ...
t = int(input()) def calc_op(l): cnt = 0 for i in range(len(l)): if l[i] % 2 == 0: cnt += l[i] // 2 else: cnt += l[i] // 2 + 1 return cnt for _ in range(T): n = int(input()) l = list(map(int, input().split()))[1:-1] if len(l) == 1: if l[0] % 2 == ...
''' Represents a single filter on a column. ''' class DrawRequestColumnFilter: ''' Initialize the filter with the column name, filter text, and operation (must be "=", "<=", ">=", "<", ">", or "!="). ''' def __init__(self, column_name, filter_text, operation): self.name = column_name ...
""" Represents a single filter on a column. """ class Drawrequestcolumnfilter: """ Initialize the filter with the column name, filter text, and operation (must be "=", "<=", ">=", "<", ">", or "!="). """ def __init__(self, column_name, filter_text, operation): self.name = column_name ...
# -*- coding: utf-8 -*- __author__ = 'Jonathan Moore' __email__ = 'firstnamelastnamephd@gmail.com' __version__ = '0.1.0'
__author__ = 'Jonathan Moore' __email__ = 'firstnamelastnamephd@gmail.com' __version__ = '0.1.0'
# md5 : b27c56d844ab064547d40bf4f0a96eae # sha1 : c314e447018b0d8711347ee26a5795480837b2d3 # sha256 : c045615fe1b44a6409610e4e94e70f1559325eb55ab1f805b0452e852771c0ae ord_names = { 1: b'SQLAllocConnect', 2: b'SQLAllocEnv', 3: b'SQLAllocStmt', 4: b'SQLBindCol', 5: b'SQLCancel', 6: b'SQLColAttrib...
ord_names = {1: b'SQLAllocConnect', 2: b'SQLAllocEnv', 3: b'SQLAllocStmt', 4: b'SQLBindCol', 5: b'SQLCancel', 6: b'SQLColAttributes', 7: b'SQLConnect', 8: b'SQLDescribeCol', 9: b'SQLDisconnect', 10: b'SQLError', 11: b'SQLExecDirect', 12: b'SQLExecute', 13: b'SQLFetch', 14: b'SQLFreeConnect', 15: b'SQLFreeEnv', 16: b'SQ...
# part 1 def check_numbers(a,b): print (a+b) check_numbers(2,6) # part 2 def check_numbers_list(a,b): i=0 if len(a)==len(b): while i<len(a): check_numbers(a[i],b[i]) i +=1 else: print ("lists ki len barabar nahi hai") check_numbers_list([10,30,40],[40,20,21])
def check_numbers(a, b): print(a + b) check_numbers(2, 6) def check_numbers_list(a, b): i = 0 if len(a) == len(b): while i < len(a): check_numbers(a[i], b[i]) i += 1 else: print('lists ki len barabar nahi hai') check_numbers_list([10, 30, 40], [40, 20, 21])
num = int(input()) soma2 = 0 soma3 = 0 soma4 = 0 soma5 = 0 lista = [int(i) for i in input().split()] for i in range(num): if(lista[i] % 2 == 0): soma2 = soma2 + 1 if(lista[i] % 3 == 0): soma3 = soma3 + 1 if(lista[i] % 4 == 0): soma4 = soma4 + 1 if(lista[i] % 5 == 0)...
num = int(input()) soma2 = 0 soma3 = 0 soma4 = 0 soma5 = 0 lista = [int(i) for i in input().split()] for i in range(num): if lista[i] % 2 == 0: soma2 = soma2 + 1 if lista[i] % 3 == 0: soma3 = soma3 + 1 if lista[i] % 4 == 0: soma4 = soma4 + 1 if lista[i] % 5 == 0: soma5 = ...
def lambda_handler(event, context): name = event.get("name") if not name: name = "person who does not want to give their name" return { "hello": f"hello {name}"}
def lambda_handler(event, context): name = event.get('name') if not name: name = 'person who does not want to give their name' return {'hello': f'hello {name}'}
# print_squares_upto_limit(30) # //For limit = 30, output would be 1 4 9 16 25 # # print_cubes_upto_limit(30) # //For limit = 30, output would be 1 8 27 def print_squares_upto_limit(limit): i = 1 while i * i < limit: print(i*i, end = " ") i = i + 1 def print_cubes_upto_limit(limit): i = 1 ...
def print_squares_upto_limit(limit): i = 1 while i * i < limit: print(i * i, end=' ') i = i + 1 def print_cubes_upto_limit(limit): i = 1 while i * i * i < limit: print(i * i * i, end=' ') i = i + 1 print_cubes_upto_limit(80)
#!/usr/bin/env python print("test1 -- > 1") print("test1 -- > 2") print("test1 -- > 3")
print('test1 -- > 1') print('test1 -- > 2') print('test1 -- > 3')
flowers = input() qty = int(input()) budget = int(input()) price = 0 Roses = 5 Dahlias = 3.8 Tulips = 2.8 Narcissus = 3 Gladiolus = 2.5 if flowers == "Roses": if qty > 80: price = Roses * qty * 0.9 else: price = Roses * qty elif flowers == "Dahlias": if qty > 90: price = Dahlias *...
flowers = input() qty = int(input()) budget = int(input()) price = 0 roses = 5 dahlias = 3.8 tulips = 2.8 narcissus = 3 gladiolus = 2.5 if flowers == 'Roses': if qty > 80: price = Roses * qty * 0.9 else: price = Roses * qty elif flowers == 'Dahlias': if qty > 90: price = Dahlias * qt...
def get_divisors(n): sum = 1 for i in range(2, int(n ** 0.5 + 1)): if n % i == 0: sum += i sum += n / i return sum def find_amicable_pair(): total = 0 for x in range(1, 10001): a = get_divisors(x) b = get_divisors(a) if b == x and x != a: ...
def get_divisors(n): sum = 1 for i in range(2, int(n ** 0.5 + 1)): if n % i == 0: sum += i sum += n / i return sum def find_amicable_pair(): total = 0 for x in range(1, 10001): a = get_divisors(x) b = get_divisors(a) if b == x and x != a: ...
#sandwiches: def orderedsandwich(items): list_of_items = [] for item in items: list_of_items.append(item) print("This is items you ordered in your sandwich:") for item in list_of_items: print(item) orderedsandwich(['kela','aloo']) orderedsandwich(['cheese','poteto']) orderedsandwich(['...
def orderedsandwich(items): list_of_items = [] for item in items: list_of_items.append(item) print('This is items you ordered in your sandwich:') for item in list_of_items: print(item) orderedsandwich(['kela', 'aloo']) orderedsandwich(['cheese', 'poteto']) orderedsandwich(['uiyer'])
class Player: name: str hp: int mp: int skills: dict def __init__(self, name: str, hp: int, mp: int): self.name = name self.hp = hp self.mp = mp self.skills = {} self.guild = 'Unaffiliated' def add_skill(self, skill_name, mana_cost): skills = [x ...
class Player: name: str hp: int mp: int skills: dict def __init__(self, name: str, hp: int, mp: int): self.name = name self.hp = hp self.mp = mp self.skills = {} self.guild = 'Unaffiliated' def add_skill(self, skill_name, mana_cost): skills = [x ...
students_number=int(input("Enter number of Students :")) per_student_kharcha=int(input("Enter per student expense :")) total_kharcha=students_number*per_student_kharcha if total_kharcha<50000: print ("Ham kharche ke andar hai ") else: print ("kharche se bahar hai ")
students_number = int(input('Enter number of Students :')) per_student_kharcha = int(input('Enter per student expense :')) total_kharcha = students_number * per_student_kharcha if total_kharcha < 50000: print('Ham kharche ke andar hai ') else: print('kharche se bahar hai ')
# # Language constants # WELCOME = " Welcome to arpspoofKicker!" # # Universal # SELECT_AN_OPTION = "Select an option" # # main # MENU = "\n1. ARPSpoof a single device\n" \ "2. ARPSpoof a multiple devices\n" \ "E. Exit" MENU_1 = "\n1. ARPSpoof a single device\n" \ "2. ARPSpoof a multipl...
welcome = ' Welcome to arpspoofKicker!' select_an_option = 'Select an option' menu = '\n1. ARPSpoof a single device\n2. ARPSpoof a multiple devices\nE. Exit' menu_1 = '\n1. ARPSpoof a single device\n2. ARPSpoof a multiple devices\n3. Run thread(s) in queue\n4. Stop running thread(s)\n5. Print thread(s) status\nE. Sto...
class JackTokenizer: def __init__(self, src_file_name): self._line_index = 0 self._line_index = 0 self._lines = [] f = open(src_file_name) # First assesment of the Assembler for line in f.readlines(): strip_line = line.lstrip() # Skipping ...
class Jacktokenizer: def __init__(self, src_file_name): self._line_index = 0 self._line_index = 0 self._lines = [] f = open(src_file_name) for line in f.readlines(): strip_line = line.lstrip() if len(strip_line) == 0 or strip_line[0:2] == '//': ...
jolts = [0] while True: try: a = int(input()) jolts.append(a) except: break jolts.sort() jolts.append(jolts[-1] + 3) diffs = [0, 0] for i in range(1,len(jolts)): if jolts[i] - jolts[i-1] == 1: diffs[0] += 1 elif jolts[i] - jolts[i-1] == 3: diffs[1] += 1 print(di...
jolts = [0] while True: try: a = int(input()) jolts.append(a) except: break jolts.sort() jolts.append(jolts[-1] + 3) diffs = [0, 0] for i in range(1, len(jolts)): if jolts[i] - jolts[i - 1] == 1: diffs[0] += 1 elif jolts[i] - jolts[i - 1] == 3: diffs[1] += 1 print...
def gen_serial(username): log_10 = 0 log_14 = 0 log_15 = 0 eax = '' edx = '' ecx = '' for c in username: hex_symbol = hex(ord(c)) eax = hex_symbol eax = log_15 eax = eax << 2 log_10 = log_10 + eax eax = hex_symbol edx = log_10 edx = edx - int(eax, 16) eax = 0x0fa eax = eax ^ edx log_10 = e...
def gen_serial(username): log_10 = 0 log_14 = 0 log_15 = 0 eax = '' edx = '' ecx = '' for c in username: hex_symbol = hex(ord(c)) eax = hex_symbol eax = log_15 eax = eax << 2 log_10 = log_10 + eax eax = hex_symbol edx = log_10 e...
def clean_t (data): # Select columns to clean df = data # Create dummies using the items in the list of 'safety&security' column ss = df['safety_security'].dropna() df_new = df.join(ss.str.join('|').str.get_dummies().add_prefix('ss_')) # Drop 'safety_security' column df_new.drop('s...
def clean_t(data): df = data ss = df['safety_security'].dropna() df_new = df.join(ss.str.join('|').str.get_dummies().add_prefix('ss_')) df_new.drop('safety_security', axis=1, inplace=True) df_new['model'] = df.model.apply(lambda x: x[1]) df_new['make'] = df.make.str.strip('\n') df_new.drop(c...
#encoding=utf-8 #Manacher is to find the longest Palindrome substring #normally, the time complexity is O(n2) #In order to reduce the time complexity #It tries to use the previous palindrome data #to reduce the time complexsity to O(n) def FindLongestPalindrome(str_line): p = [1]* len(str_line) mx = 1 i...
def find_longest_palindrome(str_line): p = [1] * len(str_line) mx = 1 id = 0 for i in range(1, len(str_line)): if mx > i: p[i] = min(p[2 * id - i], mx - i) idx = p[i] while i + idx < len(str_line) and str_line[i - idx] == str_line[i + idx]: p[i] = p[i] + 1...
# gunicorn config file access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" "pid=%(p)s"' raw_env = [ 'FLASK_APP=webhook', ] bind="0.0.0.0:5000" workers=5 accesslog="-"
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" "pid=%(p)s"' raw_env = ['FLASK_APP=webhook'] bind = '0.0.0.0:5000' workers = 5 accesslog = '-'
# coding=utf-8 class NodeType: select = 'SELECT' insert = 'INSERT' delete = 'DELETE' update = 'UPDATE' train = 'TRAIN' register = 'REGISTER' load = 'LOAD' save = 'SAVE' connect = 'CONNECT' set = 'SET' alert = 'ALERT' create_table = 'CREATETABLE' drop_table = 'DROPTA...
class Nodetype: select = 'SELECT' insert = 'INSERT' delete = 'DELETE' update = 'UPDATE' train = 'TRAIN' register = 'REGISTER' load = 'LOAD' save = 'SAVE' connect = 'CONNECT' set = 'SET' alert = 'ALERT' create_table = 'CREATETABLE' drop_table = 'DROPTABLE' create_i...
sentence='I am interested in {num}' pi=3.14 print(sentence.format(num=pi)) e=2.712 print(sentence.format(num=e))
sentence = 'I am interested in {num}' pi = 3.14 print(sentence.format(num=pi)) e = 2.712 print(sentence.format(num=e))
l = [int(i) for i in input().split()] print("largest - ", max(l)) print('smallest - ', min(l)) print('2nd largest - ', sorted(l)[-2]) print('2nd smallest - ', sorted(l)[1])
l = [int(i) for i in input().split()] print('largest - ', max(l)) print('smallest - ', min(l)) print('2nd largest - ', sorted(l)[-2]) print('2nd smallest - ', sorted(l)[1])
N, M = list(map(int, input().split())) # N, M = (2, 3) def simple_add(n, m): if m == 0: return n elif m > 0: return simple_add(n + m, 0) else: return simple_add(n + m, 0) print(simple_add(N, M))
(n, m) = list(map(int, input().split())) def simple_add(n, m): if m == 0: return n elif m > 0: return simple_add(n + m, 0) else: return simple_add(n + m, 0) print(simple_add(N, M))
qtd=int(input()) if qtd>=0 and qtd<=1000: lista=[] for a in range(0,qtd): A=int(input()) while A<0 or A>10**6: A=int(input()) lista.append(A) acessos=0 dias=0 for a in lista: acessos+=a print(a, acessos) if acessos+a<10**6: ...
qtd = int(input()) if qtd >= 0 and qtd <= 1000: lista = [] for a in range(0, qtd): a = int(input()) while A < 0 or A > 10 ** 6: a = int(input()) lista.append(A) acessos = 0 dias = 0 for a in lista: acessos += a print(a, acessos) if acessos ...
class person: count=0 #class attribute def __init__(self,name="bol",age=23): #constructor self.__name=name #instance attribute self.__age=age #instance attribute person.count=person.count+1 def setname(self,name): self.__name=name def getname(self): retur...
class Person: count = 0 def __init__(self, name='bol', age=23): self.__name = name self.__age = age person.count = person.count + 1 def setname(self, name): self.__name = name def getname(self): return self.__name def display_info(self): print(self...
# # PySNMP MIB module ELTEX-IP-OSPF-IF-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-IP-OSPF-IF-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:45:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union, constraints_intersection, value_range_constraint, value_size_constraint) ...
# -*- coding: utf-8 -*- def main(): s = input().split() ans = list() for si in s: if '@' in si: is_at = False string = '' for sii in si: if sii == '@': if string != '': ans.append(strin...
def main(): s = input().split() ans = list() for si in s: if '@' in si: is_at = False string = '' for sii in si: if sii == '@': if string != '': ans.append(string) string = '' ...
# move.py # handles movement in the world def toRoom(server, player, command): ''' moves player from their currentRoom to newRoom ''' newRoom = None #print "cmd:" + str(command) #print "cmd0:" + str(command[0]) #print str(player.currentRoom.orderedExits) # args = <some int> if int(command[0]) <= len(player.cu...
def to_room(server, player, command): """ moves player from their currentRoom to newRoom """ new_room = None if int(command[0]) <= len(player.currentRoom.orderedExits): target_room = player.currentRoom.orderedExits[int(command[0]) - 1][0] for room in server.structureManager.masterRooms: ...
#!/usr/bin/env python3 # Testing apostraphes' in single quotes # if I were to: print('he's done') # error: compiler thinks the statement # is ended at the apostraphe after 'he'. # In order to print apostraphes and other # characters like it, escape them: print('he\'s done')
print("he's done")
# Given: A protein string P of length at most 1000 aa. # # Return: The total weight of P. Consult the monoisotopic mass table. table = {} tableFile = open("mass table.txt","r") for line in tableFile: table[line[0]]=float(line[4::].strip()) aaFile = open("input.txt","r") total = float(0) for aa in aaFile.read().re...
table = {} table_file = open('mass table.txt', 'r') for line in tableFile: table[line[0]] = float(line[4:].strip()) aa_file = open('input.txt', 'r') total = float(0) for aa in aaFile.read().replace('\n', ''): total += table[aa] print('%.3f' % total)
__author__ = "xTrinch" __email__ = "mojca.rojko@gmail.com" __version__ = "0.2.21" class NotificationError(Exception): pass default_app_config = 'fcm_django.apps.FcmDjangoConfig'
__author__ = 'xTrinch' __email__ = 'mojca.rojko@gmail.com' __version__ = '0.2.21' class Notificationerror(Exception): pass default_app_config = 'fcm_django.apps.FcmDjangoConfig'
''' Intuition Imagine you are writing a small compiler for your college project and one of the tasks (or say sub-tasks) for the compiler would be to detect if the parenthesis are in place or not. The algorithm we will look at in this article can be then used to process all the parenthesis in the program your compiler...
""" Intuition Imagine you are writing a small compiler for your college project and one of the tasks (or say sub-tasks) for the compiler would be to detect if the parenthesis are in place or not. The algorithm we will look at in this article can be then used to process all the parenthesis in the program your compiler...
kDragAttributeFromAE = [] kIncompatibleAttribute = [] kInvalidAttribute = [] kLayer = []
k_drag_attribute_from_ae = [] k_incompatible_attribute = [] k_invalid_attribute = [] k_layer = []
DOTNETIMPL = { "mono": None, "core": None, "net": None, } DOTNETOS = { "darwin": "@bazel_tools//platforms:osx", "linux": "@bazel_tools//platforms:linux", "windows": "@bazel_tools//platforms:windows", } DOTNETARCH = { "amd64": "@bazel_tools//platforms:x86_64", } DOTNETIMPL_OS_ARCH = ( ...
dotnetimpl = {'mono': None, 'core': None, 'net': None} dotnetos = {'darwin': '@bazel_tools//platforms:osx', 'linux': '@bazel_tools//platforms:linux', 'windows': '@bazel_tools//platforms:windows'} dotnetarch = {'amd64': '@bazel_tools//platforms:x86_64'} dotnetimpl_os_arch = (('mono', 'darwin', 'amd64'), ('mono', 'linux'...
def cheese_and_crackers(cheese_count, boxes_of_crackers): print("You have ", cheese_count, "cheese!") print("you have ", boxes_of_crackers," boxes of crackers!") print("Man that's enough for a party!") print("Get a blamnket.\n") print("We can just give the function numbers directly:") cheese_and_cracke...
def cheese_and_crackers(cheese_count, boxes_of_crackers): print('You have ', cheese_count, 'cheese!') print('you have ', boxes_of_crackers, ' boxes of crackers!') print("Man that's enough for a party!") print('Get a blamnket.\n') print('We can just give the function numbers directly:') cheese_and_cracke...
x=100 text="python tutorial" print(x) print(text) # Assign values to multiple variables x,y,z=10,20,30 print(x) print(y) print(z)
x = 100 text = 'python tutorial' print(x) print(text) (x, y, z) = (10, 20, 30) print(x) print(y) print(z)
p = [0, 4, 8, 6, 2, 10, 100000000] s=[] d = {} rem=10 for i in p: if i in d: d[i] += 1 else: d[i] = 1 for i in range(0,rem/2+1): if i in d: pair = [i, rem-i] if pair[0]==pair[1] and d[i]>=2: s.append(pair) elif pair[1] in d: s.append(pair) p...
p = [0, 4, 8, 6, 2, 10, 100000000] s = [] d = {} rem = 10 for i in p: if i in d: d[i] += 1 else: d[i] = 1 for i in range(0, rem / 2 + 1): if i in d: pair = [i, rem - i] if pair[0] == pair[1] and d[i] >= 2: s.append(pair) elif pair[1] in d: s.ap...
class Solution(object): def wordPattern(self, pattern, str): dic = {} dic2 = {} words = str.split(" ") if len(pattern) != len(words): return False i = 0 for cha in pattern: if cha in dic.keys(): if dic[cha] != words[i]: ...
class Solution(object): def word_pattern(self, pattern, str): dic = {} dic2 = {} words = str.split(' ') if len(pattern) != len(words): return False i = 0 for cha in pattern: if cha in dic.keys(): if dic[cha] != words[i]: ...
class Solution: def lastStoneWeight(self, stones: List[int]) -> int: while len(stones) > 1: stones.sort() a = stones.pop() b = stones.pop() last = a - b if last: stones.append(last) return stones[0] if stones else 0
class Solution: def last_stone_weight(self, stones: List[int]) -> int: while len(stones) > 1: stones.sort() a = stones.pop() b = stones.pop() last = a - b if last: stones.append(last) return stones[0] if stones else 0
class MyHashSet: def __init__(self): self.buckets = [] def hash(self, key: int) -> str: return chr(key) def add(self, key: int) -> None: val = self.hash(key) if val not in self.buckets: self.buckets.append(val) def remove(self, key: int) -> None: ...
class Myhashset: def __init__(self): self.buckets = [] def hash(self, key: int) -> str: return chr(key) def add(self, key: int) -> None: val = self.hash(key) if val not in self.buckets: self.buckets.append(val) def remove(self, key: int) -> None: v...
def min_number(num_list): min_num = None for num in num_list: if min_num is None or min_num > num: min_num = num return min_num
def min_number(num_list): min_num = None for num in num_list: if min_num is None or min_num > num: min_num = num return min_num
def pytest_addoption(parser): group = parser.getgroup("pypyjit options") group.addoption("--pypy", action="store", default=None, dest="pypy_c", help="the location of the JIT enabled pypy-c")
def pytest_addoption(parser): group = parser.getgroup('pypyjit options') group.addoption('--pypy', action='store', default=None, dest='pypy_c', help='the location of the JIT enabled pypy-c')
expected_output = { "interfaces": { "Port-channel20": { "description": "distacc Te1/1/1, Te2/1/1", "switchport_trunk_vlans": "9,51", "switchport_mode": "trunk", "ip_arp_inspection_trust": True, "ip_dhcp_snooping_trust": True, }, "Gi...
expected_output = {'interfaces': {'Port-channel20': {'description': 'distacc Te1/1/1, Te2/1/1', 'switchport_trunk_vlans': '9,51', 'switchport_mode': 'trunk', 'ip_arp_inspection_trust': True, 'ip_dhcp_snooping_trust': True}, 'GigabitEthernet0/0': {'vrf': 'Mgmt-vrf', 'shutdown': True, 'negotiation_auto': True}, 'GigabitE...
#SKill : array iteration #A UTF-8 character encoding is a variable width character encoding # that can vary from 1 to 4 bytes depending on the character. The structure of the encoding is as follows: #1 byte: 0xxxxxxx #2 bytes: 110xxxxx 10xxxxxx #3 bytes: 1110xxxx 10xxxxxx 10xxxxxx #4 bytes: 11110xxx 10xxxxxx 10xxxxxx ...
byte_masks = [None, 128, 224, 240, 248] byte_equal = [None, 0, 192, 224, 240] def utf8_validator(bytes): num_of_bytes = 4 cnt = 0 while cnt < len(bytes): while numOfBytes > 0: value = bytes[cnt] & BYTE_MASKS[numOfBytes] if value == BYTE_EQUAL[numOfBytes]: bre...
ES_HOST = 'localhost' ES_PORT = 9200 BULK_MAX_OPS_CNT = 1000 INDEX_NAME = 'cosc488' INDEX_SETTINGS_FP = 'properties/index_settings.json' DATA_DIR = 'data/docs' QUERIES_FP = 'data/queryfile.txt' QRELS_FP = 'data/qrel.txt' TRECEVAL_FP = 'bin/trec_eval'
es_host = 'localhost' es_port = 9200 bulk_max_ops_cnt = 1000 index_name = 'cosc488' index_settings_fp = 'properties/index_settings.json' data_dir = 'data/docs' queries_fp = 'data/queryfile.txt' qrels_fp = 'data/qrel.txt' treceval_fp = 'bin/trec_eval'
prev = None def check_bst(root): if not root: return True ans = check_bst(root.left) if ans == False: return False if prev and root.value < prev: return False global prev prev = root return check_bst(root.right)
prev = None def check_bst(root): if not root: return True ans = check_bst(root.left) if ans == False: return False if prev and root.value < prev: return False global prev prev = root return check_bst(root.right)
#!/usr/bin/python3.5 class MyClass: "This is a class" a = 10; def func(self): print('Hello World'); return 3; def my_function(a: MyClass): return a.func(); def other_function(b: my_function): a = MyClass(); return my_function(a); def object_function(obj: object): return 3;
class Myclass: """This is a class""" a = 10 def func(self): print('Hello World') return 3 def my_function(a: MyClass): return a.func() def other_function(b: my_function): a = my_class() return my_function(a) def object_function(obj: object): return 3
### PROBLEM 1 def main(): print("Name: Shaymae Senhaji") print("Favorite Food: Brie Cheese") print("Favorite Color: Red") print("Favorite Hobby: Traveling") if __name__ == "__main__": main() #Name: Shaymae Senhaji #Favorite Food: Brie Cheese #Favorite Color: Red #Favorite Hobby: Traveling
def main(): print('Name: Shaymae Senhaji') print('Favorite Food: Brie Cheese') print('Favorite Color: Red') print('Favorite Hobby: Traveling') if __name__ == '__main__': main()
## Does my number look big in this? ## 6 kyu ## https://www.codewars.com/kata/5287e858c6b5a9678200083c def narcissistic(value): total = 0 for digit in str(value): total += int(digit) ** len(str(value)) return value == total
def narcissistic(value): total = 0 for digit in str(value): total += int(digit) ** len(str(value)) return value == total
# This is the ball class that handles everything related to Balls class Ball: # The __init__ method is used to initialize class variables def __init__(self, position, velocity, acceleration): # Each ball has a position, velocity and acceleration self.position = position self.velocity = v...
class Ball: def __init__(self, position, velocity, acceleration): self.position = position self.velocity = velocity self.acceleration = acceleration def display(self): no_stroke() fill(255, 0, 0) ellipse(self.position.x, self.position.y, 50, 50) def move(se...
def hashfunction(key): sum=0 for i in key: sum+=ord(i) return sum%100 hashtable=[] def insertkey(key,value): hashkey=hashfunction(key) return hashtable[hashkey].append(value)
def hashfunction(key): sum = 0 for i in key: sum += ord(i) return sum % 100 hashtable = [] def insertkey(key, value): hashkey = hashfunction(key) return hashtable[hashkey].append(value)