content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def subset_sum(s, target): n = len(s) for i in range(2 ** n): print("[ ", end='') sum = 0 for j in range(n): if i & (2 ** j): sum += s[j] print(s[j], " ", end='') print("] sum = ", sum) if sum == target: return True ...
def subset_sum(s, target): n = len(s) for i in range(2 ** n): print('[ ', end='') sum = 0 for j in range(n): if i & 2 ** j: sum += s[j] print(s[j], ' ', end='') print('] sum = ', sum) if sum == target: return True ...
#Tom Mirrigton #Exercise 6 submission #define the function factorial #set y to 1 or for loop will just multiply through 0 def fact(x): y = 1 #for loop using a range of all values up to and including x #iterating though the for loop will multiply i value by cumaltive y value for i in range (1, x + 1): ...
def fact(x): y = 1 for i in range(1, x + 1): y = y * i return y m = 5 n = 7 p = 10 print(fact(m)) print(fact(n)) print(fact(p))
#this function takes two strings that only contain #string.digits and returns the sum of the two as a string def add(a,b): #reverse stings so they can be combined in order of magnitude a = a[::-1] b = b[::-1] #hold the remainder r = 0 #keep track of where we are at in order of magnitude i ...
def add(a, b): a = a[::-1] b = b[::-1] r = 0 i = 0 l_a = len(a) - 1 l_b = len(b) - 1 s = '' t_1 = 0 t_2 = 0 while i <= l_a or i <= l_b or r > 0: if i <= l_a: t_1 = int(a[i]) else: t_1 = 0 if i <= l_b: t_2 = int(b[i]) ...
# coding: utf-8 class YouTubeURLs(object): def __init__(self, url, quality, sig): self.url = url self.quality = quality self.sig = sig
class Youtubeurls(object): def __init__(self, url, quality, sig): self.url = url self.quality = quality self.sig = sig
# -*- coding: utf-8 -*- # @package: __init__.py # @author: Guilherme N. Ramos (gnramos@unb.br) # # if __name__ == '__main__': pass
if __name__ == '__main__': pass
n = int(input('Enter an integer number: ')) n_len = len(str(n)) while n > 1: i = 2 while n % i != 0: i += 1 print(f'{n:{n_len}}|{i}') n //= i print(f'{n:{n_len}}|')
n = int(input('Enter an integer number: ')) n_len = len(str(n)) while n > 1: i = 2 while n % i != 0: i += 1 print(f'{n:{n_len}}|{i}') n //= i print(f'{n:{n_len}}|')
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( start , end , arr ) : frequency = dict ( ) for i in range ( start , end + 1 ) : if arr [ i ] in fre...
def f_gold(start, end, arr): frequency = dict() for i in range(start, end + 1): if arr[i] in frequency.keys(): frequency[arr[i]] += 1 else: frequency[arr[i]] = 1 count = 0 for x in frequency: if x == frequency[x]: count += 1 return count if...
class Calc: def __init__(self): self.total = 0 self.memory = [] def add(self, a, b = None): if b is None: self.total += a self.memory.append(' + {0}'.format(a)) else: self.total = a + b self.memory = [] def subtract(self, a, b = None): if b is None: self.total -= a ...
class Calc: def __init__(self): self.total = 0 self.memory = [] def add(self, a, b=None): if b is None: self.total += a self.memory.append(' + {0}'.format(a)) else: self.total = a + b self.memory = [] def subtract(self, a, b=...
# Hayato Tutorial Clipsence | Momijigaoka : Unfamiliar Hillside (807040000) # Author: Tiger sm.giveExp(3500) sm.jobAdvance(4100) sm.lockInGameUI(True) #sm.playVideoByScript("JPHayato.avi") sm.lockInGameUI(False)
sm.giveExp(3500) sm.jobAdvance(4100) sm.lockInGameUI(True) sm.lockInGameUI(False)
# to run this, in this directory, simply do # # pytest . def multiply(a, b): return a*b def test_multiply(): assert multiply(4, 6) == 24 def test_multiply2(): assert multiply(5, 6) == 24
def multiply(a, b): return a * b def test_multiply(): assert multiply(4, 6) == 24 def test_multiply2(): assert multiply(5, 6) == 24
def f(n): fibo(n) def fibo(n): if(n<=2): return 1 else: return fibo(n-1) + fibo(n-2)
def f(n): fibo(n) def fibo(n): if n <= 2: return 1 else: return fibo(n - 1) + fibo(n - 2)
# sharing of common functionanlity using classes # Overriding attributes/methods # if the parent class has an attributes/methods and the child class implements the same attributes/methods, # the parent's implementation is overridden # Super (Parent) class class Wolf: def __init__(self, name): self.name = name ...
class Wolf: def __init__(self, name): self.name = name def bark(self): print(f' {self.name} Grr.. Woof..!!') class Dog(Wolf): pass andy = wolf('Andy Wolf') andy.bark() sam = dog('Sam Dog') sam.bark()
# Category: Sorting, Greedy if __name__ == '__main__': n = int(input()) k = int(input()) arr = [] for _ in range(n): a = int(input()) arr.append(a) arr.sort() ans = arr[n - 1] to = n - k + 1 for i in range(to): ans = min(ans, arr[i + k - 1] - arr[i]) pr...
if __name__ == '__main__': n = int(input()) k = int(input()) arr = [] for _ in range(n): a = int(input()) arr.append(a) arr.sort() ans = arr[n - 1] to = n - k + 1 for i in range(to): ans = min(ans, arr[i + k - 1] - arr[i]) print(ans)
GUARD = 0 THUG = 1 SPY = 2 ASSISTANT = 3 CHAMPION = 4 ANIMAL = 5 SMALL_ANIMAL = 6
guard = 0 thug = 1 spy = 2 assistant = 3 champion = 4 animal = 5 small_animal = 6
# Welcome to Wakka Maul! Prepare for combat! # Venture through the maze and pick up gems to fund your warchest. # Break down doors to unleash allies (or enemies). # For example, to attack the door labeled "g" use: #hero.attack("g") # If you have enough gold, you can call out for help by saying the type of unit you woul...
while True: hero.moveDown() hero.moveRight() hero.attack('g') hero.say('soldier')
data = input().split(':') #TODO gives 80% for n in range(0, len(data)): print(':' + data[n][0])
data = input().split(':') for n in range(0, len(data)): print(':' + data[n][0])
# The guess API is already defined for you. # @param num, your guess # @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 class Solution: def guessNumber(self, n: int) -> int: l= 1 r = n while r>l: m = (l + r) // 2 ...
class Solution: def guess_number(self, n: int) -> int: l = 1 r = n while r > l: m = (l + r) // 2 if guess(m) == 1: l = m + 1 else: r = m return l
while True: pass if True: if True: print('hey world!') break
while True: pass if True: if True: print('hey world!') break
str = "The graet wall of china is such a piece of shit"; lst = []; print(lst) wrds = str.split(); print(wrds); for wrd in wrds : if not wrd in lst : print(wrd) lst.append(wrd); print(lst)
str = 'The graet wall of china is such a piece of shit' lst = [] print(lst) wrds = str.split() print(wrds) for wrd in wrds: if not wrd in lst: print(wrd) lst.append(wrd) print(lst)
tests=int(input()) z=[] for _ in range(tests): l,b=[int(x) for x in input().split(" ")] a=l*b for i in range(1,max(l,b)+1): c=i*i if a%c==0: d=a//c z.append(d) for x in z: print(x)
tests = int(input()) z = [] for _ in range(tests): (l, b) = [int(x) for x in input().split(' ')] a = l * b for i in range(1, max(l, b) + 1): c = i * i if a % c == 0: d = a // c z.append(d) for x in z: print(x)
class Solution: def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]: old = image[sr][sc] if old == newColor: return image image[sr][sc] = newColor lst = [ [sr+x,sc+y] for x,y in [[-1, 0], [0, -1], [1, 0], [0,1]]] newPts = filter(la...
class Solution: def flood_fill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]: old = image[sr][sc] if old == newColor: return image image[sr][sc] = newColor lst = [[sr + x, sc + y] for (x, y) in [[-1, 0], [0, -1], [1, 0], [0, 1]]] ...
a = [[1, 2], [3, 4], [], [1], [], [], [9]] class vector2D: def __init__(self, vec): self.vec = vec self.outer = 0 self.inner = 0 self.n = len(vec) def next(self): while self.outer < self.n and self.inner == len(self.vec[self.outer]): self.outer += 1 ...
a = [[1, 2], [3, 4], [], [1], [], [], [9]] class Vector2D: def __init__(self, vec): self.vec = vec self.outer = 0 self.inner = 0 self.n = len(vec) def next(self): while self.outer < self.n and self.inner == len(self.vec[self.outer]): self.outer += 1 ...
# # PySNMP MIB module VDSL-LINE-EXT-SCM-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/VDSL-LINE-EXT-SCM-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:32:51 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016,...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, constraints_union, value_size_constraint) ...
file=open("18.txt", "r") a=[[int(val) for val in line.split()] for line in file.readlines()] file.close() b=a[-1] c=size=a.__len__()-1 for i in range(size-1, -1, -1): for j in range(0, c, 1): if (a[i][j]+b[j]>a[i][j]+b[j+1]): b[j]=a[i][j]+b[j] else: b[j]=a[i][j]+b[j+1] c-=1 print(b[0])
file = open('18.txt', 'r') a = [[int(val) for val in line.split()] for line in file.readlines()] file.close() b = a[-1] c = size = a.__len__() - 1 for i in range(size - 1, -1, -1): for j in range(0, c, 1): if a[i][j] + b[j] > a[i][j] + b[j + 1]: b[j] = a[i][j] + b[j] else: b[...
n=int(input()) farm=[] for i in range(n): farm.append(list(map(int,input().split()))) orange=0 x=0 y=0 last=0 i=0 j=0 # print(farm) while(i<n and j<n): # print(i,j) if i+1<n and farm[i+1][j]==1: x=i+1 i=x farm[i][j]=0 orange+=1 elif j+1<n and farm[...
n = int(input()) farm = [] for i in range(n): farm.append(list(map(int, input().split()))) orange = 0 x = 0 y = 0 last = 0 i = 0 j = 0 while i < n and j < n: if i + 1 < n and farm[i + 1][j] == 1: x = i + 1 i = x farm[i][j] = 0 orange += 1 elif j + 1 < n and farm[i][j + 1] == ...
# to update dictinoary.txt def main(): # extract text file, dictionary, and studied words fname = input('Enter the txt file name without txt extension to add to update: ') text = open(fname + '.txt', 'r').read() text = text.split() fdict = open('dictionary.txt', 'r').read() fdict = fdict.split(...
def main(): fname = input('Enter the txt file name without txt extension to add to update: ') text = open(fname + '.txt', 'r').read() text = text.split() fdict = open('dictionary.txt', 'r').read() fdict = fdict.split() combined = text + fdict combined.sort() with open('dictionary.new.txt...
################################### SORTER ###################################### # This function sorts the entries starting from startRow to endRow (inclusive) # of the given table with respect to the given column according to the # given order ('ascending' or 'descending'). # @Parameter: table # - List of list of ...
def sort_table(table, column, startRow, endRow, order): for i in range(startRow, endRow + 1): m_index = i m_value = table[i][column] for j in range(i + 1, endRow + 1): if order == 'ascending': if table[j][column] < m_value: m_index = j ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isValidBST(self, root: Optional[TreeNode]) -> bool: # inorder traversal of a valid BST ...
class Solution: def is_valid_bst(self, root: Optional[TreeNode]) -> bool: self.shouldBeSorted = [] def traverse(node): if not node: return traverse(node.left) self.shouldBeSorted.append(node.val) traverse(node.right) traverse(...
# 1022. Sum of Root To Leaf Binary Numbers # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def sumRootToLeaf2(self, root: TreeNode) -> int: self.ans = 0 self.dfs(root, '...
class Solution: def sum_root_to_leaf2(self, root: TreeNode) -> int: self.ans = 0 self.dfs(root, '') return self.ans def dfs(self, root, cur): cur += str(root.val) if not root.left and (not root.right): self.ans += int(cur, 2) return if ro...
a, b = 0, 0 command = input() for i in command: if i == 'L': a = a-1 elif i == 'R': a = a+1 elif i == 'U': b = b+1 else: b = b-1 print(a,b)
(a, b) = (0, 0) command = input() for i in command: if i == 'L': a = a - 1 elif i == 'R': a = a + 1 elif i == 'U': b = b + 1 else: b = b - 1 print(a, b)
__all__ = [ 'depth_first_apply', 'flatten_dict', ] def depth_first_apply(dict_like, func): out = {} for k, v in dict_like.items(): if type(v) is type(dict_like): out[k] = depth_first_apply(v, func) else: out[k] = func(v) return out def flatten_dict(dd, sep...
__all__ = ['depth_first_apply', 'flatten_dict'] def depth_first_apply(dict_like, func): out = {} for (k, v) in dict_like.items(): if type(v) is type(dict_like): out[k] = depth_first_apply(v, func) else: out[k] = func(v) return out def flatten_dict(dd, separator='/',...
# SOURCE: https://github.com/RickGriff/decimath # Abbreviation: DP stands for 'Decimal Places' TEN38 = int(10 ** 38) TEN30 = int(10 ** 30) TEN20 = int(10 ** 20) TEN19 = int(10 ** 19) TEN18 = int(10 ** 18) TEN17 = int(10 ** 17) TEN12 = int(10 ** 12) TEN11 = int(10 ** 11) TEN10 = int(10 ** 10) TEN9 = int(10 ** 9) TEN8 ...
ten38 = int(10 ** 38) ten30 = int(10 ** 30) ten20 = int(10 ** 20) ten19 = int(10 ** 19) ten18 = int(10 ** 18) ten17 = int(10 ** 17) ten12 = int(10 ** 12) ten11 = int(10 ** 11) ten10 = int(10 ** 10) ten9 = int(10 ** 9) ten8 = int(10 ** 8) ten7 = int(10 ** 7) ln2 = 693147180559945309417232121458 one_over_ln2 = 1442695040...
class QueueItem(object): def __init__(self, val, prev=None, next=None): self.val = val self.next = next self.prev = prev class Queue(object): def __init__(self, first=None, last=None): self.first = first self.last = last def enqueue(self, val): # adds val...
class Queueitem(object): def __init__(self, val, prev=None, next=None): self.val = val self.next = next self.prev = prev class Queue(object): def __init__(self, first=None, last=None): self.first = first self.last = last def enqueue(self, val): new = queue...
in_size = input().split() in_size = list(map(int, in_size)) scores = list() for i in range(in_size[1]): scores_horizontal = input().split() scores_horizontal = list(map(float, scores_horizontal)) scores.append(scores_horizontal) scores_T = list( zip(*scores) ) scores_list = list(map(sum, scores_T)) re...
in_size = input().split() in_size = list(map(int, in_size)) scores = list() for i in range(in_size[1]): scores_horizontal = input().split() scores_horizontal = list(map(float, scores_horizontal)) scores.append(scores_horizontal) scores_t = list(zip(*scores)) scores_list = list(map(sum, scores_T)) result_lis...
# Team 5 def save_data(datatables: list, cleandata: list, directories: list=None): pass def read_data(): pass
def save_data(datatables: list, cleandata: list, directories: list=None): pass def read_data(): pass
QCODES = r"\/Q[A-Z]{4}\/" D_IZE = r"D\)[ \-A-Z0-9\n]*E\)" MESSAGE = r"[\s\S]*CREATED" MRLC = r"(?:RWY|RUNWAY) *[0-9]{2}[LRC]*(?:\/[0-9]{2}[LRC]*)* *(?:CLOSED|CLSD)" FAAH = STAH = FALC = ATCA = SPAH = ACAH = AECA = r"(?:(?:[A-Z]{3})|(?:[0-9]{2}))[\-\/A-Z0-9 ,]{0,24}:*(?: [0-9\-]*)*(?:[ \n,]*[0-9: ]{4,5}-[0-9: ]{4,5}...
qcodes = '\\/Q[A-Z]{4}\\/' d_ize = 'D\\)[ \\-A-Z0-9\\n]*E\\)' message = '[\\s\\S]*CREATED' mrlc = '(?:RWY|RUNWAY) *[0-9]{2}[LRC]*(?:\\/[0-9]{2}[LRC]*)* *(?:CLOSED|CLSD)' faah = stah = falc = atca = spah = acah = aeca = '(?:(?:[A-Z]{3})|(?:[0-9]{2}))[\\-\\/A-Z0-9 ,]{0,24}:*(?: [0-9\\-]*)*(?:[ \\n,]*[0-9: ]{4,5}-[0-9: ]{...
def sec_to_str(t): # Convert seconds to hours:minutes:seconds m, s = divmod(t, 60) h, m = divmod(m, 60) return "%d:%02d:%02d" % (h, m, s) def _remove_dtype(x): # Removes dtype: float64 and dtype: int64 from pandas printouts x = str(x) x = x.replace('\ndtype: int64', '') x = x.replace('...
def sec_to_str(t): (m, s) = divmod(t, 60) (h, m) = divmod(m, 60) return '%d:%02d:%02d' % (h, m, s) def _remove_dtype(x): x = str(x) x = x.replace('\ndtype: int64', '') x = x.replace('\ndtype: float64', '') return x class Logger(object): def __init__(self, fh): self.log_fh = op...
# automatically generated by the FlatBuffers compiler, do not modify # namespace: flat class MaxScore(object): Unlimited = 0 One_Goal = 1 Three_Goals = 2 Five_Goals = 3
class Maxscore(object): unlimited = 0 one__goal = 1 three__goals = 2 five__goals = 3
# ============================================================================= # Python examples - casting # ============================================================================= s = "12.5" print(type(s)) print(s) f = float(s) print(type(f)) print(f) i = int(s) # ===========================================...
s = '12.5' print(type(s)) print(s) f = float(s) print(type(f)) print(f) i = int(s)
# INPUT NUMBER OF ODD NUMBERS n = int(input('Amount: ')) start = 1 for i in range(n): print(start) start += 2
n = int(input('Amount: ')) start = 1 for i in range(n): print(start) start += 2
def sum_with_distance(nums, dist): s, n_len = 0, len(nums) for i in range(n_len): ni = (i + dist) % n_len if nums[i] == nums[ni]: s += nums[i] return s with open("input.txt") as file: data = file.read() nums = [int(c) for c in data] p1 = sum_with_distance(nums, 1) print(f...
def sum_with_distance(nums, dist): (s, n_len) = (0, len(nums)) for i in range(n_len): ni = (i + dist) % n_len if nums[i] == nums[ni]: s += nums[i] return s with open('input.txt') as file: data = file.read() nums = [int(c) for c in data] p1 = sum_with_distance(nums, 1) print(f...
class MockWorker: def __init__(self): pass def set_work_size(self, _size : int) -> None: pass def set_progress(self, _value : int) -> None: pass
class Mockworker: def __init__(self): pass def set_work_size(self, _size: int) -> None: pass def set_progress(self, _value: int) -> None: pass
''' Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1: Input: target = 7, nums = [2,3,1,2,4,3] O...
""" Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1: Input: target = 7, nums = [2,3,1,2,4,3] O...
def test_wrong_select_db_index(cli): cli.sendline("select 1") cli.expect(["OK", "127.0.0.1"]) cli.sendline("select 128") cli.expect(["DB index is out of range", "127.0.0.1:6379[1]>"]) cli.sendline("select abc") cli.expect(["invalid DB index", "127.0.0.1:6379[1]>"]) cli.sendline("select 15...
def test_wrong_select_db_index(cli): cli.sendline('select 1') cli.expect(['OK', '127.0.0.1']) cli.sendline('select 128') cli.expect(['DB index is out of range', '127.0.0.1:6379[1]>']) cli.sendline('select abc') cli.expect(['invalid DB index', '127.0.0.1:6379[1]>']) cli.sendline('select 15') ...
def countChar(string): array = list(string) index = 0 finalString = '' while(index < len(array)-1): for j in range(index, len(array)-1): if(array[j] == array[j+1]): print(array[j], j) else: index = index + j print('index'. ...
def count_char(string): array = list(string) index = 0 final_string = '' while index < len(array) - 1: for j in range(index, len(array) - 1): if array[j] == array[j + 1]: print(array[j], j) else: index = index + j print('ind...
#%% SET s1=set() #bo'sh set e'lon qilish s1={1,1,3,1,531,1,15,14,311,651,63,1} print(s1,type(s1)) s1={1,'salom',3,False,5} s2={0,1,2,3,4,5} # s2.add(int(input("text:"))) # print(s2) # #s2.clear() # print(s2) print(s1.difference(s2)) #s1 ning s2 dan farqini chiqaradi print(s2.difference(s1)) #s2 ning s1 dan farqini chiq...
s1 = set() s1 = {1, 1, 3, 1, 531, 1, 15, 14, 311, 651, 63, 1} print(s1, type(s1)) s1 = {1, 'salom', 3, False, 5} s2 = {0, 1, 2, 3, 4, 5} print(s1.difference(s2)) print(s2.difference(s1)) print(s2.intersection(s1)) print(s2.union(s1)) print(sum(s2), max(s2), min(s2)) for i in range(int(input('nechta:'))): s1.pop() s...
class Policy: def __init__(self, **kwargs): self.__length = kwargs.get('length') self.__has_lowercase = kwargs.get('has_lowercase') self.__has_uppercase = kwargs.get('has_uppercase') self.__has_numbers = kwargs.get('has_numbers') self.__has_special_chars = kwargs.get('has_sp...
class Policy: def __init__(self, **kwargs): self.__length = kwargs.get('length') self.__has_lowercase = kwargs.get('has_lowercase') self.__has_uppercase = kwargs.get('has_uppercase') self.__has_numbers = kwargs.get('has_numbers') self.__has_special_chars = kwargs.get('has_sp...
t = int(input()) for n in range(t): x, y = list(map(int, input().split())) print(x + y)
t = int(input()) for n in range(t): (x, y) = list(map(int, input().split())) print(x + y)
__package__ = "translate.readers" __all__ = ["constants", "datareader", "datawrapper", "dummydata", "paralleldata", "preprocess", "tokenizer", "vocabulary"] __author__ = "Hassan S. Shavarani" __copyright__ = "Copyright 2018, SFUTranslate Project" __credits__ = ["Hassan S. Shavarani"] __license__ = "MIT" __ve...
__package__ = 'translate.readers' __all__ = ['constants', 'datareader', 'datawrapper', 'dummydata', 'paralleldata', 'preprocess', 'tokenizer', 'vocabulary'] __author__ = 'Hassan S. Shavarani' __copyright__ = 'Copyright 2018, SFUTranslate Project' __credits__ = ['Hassan S. Shavarani'] __license__ = 'MIT' __version__ = '...
# Test { 'variables': { }, 'targets': [ { 'target_name': 'electron-celt-<@(target_arch)', 'dependencies': [ 'deps/binding.gyp:libcelt' ], 'cflags': [ '-pthread', '-fno-exceptions', '-fno-...
{'variables': {}, 'targets': [{'target_name': 'electron-celt-<@(target_arch)', 'dependencies': ['deps/binding.gyp:libcelt'], 'cflags': ['-pthread', '-fno-exceptions', '-fno-strict-aliasing', '-Wall', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wextra', '-pipe', '-fno-ident', '-fdata-sections', '-ffunc...
# https://leetcode.com/problems/valid-parentheses/ class Solution: def isValid(self, s: str) -> bool: open_to_close = {'(': ')', '{': '}', '[': ']'} close_stack = list() for bracket in s: if bracket in open_to_close: close_stack.append(open_to_close[bracket]) ...
class Solution: def is_valid(self, s: str) -> bool: open_to_close = {'(': ')', '{': '}', '[': ']'} close_stack = list() for bracket in s: if bracket in open_to_close: close_stack.append(open_to_close[bracket]) elif not close_stack or close_stack.pop()...
# Optional Static Typing in Python 3.6+ # # pip3.6 install mypy # # Mypy is an optional static type checker for Python # More info at http://mypy-lang.org/ # # Python2 support with `mypy --py2 program.py` kind of commands # def add(p1: int, p2: int) -> int: return p1 + p2
def add(p1: int, p2: int) -> int: return p1 + p2
def no_condition(obj, value): return True def skip_none(obj, value): return value is not None def skip_empty(obj, value): return value is not None and len(value) > 0 def skip_false(obj, value): return bool(value)
def no_condition(obj, value): return True def skip_none(obj, value): return value is not None def skip_empty(obj, value): return value is not None and len(value) > 0 def skip_false(obj, value): return bool(value)
def analisa(x,y): if(x>y): print(x) print(y) print("diferentes") if(x==y): print(x) print(y) print("iguais") if (x<y): print(y) print(x) print("diferentes")
def analisa(x, y): if x > y: print(x) print(y) print('diferentes') if x == y: print(x) print(y) print('iguais') if x < y: print(y) print(x) print('diferentes')
def create_dummy_classes(db): class dummy(db.Model): __tablename__ = 'dummy_data' id_col = db.Column(db.Integer, primary_key=True, autoincrement = True) int_col = db.Column(db.String(64)) float_col = db.Column(db.String(64)) string_col = db.Column(db.String(64)) bool_...
def create_dummy_classes(db): class Dummy(db.Model): __tablename__ = 'dummy_data' id_col = db.Column(db.Integer, primary_key=True, autoincrement=True) int_col = db.Column(db.String(64)) float_col = db.Column(db.String(64)) string_col = db.Column(db.String(64)) bool_c...
a = [0, 0, 0, 1, 2, 5, 0, 0, 2] def resort_priority_array(array, current_index): if current_index == 0: return array if array[current_index] < array[current_index - 1]: array[current_index - 1], array[current_index] = ( array[current_index], array[current_index - 1], ...
a = [0, 0, 0, 1, 2, 5, 0, 0, 2] def resort_priority_array(array, current_index): if current_index == 0: return array if array[current_index] < array[current_index - 1]: (array[current_index - 1], array[current_index]) = (array[current_index], array[current_index - 1]) array = resort_pri...
# This file was auto-generated with update_bot_list.py # Local modifications will likely be overwritten. # Add custom account entries to update_bot_list.py BOTS = [ 'a-bot', 'abcor', 'aksdwi', 'alfanso', 'all.cars', 'allaz', 'alliedforces', 'alphaprime', 'appreciator', 'astrobot...
bots = ['a-bot', 'abcor', 'aksdwi', 'alfanso', 'all.cars', 'allaz', 'alliedforces', 'alphaprime', 'appreciator', 'astrobot', 'authors.league', 'automation', 'banjo', 'bdvoter', 'bekirsolak', 'bestvote', 'bid4joy', 'bidbot', 'bidseption', 'big-whale', 'blissfish', 'blockgators', 'bodzila', 'boinger', 'boomerang', 'boost...
# Project: GBS Tool # Author: Dr. Marc Mueller-Stoffels, marc@denamics.com, denamics GmbH # Date: November 27, 2017 # License: MIT License (see LICENSE file of this package for more information) class Solarfarm: # Solar resources pvArray = None
class Solarfarm: pv_array = None
# NAME: Rudransh Joshi # GITHUB USERNAMME: FireHead90544 # COUNTRY: India # PROGRAMMING LANGUAGE: Python # I LOVE HACKTOBERFEST2021 print("Hello Hacktoberfest2021!")
print('Hello Hacktoberfest2021!')
material_all_str = ["brick", "carpet", "ceramic", "fabric", "foliage", "food", "glass", "hair", "leather", "metal", "mirror", "other", "painted", "paper", "plastic", "polishedstone", "skin", "sky", "stone", "tile", "wallpaper", "water", "wood"] material_ipalm_ignore = ["mirror", "sky", "...
material_all_str = ['brick', 'carpet', 'ceramic', 'fabric', 'foliage', 'food', 'glass', 'hair', 'leather', 'metal', 'mirror', 'other', 'painted', 'paper', 'plastic', 'polishedstone', 'skin', 'sky', 'stone', 'tile', 'wallpaper', 'water', 'wood'] material_ipalm_ignore = ['mirror', 'sky', 'skin', 'leather', 'hair', 'paint...
{ 'targets': [ { 'target_name': 'pemify', 'sources': [ 'src/der.cpp' ], 'include_dirs': [ "<!(node -e \"require('nan')\")", "<(node_root_dir)/deps/openssl/openssl/include" ] } ] }
{'targets': [{'target_name': 'pemify', 'sources': ['src/der.cpp'], 'include_dirs': ['<!(node -e "require(\'nan\')")', '<(node_root_dir)/deps/openssl/openssl/include']}]}
#!/usr/bin/env python3 def calculate(): limit = 10**6 solutions = [0] * limit for i in range(1, limit * 2): for j in range(i // 5 + 1, (i + 1) // 2): temp = (i - j) * (j * 5 - i) if temp >= limit: break solutions[temp] += 1 answer = solut...
def calculate(): limit = 10 ** 6 solutions = [0] * limit for i in range(1, limit * 2): for j in range(i // 5 + 1, (i + 1) // 2): temp = (i - j) * (j * 5 - i) if temp >= limit: break solutions[temp] += 1 answer = solutions.count(10) return s...
if __name__ == '__main__': n = int(input()) student_marks = {} zero= str().zfill(1) for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() for i in student_marks: if i==f"{query_name}": ...
if __name__ == '__main__': n = int(input()) student_marks = {} zero = str().zfill(1) for _ in range(n): (name, *line) = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() for i in student_marks: if i == f'{query_name}...
# -*- coding: utf-8 -*- KEY_TOKEN = "bot_token" LOG_FOLDER = "log" LOG_FILE = LOG_FOLDER + "/error.log" CONFIG_FILE_NAME = "settings.ini" SECTION_NAME = "Settings" KEY_NOTICE_CHANNEL_NAME = "notice_channel" KEY_WATCH_CHANNEL_NAME = "watch_channel" KEY_NOTICE_FILTERS = "notice_filters"
key_token = 'bot_token' log_folder = 'log' log_file = LOG_FOLDER + '/error.log' config_file_name = 'settings.ini' section_name = 'Settings' key_notice_channel_name = 'notice_channel' key_watch_channel_name = 'watch_channel' key_notice_filters = 'notice_filters'
#Write a function that takes a string consisting of alphabetic characters as #input argument and returns True if the string is a palindrome. A palindrome #is a string which is the same backward or forward. #Note that capitalization does not matter here i.e. a lower case character #can be considered the same as an upper...
def palindromes(line): reverse = '' line = line.lower() for x in range(len(line) - 1, -1, -1): reverse += line[x] return line == reverse k = palindromes('Ana') print(k)
# Set your write-permitted CKAN API key CKAN = { "dpaw-internal":{ "url": "http://internal-data.dpaw.wa.gov.au/", "key": "your-api-key" } } # These resource IDs change when a resource is deleted and re-created (not when updated) LCI = { "sites":"94b8f31e-b30a-48c3-a6bf-033f63405ed2", "vegetation":...
ckan = {'dpaw-internal': {'url': 'http://internal-data.dpaw.wa.gov.au/', 'key': 'your-api-key'}} lci = {'sites': '94b8f31e-b30a-48c3-a6bf-033f63405ed2', 'vegetation': 'fac44676-3932-4f1b-826d-6d0df8d651de', 'stratum_summary': '0f26a607-c835-4aa8-93c0-ff46079db691', 'dominant_vegetation': 'a9991525-455d-4265-9485-f30b1b...
# Category description for the widget registry NAME = "Tools" DESCRIPTION = "Widgets for Photoclub/Tools" BACKGROUND = "#CED82C" ICON = "icons/tools.png" PRIORITY = 10005
name = 'Tools' description = 'Widgets for Photoclub/Tools' background = '#CED82C' icon = 'icons/tools.png' priority = 10005
class Node: def __init__(self,data,next=None): #constructor self.data = data self.next = next class LinkedList: def __init__(self): self.head = None def insert(self, data): newNode = Node(data) if(self.head): current = self.head...
class Node: def __init__(self, data, next=None): self.data = data self.next = next class Linkedlist: def __init__(self): self.head = None def insert(self, data): new_node = node(data) if self.head: current = self.head while current.next: ...
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: temp = '' num = 0 index = 0 while index < len(s): char = s[index] if char not in temp: temp += char index += 1 else: while char in te...
class Solution: def length_of_longest_substring(self, s: str) -> int: temp = '' num = 0 index = 0 while index < len(s): char = s[index] if char not in temp: temp += char index += 1 else: while char i...
message = 'GUVF VF ZL FRPERG ZRFFNTR' LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # loop through every possible key for key in range(len(LETTERS)): # It is important to set translated to the blank string so that the # previous iteration's value for translated is cleared. translated = '' # The rest of the program ...
message = 'GUVF VF ZL FRPERG ZRFFNTR' letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for key in range(len(LETTERS)): translated = '' for symbol in message: if symbol in LETTERS: num = LETTERS.find(symbol) num = num - key if num < 0: num = num + len(LETTERS) ...
DEVICE = "cpu" MAX_LEN = 70 TRAIN_BATCH_SIZE = 16 VALID_BATCH_SIZE = 8 EPOCHS = 10 BASE_MODEL_PATH = r'./base model' PATH = r'./trained model/' MODEL_PATH = PATH + "model.bin" # path to bert model META_PATH = PATH + "meta.bin" TRAINING_FILE = "./data/input_data.csv" # path to training data learning_rate = 5.65455089109...
device = 'cpu' max_len = 70 train_batch_size = 16 valid_batch_size = 8 epochs = 10 base_model_path = './base model' path = './trained model/' model_path = PATH + 'model.bin' meta_path = PATH + 'meta.bin' training_file = './data/input_data.csv' learning_rate = 5.654550891094924e-05 drop_out1 = 0.12520394654248432 drop_o...
class Nanovor: def __init__(self, name, health, armor, speed, strength, sv, family_class, attacks:list): #String defining the nanovor's name self._nano_name = name #int, there are no decimals when it comes to dealing and taking damage self._nano_health = health ...
class Nanovor: def __init__(self, name, health, armor, speed, strength, sv, family_class, attacks: list): self._nano_name = name self._nano_health = health self._nano_armor = armor self._nano_speed = speed self._nano_strength = strength self._swarm_value = sv ...
def main(): file = open("test.txt","r") if file: #print ('read\t' + file.read() + '\n') i = file.readline() print ('readline ' + i + '\n') i = file.readline() ans1 = 7 if i == ans1: print ('Test passed') #print ('readlines\t' + str(file.readlines()) + '\n') file.close() if __name__ == '__main__': ...
def main(): file = open('test.txt', 'r') if file: i = file.readline() print('readline ' + i + '\n') i = file.readline() ans1 = 7 if i == ans1: print('Test passed') file.close() if __name__ == '__main__': main()
nums = [25, 12, 35, 88, 11] print(nums) print(nums[0]) print(nums[2:4]) print(nums[-1]) names = ["pd", "hk", "hp"] print(names) mx = [nums, names] print(mx) nums.append(33) # appends the list from last print(nums) nums.insert(3, 43) # inserts element at a specific location print(nums) nums.remove(43) # removes ...
nums = [25, 12, 35, 88, 11] print(nums) print(nums[0]) print(nums[2:4]) print(nums[-1]) names = ['pd', 'hk', 'hp'] print(names) mx = [nums, names] print(mx) nums.append(33) print(nums) nums.insert(3, 43) print(nums) nums.remove(43) print(nums) nums.pop(1) print(nums) nums.pop() print(nums) del nums[2:] print(nums) nums...
file_loaded_style = u"QPushButton{\n" \ "border-color: rgb(60,179,113);\n" \ "}\n" \ u"QPushButton:hover{\n" \ "background-color: rgb(235, 225, 240);\n" \ "}\n" \ "QPushButton:pressed{\n" \ ...
file_loaded_style = u'QPushButton{\nborder-color: rgb(60,179,113);\n}\nQPushButton:hover{\nbackground-color: rgb(235, 225, 240);\n}\nQPushButton:pressed{\nbackground-color: rgb(220, 211, 230);\nborder-left-color: rgb(60,179,113);\nborder-top-color: rgb(60,179,113);\nborder-bottom-color: rgb(85, 194, 132);\nborder-right...
def main(): a = int(input()) b = a / 5 if (a % 5) > 0: b = b + 1 print(int(b)) if __name__ == "__main__": main()
def main(): a = int(input()) b = a / 5 if a % 5 > 0: b = b + 1 print(int(b)) if __name__ == '__main__': main()
S, L, R = map(int, input().split()) if L <= S <= R: print(S) elif S < L: print(L) elif S > R: print(R)
(s, l, r) = map(int, input().split()) if L <= S <= R: print(S) elif S < L: print(L) elif S > R: print(R)
STATE_NOT_STARTED = "NOT_STARTED" STATE_COIN_FLIPPED = "COIN_FLIPPED" STATE_DRAFT_COMPLETE = "COMPLETE" STATE_BANNING = "BANNING" STATE_PICKING = "PICKING" STATE_RESTRICTING = "RESTRICTING" STATE_FIRST_ROUND_BANNING = "FIRST_ROUND_BANNING" STATE_FIRST_ROUND_PICKING = "FIRST_ROUND_PICKING" STATE_SECOND_ROUND_BANNING = ...
state_not_started = 'NOT_STARTED' state_coin_flipped = 'COIN_FLIPPED' state_draft_complete = 'COMPLETE' state_banning = 'BANNING' state_picking = 'PICKING' state_restricting = 'RESTRICTING' state_first_round_banning = 'FIRST_ROUND_BANNING' state_first_round_picking = 'FIRST_ROUND_PICKING' state_second_round_banning = '...
x=int(input()) for i in range(0,x+1): for j in range(0,x+1): if(x==i*j): print(i,end=" ")
x = int(input()) for i in range(0, x + 1): for j in range(0, x + 1): if x == i * j: print(i, end=' ')
s1 = 466576 s2 = 466591 s3 = 555555 def test_names(lib): assert lib.name(s1) == "Conan" assert lib.description(s1) == "Conan, Level 2 Barbarian" def test_scores(lib): assert lib.ability_scores(s1) == (18, 14, 14, 10, 10, 8) assert lib.ability_scores_full(s1) == ((18, 14, 14, 10, 10, 8), (4, 2, 2, 0,...
s1 = 466576 s2 = 466591 s3 = 555555 def test_names(lib): assert lib.name(s1) == 'Conan' assert lib.description(s1) == 'Conan, Level 2 Barbarian' def test_scores(lib): assert lib.ability_scores(s1) == (18, 14, 14, 10, 10, 8) assert lib.ability_scores_full(s1) == ((18, 14, 14, 10, 10, 8), (4, 2, 2, 0, 0...
#!/usr/bin/env python ''' This module holds package level constants for Pali. ''' LOG_FILE='pali.log'
""" This module holds package level constants for Pali. """ log_file = 'pali.log'
def letter_check(word,letter): counter = 0 for i in word: if i == letter: counter += 1 if counter >= 1: return True else: return False
def letter_check(word, letter): counter = 0 for i in word: if i == letter: counter += 1 if counter >= 1: return True else: return False
description = 'Sample devices in the SINQ HRPT.' pvprefix = 'SQ:HRPT:motc:' devices = dict( som=device('nicos_ess.devices.epics.motor.EpicsMotor', epicstimeout=3.0, description='Sample omega motor', motorpv=pvprefix + 'SOM', errormsgpv=pvprefix + 'SOM-Ms...
description = 'Sample devices in the SINQ HRPT.' pvprefix = 'SQ:HRPT:motc:' devices = dict(som=device('nicos_ess.devices.epics.motor.EpicsMotor', epicstimeout=3.0, description='Sample omega motor', motorpv=pvprefix + 'SOM', errormsgpv=pvprefix + 'SOM-MsgTxt', precision=0.01), chpos=device('nicos_ess.devices.epics.motor...
def funcion(x): #codigo x = x*x p = z z = 10 return x + p z = 1 x = 5 y = 2 print(funcion(y)) print(x)
def funcion(x): x = x * x p = z z = 10 return x + p z = 1 x = 5 y = 2 print(funcion(y)) print(x)
hico_text_label = {(4, 4): 'a photo of a person boarding an airplane', (17, 4): 'a photo of a person directing an airplane', (25, 4): 'a photo of a person exiting an airplane', (30, 4): 'a photo of a person flying an airplane', (41, 4): 'a phot...
hico_text_label = {(4, 4): 'a photo of a person boarding an airplane', (17, 4): 'a photo of a person directing an airplane', (25, 4): 'a photo of a person exiting an airplane', (30, 4): 'a photo of a person flying an airplane', (41, 4): 'a photo of a person inspecting an airplane', (52, 4): 'a photo of a person loading...
wt6_16_7 = {'192.168.122.111': [10.8585, 11.0817, 11.244, 9.793, 10.0625, 9.331, 8.9054, 8.5512, 8.3955, 8.0993, 8.0011, 8.1955, 8.1313, 8.0122, 8.2348, 8.0685, 8.0046, 7.8597, 7.7344, 7.6244, 7.5289, 7.6915, 7.5995, 7.5681, 7.4934, 7.4172, 7.3587, 7.4773, 7.4459, 7.4032, 7.3506, 7.3069, 7.2601, 7.2327, 7.3383, 7.2872...
wt6_16_7 = {'192.168.122.111': [10.8585, 11.0817, 11.244, 9.793, 10.0625, 9.331, 8.9054, 8.5512, 8.3955, 8.0993, 8.0011, 8.1955, 8.1313, 8.0122, 8.2348, 8.0685, 8.0046, 7.8597, 7.7344, 7.6244, 7.5289, 7.6915, 7.5995, 7.5681, 7.4934, 7.4172, 7.3587, 7.4773, 7.4459, 7.4032, 7.3506, 7.3069, 7.2601, 7.2327, 7.3383, 7.2872,...
max_seat = 0 seats = set() with open('input.txt') as file: for input in file: row = 0 col = 0 for idx, char in enumerate(input[:7]): if char == 'B': row += pow(2, 6-idx) for idx, char in enumerate(input[7:]): if char == 'R': col...
max_seat = 0 seats = set() with open('input.txt') as file: for input in file: row = 0 col = 0 for (idx, char) in enumerate(input[:7]): if char == 'B': row += pow(2, 6 - idx) for (idx, char) in enumerate(input[7:]): if char == 'R': ...
class Solution: def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]: i, j = 0, 0 res = [] while i<len(A) and j<len(B): left = max(A[i][0],B[j][0]) right = min(A[i][1], B[j][1]) if left<=right: interval ...
class Solution: def interval_intersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]: (i, j) = (0, 0) res = [] while i < len(A) and j < len(B): left = max(A[i][0], B[j][0]) right = min(A[i][1], B[j][1]) if left <= right: ...
config = { "lr": ( 0.0007058630744815441, 0.00045976866944110974, 1.4142718290111939e-05, 1.9346548814094763e-05, ), "target_stepsize": 0.09962995994670613, "feedback_wd": 6.731653502569897e-07, "beta1": 0.9, "beta2": 0.999, "epsilon": ( 1.884748418104...
config = {'lr': (0.0007058630744815441, 0.00045976866944110974, 1.4142718290111939e-05, 1.9346548814094763e-05), 'target_stepsize': 0.09962995994670613, 'feedback_wd': 6.731653502569897e-07, 'beta1': 0.9, 'beta2': 0.999, 'epsilon': (1.8847484181047474e-07, 1.3177870193660672e-08, 1.2706140743156817e-06, 1.5886518322735...
# 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 glibc(): http_archive( name = "glibc", build_file = "...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_file') def glibc(): http_archive(name='glibc', build_file='//bazel/deps/glibc:build.BUILD', sha256='4f73cc1025bb8d8a26151d75748bb5325e9f5501a9809ed3edcb193e1876232d', strip_prefix='glibc-...
def calculate(distance, no_of_passengers): price_fuel = 70 price_ticket = 80 fuel_cost = (distance/10)*price_fuel ticket_cost = no_of_passengers * price_ticket profit_earned = ticket_cost - fuel_cost if(profit_earned > 0): return profit_earned else: return -1 # Provide dif...
def calculate(distance, no_of_passengers): price_fuel = 70 price_ticket = 80 fuel_cost = distance / 10 * price_fuel ticket_cost = no_of_passengers * price_ticket profit_earned = ticket_cost - fuel_cost if profit_earned > 0: return profit_earned else: return -1 distance = 20 n...
colors = {'LIGHTGRAY': (175, 175, 175), 'GRAY': (100, 100, 100), 'DARKGRAY': (50, 50, 50), 'BLACK': (0, 0, 0), 'NAVYBLUE': (60, 60, 100), 'WHITE': (255, 255, 255), 'WHITERED': (255, 230, 230), 'RED': (255, 0, 0), 'PALERED': (255, 75, 75), ...
colors = {'LIGHTGRAY': (175, 175, 175), 'GRAY': (100, 100, 100), 'DARKGRAY': (50, 50, 50), 'BLACK': (0, 0, 0), 'NAVYBLUE': (60, 60, 100), 'WHITE': (255, 255, 255), 'WHITERED': (255, 230, 230), 'RED': (255, 0, 0), 'PALERED': (255, 75, 75), 'GREEN': (0, 255, 0), 'DARKGREEN': (0, 55, 0), 'BLUE': (50, 50, 255), 'DARKBLUE':...
pi=3.1415927 inchToFoot=12 footToMile=5280 secondInHour=3600 revolution=1 diameters=[] revolutions=[] times=[] while(revolution!=0): line=input() line=line.split(" ") revolution=int(line[1]) diameters.append(float(line[0])) times.append(float(line[2])) revolutions.append(revo...
pi = 3.1415927 inch_to_foot = 12 foot_to_mile = 5280 second_in_hour = 3600 revolution = 1 diameters = [] revolutions = [] times = [] while revolution != 0: line = input() line = line.split(' ') revolution = int(line[1]) diameters.append(float(line[0])) times.append(float(line[2])) revolutions.ap...
PACKAGE_INFO = { "name": "iTeML", "description": "Inline (Unit) Tests for OCaml", "homepages": ["https://github.com/vincent-hugot/iTeML"], "licenses": ["GPL-3"], "versions": [ {"version": "2.6", "cpes": []}, ], }
package_info = {'name': 'iTeML', 'description': 'Inline (Unit) Tests for OCaml', 'homepages': ['https://github.com/vincent-hugot/iTeML'], 'licenses': ['GPL-3'], 'versions': [{'version': '2.6', 'cpes': []}]}
def solve_memory(stage, display): if (stage == 1): if (display == 1 or display == 2): return 'Press the button in the second position' if (display == 3): return 'Press the button in the third position' if (display == 4): return 'Press the button in ...
def solve_memory(stage, display): if stage == 1: if display == 1 or display == 2: return 'Press the button in the second position' if display == 3: return 'Press the button in the third position' if display == 4: return 'Press the button in the fourth posi...
class Node: def __init__(self, statement): self.statement = statement def visit(self, context): return self.statement.visit(context)
class Node: def __init__(self, statement): self.statement = statement def visit(self, context): return self.statement.visit(context)
def greet(): print("Hello") print("How do you do?") def greet2(name): print("hello", name) print("How do you do?") def add_numbers(n1, n2): result = n1 + n2 return result greet() greet() greet() # greet2("Jack") rs = add_numbers(6.7, 5.4) print(rs)
def greet(): print('Hello') print('How do you do?') def greet2(name): print('hello', name) print('How do you do?') def add_numbers(n1, n2): result = n1 + n2 return result greet() greet() greet() rs = add_numbers(6.7, 5.4) print(rs)
class SSHLog: def __init__(self, output, node_id): self.output = output self.node_id = node_id
class Sshlog: def __init__(self, output, node_id): self.output = output self.node_id = node_id
def add(a, b): ''' add adds two numbers together. ''' res = a - b return a+b def minus(a, b): res = a - b return res a = 2 b = 4 res = minus(a, b) resTwo = add(res, 4) # == # True # False # == equal # != not equal # < less than # > greater than # <= less than or equal # >= greater th...
def add(a, b): """ add adds two numbers together. """ res = a - b return a + b def minus(a, b): res = a - b return res a = 2 b = 4 res = minus(a, b) res_two = add(res, 4) True False 1 '1' a = 1 b = '1' list_of_numbers = [1, 2, 3, 4] new_list = list() new_list.append('Apple') list_of_numbers...
class User: def __init__(self, id, title, body): self.id = id self.title = title self.body = body a1 = User(1, 'Article 1 title', 'Article 1 body') a2 = User(2, 'Article 2 title', 'Article 2 body') aList = [a1, a2]
class User: def __init__(self, id, title, body): self.id = id self.title = title self.body = body a1 = user(1, 'Article 1 title', 'Article 1 body') a2 = user(2, 'Article 2 title', 'Article 2 body') a_list = [a1, a2]