content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
db_file_name = 'bills.db' table_name = 'bills' elasticsearch_server_addr = 'http://localhost:9200' # IMPORTANT: # enable https://www.google.com/settings/security/lesssecureapps # in specifed gmail account in order to login from code and to start smtp server email_acc = 'california.bills.notifier.bot@gmail.com' email_...
db_file_name = 'bills.db' table_name = 'bills' elasticsearch_server_addr = 'http://localhost:9200' email_acc = 'california.bills.notifier.bot@gmail.com' email_pass = 'Jfej4_3io487eMfke' email_server = 'smtp.gmail.com' email_port = 587 site_addr = 'http://54.180.108.54/'
def fcfs(processes): CT=TAT=WT=T=cur=0 for i in processes: WT+=max(0, cur-i[0]) cur=max(i[0], cur)+i[1] CT+=cur TAT+=cur-i[0] T+=i[1] return tuple(round(i/len(processes), 2) for i in (CT, TAT, WT, T))
def fcfs(processes): ct = tat = wt = t = cur = 0 for i in processes: wt += max(0, cur - i[0]) cur = max(i[0], cur) + i[1] ct += cur tat += cur - i[0] t += i[1] return tuple((round(i / len(processes), 2) for i in (CT, TAT, WT, T)))
#! /usr/bin/env python # -- coding: utf-8 -- # ULL - Sistemas Inteligentes 2018/2019 # # User class and functions to create, write and read users USERS_DATA = "../Data/users.txt" LAST_USER_ID = "../Data/last_user_id.txt" class User: def __init__(self, uid, age = 30, height = 170, weight = 70, sex = "M", exerci...
users_data = '../Data/users.txt' last_user_id = '../Data/last_user_id.txt' class User: def __init__(self, uid, age=30, height=170, weight=70, sex='M', exercise_level=0.5, goal='maintain'): self.uid = uid self.age = age self.height = height self.weight = weight self.sex = se...
f = 'apolonia.txt' with open(f, 'r') as _f: source = _f.read() print(source.split('\n'))
f = 'apolonia.txt' with open(f, 'r') as _f: source = _f.read() print(source.split('\n'))
#-*- coding:utf-8; mode:python; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- class algorithm(object): 'algorithm' @staticmethod def remove_empties(l, recurse = True): 'Return a list of the non empty items in l' assert isinstance(l, list) def is_empty(x): return x in [ (), [], Non...
class Algorithm(object): """algorithm""" @staticmethod def remove_empties(l, recurse=True): """Return a list of the non empty items in l""" assert isinstance(l, list) def is_empty(x): return x in [(), [], None, ''] result = [x for x in l if not is_empty(x)] ...
#mi taller: Juan-gonzalez #UCC #2017-1 print("numero uno:") #comentari 1 a=input() #input tiene como funcion leer las entradas b=int(a) #int tiene como funcion convertir las cadenas a numeros print(a) print(b) print("numero dos:") holaamor=input() c=int(holaamor) print(holaamor) print(c) suma=a+holaamor otrasuma=b+c pr...
print('numero uno:') a = input() b = int(a) print(a) print(b) print('numero dos:') holaamor = input() c = int(holaamor) print(holaamor) print(c) suma = a + holaamor otrasuma = b + c print(suma) print(otrasuma)
'''VetCond ========== The CPL conditioning project in the vet school. ''' __version__ = '0.1-dev'
"""VetCond ========== The CPL conditioning project in the vet school. """ __version__ = '0.1-dev'
def outer(): i = 10 def inner(): print("inner i=", i) inner() print("Outer i=", i) outer()
def outer(): i = 10 def inner(): print('inner i=', i) inner() print('Outer i=', i) outer()
# # Copyright (c) 2017-2018 Joy Diamond. All rights reserved. # @gem('Sapphire.Tokenize1Header') def gem(): show = 0 @share def tokenize_header_parenthesis_atom(): assert qd() is 0 assert qk() is none assert qn() is none s = qs() m = definition_header_parenthes...
@gem('Sapphire.Tokenize1Header') def gem(): show = 0 @share def tokenize_header_parenthesis_atom(): assert qd() is 0 assert qk() is none assert qn() is none s = qs() m = definition_header_parenthesis_match(s, qj()) if m is none: raise_unknown_line...
class Visible(): def __init__(self, color): self._color = color def draw(self): pass
class Visible: def __init__(self, color): self._color = color def draw(self): pass
# Aiden B. # 2/23/2021 # lab 1.04 # Part 1 or 2 part=input("run part 1 or 2?") print("I am a genie. You have three wishes.") w1=input("What would you like to wish for?\n") w2=input("What would you like to wish for?\n") w3=input("What would you like to wish for?\n") if part=="1": print("Your wishes are "+w1+", "...
part = input('run part 1 or 2?') print('I am a genie. You have three wishes.') w1 = input('What would you like to wish for?\n') w2 = input('What would you like to wish for?\n') w3 = input('What would you like to wish for?\n') if part == '1': print('Your wishes are ' + w1 + ', ' + w2 + ', and ' + w3) elif part == '2...
class Solution: def isPalindrome(self, x: int) -> bool: if x < 0: return False num = x res = 0 while num > 0: res = res * 10 + num%10 num = num//10 return x == res if __name__ == "__main__": sol = Solution() n = 121 pr...
class Solution: def is_palindrome(self, x: int) -> bool: if x < 0: return False num = x res = 0 while num > 0: res = res * 10 + num % 10 num = num // 10 return x == res if __name__ == '__main__': sol = solution() n = 121 print(...
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def xorgLibXrender(): http_archive( name = "xorg_libXrender", ...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_file') def xorg_lib_xrender(): http_archive(name='xorg_libXrender', build_file='//bazel/deps/xorg_libXrender:build.BUILD', sha256='f7ec77bdde44d3caa991100760da7ae0af6fa4555b5796bb000f57d8...
def Pascal_Triangle(n): for row in range(1, n + 1): # Initializing the Initial Value of Pascal Value as 1 pascal_value = 1 # For printing blank spaces for i in range(1, n - row + 1): print(' ', end=' ') # For calculating the pascal value for i in ran...
def pascal__triangle(n): for row in range(1, n + 1): pascal_value = 1 for i in range(1, n - row + 1): print(' ', end=' ') for i in range(1, row + 1): s = ' ' + str(pascal_value) + ' ' print(s, end=' ') pascal_value = int(pascal_value * (row - i...
Q = int(input()) def lcs(X, Y): dp = [[0] * (len(X)+1) for _ in range(len(Y)+1)] for i in range(1,len(Y)+1): for j in range(1,len(X)+1): if X[j-1]==Y[i-1]: dp[i][j] = dp[i-1][j-1] + 1 else: dp[i][j] = max(dp[i][j-1],dp[i-1][j]) return dp[-1][-...
q = int(input()) def lcs(X, Y): dp = [[0] * (len(X) + 1) for _ in range(len(Y) + 1)] for i in range(1, len(Y) + 1): for j in range(1, len(X) + 1): if X[j - 1] == Y[i - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 else: dp[i][j] = max(dp[i][j - 1], dp[i - 1...
#!/usr/bin/env python3 MAX_STATION = 19 def validate_station(name, station): if not 0 <= station <= MAX_STATION: raise ValueError('%s out of range: no station %d' % (name, station)) def validate_direction(direction): if len(direction) != 1 or direction not in 'DU': raise ValueError('direction...
max_station = 19 def validate_station(name, station): if not 0 <= station <= MAX_STATION: raise value_error('%s out of range: no station %d' % (name, station)) def validate_direction(direction): if len(direction) != 1 or direction not in 'DU': raise value_error('direction out of range: no dire...
pkgname = "exiv2" pkgver = "0.27.5" pkgrel = 0 build_style = "cmake" configure_args = [ "-DEXIV2_BUILD_SAMPLES=OFF", "-DEXIV2_ENABLE_BMFF=ON", "-DEXIV2_BUILD_UNIT_TESTS=OFF" ] make_check_target = "unit_test" hostmakedepends = ["cmake", "ninja", "pkgconf"] makedepends = ["libexpat-devel", "zlib-devel"] pkgdesc =...
pkgname = 'exiv2' pkgver = '0.27.5' pkgrel = 0 build_style = 'cmake' configure_args = ['-DEXIV2_BUILD_SAMPLES=OFF', '-DEXIV2_ENABLE_BMFF=ON', '-DEXIV2_BUILD_UNIT_TESTS=OFF'] make_check_target = 'unit_test' hostmakedepends = ['cmake', 'ninja', 'pkgconf'] makedepends = ['libexpat-devel', 'zlib-devel'] pkgdesc = 'Image me...
def yaml_write(data, filename): f = open(filename, "w+") for key in data: f.write(f"{key}:\n- {data[key]}\n") def yaml_read(data, filename): try: with open(filename) as f: for lineKey in f: key = lineKey[:-2] lineVal = next(f) val...
def yaml_write(data, filename): f = open(filename, 'w+') for key in data: f.write(f'{key}:\n- {data[key]}\n') def yaml_read(data, filename): try: with open(filename) as f: for line_key in f: key = lineKey[:-2] line_val = next(f) va...
def compress(iterable, mask): index = 0 while index != len(iterable): if mask[index] is True: yield iterable[index] index += 1 arr_2 = list(compress(["Ivo", "Rado", "Panda"], [True, False, True])) print(arr_2)
def compress(iterable, mask): index = 0 while index != len(iterable): if mask[index] is True: yield iterable[index] index += 1 arr_2 = list(compress(['Ivo', 'Rado', 'Panda'], [True, False, True])) print(arr_2)
t=int(input()) t1=0 a=[0]*54 a[1]=2 a[2]=3 a[3]=5 for i in range(4,54): a[i]=a[i-1]+a[i-2] while(t1!=t): t1=t1+1 n=int(input()) print("Scenario #"+str(t1)+":",end="",sep="") print() print(a[n]) print()
t = int(input()) t1 = 0 a = [0] * 54 a[1] = 2 a[2] = 3 a[3] = 5 for i in range(4, 54): a[i] = a[i - 1] + a[i - 2] while t1 != t: t1 = t1 + 1 n = int(input()) print('Scenario #' + str(t1) + ':', end='', sep='') print() print(a[n]) print()
class Heap(object): def __init__(self, array = []): self.array = array def insert(self, value): pass class Min_Heap(Heap): def __init__(self, array): super().__init__(array) def insert(self, value): self.array.append(value) pos = len(...
class Heap(object): def __init__(self, array=[]): self.array = array def insert(self, value): pass class Min_Heap(Heap): def __init__(self, array): super().__init__(array) def insert(self, value): self.array.append(value) pos = len(self.array) - 1 whi...
def getDeviceConfigs(deviceIdentifier=''): # TODO read from separate yaml file # TODO validate configuration for missing/invalid values and for uniqueness property 'uniquePrefix' deviceConfigs = [ { 'patchConfType': 'csv', 'uniquePrefix': 'wb12', 'vendor': 'Waldo...
def get_device_configs(deviceIdentifier=''): device_configs = [{'patchConfType': 'csv', 'uniquePrefix': 'wb12', 'vendor': 'Waldorf', 'model': 'Blofeld', 'yearOfConstruction': 2007, 'patchSetName': 'Factory 2012', 'midiPort': 3, 'midiChannel': 11, 'color': 'darkgoldenrod', 'csvPath': 'csv/patchlist/Waldorf - Blofeld...
# Hello WOrld print("Hello World") x = 1 if x == 1: print("X = 1")
print('Hello World') x = 1 if x == 1: print('X = 1')
def state_update(S, K, i_round): for i in range (i_round): feedback = S[0] ^ S[47] ^ (0x1 - (S[70] & S[85])) ^ S[91] ^ (K[(i % klen)]) for j in range(127): S.insert(0, S.pop()) # print(S) S[127] = feedback return S #128-bit key #96-bit nonce #64-bit tag #128-bit ...
def state_update(S, K, i_round): for i in range(i_round): feedback = S[0] ^ S[47] ^ 1 - (S[70] & S[85]) ^ S[91] ^ K[i % klen] for j in range(127): S.insert(0, S.pop()) S[127] = feedback return S klen = 128 s = [0] * 128 k = [0] * 128 a = state_update(S, K, 2048)
class Post: id = None # type: str date_submitted = None # type: str user = None # type: str message = None # type: str sentiment = None # type: float url = None
class Post: id = None date_submitted = None user = None message = None sentiment = None url = None
def get_gene_background_header(global_variables): header_list = [] # adds the background information if global_variables["GENE_SYMBOL_FLAG"]: header_list.append("symbol") if global_variables["GENE_BIOTYPE_FLAG"]: header_list.append("biotype") if global_variables["GENE_CHROMOSOME_FL...
def get_gene_background_header(global_variables): header_list = [] if global_variables['GENE_SYMBOL_FLAG']: header_list.append('symbol') if global_variables['GENE_BIOTYPE_FLAG']: header_list.append('biotype') if global_variables['GENE_CHROMOSOME_FLAG']: header_list.append('chromo...
# sum all numbers in lista until the first even (included) lista=[1, 5, -2, 'Hey', 4, 3, 7] summa = 0 for elem in lista: if type(elem) is int: summa += elem if elem % 2 == 0: break print('The sum until the first even included is:', summa)
lista = [1, 5, -2, 'Hey', 4, 3, 7] summa = 0 for elem in lista: if type(elem) is int: summa += elem if elem % 2 == 0: break print('The sum until the first even included is:', summa)
al=0 gas=0 die=0 while True: codigo=int(input()) if(codigo==1): al=al+1 elif(codigo==2): gas=gas+1 elif(codigo==3): die=die+1 elif(codigo==4): break print(f"MUITO OBRIGADO\nAlcool:{al}\nGasolina: {gas}\nDiesel: {die}")
al = 0 gas = 0 die = 0 while True: codigo = int(input()) if codigo == 1: al = al + 1 elif codigo == 2: gas = gas + 1 elif codigo == 3: die = die + 1 elif codigo == 4: break print(f'MUITO OBRIGADO\nAlcool:{al}\nGasolina: {gas}\nDiesel: {die}')
''' Created on Feb 24, 2016 @author: T0157129 ''' ''' Cast a string into boolean. The trueVal list represents the accepted values for True. Return the boolean value. ''' def strToBool(string): trueVal=['True', 'true', 't', '1'] if string in trueVal: return True else: return Fa...
""" Created on Feb 24, 2016 @author: T0157129 """ '\n Cast a string into boolean.\n The trueVal list represents the accepted values for True.\n Return the boolean value.\n' def str_to_bool(string): true_val = ['True', 'true', 't', '1'] if string in trueVal: return True else: retur...
class HardWorker(object): u"Almost Sisyphos" def __init__(self, task): self.task = task def work_hard(self, repeat=100): for i in range(repeat): self.task() def add_simple_stuff(): x = 1+1 HardWorker(add_simple_stuff).work_hard(repeat=100) # cython worker.py
class Hardworker(object): u"""Almost Sisyphos""" def __init__(self, task): self.task = task def work_hard(self, repeat=100): for i in range(repeat): self.task() def add_simple_stuff(): x = 1 + 1 hard_worker(add_simple_stuff).work_hard(repeat=100)
student_list1 = ['tim', 'drake', 'ashish', 'shubham'] student_list2 = ['andrew', 'harshit', 'lary', 'shubham', 'chris'] def checkStudent(student_list2): for student in student_list2: if student == 'chris': print('Available') checkStudent(student_list2)
student_list1 = ['tim', 'drake', 'ashish', 'shubham'] student_list2 = ['andrew', 'harshit', 'lary', 'shubham', 'chris'] def check_student(student_list2): for student in student_list2: if student == 'chris': print('Available') check_student(student_list2)
def Insertion_sort(list): for i in range(1,len(list)): j = i - 1 temp=list[i] while j >= 0 and temp < list[j]: list[j + 1] = list[j] j = j - 1 list[j+1]=temp return list if __name__ == "__main__": list= [8,4,23,42,16,15] print(Insertion_sort(li...
def insertion_sort(list): for i in range(1, len(list)): j = i - 1 temp = list[i] while j >= 0 and temp < list[j]: list[j + 1] = list[j] j = j - 1 list[j + 1] = temp return list if __name__ == '__main__': list = [8, 4, 23, 42, 16, 15] print(insertio...
# https://www.hackerrank.com/challenges/ctci-ransom-note/problem def checkMagazine(magazine, note): magazine.sort() note.sort() for w in note: if not w in magazine: print("No") return else: magazine.remove(w) print("Yes") magazine = input().rstrip()....
def check_magazine(magazine, note): magazine.sort() note.sort() for w in note: if not w in magazine: print('No') return else: magazine.remove(w) print('Yes') magazine = input().rstrip().split() note = input().rstrip().split() check_magazine(magazine, n...
class Bird: def __init__(self, id, name): self.id = id self.name = name def intro(self): print("There are many types of birds.") def flight(self): print("Most of the birds can fly but some cannot.") class Sparrow(Bird): def __init__(self, id, name, age,...
class Bird: def __init__(self, id, name): self.id = id self.name = name def intro(self): print('There are many types of birds.') def flight(self): print('Most of the birds can fly but some cannot.') class Sparrow(Bird): def __init__(self, id, name, age, factor): ...
# [Silent Crusade] Into the Gate STARLING = 9120221 sm.setSpeakerID(STARLING) response = sm.sendAskYesNo("I bet this weird gate has something to do with all the monsters going crazy. I think we oughtta take a closer look. You ready?") if response: sm.sendNext("I'm counting on you to keep me safe from the big, ba...
starling = 9120221 sm.setSpeakerID(STARLING) response = sm.sendAskYesNo('I bet this weird gate has something to do with all the monsters going crazy. I think we oughtta take a closer look. You ready?') if response: sm.sendNext("I'm counting on you to keep me safe from the big, bad, scary monsters! Let's go!") s...
_base_ = './faster_rcnn_r50_fpn.py' model = dict( type='QDTrack', rpn_head=dict( loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)), roi_head=dict( type='QuasiDenseRoIHead', track_roi_extractor=dict( type='SingleRoIExtractor', roi_layer=dict...
_base_ = './faster_rcnn_r50_fpn.py' model = dict(type='QDTrack', rpn_head=dict(loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)), roi_head=dict(type='QuasiDenseRoIHead', track_roi_extractor=dict(type='SingleRoIExtractor', roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0), out_channels...
carWidth = 160 carHeight = 240 chessboardSize = 80 shiftWidth = 120 shiftHeight = 120 innerShiftWidth = 0 innerShiftHeight = 0 totalWidth = carWidth + 2 * chessboardSize + 2 * shiftWidth totalHeight = carHeight + 2 * chessboardSize + 2 * shiftHeight x1 = shiftWidth + chessboardSize + innerShiftWidth x2 = totalWidth - ...
car_width = 160 car_height = 240 chessboard_size = 80 shift_width = 120 shift_height = 120 inner_shift_width = 0 inner_shift_height = 0 total_width = carWidth + 2 * chessboardSize + 2 * shiftWidth total_height = carHeight + 2 * chessboardSize + 2 * shiftHeight x1 = shiftWidth + chessboardSize + innerShiftWidth x2 = tot...
#https://www.hackerrank.com/challenges/list-comprehensions #!/us/bin/env python # x_coordinates = 1 # y_coordinates = 1 # z_coordinates = 1 # n = 2 x_coordinates = int(raw_input()) y_coordinates = int(raw_input()) z_coordinates = int(raw_input()) n = int(raw_input()) result = [[x, y, z] for x in xrange(x_c...
x_coordinates = int(raw_input()) y_coordinates = int(raw_input()) z_coordinates = int(raw_input()) n = int(raw_input()) result = [[x, y, z] for x in xrange(x_coordinates + 1) for y in xrange(y_coordinates + 1) for z in xrange(z_coordinates + 1) if x + y + z != n] print(result)
#!/usr/bin/env python def pV2Str(pv): if pv < 0.0001: return "%.0e" % (pv) elif pv < 0.001: return "%.5f" % (pv) elif pv < 0.01: return "%.4f" % (pv) elif pv < 0.1: return "%.3f" % (pv) else: return "%.2f" % (pv)
def p_v2_str(pv): if pv < 0.0001: return '%.0e' % pv elif pv < 0.001: return '%.5f' % pv elif pv < 0.01: return '%.4f' % pv elif pv < 0.1: return '%.3f' % pv else: return '%.2f' % pv
a = int(input()) b = int(input()) c = int(input()) if a == b == c == 0: print("MANY SOLUTIONS") elif c < 0: print("NO SOLUTION") else: if a != 0: ans = int((c ** 2 - b) / a) if a * ans + b == c ** 2: print(ans) else: print("NO SOLUTION") elif a == 0 and ...
a = int(input()) b = int(input()) c = int(input()) if a == b == c == 0: print('MANY SOLUTIONS') elif c < 0: print('NO SOLUTION') elif a != 0: ans = int((c ** 2 - b) / a) if a * ans + b == c ** 2: print(ans) else: print('NO SOLUTION') elif a == 0 and b == c ** 2: print('MANY SOLUT...
# An OO lightswitch. It can be turned on or off and have it's status checked class LightSwitch(): def __init__(self): self.isSwitchOn = False def turnOn(self): self.isSwitchOn = True def turnOff(self): self.isSwitchOn = False def status(self): print(f"Is the lightswit...
class Lightswitch: def __init__(self): self.isSwitchOn = False def turn_on(self): self.isSwitchOn = True def turn_off(self): self.isSwitchOn = False def status(self): print(f'Is the lightswitch on? {self.isSwitchOn}') o_light_switch = light_switch() oLightSwitch.turnO...
dict = {} dict['one'] = "This is one" dict[2] = "This is two" tinydict = {'name': 'john','code':6734, 'dept': 'sales'} print(dict['one']) # Prints value for 'one' key print(dict[2]) # Prints value for 2 key print(tinydict) # Prints complete dictionary print(tinydict.keys()) # Prints all t...
dict = {} dict['one'] = 'This is one' dict[2] = 'This is two' tinydict = {'name': 'john', 'code': 6734, 'dept': 'sales'} print(dict['one']) print(dict[2]) print(tinydict) print(tinydict.keys()) print(tinydict.values())
game_rounds_number = int(input()) mishka_total_wins = 0 chris_total_wins = 0 for i in range(game_rounds_number): mishka_dice_value, chris_dice_value = map(int, input().split()) if mishka_dice_value > chris_dice_value: mishka_total_wins += 1 elif mishka_dice_value < chris_dice_value: chris_...
game_rounds_number = int(input()) mishka_total_wins = 0 chris_total_wins = 0 for i in range(game_rounds_number): (mishka_dice_value, chris_dice_value) = map(int, input().split()) if mishka_dice_value > chris_dice_value: mishka_total_wins += 1 elif mishka_dice_value < chris_dice_value: chris_...
# Given a string with repeated characters, rearrange the string so that no two # adjacent characters are the same. If this is not possible, return None. # For example, given "aaabbc", you could return "ababac". Given "aaab", # return None. def rearrange(text): text = list(text) n = len(text) ...
def rearrange(text): text = list(text) n = len(text) for i in range(n - 1): if text[i] == text[i + 1]: found = False for j in range(i + 1, n): if text[j] != text[i]: (text[i + 1], text[j]) = (text[j], text[i + 1]) found ...
def load(): with open("input") as f: data = {} for y, row in enumerate(f): data.update({(x, y): int(z) for x, z in enumerate(list(row.strip()))}) return data def get_adjacent_height(pos, heightmap): x, y = pos for p in [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]: ...
def load(): with open('input') as f: data = {} for (y, row) in enumerate(f): data.update({(x, y): int(z) for (x, z) in enumerate(list(row.strip()))}) return data def get_adjacent_height(pos, heightmap): (x, y) = pos for p in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1...
def round_sum(a, b, c): return round10(a) + round10(b) + round10(c) def round10(num): if num % 10 < 5: return num - (num % 10) return num + (10 - num % 10)
def round_sum(a, b, c): return round10(a) + round10(b) + round10(c) def round10(num): if num % 10 < 5: return num - num % 10 return num + (10 - num % 10)
# # PySNMP MIB module MPLS-TC-STD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MPLS-TC-STD-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:31:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint, constraints_union) ...
class Solution: def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int: mod = 10 ** 9 + 7 best = 0 total = 0 h = [] for eff, sp in sorted(zip(efficiency, speed), reverse=True): total += sp heapq.heappush(h, sp) ...
class Solution: def max_performance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int: mod = 10 ** 9 + 7 best = 0 total = 0 h = [] for (eff, sp) in sorted(zip(efficiency, speed), reverse=True): total += sp heapq.heappush(h, sp) ...
try: EMAIL = str((open('login.txt')).read()) PASSWORD = str((open('password.txt')).read()) except: EMAIL = None PASSWORD = None
try: email = str(open('login.txt').read()) password = str(open('password.txt').read()) except: email = None password = None
#program to print pattern(day5) def isPrime(n): if n==1: return False flag = True if(n > 1): for i in range(2, n): if(n % i == 0): flag = False break return flag x= 1 for i in range(1,n+1): for j in range(1,i+1): if(isPrime(x)):...
def is_prime(n): if n == 1: return False flag = True if n > 1: for i in range(2, n): if n % i == 0: flag = False break return flag x = 1 for i in range(1, n + 1): for j in range(1, i + 1): if is_prime(x): print('#', end=...
# <auto-generated> # This code was generated by the UnitCodeGenerator tool # # Changes to this file will be lost if the code is regenerated # </auto-generated> def to_square_kilometres(value): return value * 2.58999 def to_square_metres(value): return value * 2589988.10 def to_square_yards(value): return value *...
def to_square_kilometres(value): return value * 2.58999 def to_square_metres(value): return value * 2589988.1 def to_square_yards(value): return value * 3097600.0 def to_square_feet(value): return value * 27878400.0 def to_square_inches(value): return value * 4014489600.0 def to_hectares(value)...
names = [] in_guest = False for row in open("participants.dat"): srow = row.strip() if srow == "" or "*******" in srow: continue srow = srow.replace("\t", " ") if "------" in srow: in_guest = True continue if "@" not in srow: name = srow names.append(nam...
names = [] in_guest = False for row in open('participants.dat'): srow = row.strip() if srow == '' or '*******' in srow: continue srow = srow.replace('\t', ' ') if '------' in srow: in_guest = True continue if '@' not in srow: name = srow names.append(name) ...
dict = open("english2.txt","r") validWords = [] for word in dict: count = 0 for letter in word: if letter in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ': count += 1 if 3 <= count <= 16: validWords.append(word) dict.close() outputfile = open("z.txt","w") for ...
dict = open('english2.txt', 'r') valid_words = [] for word in dict: count = 0 for letter in word: if letter in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ': count += 1 if 3 <= count <= 16: validWords.append(word) dict.close() outputfile = open('z.txt', 'w') for outword ...
corona_people = 'Maharashtra 1100 Delhi 3300 Gujarat 4500 TamilNadu 7500' c=list(corona_people.split(" ")) corona_db={} for i in range(0,len(c),2): corona_db[c[i]]=c[i+1] print("Corona Database:",corona_db) x=input("Enter a State name :") if corona_db.get(x): print("The {} state has {} infected people".format(...
corona_people = 'Maharashtra 1100 Delhi 3300 Gujarat 4500 TamilNadu 7500' c = list(corona_people.split(' ')) corona_db = {} for i in range(0, len(c), 2): corona_db[c[i]] = c[i + 1] print('Corona Database:', corona_db) x = input('Enter a State name :') if corona_db.get(x): print('The {} state has {} infected peo...
m = sum([float(x) for x in input().split()]) / 2 if 7 <= m: print('Aprovado') elif 4 <= m: print('Recuperacao') else: print('Reprovado')
m = sum([float(x) for x in input().split()]) / 2 if 7 <= m: print('Aprovado') elif 4 <= m: print('Recuperacao') else: print('Reprovado')
#!/usr/bin/env python # coding: utf-8 # # 10: Solutions # # 1. Create a class named `Vehicle`. # * Give the class attributes `max_speed` and `mileage`. # * Instantiate an object `car` with: # * `max_speed` of 120, # * `mileage` of 10,000 # * Print these attributes _via an object reference...
class Vehicle: def __init__(self, max_speed, mileage): self.max_speed = max_speed self.mileage = mileage car = vehicle(120, 10000) print(f'The car has max speed {car.max_speed} and mileage {car.mileage}') class Bus(Vehicle): def __init__(self, max_speed, mileage, capacity=60): super()...
# Copyright 2018- The Pixie Authors. # # 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 w...
load('@bazel_gazelle//:deps.bzl', 'gazelle_dependencies') load('@com_github_bazelbuild_buildtools//buildifier:deps.bzl', 'buildifier_dependencies') load('@distroless//package_manager:dpkg.bzl', 'dpkg_list', 'dpkg_src') load('@distroless//package_manager:package_manager.bzl', 'package_manager_repositories') load('@io_ba...
personal_info = { 'name': 'sean venard', 'age': 26, 'gender': 'male', 'location': 'California' } print(personal_info['name']) print(personal_info['age']) print(personal_info['gender'])
personal_info = {'name': 'sean venard', 'age': 26, 'gender': 'male', 'location': 'California'} print(personal_info['name']) print(personal_info['age']) print(personal_info['gender'])
# Adapted from a Java code in the "Refactoring" book by Martin Fowler. # Replace nested conditional with guard clauses. ADJ_FACTOR = 0.7 def elegible_adjusted_capital(capital, rate, duration): return capital > 0 and rate > 0 and duration > 0 def calculate_adjusted_capital(duration, income): return (income / ...
adj_factor = 0.7 def elegible_adjusted_capital(capital, rate, duration): return capital > 0 and rate > 0 and (duration > 0) def calculate_adjusted_capital(duration, income): return income / duration * ADJ_FACTOR def get_adjusted_capital(capital, rate, duration, income): if elegible_adjusted_capital(capit...
def cmdissue(toissue, activesession): ssh_stdin, ssh_stdout, ssh_stderr = activesession.exec_command(toissue) return ssh_stdout.read().decode('UTF-8')
def cmdissue(toissue, activesession): (ssh_stdin, ssh_stdout, ssh_stderr) = activesession.exec_command(toissue) return ssh_stdout.read().decode('UTF-8')
# -*- coding: utf-8 -*- def main(): n = int(input()) s = [input() for _ in range(n)] ans = 0 back_a_count = 0 front_b_count = 0 front_b_back_a_count = 0 for si in s: if si[0] == 'B': front_b_count += 1 if si[-1] == 'A': back_a_count +...
def main(): n = int(input()) s = [input() for _ in range(n)] ans = 0 back_a_count = 0 front_b_count = 0 front_b_back_a_count = 0 for si in s: if si[0] == 'B': front_b_count += 1 if si[-1] == 'A': back_a_count += 1 if si[0] == 'B' and si[-1] == ...
class Solution: def maxValueAfterReverse(self, nums: List[int]) -> int: mini = math.inf maxi = -math.inf for a, b in zip(nums, nums[1:]): mini = min(mini, max(a, b)) maxi = max(maxi, min(a, b)) diff = max(0, (maxi - mini) * 2) for a, b in zip(nums, nums[1:]): headDiff = -abs(a ...
class Solution: def max_value_after_reverse(self, nums: List[int]) -> int: mini = math.inf maxi = -math.inf for (a, b) in zip(nums, nums[1:]): mini = min(mini, max(a, b)) maxi = max(maxi, min(a, b)) diff = max(0, (maxi - mini) * 2) for (a, b) in zip(n...
file = open('./input_01_01.txt', 'r') string = file.read() lines = string.split() int_lines = list(map(lambda x: int(x), lines)) def checkNumber(): r = 0 first = int_lines.pop(0) for n in int_lines: if first + n == 2020: r = first * n break if r == 0: return checkNumber() else: ret...
file = open('./input_01_01.txt', 'r') string = file.read() lines = string.split() int_lines = list(map(lambda x: int(x), lines)) def check_number(): r = 0 first = int_lines.pop(0) for n in int_lines: if first + n == 2020: r = first * n break if r == 0: return che...
# Ask a user to enter a number # Ask a user to enter a second number # Calculate the total of the two numbers added together # Print 'first number + second number = answer' # For example if someone enters 4 and 6 the output should read # 4 + 6 = 10 First_num = input("Give me a number: ") Second_num = input("Give me a ...
first_num = input('Give me a number: ') second_num = input('Give me a second number: ') answer = float(First_num) + float(Second_num) print(First_num + '+' + Second_num + '=' + str(round(answer)))
USTP_FTDC_VC_AV = '1' USTP_FTDC_VC_MV = '2' USTP_FTDC_VC_CV = '3' USTP_FTDC_FCR_NotForceClose = '0' USTP_FTDC_FCR_LackDeposit = '1' USTP_FTDC_FCR_ClientOverPositionLimit = '2' USTP_FTDC_FCR_MemberOverPositionLimit = '3' USTP_FTDC_FCR_NotMultiple = '4' USTP_FTDC_FCR_Violation = '5' USTP_FTDC_FCR_Other = '6' USTP_FTDC_FC...
ustp_ftdc_vc_av = '1' ustp_ftdc_vc_mv = '2' ustp_ftdc_vc_cv = '3' ustp_ftdc_fcr__not_force_close = '0' ustp_ftdc_fcr__lack_deposit = '1' ustp_ftdc_fcr__client_over_position_limit = '2' ustp_ftdc_fcr__member_over_position_limit = '3' ustp_ftdc_fcr__not_multiple = '4' ustp_ftdc_fcr__violation = '5' ustp_ftdc_fcr__other =...
#! /usr/bin/env python # -*- coding: utf-8 -*- def after(caller_name, *caller_args, **caller_kwargs): ''' Connect two functions of the same class to execute in order as the function name means :param caller_name: Given the name of the function which should be called afterwards :param caller_args: :...
def after(caller_name, *caller_args, **caller_kwargs): """ Connect two functions of the same class to execute in order as the function name means :param caller_name: Given the name of the function which should be called afterwards :param caller_args: :param caller_kwargs: :return: """ d...
def average(x): return sum(x)/float(len(x)) if x else 0 print (average([0,0,3,1,4,1,5,9,0,0])) print (average([1e20,-1e-20,3,1,4,1,5,9,-1e20,1e-20]))
def average(x): return sum(x) / float(len(x)) if x else 0 print(average([0, 0, 3, 1, 4, 1, 5, 9, 0, 0])) print(average([1e+20, -1e-20, 3, 1, 4, 1, 5, 9, -1e+20, 1e-20]))
expected_output = { 'peer_session': {'PEER-SESSION': {'bfd': True, 'description': 'PEER-SESSION', 'disable_connectivity_check': True, 'ebgp_multihop_enable': True, 'ebgp_multihop_limit': 255, 'holdtime': 111, 'inheri...
expected_output = {'peer_session': {'PEER-SESSION': {'bfd': True, 'description': 'PEER-SESSION', 'disable_connectivity_check': True, 'ebgp_multihop_enable': True, 'ebgp_multihop_limit': 255, 'holdtime': 111, 'inherited_vrf_default': '10.16.2.5', 'keepalive': 222, 'local_as': True, 'transport_connection_mode': 'Passive'...
# loop condition list for i in [2, 4, 6, 8, 10]: print("i = ", i) # loop condition: range() print('My name is ') for i in range(5): print('Susanna Five Times ' + str(i)) for i in range(12, 16): print('Susanna Five Times ' + str(i)) for i in range(0, 10, 2): print('Susanna Five Times ' + str(i)) for ...
for i in [2, 4, 6, 8, 10]: print('i = ', i) print('My name is ') for i in range(5): print('Susanna Five Times ' + str(i)) for i in range(12, 16): print('Susanna Five Times ' + str(i)) for i in range(0, 10, 2): print('Susanna Five Times ' + str(i)) for i in range(5, -1, -1): print('Susanna Five Times...
def waveread(): return "This function name is waveread"
def waveread(): return 'This function name is waveread'
while True: N = int(input('')) if N == 0: break else: V = list(map(int, input().split())) X = sorted(V) for i in V: if i == X[-2]: Y = V.index(i) + 1 print(Y)
while True: n = int(input('')) if N == 0: break else: v = list(map(int, input().split())) x = sorted(V) for i in V: if i == X[-2]: y = V.index(i) + 1 print(Y)
number_list=[] def max_min(number_list,n): min_position=number_list.index(min(number_list)) max_position=number_list.index(max(number_list)) print("Minimum element in array at index:", number_list[min_position],min_position ) print("Maximum element in array at index:", number_list[max_position],max...
number_list = [] def max_min(number_list, n): min_position = number_list.index(min(number_list)) max_position = number_list.index(max(number_list)) print('Minimum element in array at index:', number_list[min_position], min_position) print('Maximum element in array at index:', number_list[max_position],...
DEBUG = True # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE' : 'django.db.backends.postgresql', 'NAME' : 'allgoods', 'USER' : 'allgoods', 'PASSWORD' : '123456', 'HOST' : '127.0.0.1', 'P...
debug = True databases = {'default': {'ENGINE': 'django.db.backends.postgresql', 'NAME': 'allgoods', 'USER': 'allgoods', 'PASSWORD': '123456', 'HOST': '127.0.0.1', 'PORT': '5432'}}
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def xaw(): http_archive( name="Xaw" , build_file="//bazel/deps/Xaw:build.BUILD" , sha256="c30f3e7bbe6bf949bca40e2c...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def xaw(): http_archive(name='Xaw', build_file='//bazel/deps/Xaw:build.BUILD', sha256='c30f3e7bbe6bf949bca40e2c0421f3bdae7d43753ae9f92d303ac44cf5de5e5a', strip_prefix='xorg-libXaw-197e9d055f3cd351ae73551955ff463294b965bf', urls=['https://github.c...
class Solution: def minCost(self, costs: List[List[int]]) -> int: costsLength = len(costs) if costsLength == 0: return 0 prevRow = costs[-1] for i in range(costsLength - 2, -1, -1): currRow = list(costs[i]) currRowLength = len(currRow) ...
class Solution: def min_cost(self, costs: List[List[int]]) -> int: costs_length = len(costs) if costsLength == 0: return 0 prev_row = costs[-1] for i in range(costsLength - 2, -1, -1): curr_row = list(costs[i]) curr_row_length = len(currRow) ...
words = list() with open("resources/google-10000-english-usa-no-swears.txt", 'r') as file: for line in file.readlines(): words.append(line.strip()) by_length = dict() for word in words: length = len(word) if length not in by_length: by_length[length] = list() by_length[length].append(wo...
words = list() with open('resources/google-10000-english-usa-no-swears.txt', 'r') as file: for line in file.readlines(): words.append(line.strip()) by_length = dict() for word in words: length = len(word) if length not in by_length: by_length[length] = list() by_length[length].append(wor...
def mkerr(): raise ValueError("Error!") def request(flow): mkerr()
def mkerr(): raise value_error('Error!') def request(flow): mkerr()
print("Welcome to Band Name Generator") city_name = input("What's the name of the city you grew up in?\n") pet_name = input("What's your pet's name?\n") print("Your band name could be " + city_name + " " + pet_name)
print('Welcome to Band Name Generator') city_name = input("What's the name of the city you grew up in?\n") pet_name = input("What's your pet's name?\n") print('Your band name could be ' + city_name + ' ' + pet_name)
# Interaction of .pend_throw() with .throw() and .close() def gen(): i = 0 while 1: yield i i += 1 g = gen() try: g.pend_throw except AttributeError: print("SKIP") raise SystemExit g.pend_throw(1) try: g.throw(ValueError()) except ValueError: print("expected ValueError #1...
def gen(): i = 0 while 1: yield i i += 1 g = gen() try: g.pend_throw except AttributeError: print('SKIP') raise SystemExit g.pend_throw(1) try: g.throw(value_error()) except ValueError: print('expected ValueError #1') g = gen() print(next(g)) g.pend_throw(2) try: g.throw(...
#Skill: Breath first search #You are given the root of a binary tree. Return the deepest node (the furthest node from the root). #Example: # a # / \ # b c # / #d #The deepest node in this tree is d at depth 3. #Here's a starting point: class Node(object): def __init__(self, val): self.val = val...
class Node(object): def __init__(self, val): self.val = val self.left = None self.right = None def __repr__(self): return self.val class Solution: def find_deepest(self, node): return self.__iterativeDeepest(node) def __recusive_deepest(self, node, level): ...
f = Function(void, 'OpenDeskAcc', (Str255, 'name', InMode), condition='#if !TARGET_API_MAC_CARBON' ) functions.append(f) f = Function(MenuHandle, 'as_Menu', (Handle, 'h', InMode)) functions.append(f) f = Method(Handle, 'as_Resource', (MenuHandle, 'h', InMode)) methods.append(f) # The following have "Mac" prepended...
f = function(void, 'OpenDeskAcc', (Str255, 'name', InMode), condition='#if !TARGET_API_MAC_CARBON') functions.append(f) f = function(MenuHandle, 'as_Menu', (Handle, 'h', InMode)) functions.append(f) f = method(Handle, 'as_Resource', (MenuHandle, 'h', InMode)) methods.append(f) f = function(MenuHandle, 'GetMenu', (short...
def main() -> None: N = int(input()) assert 1 <= N <= 300 for _ in range(N): X_i, A_i = map(int, input().split()) assert -10**9 <= X_i <= 10**9 assert 1 <= A_i <= 10**9 if __name__ == '__main__': main()
def main() -> None: n = int(input()) assert 1 <= N <= 300 for _ in range(N): (x_i, a_i) = map(int, input().split()) assert -10 ** 9 <= X_i <= 10 ** 9 assert 1 <= A_i <= 10 ** 9 if __name__ == '__main__': main()
class BinaryTree: def __init__(self,root): self.key=root self.leftChild=None self.rightChild=None def insertLeft(self,root): if self.leftChild==None: self.leftChild=BinaryTree(root) else: tempNode=BinaryTree(root) tempNode.leftChild=self.leftChild self.leftChild=tempNode def insertRight(self,ro...
class Binarytree: def __init__(self, root): self.key = root self.leftChild = None self.rightChild = None def insert_left(self, root): if self.leftChild == None: self.leftChild = binary_tree(root) else: temp_node = binary_tree(root) te...
def generate_get_uri(endpoint: str, **params): unpacked_params = [f"{p}={params[p]}" for p in params] return endpoint + '?' + '&'.join(unpacked_params)
def generate_get_uri(endpoint: str, **params): unpacked_params = [f'{p}={params[p]}' for p in params] return endpoint + '?' + '&'.join(unpacked_params)
def geometric_progression(a, q): k = 0 while True: result = a * q**k if result <= 100000: yield result else: return k += 1 for n in geometric_progression(2, 5): print(n)
def geometric_progression(a, q): k = 0 while True: result = a * q ** k if result <= 100000: yield result else: return k += 1 for n in geometric_progression(2, 5): print(n)
''' Print out each element of the following array on a separate line: ["Joe", "2", "Ted", "4.98", "14", "Sam", "void *", "42", "float", "pointers", "5006"] You may use whatever programming language you'd like. Verbalize your thought process as much as possible before writing any code. Run through the UPER problem sol...
""" Print out each element of the following array on a separate line: ["Joe", "2", "Ted", "4.98", "14", "Sam", "void *", "42", "float", "pointers", "5006"] You may use whatever programming language you'd like. Verbalize your thought process as much as possible before writing any code. Run through the UPER problem sol...
# Define states and events, including symbolic (numeric) constants and their friendly names. STATE_NAMES = ['open', 'closed', 'opening', 'closing'] for i in range(len(STATE_NAMES)): globals()[STATE_NAMES[i].upper() + '_STATE'] = i EVENT_NAMES = ['open requested', 'close requested', 'finished opening', 'finished clo...
state_names = ['open', 'closed', 'opening', 'closing'] for i in range(len(STATE_NAMES)): globals()[STATE_NAMES[i].upper() + '_STATE'] = i event_names = ['open requested', 'close requested', 'finished opening', 'finished closing'] for i in range(len(EVENT_NAMES)): globals()[EVENT_NAMES[i].upper().replace(' ', '_...
def multi(x): total = 1 for num in x: total = total * num return total user_list = [1,2,3,-4] print(multi(user_list))
def multi(x): total = 1 for num in x: total = total * num return total user_list = [1, 2, 3, -4] print(multi(user_list))
# Copyright (c) 2020 fortiss GmbH # # This software is released under the MIT License. # https://opensource.org/licenses/MIT class AgentTrackInfo: def __init__(self, filename, track_id, start_offset, end_offset, first_ts_on_map=None, precision=-2): self._filename = filename self._track_id = track_...
class Agenttrackinfo: def __init__(self, filename, track_id, start_offset, end_offset, first_ts_on_map=None, precision=-2): self._filename = filename self._track_id = track_id self._start_offset = int(round(start_offset, precision)) self._end_offset = int(round(end_offset, precision...
''' Created on Dec 22, 2019 @author: ballance ''' class DB(): def __init__(self): pass def createCrossByName(self): pass
""" Created on Dec 22, 2019 @author: ballance """ class Db: def __init__(self): pass def create_cross_by_name(self): pass
h,w=map(int,input().split()) a=[] for i in range(h): x = input() if "#" in x: a.append(x) a=list(zip(*a)) b=[] for y in a: if "#" in y: b.append(y) b=list(zip(*b)) for c in b: print("".join(c))
(h, w) = map(int, input().split()) a = [] for i in range(h): x = input() if '#' in x: a.append(x) a = list(zip(*a)) b = [] for y in a: if '#' in y: b.append(y) b = list(zip(*b)) for c in b: print(''.join(c))
emtiaz=0 majmoEmtiaz=0 bord=0 for i in range(1,31): emtiaz = int(input()) majmoEmtiaz += emtiaz if emtiaz ==3: bord +=1 print(majmoEmtiaz,bord)
emtiaz = 0 majmo_emtiaz = 0 bord = 0 for i in range(1, 31): emtiaz = int(input()) majmo_emtiaz += emtiaz if emtiaz == 3: bord += 1 print(majmoEmtiaz, bord)
''' This file is a place to store flags that affect the operation of mwahpy ''' verbose=1 #If on, functions are a lot noisier #will slow things down slightly, but it may be helpful for debugging progress_bars=1 #Display progress bars #slows down a program somewhat, but is useful for making sure that #a long program i...
""" This file is a place to store flags that affect the operation of mwahpy """ verbose = 1 progress_bars = 1 auto_update = 1
# The class and its functions are designed to write into an empty .html file # Each object takes three parameters - center latitude and -longitude and the zoom # for the height of the map class GoogleMaps_HeatMap(object): def __init__(self, center_lat, center_lng, zoom, apikey=''): self.center = ...
class Googlemaps_Heatmap(object): def __init__(self, center_lat, center_lng, zoom, apikey=''): self.center = (float(center_lat), float(center_lng)) self.zoom = int(zoom) self.apikey = str(apikey) self.circles = [] self.heatmap_points = [] def circle(self, lat, lng, radi...
#stats.py class stats(): def __init__(self): print("You created an instance of stats()") def total(self, list_obj): total = 0 n = len(list_obj) for i in range(n): total += list_obj[i] return total def mean(self, list_obj): n = len(lis...
class Stats: def __init__(self): print('You created an instance of stats()') def total(self, list_obj): total = 0 n = len(list_obj) for i in range(n): total += list_obj[i] return total def mean(self, list_obj): n = len(list_obj) mean_ = ...
# # WAP to find no of occurance of each letter in a String using dictionary. String = input("Enter String: ") d = {} s = "" for i in range(0, len(String)): if(String[i] not in s): c = String.count(String[i]) d[String[i]] = c s += String[i] print(d) # # WAP convert the following String into...
string = input('Enter String: ') d = {} s = '' for i in range(0, len(String)): if String[i] not in s: c = String.count(String[i]) d[String[i]] = c s += String[i] print(d) string = 'Vijay=23,Ganesh=20,Lakshmi=19,Nikhil=22' string += ',' d = {} (p, st, st1) = (0, '', 0) for i in range(0, len(S...
{ 'variables': { 'bin': '<!(node -p "require(\'addon-tools-raub\').bin")', }, 'targets': [ { 'target_name': 'segfault', 'sources': [ 'cpp/bindings.cpp', 'cpp/segfault-handler.cpp', ], 'include_dirs': [ '<!@(node -p "require(\'addon-tools-raub\').include")', ], 'cflags!': ['-fno-exce...
{'variables': {'bin': '<!(node -p "require(\'addon-tools-raub\').bin")'}, 'targets': [{'target_name': 'segfault', 'sources': ['cpp/bindings.cpp', 'cpp/segfault-handler.cpp'], 'include_dirs': ['<!@(node -p "require(\'addon-tools-raub\').include")'], 'cflags!': ['-fno-exceptions'], 'cflags_cc!': ['-fno-exceptions'], 'cfl...
# # PySNMP MIB module MRV-IN-REACH-CHASSIS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MRV-IN-REACH-CHASSIS-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:15:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, constraints_intersection, constraints_union, value_range_constraint) ...
# Exercise for Classes: Homework Solution class Car(): # we initialize a class called "Car" def __init__(self, topSpeed, acc): # __init__ method, called when an object of this class is created ...
class Car: def __init__(self, topSpeed, acc): self.topSpeed = topSpeed self.acceleration = acc def calc_time(self, currentSpeed): t = (self.topSpeed - currentSpeed) / self.acceleration return t car = car(75, 3.5) time = car.calcTime(30) print(time)
''' Desription: Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors. class Node { public int val; public List<Node> neighbors; } Test case format: For simplicity sake, ...
""" Desription: Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors. class Node { public int val; public List<Node> neighbors; } Test case format: For simplicity sake, ...