content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
###---> type_function <---#### a=input("Enter a Number:") if a.isnumeric(): print(type(int(a))) elif len(a)>2 and "." in a and not a.endswith(".") and not a.startswith("."): print(type(float(a))) elif len(a)>1 and "j" in a: print(type(complex(a))) else: print(type(str(a))) ###---> type_function <---#### def type_of(...
a = input('Enter a Number:') if a.isnumeric(): print(type(int(a))) elif len(a) > 2 and '.' in a and (not a.endswith('.')) and (not a.startswith('.')): print(type(float(a))) elif len(a) > 1 and 'j' in a: print(type(complex(a))) else: print(type(str(a))) def type_of(elem): try: elem + 'h' ...
# Edit this file to override the default graphite settings, do not edit settings.py # Turn on debugging and restart apache if you ever see an "Internal Server Error" page #DEBUG = True # Set your local timezone (django will try to figure this out automatically) TIME_ZONE = 'UTC' # Setting MEMCACHE_HOSTS to be empty ...
time_zone = 'UTC' secret_key = 'notSoSecret123'
def is_year_leap(year): return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def days_in_month(year, month): if month in [1, 3, 5, 7, 8, 10, 12]: return 31 if month in [4, 6, 9, 11]: return 30 if month == 2: if is_year_leap(year): return 29 else: ...
def is_year_leap(year): return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def days_in_month(year, month): if month in [1, 3, 5, 7, 8, 10, 12]: return 31 if month in [4, 6, 9, 11]: return 30 if month == 2: if is_year_leap(year): return 29 else: ...
class Solution: def reverseVowels(self, s: str) -> str: left =0 right=len(s)-1 a=['a','e','i','o','u'] s_lst=list(s) while left <=right: while left<=right and s_lst[left] not in a: left+=1 while left<=right and s_lst[right] not in a: ...
class Solution: def reverse_vowels(self, s: str) -> str: left = 0 right = len(s) - 1 a = ['a', 'e', 'i', 'o', 'u'] s_lst = list(s) while left <= right: while left <= right and s_lst[left] not in a: left += 1 while left <= right and s_l...
class DictQuery(dict): def get(self, path, default = None): keys = path.split("/") val = None for key in keys: if val: if isinstance(val, list): val = [ v.get(key, default) if v else None for v in val] else: ...
class Dictquery(dict): def get(self, path, default=None): keys = path.split('/') val = None for key in keys: if val: if isinstance(val, list): val = [v.get(key, default) if v else None for v in val] else: va...
STATUSMARIO = 0x72B481 MOEDAS = 0x72C227 YOSHICOINS = 0x72C888 MARIO_PEQUENO = 0 MARIO_GRANDE = 1 MARIO_PENINHA = 2 MARIO_FLOR_DE_FOGO = 3
statusmario = 7517313 moedas = 7520807 yoshicoins = 7522440 mario_pequeno = 0 mario_grande = 1 mario_peninha = 2 mario_flor_de_fogo = 3
def getRootVal(root): return root[0] def setRootVal(root,newVal): root[0] = newVal def getLeftChild(root): return root[1] def getRightChild(root): return root[2]
def get_root_val(root): return root[0] def set_root_val(root, newVal): root[0] = newVal def get_left_child(root): return root[1] def get_right_child(root): return root[2]
# Copyright 2020 PCL & PKU # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, softwa...
params = [{'label': 'distribute', 'value': 'true'}, {'label': 'train_with_eval', 'value': 'true'}, {'label': 'eval_data_dir', 'value': '/cache/data/eval'}, {'label': 'data_dir', 'value': '/cache/data/train'}, {'label': 'enable_save_ckpt', 'value': 'false'}, {'label': 'enable_lossscale', 'value': 'true'}, {'label': 'do_...
class Solution: def reverseStr(self, s: str, k: int) -> str: n = len(s) s = list(s) for i in range(0, n, 2*k): # # tmp = s[i:i+k] # if k % 2 != 0: # SpanEnd = i+k//2+1 # for j in range(i, SpanEnd-1): # # print(i, j...
class Solution: def reverse_str(self, s: str, k: int) -> str: n = len(s) s = list(s) for i in range(0, n, 2 * k): s[i:i + k] = reversed(s[i:i + k]) return ''.join(s) solu = solution() (s, k) = ('abcdefg', 2) print(solu.reverseStr(s, k))
page = { 'node': 'posts', 'permalink': 'index', 'name': 'Dan', 'template': 'template', 'excerpts': [ { 'title': 'Alpha', 'permalink': "alpha", 'node': 'greekletters', 'date': 'today', 'author': 'Dan', 'content': 'Lorem ipsum dolor sit amet, con...
page = {'node': 'posts', 'permalink': 'index', 'name': 'Dan', 'template': 'template', 'excerpts': [{'title': 'Alpha', 'permalink': 'alpha', 'node': 'greekletters', 'date': 'today', 'author': 'Dan', 'content': 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore...
class Solution: def maxSubArray(self, nums): if len(nums) == 0: return 0 if len(nums) == 1: return nums[0] # init variables current_max = nums[0] current_sum = nums[0] for i in range(1, len(nums)): n = nums[i] if n...
class Solution: def max_sub_array(self, nums): if len(nums) == 0: return 0 if len(nums) == 1: return nums[0] current_max = nums[0] current_sum = nums[0] for i in range(1, len(nums)): n = nums[i] if n >= 0: if cu...
def mapmain(n): arraycomb=[0]*n x=0 mapcomb(n,1,x) def mapcomb(n,i,x): if n==0: print(arraycomb) else: for k in list(range(i,int((n/2)+1)))+[n]: arraycomb[x]=(k) mapcomb(n-k,k,x+1) def mapmain(y,x): arraycomb=[0]*x mapcomb(y,0,x) def mapcomb(n,i,x): if i==x-1: arraycomb[i]=n print...
def mapmain(n): arraycomb = [0] * n x = 0 mapcomb(n, 1, x) def mapcomb(n, i, x): if n == 0: print(arraycomb) else: for k in list(range(i, int(n / 2 + 1))) + [n]: arraycomb[x] = k mapcomb(n - k, k, x + 1) def mapmain(y, x): arraycomb = [0] * x mapcomb...
dictionary = dict() command = input() while ':' in command: data = command.split(':') product = data[0] quantity = int(data[1]) if product not in dictionary: dictionary[product] = quantity else: dictionary[product] += quantity command = input() print("Products in stock:") to...
dictionary = dict() command = input() while ':' in command: data = command.split(':') product = data[0] quantity = int(data[1]) if product not in dictionary: dictionary[product] = quantity else: dictionary[product] += quantity command = input() print('Products in stock:') total_p...
#insert this code to train function of predict_3dpose.py # export_dataset(train_set_2d,data_mean_2d,data_std_2d,train_set_3d,data_mean_3d,data_std_3d,"train.h5") # export_dataset(test_set_2d,data_mean_2d,data_std_2d,test_set_3d,data_mean_3d,data_std_3d,"test.h5") def export_dataset(train_set_2d,data_mean_2d,data_std...
def export_dataset(train_set_2d, data_mean_2d, data_std_2d, train_set_3d, data_mean_3d, data_std_3d, hdf5_name): data_x = train_set_2d data_y = train_set_3d camera_frame = FLAGS.camera_frame n = 0 for key2d in data_x.keys(): (n2d, _) = data_x[key2d].shape n = n + n2d encoder_inpu...
#Class holder containing imports to prevent circular imports imported={} diagram=None registered={} registered['types']=None registered['sheets']=None
imported = {} diagram = None registered = {} registered['types'] = None registered['sheets'] = None
p1 = input().split() x1, y1 = p1 p2 = input().split() x2, y2 = p2 dist =(((float(x2) - float(x1)) ** 2) + ((float(y2) - float(y1)) ** 2)) ** (1/2) print(f'{dist:.4f}')
p1 = input().split() (x1, y1) = p1 p2 = input().split() (x2, y2) = p2 dist = ((float(x2) - float(x1)) ** 2 + (float(y2) - float(y1)) ** 2) ** (1 / 2) print(f'{dist:.4f}')
# 6. * Tri-bit Switch # Write a program that inverts the 3 bits from position p to the left with their # XOR opposites (e.g. 111 -> 000, 101 -> 010) in 32-bit number. Print the resulting integer on the console. number = int(input()) p = int(input()) mask = 7 << p result = number ^ mask print(result)
number = int(input()) p = int(input()) mask = 7 << p result = number ^ mask print(result)
_base_ = './htc_hrnetv2p_w40_20e_coco.py' # learning policy lr_config = dict(step=[24, 27]) total_epochs = 28
_base_ = './htc_hrnetv2p_w40_20e_coco.py' lr_config = dict(step=[24, 27]) total_epochs = 28
# A program to calculate sqaure root of num_list elements class Program: def __init__(self, num_list): self.num_list = num_list def calcualte_square_root(self): return [num * num for num in self.num_list] def calculate_sq_root_using_map(self): squares = list(map(lambda num: num *...
class Program: def __init__(self, num_list): self.num_list = num_list def calcualte_square_root(self): return [num * num for num in self.num_list] def calculate_sq_root_using_map(self): squares = list(map(lambda num: num ** 2, self.num_list)) return squares num_list = [1, ...
# A Linked List Node class Node: def __init__(self, data, next=None): self.data = data self.next = next # Recursive function to check if the linked list is a palindrome or not def checkPalindrome(left, right): # base case if right is None: return True, left val, left = ch...
class Node: def __init__(self, data, next=None): self.data = data self.next = next def check_palindrome(left, right): if right is None: return (True, left) (val, left) = check_palindrome(left, right.next) result = val and left.data == right.data left = left.next return ...
# Printing # You can print other types besides strings; we'll get to that later print("Hello") print(1) print(99.99) # Strings can be in single or double quotes print("Message") print("Message") # You can print with multiple arguments # Arguments are separated by a space by default print("Message", "with", "argument...
print('Hello') print(1) print(99.99) print('Message') print('Message') print('Message', 'with', 'arguments') print('Message' + 'with' + 'concatenation')
def reverseWordOrder(str): return " ".join(str.split(" ")[::-1]) if __name__ == "__main__": print(reverseWordOrder("Hi my name is Gergo and I like Python"))
def reverse_word_order(str): return ' '.join(str.split(' ')[::-1]) if __name__ == '__main__': print(reverse_word_order('Hi my name is Gergo and I like Python'))
class ValidationError(Exception): pass class InvalidChecksum(ValidationError): pass class InvalidSourceError(InvalidChecksum): pass class InvalidModifiedError(InvalidChecksum): pass
class Validationerror(Exception): pass class Invalidchecksum(ValidationError): pass class Invalidsourceerror(InvalidChecksum): pass class Invalidmodifiederror(InvalidChecksum): pass
# application (route /, i.e. the main entry point) # required # default EPSG code for queried pair of coordinates (default EPSG code of OLC: 4326) DEFAULT_EPSG_IN = 4326 # default EPSG code for all returned pairs of coordinates DEFAULT_EPSG_OUT = 4326 # enable querying for regional Plus codes containing municipality ...
default_epsg_in = 4326 default_epsg_out = 4326 code_regional_in = True code_regional_out = True access_control_allow_origin = '*' municipality_forward_url = 'https://nominatim.openstreetmap.org/search?format=json' municipality_reverse_url = 'https://nominatim.openstreetmap.org/reverse?format=jsonv2&zoom=10' municipalit...
_base_ = [ '../../../../_base_/default_runtime.py', '../../../../_base_/datasets/panoptic_body3d.py' ] checkpoint_config = dict(interval=1) evaluation = dict(interval=1, metric='mAP', save_best='mAP') optimizer = dict( type='Adam', lr=0.0001, ) optimizer_config = dict(grad_clip=None) # learning policy ...
_base_ = ['../../../../_base_/default_runtime.py', '../../../../_base_/datasets/panoptic_body3d.py'] checkpoint_config = dict(interval=1) evaluation = dict(interval=1, metric='mAP', save_best='mAP') optimizer = dict(type='Adam', lr=0.0001) optimizer_config = dict(grad_clip=None) lr_config = dict(policy='step', warmup='...
#pragma repy try: pass except: pass
try: pass except: pass
class RomanNumeral(): NULL = 0 # Sentinel value. I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M = 1000 __members__ = { 'I' : I, 'V' : V, 'X' : X, 'L' : L, 'C' : C, 'D' : D, 'M' : M } class RomanNumber(): __KEYS = dict((v,k) for (k,v) in RomanNumeral.__members__.items()) def...
class Romannumeral: null = 0 i = 1 v = 5 x = 10 l = 50 c = 100 d = 500 m = 1000 __members__ = {'I': I, 'V': V, 'X': X, 'L': L, 'C': C, 'D': D, 'M': M} class Romannumber: __keys = dict(((v, k) for (k, v) in RomanNumeral.__members__.items())) def __init__(self, string): ...
def main(j, args, params, tags, tasklet): try: doc = args.doc out = [] account = tags.tagGet('account') repo = tags.tagGet('repo') provider = tags.tagGet('provider') # First try to get the version/branch from the build.xml if it is exists # this mean you are ...
def main(j, args, params, tags, tasklet): try: doc = args.doc out = [] account = tags.tagGet('account') repo = tags.tagGet('repo') provider = tags.tagGet('provider') cfg_path = j.sal.fs.joinPaths(j.dirs.BASEDIR, 'build.yaml') if j.sal.fs.exists(cfg_path): ...
# 4. Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple # which contains every number.Suppose the following input is supplied to the program: # 34,67,55,33,12,98 # Then, the output should be: # ['34', '67', '55', '33', '12', '98'] # ('34', '67', '55', '33', ...
numbers = input() numbers = numbers.split(',') list = [] for num in numbers: list.append(num) my_tuple = tuple(list) print(list) print(my_tuple)
prim_tags = { 'parameter': b'\x00', 'storage': b'\x01', 'code': b'\x02', 'False': b'\x03', 'Elt': b'\x04', 'Left': b'\x05', 'None': b'\x06', 'Pair': b'\x07', 'Right': b'\x08', 'Some': b'\x09', 'True': b'\x0A', 'Unit': b'\x0B', 'PACK': b'\x0C', 'UNPACK': b'\x0D', ...
prim_tags = {'parameter': b'\x00', 'storage': b'\x01', 'code': b'\x02', 'False': b'\x03', 'Elt': b'\x04', 'Left': b'\x05', 'None': b'\x06', 'Pair': b'\x07', 'Right': b'\x08', 'Some': b'\t', 'True': b'\n', 'Unit': b'\x0b', 'PACK': b'\x0c', 'UNPACK': b'\r', 'BLAKE2B': b'\x0e', 'SHA256': b'\x0f', 'SHA512': b'\x10', 'ABS':...
number_of_pages = int(input()) pages_for_1_hour = int(input()) number_of_days = int(input()) time_needed_for_book = number_of_pages / pages_for_1_hour hours_per_day = time_needed_for_book / number_of_days print(hours_per_day)
number_of_pages = int(input()) pages_for_1_hour = int(input()) number_of_days = int(input()) time_needed_for_book = number_of_pages / pages_for_1_hour hours_per_day = time_needed_for_book / number_of_days print(hours_per_day)
def process_line(line): policy, password = line.split(":") password = password.strip() limits, char = policy.split(" ") lower, higher = [int(n) - 1 for n in limits.split("-")] return (password[lower] == char) != (password[higher] == char) with open("inputs/day02.input", "r") as in_file: count ...
def process_line(line): (policy, password) = line.split(':') password = password.strip() (limits, char) = policy.split(' ') (lower, higher) = [int(n) - 1 for n in limits.split('-')] return (password[lower] == char) != (password[higher] == char) with open('inputs/day02.input', 'r') as in_file: co...
A=int(input()) B=int(input()) B2=B**2 if (B-2) > 0 : C=A % (B-2) if ((A==B2) and (C==0)): print ("100%") elif ((A==B2) and (C!=0)): print ("50%") else: print ("0%")
a = int(input()) b = int(input()) b2 = B ** 2 if B - 2 > 0: c = A % (B - 2) if A == B2 and C == 0: print('100%') elif A == B2 and C != 0: print('50%') else: print('0%')
num = int(input("Enter an integer: ")) isprime = 1 for i in range(2,num//2): if (num%i==0): isprime = 0 break if(isprime==1): print(num, "is a prime number") else: print(num, "is not a prime number")
num = int(input('Enter an integer: ')) isprime = 1 for i in range(2, num // 2): if num % i == 0: isprime = 0 break if isprime == 1: print(num, 'is a prime number') else: print(num, 'is not a prime number')
def multiply(times): def decorator(function): def wrapper(number): result = function(number) * times return result return wrapper return decorator @multiply(3) def add_ten(number): return number + 10 print(add_ten(3))
def multiply(times): def decorator(function): def wrapper(number): result = function(number) * times return result return wrapper return decorator @multiply(3) def add_ten(number): return number + 10 print(add_ten(3))
while True: answer = input("Why do you like programming? Enter 'q' to quit\n") if answer == 'q': break with open('r_programming', 'a') as file_object: file_object.write(answer + "\n")
while True: answer = input("Why do you like programming? Enter 'q' to quit\n") if answer == 'q': break with open('r_programming', 'a') as file_object: file_object.write(answer + '\n')
class Solution: def backtracking(self, nums: List[int], tmp: List[int], res: List[List[int]], visited: List[int]) -> List[List[int]]: if len(nums) == len(tmp): res.append(tmp[:]) else: for i in range(len(nums)): if visited[i] or i > 0 and nums[i - 1] == nums[i...
class Solution: def backtracking(self, nums: List[int], tmp: List[int], res: List[List[int]], visited: List[int]) -> List[List[int]]: if len(nums) == len(tmp): res.append(tmp[:]) else: for i in range(len(nums)): if visited[i] or (i > 0 and nums[i - 1] == nums...
partidas = list() fuut = {'nome': str(input('Qual o nome do jogador? '))} tot = int(input(f'Quantas partidas {fuut["nome"]} jogou? ')) for c in range(1, tot + 1): partidas.append(int(input(f'Quantos gols na partida {c}? '))) fuut['gols'] = partidas[:] fuut['total'] = sum(partidas) print('=-=' * 20, f'\nDicionario: ...
partidas = list() fuut = {'nome': str(input('Qual o nome do jogador? '))} tot = int(input(f"Quantas partidas {fuut['nome']} jogou? ")) for c in range(1, tot + 1): partidas.append(int(input(f'Quantos gols na partida {c}? '))) fuut['gols'] = partidas[:] fuut['total'] = sum(partidas) print('=-=' * 20, f'\nDicionario: ...
expected_output = { 'interfaces': { 'Port-channel1': { 'last_update_success': True, 'total_ports': 2, 'up_ports': 2, 'first_oper_port': 'Ethernet1/1', 'port_channel_age': '0d:02h:31m:22s', 'time_last_bundle': '0d:02h:28m:30s', ...
expected_output = {'interfaces': {'Port-channel1': {'last_update_success': True, 'total_ports': 2, 'up_ports': 2, 'first_oper_port': 'Ethernet1/1', 'port_channel_age': '0d:02h:31m:22s', 'time_last_bundle': '0d:02h:28m:30s', 'last_bundled_member': 'Ethernet1/2', 'members': {'Ethernet1/1': {'activity': 'active', 'status'...
class AllostericParams(object): def __init__(self, args): self.allosteric = args.allosteric self.n_components = args.n_components if args.n_components else self.simulation_params.get("n_components", 10)
class Allostericparams(object): def __init__(self, args): self.allosteric = args.allosteric self.n_components = args.n_components if args.n_components else self.simulation_params.get('n_components', 10)
def addStrings(num1: str, num2: str) -> str: num1, num2 = list(num1), list(num2) carry, res = 0, [] while len(num1) > 0 or len(num2) > 0: n1 = n2 = 0 if num1: n1 = ord(num1.pop()) - ord('0') if num2: n2 = ord(num2.pop()) - ord('0') temp = n1 + n2 + ...
def add_strings(num1: str, num2: str) -> str: (num1, num2) = (list(num1), list(num2)) (carry, res) = (0, []) while len(num1) > 0 or len(num2) > 0: n1 = n2 = 0 if num1: n1 = ord(num1.pop()) - ord('0') if num2: n2 = ord(num2.pop()) - ord('0') temp = n1 +...
#exercicio 69 homems = mulheresvinte = dezoito = 0 while True: print ('-'*60) print ('Cadastre uma pessoa') print ('-'*60) idade = int(input('Qual sua idade: ')) sexo = str(input('Qual seu sexo: [M/F] ')) print ('-'*60) if sexo in 'Mm': homems += 1 elif sexo in 'Ff' and idade < 2...
homems = mulheresvinte = dezoito = 0 while True: print('-' * 60) print('Cadastre uma pessoa') print('-' * 60) idade = int(input('Qual sua idade: ')) sexo = str(input('Qual seu sexo: [M/F] ')) print('-' * 60) if sexo in 'Mm': homems += 1 elif sexo in 'Ff' and idade < 20: m...
rs = [306] for _ in range(10**5): rs.append((rs[-1]**2)%10007) K = 500 M = 10 ps = [0] * K for t in range(200): nps = [0] * K for i in range(K): for j in range(M): q = rs[i*M+j]%5 if q == 0: nps[i] += 1. elif q == 1: ...
rs = [306] for _ in range(10 ** 5): rs.append(rs[-1] ** 2 % 10007) k = 500 m = 10 ps = [0] * K for t in range(200): nps = [0] * K for i in range(K): for j in range(M): q = rs[i * M + j] % 5 if q == 0: nps[i] += 1.0 elif q == 1: nps[...
def RequestAction(Action, OBD): Result = "error"; if Action == b"Connect": Result = OBD.ConnectToOBD() return Result
def request_action(Action, OBD): result = 'error' if Action == b'Connect': result = OBD.ConnectToOBD() return Result
#based on SparkFunISL29125.h # ISL29125 I2C Address ISL_I2C_ADDR = 0x44 # ISL29125 Registers DEVICE_ID = 0x00 CONFIG_1 = 0x01 CONFIG_2 = 0x02 CONFIG_3 = 0x03 THRESHOLD_LL = 0x04 THRESHOLD_LH = 0x05 THRESHOLD_HL = 0x06 THRESHOLD_HH = 0x07 STATUS = 0x08 GREEN_L = 0x09 GREEN_H = 0x0A RED_L = 0x0B RED_H = 0x0C BLUE_L =...
isl_i2_c_addr = 68 device_id = 0 config_1 = 1 config_2 = 2 config_3 = 3 threshold_ll = 4 threshold_lh = 5 threshold_hl = 6 threshold_hh = 7 status = 8 green_l = 9 green_h = 10 red_l = 11 red_h = 12 blue_l = 13 blue_h = 14 cfg_default = 0 cfg1_mode_powerdown = 0 cfg1_mode_g = 1 cfg1_mode_r = 2 cfg1_mode_b = 3 cfg1_mode_...
class StateWinner: def __str__(self): return "winner" def __init__(self, winners, players): self.winners = winners self.players = players @property def json(self): return { "winners": [player.json for player in self.winners], "players": [player.j...
class Statewinner: def __str__(self): return 'winner' def __init__(self, winners, players): self.winners = winners self.players = players @property def json(self): return {'winners': [player.json for player in self.winners], 'players': [player.json for player in self.p...
tuxURL = "https://tuxexchange.com/api" poloURL = "https://poloniex.com/public" BUY = 'buy' SELL = 'sell' ID = 'id' PRICE = 'price' USER_ID = 'user_id' AMOUNT = 'amount' known_exchanges = { 'tux': 'tux', 'polo': 'polo', 'bit': 'bit', 'test': 'test', 'bina': 'bina' } known_assets = { 'XMR': 'XMR'...
tux_url = 'https://tuxexchange.com/api' polo_url = 'https://poloniex.com/public' buy = 'buy' sell = 'sell' id = 'id' price = 'price' user_id = 'user_id' amount = 'amount' known_exchanges = {'tux': 'tux', 'polo': 'polo', 'bit': 'bit', 'test': 'test', 'bina': 'bina'} known_assets = {'XMR': 'XMR', 'BTC': 'BTC', 'PEPECASH'...
my_list = [0, 1, 2, 3, 4] an_equal_list = [x for x in range(5)] multiply_list = [x * 3 for x in range(5)] print(multiply_list) odds = [n for n in range(10) if n % 2 == 0] print("Odds", odds) people_you_know = ["Rolf", "AnnA", "GREG"] normalised_people = [person.lower() for person in people_you_know] print("Normalis...
my_list = [0, 1, 2, 3, 4] an_equal_list = [x for x in range(5)] multiply_list = [x * 3 for x in range(5)] print(multiply_list) odds = [n for n in range(10) if n % 2 == 0] print('Odds', odds) people_you_know = ['Rolf', 'AnnA', 'GREG'] normalised_people = [person.lower() for person in people_you_know] print('Normalised:'...
r=int(input("Rate the product from 0 to 10 : ")) def checking_your_Emotion(r): if r in range(0,4): print("You are angry with the service") elif r in range(5,7): print("You're OK with our service") else : print("You're very much satisfied") checking_your_Emotion(r)
r = int(input('Rate the product from 0 to 10 : ')) def checking_your__emotion(r): if r in range(0, 4): print('You are angry with the service') elif r in range(5, 7): print("You're OK with our service") else: print("You're very much satisfied") checking_your__emotion(r)
a,b=input().split();n=len(a);m=len(b) ridx=-1;cidx=-1;f=False;r="" for i in a: if not f: if i in b: f=True ridx=b.index(i) cidx=a.index(i) for i in range(m): if i==ridx: r+=a+'\n' else: r+='.'*cidx+b[i]+'.'*(n-1-cidx)+'\n' print(r,end="")
(a, b) = input().split() n = len(a) m = len(b) ridx = -1 cidx = -1 f = False r = '' for i in a: if not f: if i in b: f = True ridx = b.index(i) cidx = a.index(i) for i in range(m): if i == ridx: r += a + '\n' else: r += '.' * cidx + b[i] + '.' * (n...
#!/usr/bin/env python def tag_user_data(value): '''Adds tags to user data so that it can be redacted later''' return '<ud>' + str(value) + '</ud>'
def tag_user_data(value): """Adds tags to user data so that it can be redacted later""" return '<ud>' + str(value) + '</ud>'
def maxlist(l): max=0 for i in range(len(l)): if(l[i]>max): max=l[i] return max w=[] n=int(input("give no ")) for j in range(n): t=int(input()) w.append(t) print(maxlist(w))
def maxlist(l): max = 0 for i in range(len(l)): if l[i] > max: max = l[i] return max w = [] n = int(input('give no ')) for j in range(n): t = int(input()) w.append(t) print(maxlist(w))
def say_little_hi(): ''' Hello Name ''' name = input('Please enter your name: ') name_s = name.lower() print('Hello there', name_s + '.') def print_date(year, month, day): ''' Print out the date, formatted as year-month-day ''' print(str(year)+'-'+str(month)+'-'+str(day)) def...
def say_little_hi(): """ Hello Name """ name = input('Please enter your name: ') name_s = name.lower() print('Hello there', name_s + '.') def print_date(year, month, day): """ Print out the date, formatted as year-month-day """ print(str(year) + '-' + str(month) + '-' + str(day)) def address(s...
x = 10 print("not (0 <= x and x < 10)", not (0 <= x and x < 10)) print("0 <= x or x < 10", 0 <= x or x < 10) print("not (0 <= x and x < 10)", not (0 <= x and x < 10)) print("DE MORGAN: not (0 <= x) and not (x < 10)", not (0 <= x) and not (x < 10)) for x in range(5): for y in range(4): print(x, y)
x = 10 print('not (0 <= x and x < 10)', not (0 <= x and x < 10)) print('0 <= x or x < 10', 0 <= x or x < 10) print('not (0 <= x and x < 10)', not (0 <= x and x < 10)) print('DE MORGAN: not (0 <= x) and not (x < 10)', not 0 <= x and (not x < 10)) for x in range(5): for y in range(4): print(x, y)
{ "targets": [ { "target_name": "hello", "sources": [ "src/hello.cc" ] }, { "target_name": "add", "sources": [ "src/add.cc" ] }, { "target_name": "callback", "sources": [ "src/callback.cc" ] }, { "target_name": "objFactory", ...
{'targets': [{'target_name': 'hello', 'sources': ['src/hello.cc']}, {'target_name': 'add', 'sources': ['src/add.cc']}, {'target_name': 'callback', 'sources': ['src/callback.cc']}, {'target_name': 'objFactory', 'sources': ['src/objFactory.cc']}, {'target_name': 'funFactory', 'sources': ['src/funFactory.cc']}]}
class Archery: def expectedPoints(self, N, ringPoints): return sum(i*r for i, r in zip(xrange(1, 2*(N+1), 2), ringPoints)) / \ float(sum(xrange(1, 2*(N+1), 2)))
class Archery: def expected_points(self, N, ringPoints): return sum((i * r for (i, r) in zip(xrange(1, 2 * (N + 1), 2), ringPoints))) / float(sum(xrange(1, 2 * (N + 1), 2)))
''' Title : Power - Mod Power Subdomain : Math Domain : Python Author : codeperfectplus Created : 17 January 2020 ''' # Enter your code here. Read input from STDIN. Print output to STDOUT a,b,m = [int(input()) for _ in range(3)] print(pow(a,b),pow(a,b,m),sep='\n')
""" Title : Power - Mod Power Subdomain : Math Domain : Python Author : codeperfectplus Created : 17 January 2020 """ (a, b, m) = [int(input()) for _ in range(3)] print(pow(a, b), pow(a, b, m), sep='\n')
def p_expression_plus(p): '''expression : expression PLUS term''' p[0] = p[1] + p[3] def p_expression_term(p): '''expression : term''' p[0] = p[1]
def p_expression_plus(p): """expression : expression PLUS term""" p[0] = p[1] + p[3] def p_expression_term(p): """expression : term""" p[0] = p[1]
a = [float(x) for x in input().split()] # a[0] = x1 , a[1] = y1 b = [float(y) for y in input().split()] # b[0] = x2 , b[1] = y2 temp_1 = (b[0] - a[0]) * (b[0] - a[0]) temp_2 = (b[1] - a[1]) * (b[1] - a[1]) distance = (temp_1 + temp_2) ** 0.5 print(f"{distance:.4f}")
a = [float(x) for x in input().split()] b = [float(y) for y in input().split()] temp_1 = (b[0] - a[0]) * (b[0] - a[0]) temp_2 = (b[1] - a[1]) * (b[1] - a[1]) distance = (temp_1 + temp_2) ** 0.5 print(f'{distance:.4f}')
linelist = [line for line in open('Day 04.input').readlines()] draws = linelist[0].strip().split(',') b_side = 5 boards = [] for i in range(0, (int(len(linelist[1:]) / (b_side + 1)))): board = {} b_solved = [0] * (b_side * 2) for row in range(0, b_side): line = linelist[1 * (i + 1) + b_side * i +...
linelist = [line for line in open('Day 04.input').readlines()] draws = linelist[0].strip().split(',') b_side = 5 boards = [] for i in range(0, int(len(linelist[1:]) / (b_side + 1))): board = {} b_solved = [0] * (b_side * 2) for row in range(0, b_side): line = linelist[1 * (i + 1) + b_side * i + row ...
CURRENCY = 'Euro' CUPS_PER_DAY = { 'John': 4, 'Paul': 6, 'George': 3, 'Ringo': 1 }
currency = 'Euro' cups_per_day = {'John': 4, 'Paul': 6, 'George': 3, 'Ringo': 1}
class Solution: def stringShift(self, s: str, shift: List[List[int]]) -> str: move = 0 # left: -1, right: 1 for direction, amount in shift: x = direction if direction == 1 else -1 move += x * amount move = move % len(s) return s[-move: ] + ...
class Solution: def string_shift(self, s: str, shift: List[List[int]]) -> str: move = 0 for (direction, amount) in shift: x = direction if direction == 1 else -1 move += x * amount move = move % len(s) return s[-move:] + s[:-move]
if 10 % 3 == 1: # true pass if 10 % 0 == 5: # none pass
if 10 % 3 == 1: pass if 10 % 0 == 5: pass
class Solution: def multiply(self, num1: str, num2: str) -> str: if num1 == "0" or num2 == "0": return "0" res = [] for loc in range(len(num2)): # multiply x2 = ord(num2[len(num2) - 1 - loc]) - ord('0') ans, tmp, car = [], 0, 0 for n1 in num1[::-1]: ...
class Solution: def multiply(self, num1: str, num2: str) -> str: if num1 == '0' or num2 == '0': return '0' res = [] for loc in range(len(num2)): x2 = ord(num2[len(num2) - 1 - loc]) - ord('0') (ans, tmp, car) = ([], 0, 0) for n1 in num1[::-1]: ...
PORT=5000 DEBUG = True # Set to False for production use secret_key="080aadd8615b023b1c296cd90f65989c" poi="data/poi.txt"
port = 5000 debug = True secret_key = '080aadd8615b023b1c296cd90f65989c' poi = 'data/poi.txt'
# -*- coding: utf-8 -*- INSTAGRAMMER = 'ahmad_monk' # STOP_CRAWL = 24 # after this hours, spider stops BOT_NAME = 'InsPhoto' SPIDER_MODULES = ['InsPhoto.spiders'] NEWSPIDER_MODULE = 'InsPhoto.spiders' # since dowmloder middlewares set to 100, this is not used # USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X ...
instagrammer = 'ahmad_monk' bot_name = 'InsPhoto' spider_modules = ['InsPhoto.spiders'] newspider_module = 'InsPhoto.spiders' robotstxt_obey = False downloader_middlewares = {'InsPhoto.middlewares.InsPhotoDownloaderMiddleware': 100, 'scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware': None, 'scrapy.downloadermid...
WINDOW_P_VALUE = 0.20 BIN_SIZE = 0.001 E_VALUE = 1000 E_VALUE_THRESHOLD = E_VALUE * .0000001
window_p_value = 0.2 bin_size = 0.001 e_value = 1000 e_value_threshold = E_VALUE * 1e-07
''' Bipartite graph class Adapted from: https://github.com/dilsonpereira/BipartiteMatching ''' class BipartiteGraph(): def __init__(self, U, V, E = [], W = None): '''Class constructor U and V are iterables containing the vertices in the left and right partitions vertices can be any hashab...
""" Bipartite graph class Adapted from: https://github.com/dilsonpereira/BipartiteMatching """ class Bipartitegraph: def __init__(self, U, V, E=[], W=None): """Class constructor U and V are iterables containing the vertices in the left and right partitions vertices can be any hashable obj...
Kansas = {"Pais": "Estados Unidos", "Poblacion": "2,911,641 habitantes", "dato": "Su capital es Topeka y su ciudad mas poblada es Wichita"} Venecia = {"Pais": "Italia", "poblacion": "261,905 habitantes", "dato":"Tiene un centro historico declarado patrimonio de la humanidad"} Paris = {"Pais": "Francia", "poblacion":"2,...
kansas = {'Pais': 'Estados Unidos', 'Poblacion': '2,911,641 habitantes', 'dato': 'Su capital es Topeka y su ciudad mas poblada es Wichita'} venecia = {'Pais': 'Italia', 'poblacion': '261,905 habitantes', 'dato': 'Tiene un centro historico declarado patrimonio de la humanidad'} paris = {'Pais': 'Francia', 'poblacion': '...
#!/usr/bin/env python ''' Copyright (C) 2020, WAFW00F Developers. See the LICENSE file for copying permission. ''' NAME = 'Distil (Distil Networks)' def is_waf(self): schemes = [ self.matchContent(r'cdn\.distilnetworks\.com/images/anomaly\.detected\.png'), self.matchContent(r'distilCaptchaForm'),...
""" Copyright (C) 2020, WAFW00F Developers. See the LICENSE file for copying permission. """ name = 'Distil (Distil Networks)' def is_waf(self): schemes = [self.matchContent('cdn\\.distilnetworks\\.com/images/anomaly\\.detected\\.png'), self.matchContent('distilCaptchaForm'), self.matchContent('distilCallbackGuard...
# # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) # # SPDX-License-Identifier: BSD-2-Clause # loops_by_fs = { 'Arch_createObject': { 0xf0013fb8 : ( 0x800, 'InductiveBinSearch') , 0xf0013fec : ( 256, 'InductiveBinSearch') , 0xf0014060 : ( 256, 'InductiveBinSearch') , 0xf00140a0 : ( 512, 'InductiveBinSearch') ,...
loops_by_fs = {'Arch_createObject': {4026613688: (2048, 'InductiveBinSearch'), 4026613740: (256, 'InductiveBinSearch'), 4026613856: (256, 'InductiveBinSearch'), 4026613920: (512, 'InductiveBinSearch'), 4026614032: (64, 'InductiveBinSearch'), 4026614096: (8192, 'InductiveBinSearch'), 4026614208: (1024, 'InductiveBinSear...
class Solution: def reverseWords(self, s: str) -> str: s = s.split(" ") s = [i for i in s if len(i)>0] if len(s)<=1: return "".join(s) res = [""]*len(s) l,r = 0,len(s)-1 while l<r: ...
class Solution: def reverse_words(self, s: str) -> str: s = s.split(' ') s = [i for i in s if len(i) > 0] if len(s) <= 1: return ''.join(s) res = [''] * len(s) (l, r) = (0, len(s) - 1) while l < r: (s[l], s[r]) = (s[r], s[l]) res[l...
def main(a, b, c): d = 0 if a > b: if b > c: c = b a = b d = a * c else: c = a * b a = c - b d = a - c d = d * 5 else: d = b return d
def main(a, b, c): d = 0 if a > b: if b > c: c = b a = b d = a * c else: c = a * b a = c - b d = a - c d = d * 5 else: d = b return d
class ModelResponse: @staticmethod def map_weights(weights): return weights.tolist() def __init__(self, model): self.model = {"id": model.id, "weights": self.map_weights(model.model.weights), "type": model.model_type, "status...
class Modelresponse: @staticmethod def map_weights(weights): return weights.tolist() def __init__(self, model): self.model = {'id': model.id, 'weights': self.map_weights(model.model.weights), 'type': model.model_type, 'status': model.status, 'creation_date': model.creation_date, 'updated_d...
class Stack: def __init__(self): self.array = [] pass def pop(self): if self.size() < 1: return None elem = self.array[-1] self.array = self.array[:-1] return elem def peek(self): return self.array[-1] def size(self): return ...
class Stack: def __init__(self): self.array = [] pass def pop(self): if self.size() < 1: return None elem = self.array[-1] self.array = self.array[:-1] return elem def peek(self): return self.array[-1] def size(self): return...
f = open("word_database.csv","r") lines = f.readlines() f.close() words = [] i = 0 for line in lines: if i<2048: k = line.split(" ") words.append(k[1]) else: break i+=1 f = open("MnemonicWords.go","w") fileString = "" for word in words: fileString += "\"" + word + "\", " f.write(fileString) f.close()
f = open('word_database.csv', 'r') lines = f.readlines() f.close() words = [] i = 0 for line in lines: if i < 2048: k = line.split(' ') words.append(k[1]) else: break i += 1 f = open('MnemonicWords.go', 'w') file_string = '' for word in words: file_string += '"' + word + '", ' f....
myColl = db.get_collection('my_collection') # Only prepare a Collection.remove() operation, but do not run it yet myRemove = myColl.remove('name = :param1 AND age = :param2') # Binding parameters to the prepared function and .execute() myRemove.bind('param1', 'mike').bind('param2', 39).execute() myRemove.bind(...
my_coll = db.get_collection('my_collection') my_remove = myColl.remove('name = :param1 AND age = :param2') myRemove.bind('param1', 'mike').bind('param2', 39).execute() myRemove.bind('param1', 'johannes').bind('param2', 28).execute() my_find = myColl.find('name like :param1 AND age > :param2') my_docs = myFind.bind('par...
data = ( 'dwaen', # 0x00 'dwaenj', # 0x01 'dwaenh', # 0x02 'dwaed', # 0x03 'dwael', # 0x04 'dwaelg', # 0x05 'dwaelm', # 0x06 'dwaelb', # 0x07 'dwaels', # 0x08 'dwaelt', # 0x09 'dwaelp', # 0x0a 'dwaelh', # 0x0b 'dwaem', # 0x0c 'dwaeb', # 0x0d 'dwaebs', # 0x0e ...
data = ('dwaen', 'dwaenj', 'dwaenh', 'dwaed', 'dwael', 'dwaelg', 'dwaelm', 'dwaelb', 'dwaels', 'dwaelt', 'dwaelp', 'dwaelh', 'dwaem', 'dwaeb', 'dwaebs', 'dwaes', 'dwaess', 'dwaeng', 'dwaej', 'dwaec', 'dwaek', 'dwaet', 'dwaep', 'dwaeh', 'doe', 'doeg', 'doegg', 'doegs', 'doen', 'doenj', 'doenh', 'doed', 'doel', 'doelg', ...
uid='t1' # user id data_produce_duration=20 # data production duration(second) kafka_topic='topic_test' # kafka topic
uid = 't1' data_produce_duration = 20 kafka_topic = 'topic_test'
class Savable(object): @staticmethod def load(model_path, *args, **kwargs): pass @staticmethod def save(model_path, *args, **kwargs): pass
class Savable(object): @staticmethod def load(model_path, *args, **kwargs): pass @staticmethod def save(model_path, *args, **kwargs): pass
def nextGreaterElement(arr): if len(arr) == 0: return for i in range(len(arr)): NGE = -1 for j in range(i +1, len(arr)): if arr[j] > arr[i]: NGE = arr[j] break print(NGE, end = " ") if __name__ == "__main__": ...
def next_greater_element(arr): if len(arr) == 0: return for i in range(len(arr)): nge = -1 for j in range(i + 1, len(arr)): if arr[j] > arr[i]: nge = arr[j] break print(NGE, end=' ') if __name__ == '__main__': arr = [13, 7, 6, 12, 1...
#!/usr/bin/env python3 class Commands: get_serial = b"<GETSERIAL>>" get_version = b"<GETVER>>" get_voltage = b"<GETVOLT>>" get_cpm = b"<GETCPM>>" get_cps = b"<GETCPS>>" get_cfg = b"<GETCFG>>" erase_cfg = b"<ECFG>>" update_cfg = b"<CFGUPDATE>>" auto_cp...
class Commands: get_serial = b'<GETSERIAL>>' get_version = b'<GETVER>>' get_voltage = b'<GETVOLT>>' get_cpm = b'<GETCPM>>' get_cps = b'<GETCPS>>' get_cfg = b'<GETCFG>>' erase_cfg = b'<ECFG>>' update_cfg = b'<CFGUPDATE>>' auto_cps_on = b'<HEARTBEAT1>>' auto_cps_off = b'<HEARTBEAT0...
def uniques(string): #with data structures O(n) stores=dict() for ith in string: if stores.get(ith,0) !=0: return False stores[ith] = 1 return True print(uniques("HELLO")) def uniques_pro(string): #without data structures O(n*logn +n)= o(n*logn) string = sorted(string) for ith in range(len(string)-1):...
def uniques(string): stores = dict() for ith in string: if stores.get(ith, 0) != 0: return False stores[ith] = 1 return True print(uniques('HELLO')) def uniques_pro(string): string = sorted(string) for ith in range(len(string) - 1): if string[ith + 1] == string[i...
# # PySNMP MIB module RADLAN-TCPSESSIONS (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADLAN-TCPSESSIONS # Produced by pysmi-0.3.4 at Wed May 1 14:49:48 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint) ...
class ResponseProcessException(Exception): def __init__(self, tapi_exception, data, *args, **kwargs): self.tapi_exception = tapi_exception self.data = data super(ResponseProcessException, self).__init__(*args, **kwargs) class TapiException(Exception): def __init__(self, message, client...
class Responseprocessexception(Exception): def __init__(self, tapi_exception, data, *args, **kwargs): self.tapi_exception = tapi_exception self.data = data super(ResponseProcessException, self).__init__(*args, **kwargs) class Tapiexception(Exception): def __init__(self, message, clien...
''' Sequential Search Traversal all elements in the list if the target element exists, return the index of it if not, return 'not exist' If the list is unordered O(n) the times (n) decides the complexity If it's an ordered list as long as the element is bigger than target we can exit in advance ''' def sequentialSearch...
""" Sequential Search Traversal all elements in the list if the target element exists, return the index of it if not, return 'not exist' If the list is unordered O(n) the times (n) decides the complexity If it's an ordered list as long as the element is bigger than target we can exit in advance """ def sequential_sear...
''' config file ''' # first dataset n_one_hot_slot = 22 # num of one-hot slots in the 1st dataset n_mul_hot_slot = 3 # num of mul-hot slots in the 1st dataset max_len_per_slot = 10 # max num of fts per mul-hot slot in the 1st dataset n_ft = 29997247 # num of unique fts in the 1st dataset num_csv_col = 53 # num of cols...
""" config file """ n_one_hot_slot = 22 n_mul_hot_slot = 3 max_len_per_slot = 10 n_ft = 29997247 num_csv_col = 53 user_ft_idx = [0, 9, 16, 17, 18, 19, 20, 21, 22, 24] ad_ft_idx = [1, 2, 4, 5, 6, 7, 8, 13, 14, 15, 23] pre = './data/' suf = '.csv' train_file_name = [pre + 'day_1' + suf, pre + 'day_2' + suf] val_file_name...
#sort a linked list class Node: def __init__(self, data): self.data = data self.next = None def __repr__(self): return 'Node data-> {0}, next -> {1}'.format(self.data, self.next) class Singly_linkedlist: def __init__(self): self.head = None def insert(self, pos, data): node = Node(data) ...
class Node: def __init__(self, data): self.data = data self.next = None def __repr__(self): return 'Node data-> {0}, next -> {1}'.format(self.data, self.next) class Singly_Linkedlist: def __init__(self): self.head = None def insert(self, pos, data): node = no...
# This file is part of sequencing. # # Copyright (c) 2021, The Sequencing Authors. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. __version_info__ = (1, 1, 4) __version__ = ".".join(map(str, __versio...
__version_info__ = (1, 1, 4) __version__ = '.'.join(map(str, __version_info__))
def gcd(a, b): if b == 0: return a return gcd(b, a%b) def exgcd(a, b): x1, x0 = 1, 0 y1, y0 = 0, 1 q = a//b r1, r0 = b, a%b while r0: x1, x0 = x0, x1-q*x0 y1, y0 = y0, y1-q*y0 q = r1//r0 r1, r0 = r0, r1%r0 return r1, x0, y0 def _...
def gcd(a, b): if b == 0: return a return gcd(b, a % b) def exgcd(a, b): (x1, x0) = (1, 0) (y1, y0) = (0, 1) q = a // b (r1, r0) = (b, a % b) while r0: (x1, x0) = (x0, x1 - q * x0) (y1, y0) = (y0, y1 - q * y0) q = r1 // r0 (r1, r0) = (r0, r1 % r0) ...
services = { '1':'tcpmux', '2':'compressnet', '3':'compressnet', '5':'rje', '7':'echo', '9':'discard', '11':'systat', '13':'daytime', '17':'qotd', '19':'chargen', '20':'ftp-data', '21':'ftp', '22':'ssh', '23':'telnet', '25':'smtp', '26':'rsftp', '27':'nsw-fe', '29':'msg-icp', '31':'msg-auth', '33':'dsp', '37':'time', '...
services = {'1': 'tcpmux', '2': 'compressnet', '3': 'compressnet', '5': 'rje', '7': 'echo', '9': 'discard', '11': 'systat', '13': 'daytime', '17': 'qotd', '19': 'chargen', '20': 'ftp-data', '21': 'ftp', '22': 'ssh', '23': 'telnet', '25': 'smtp', '26': 'rsftp', '27': 'nsw-fe', '29': 'msg-icp', '31': 'msg-auth', '33': 'd...
my_list = [1, 2, 3, 4, 5] my_iter = iter(my_list) # print(type(my_iter)) print(next(my_iter))
my_list = [1, 2, 3, 4, 5] my_iter = iter(my_list) print(next(my_iter))
class NIGraphEdge: def __init__(self, source, target, delay, isFeedback): self.source = source self.target = target self.delay = delay self.isFeedback = isFeedback class NIGraphVertex: def __init__(self, vertexId, nodeUniqueId, throughputCostIfRegistere...
class Nigraphedge: def __init__(self, source, target, delay, isFeedback): self.source = source self.target = target self.delay = delay self.isFeedback = isFeedback class Nigraphvertex: def __init__(self, vertexId, nodeUniqueId, throughputCostIfRegistered, latencyCostIfRegister...
class Tile(object): def __init__(self, suite, value): self.suite = suite self.value = value def getHashables(self): return (self.suite, self.value) def __hash__(self): return hash(self.getHashables()) def __eq__(self, other): return (isinstance(other, Tile) and self.suite==other.suite and self.value==oth...
class Tile(object): def __init__(self, suite, value): self.suite = suite self.value = value def get_hashables(self): return (self.suite, self.value) def __hash__(self): return hash(self.getHashables()) def __eq__(self, other): return isinstance(other, Tile) an...
# in this module we are going to learn how to use command prompt in windows. # it is essential for all of windows users especially for developers. # note that: here casing doesn't matter. # system info # we can see all the information of our system using "SYSTEMINFO" # we can change the color too. "COLOR /?" # color...
"""SYSTEMINFO""" 'COLOR /?' 'COLOR 04' 'COLOR' 'cls' 'DATE' 'TIME' 'cd ..' 'cd User' 'f:' 'dir' 'dir /?' 'dir /AD' 'dir /B' 'dir /AD /B' 'dir /ON' 'dir /O-N' 'dir /B /O-N' 'dir /OD' 'dir /O-D' 'dir | sort' 'dir /S' 'dir /S /P' 'dir a*' 'dir /B a*' 'dir /B am*' 'dir /B *' 'dir /B *.zip' 'dir /B ?' 'dir /B ???????' 'dir ...
# -------------- # Code starts here class_1 = ['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio'] class_2 = ['Hilary Mason','Carla Gentry','Corinna Cortes'] new_class = class_1 + class_2 print(new_class) new_class.append('Peter Warden') print(new_class) new_class.remove('Carla Gentry') print(new_class...
class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio'] class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes'] new_class = class_1 + class_2 print(new_class) new_class.append('Peter Warden') print(new_class) new_class.remove('Carla Gentry') print(new_class) courses = dict([('Math', 65), (...
arrays = [0,1,0,1] state =0 ans = 0 for i in range(arrays): if array[i] == state: ans += 1 state = 1 - state print(ans)
arrays = [0, 1, 0, 1] state = 0 ans = 0 for i in range(arrays): if array[i] == state: ans += 1 state = 1 - state print(ans)
# Pay calculator from exercise 02.03 rewritten to give the employee 1.5 times # the hourly rate for hours worked above 40 hours, now with error handling for input! # Define constants MAX_NORMAL_HOURS = 40 OVERTIME_RATE_MULTIPLIER = 1.5 # Prompt user for hours worked and hourly rate of pay. Handle type errors by # sho...
max_normal_hours = 40 overtime_rate_multiplier = 1.5 try: hours = input('Enter Hours: ') hours = float(hours) rate = input('Enter rate: ') normal_rate = float(rate) except: print('Error, please enter numeric input') exit(1) overtime_rate = normal_rate * OVERTIME_RATE_MULTIPLIER if hours <= MAX_N...
class User: ''' Class that generates new instances of users. ''' user_list = [] #empty user list def __init__(self,username,password): self.username = username self.password = password def save_user(self): ''' save_user method saves user objects into user_lis...
class User: """ Class that generates new instances of users. """ user_list = [] def __init__(self, username, password): self.username = username self.password = password def save_user(self): """ save_user method saves user objects into user_list """ ...
#!/usr/bin/env/python3 API_NAME_KEY = 'api_name' MESSAGE_KEY = 'message' VERSION_KEY = 'version' API_NAME = 'tv' VERSION = '1.0'
api_name_key = 'api_name' message_key = 'message' version_key = 'version' api_name = 'tv' version = '1.0'