content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
t = int(input()) for i in range(t): count = 0 n = int(input()) l = list(map(int, input().split())) for j in range(1,len(l)-1): if l[j-1]<l[j] and l[j+1]<l[j]: count += 1 print(f'Case #{i+1}: {count}')
t = int(input()) for i in range(t): count = 0 n = int(input()) l = list(map(int, input().split())) for j in range(1, len(l) - 1): if l[j - 1] < l[j] and l[j + 1] < l[j]: count += 1 print(f'Case #{i + 1}: {count}')
def linear_search(arr, x): for i in range(len(arr)): if arr[i] == x: return i return -1 def binary_search(arr, low, high, x): if high >= 1: mid = (high + low) // 2 if arr[mid] == x: return mid elif arr[mid] > x: return binary_search(arr...
def linear_search(arr, x): for i in range(len(arr)): if arr[i] == x: return i return -1 def binary_search(arr, low, high, x): if high >= 1: mid = (high + low) // 2 if arr[mid] == x: return mid elif arr[mid] > x: return binary_search(arr, l...
# Used for import directories into other modules. Good for setting # project wide parameters, such as the location of the database. class settings(): db = "C:\\Users\\Andrew\\lab_project\\database\\frontiers_corpus.db" d2v = "C:\\Users\\Andrew\\lab_project\\models\\doc2vecmodels\\" d2v500 = "C:\\Users\\Andrew\...
class Settings: db = 'C:\\Users\\Andrew\\lab_project\\database\\frontiers_corpus.db' d2v = 'C:\\Users\\Andrew\\lab_project\\models\\doc2vecmodels\\' d2v500 = 'C:\\Users\\Andrew\\lab_project\\models\\doc2vecmodels\\500model' d2v300 = 'C:\\Users\\Andrew\\lab_project\\models\\doc2vecmodels\\300model' d...
class OverrideRootError(Exception): def __init__(self): super().__init__(self, "Cannot override Tree root node") class TreeHeightError(Exception): def __init__(self): super().__init__(self, "Cannot add node lower than tree height")
class Overriderooterror(Exception): def __init__(self): super().__init__(self, 'Cannot override Tree root node') class Treeheighterror(Exception): def __init__(self): super().__init__(self, 'Cannot add node lower than tree height')
CROCKFORD_MODIFIED = ( b"ahm6a81a59rqaub3dcn2m832e9qqevh0ctqqg83aenpq0wt0dxv6awh0ehm6a818dhgqmy994" b"1j6ytt1" ) CROCKFORD = ( b"AHM6A81A59RQATB3DCN2M832E9QQEVH0CSQQG83AENPQ0WS0DXV6AWH0EHM6A818DHGQMY994" b"1J6YSS1" ) ZBASE32 = ( b"ktwgkebkfjazk4mdpcinwednqjzzq5tyc3zzoedkqiszyh3yp75gkhtyqtwgkebeptozw...
crockford_modified = b'ahm6a81a59rqaub3dcn2m832e9qqevh0ctqqg83aenpq0wt0dxv6awh0ehm6a818dhgqmy9941j6ytt1' crockford = b'AHM6A81A59RQATB3DCN2M832E9QQEVH0CSQQG83AENPQ0WS0DXV6AWH0EHM6A818DHGQMY9941J6YSS1' zbase32 = b'ktwgkebkfjazk4mdpcinwednqjzzq5tyc3zzoedkqiszyh3yp75gkhtyqtwgkebeptozw6jjrb1g633b' rfc_3548 = b'KRUGKIBKFJYX...
# Script to help automation of converting a cpu/layoutX/CpuConstraintPoly.sol contract to Rust # Parses out "mload(0xDEADBEEF)" (Solidity EVM Assembley Command) from the file and replaces it with the proper Rust equivalent # Note: replace file_name.txt appropriately # file_name.txt should contain Solidity Assembly fro...
f = open('file_name.txt', 'r') text = f.read() parsed_num = '' start_parsing = False i = 5 mload_start_idx = -1 while i < len(text): if text[i] == ')' and startParsing: addr = int(parsedNum, 0) new_text = '' if addr == 0: new_text += 'ctx[map::MM_PERIODIC_COLUMN__PEDERSEN__POINTS...
del_items(0x80137B7C) SetType(0x80137B7C, "void EA_cd_seek(int secnum)") del_items(0x80137BA4) SetType(0x80137BA4, "void MY_CdGetSector(unsigned long *src, unsigned long *dst, int size)") del_items(0x80137BD8) SetType(0x80137BD8, "void init_cdstream(int chunksize, unsigned char *buf, int bufsize)") del_items(0x80137BE8...
del_items(2148760444) set_type(2148760444, 'void EA_cd_seek(int secnum)') del_items(2148760484) set_type(2148760484, 'void MY_CdGetSector(unsigned long *src, unsigned long *dst, int size)') del_items(2148760536) set_type(2148760536, 'void init_cdstream(int chunksize, unsigned char *buf, int bufsize)') del_items(2148760...
MONOBANK_API_TOKEN = None MONOBANK_API_BASE_URL = 'https://api.monobank.ua' MONOBANK_API_CURRENCY_ENDPOINT = MONOBANK_API_BASE_URL + '/bank/currency' MONOBANK_API_CLIENT_INFO_ENDPOINT = MONOBANK_API_BASE_URL + '/personal/client-info' MONOBANK_API_WEBHOOK_ENDPOINT = MONOBANK_API_BASE_URL + '/personal/webhook' MONOBANK_...
monobank_api_token = None monobank_api_base_url = 'https://api.monobank.ua' monobank_api_currency_endpoint = MONOBANK_API_BASE_URL + '/bank/currency' monobank_api_client_info_endpoint = MONOBANK_API_BASE_URL + '/personal/client-info' monobank_api_webhook_endpoint = MONOBANK_API_BASE_URL + '/personal/webhook' monobank_a...
arquivo = open('numeros.txt', 'w') for linha in range(1, 101): arquivo.write('%d\n' % linha) arquivo.close()
arquivo = open('numeros.txt', 'w') for linha in range(1, 101): arquivo.write('%d\n' % linha) arquivo.close()
def getMessage(content): firstCarrot = content.index('<') secondCarrot = content.index('>') return content[firstCarrot+3:secondCarrot] y = getMessage('GG <@!799778925936246804>, you just advanced to level 5') print(y)
def get_message(content): first_carrot = content.index('<') second_carrot = content.index('>') return content[firstCarrot + 3:secondCarrot] y = get_message('GG <@!799778925936246804>, you just advanced to level 5') print(y)
# Bubble sort def sort_bubble(my_list): for i in range(len(my_list) - 1, 0, -1): for j in range(i): if my_list[j] > my_list[j + 1]: my_list[j], my_list[j + 1] = my_list[j + 1], my_list[j] return my_list print(sort_bubble([1,4,2,6,5,3,1]))
def sort_bubble(my_list): for i in range(len(my_list) - 1, 0, -1): for j in range(i): if my_list[j] > my_list[j + 1]: (my_list[j], my_list[j + 1]) = (my_list[j + 1], my_list[j]) return my_list print(sort_bubble([1, 4, 2, 6, 5, 3, 1]))
#program to enter number followed by commas and the storing those numbers in a list arr=[];r=0; a=input("ENter numbers followed by commas :") l=a.split(",") m='' for c in a: if(c!=','): m=m+c; else: arr.append(int(m)); m=''; arr.append(int(m)); print(arr);
arr = [] r = 0 a = input('ENter numbers followed by commas :') l = a.split(',') m = '' for c in a: if c != ',': m = m + c else: arr.append(int(m)) m = '' arr.append(int(m)) print(arr)
file = open ("employees.txt" , "r") if(file.readable()): print("Success") else: print("Error") print() #read the whole file print(file.read()) #rewind file pointer file.seek(0) print() #read individual line print(file.readline()) #rewind file pointer file.seek(0) print() #read the whole file and set as l...
file = open('employees.txt', 'r') if file.readable(): print('Success') else: print('Error') print() print(file.read()) file.seek(0) print() print(file.readline()) file.seek(0) print() print(file.readlines()) file.seek(0) print() print(file.readlines()[1]) file.seek(0) print() for employee in file.readlines(): ...
''' Script converts data from newline seperated values to comma seperated values ''' fName = input('Enter File Name:') with open(fName,'r') as f: lines = f.read() f.close() values = lines.splitlines() s = 'time\n' for val in values: s = s + val.strip() + '\n' print(s) with open(fName,'w') as f: f.w...
""" Script converts data from newline seperated values to comma seperated values """ f_name = input('Enter File Name:') with open(fName, 'r') as f: lines = f.read() f.close() values = lines.splitlines() s = 'time\n' for val in values: s = s + val.strip() + '\n' print(s) with open(fName, 'w') as f: f.wri...
# Spiritual Release (57462) sakuno = 9130021 sm.setSpeakerID(sakuno) sm.sendNext("Kanna, please come to Momijigaoka. We have news.") sm.setPlayerAsSpeaker() sm.sendSay("I wonder what's going on? I hope Oda's Army isn't on the move.") sm.startQuest(parentID)
sakuno = 9130021 sm.setSpeakerID(sakuno) sm.sendNext('Kanna, please come to Momijigaoka. We have news.') sm.setPlayerAsSpeaker() sm.sendSay("I wonder what's going on? I hope Oda's Army isn't on the move.") sm.startQuest(parentID)
Theatre_1 = {"Name":'Lviv', "Seats_Number":120, "Actors_1":["Andrew Kigan","Jhon Speelberg","Alan Mask","Neil Bambino"], "Play_1":["25/03/2018","Aida",80,"Andrew Kigan","Jhon Speelberg",60,"OK"], "Play_2":["26/03/2018","War",220,"Jhon Speelberg","Jhon Speelberg","Alan...
theatre_1 = {'Name': 'Lviv', 'Seats_Number': 120, 'Actors_1': ['Andrew Kigan', 'Jhon Speelberg', 'Alan Mask', 'Neil Bambino'], 'Play_1': ['25/03/2018', 'Aida', 80, 'Andrew Kigan', 'Jhon Speelberg', 60, 'OK'], 'Play_2': ['26/03/2018', 'War', 220, 'Jhon Speelberg', 'Jhon Speelberg', 'Alan Mask', 'Neil Bambino', 100, 'OK'...
''' Subgraphs II In the previous exercise, we gave you a list of nodes whose neighbors we asked you to extract. Let's try one more exercise in which you extract nodes that have a particular metadata property and their neighbors. This should hark back to what you've learned about using list comprehensions to find node...
""" Subgraphs II In the previous exercise, we gave you a list of nodes whose neighbors we asked you to extract. Let's try one more exercise in which you extract nodes that have a particular metadata property and their neighbors. This should hark back to what you've learned about using list comprehensions to find node...
# program description # :: python # :: allows user to enter initial height of ball before dropped # :: outputs total distance traveled by ball based on number of bounces # constants bounceIndex = float(0.6) # input variables height = int(input("Enter Ball Height: ")) numberOfBounces = float(input("Enter Number Of Bal...
bounce_index = float(0.6) height = int(input('Enter Ball Height: ')) number_of_bounces = float(input('Enter Number Of Ball Bounces: ')) distance = 0 while numberOfBounces > 0: distance += height height *= bounceIndex distance += height number_of_bounces -= 1 print('Total Distance Traveled: ' + str(dista...
class Stack: def __init__(self): self.items = [] def push(self, e): self.items = [e] + self.items def pop(self): return self.items.pop() s = Stack() s.push(5) # [5] s.push(7) # [7, 5] s.push(11) # [11, 7, 5] print(s.pop()) # returns 11, left is [7, 5] print(s.pop()) ...
class Stack: def __init__(self): self.items = [] def push(self, e): self.items = [e] + self.items def pop(self): return self.items.pop() s = stack() s.push(5) s.push(7) s.push(11) print(s.pop()) print(s.pop())
i=map(int, raw_input()) c=0 for m in i: c = c+1 if m==4 or m==7 else c print("YES" if c==4 or c==7 else "NO")
i = map(int, raw_input()) c = 0 for m in i: c = c + 1 if m == 4 or m == 7 else c print('YES' if c == 4 or c == 7 else 'NO')
class Solution: def tribonacci(self, n: int) -> int: if n <= 1: return n arr = [0 for i in range(n+1)] arr[1], arr[2] = 1, 1 for i in range(3, len(arr)): arr[i] = arr[i-1] + arr[i-2] + arr[i-3] return arr[n] s = Solution() print(s.tribonacc...
class Solution: def tribonacci(self, n: int) -> int: if n <= 1: return n arr = [0 for i in range(n + 1)] (arr[1], arr[2]) = (1, 1) for i in range(3, len(arr)): arr[i] = arr[i - 1] + arr[i - 2] + arr[i - 3] return arr[n] s = solution() print(s.tribonac...
class Yo(): def __init__(self, name): self.name = name def say_name(self): print('Yo {}!'.format(self.name))
class Yo: def __init__(self, name): self.name = name def say_name(self): print('Yo {}!'.format(self.name))
class AlreadyFiredError(RuntimeError): pass class InvalidBoardError(RuntimeError): pass class InvalidMoveError(RuntimeError): pass
class Alreadyfirederror(RuntimeError): pass class Invalidboarderror(RuntimeError): pass class Invalidmoveerror(RuntimeError): pass
class Solution: def canPermutePalindrome(self, s: str) -> bool: x={} k=0 for i in set(s): x[i]=s.count(i) for i,j in x.items(): if j%2!=0: k=k+1 if k>1: return False return True
class Solution: def can_permute_palindrome(self, s: str) -> bool: x = {} k = 0 for i in set(s): x[i] = s.count(i) for (i, j) in x.items(): if j % 2 != 0: k = k + 1 if k > 1: return False return True
def test_user_creation(faunadb_client): username = "burgerbob" created_user = faunadb_client.create_user( username=username, password="password1234" ) assert created_user["username"] == username all_users = faunadb_client.all_users() assert len(all_users) == 1
def test_user_creation(faunadb_client): username = 'burgerbob' created_user = faunadb_client.create_user(username=username, password='password1234') assert created_user['username'] == username all_users = faunadb_client.all_users() assert len(all_users) == 1
''' ## Questions ### 154. [Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/) Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Find the minimum element....
""" ## Questions ### 154. [Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/) Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Find the minimum element....
# # PySNMP MIB module CISCO-ATM-SERVICE-REGISTRY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ATM-SERVICE-REGISTRY-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:33:26 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constraint, single_value_constraint, constraints_intersection, constraints_union) ...
def is_anagram(first, second): return sorted(list(first)) == sorted(list(second)) def main(): valid = 0 with open('day_4.in', 'r') as f: for l in f.readlines(): split = l.strip().split(' ') valid_passphrase = True for start in range(0, len(split) - 1): ...
def is_anagram(first, second): return sorted(list(first)) == sorted(list(second)) def main(): valid = 0 with open('day_4.in', 'r') as f: for l in f.readlines(): split = l.strip().split(' ') valid_passphrase = True for start in range(0, len(split) - 1): ...
APP_KEY = 'u5lo5mX6IzAyv9TQJZG5tErDP' APP_SECRET = 'pJ294qcsbwcEty3ePPbGYVbD9sTL2J7dgC7BDdQ4KyoupmAxHS' OAUTH_TOKEN = '1285969065996095488-WqwqIQPP69TovfaCISoY6DkWWgwajY' OAUTH_TOKEN_SECRET = 'PIC1rTAs9Q9HD8zpGV7dMC5FMXpWmM5yn5WFhpJHt3li5' ## Your Telegram Channel Name ## channel_name = 'uchihacommunity' ## Telegram A...
app_key = 'u5lo5mX6IzAyv9TQJZG5tErDP' app_secret = 'pJ294qcsbwcEty3ePPbGYVbD9sTL2J7dgC7BDdQ4KyoupmAxHS' oauth_token = '1285969065996095488-WqwqIQPP69TovfaCISoY6DkWWgwajY' oauth_token_secret = 'PIC1rTAs9Q9HD8zpGV7dMC5FMXpWmM5yn5WFhpJHt3li5' channel_name = 'uchihacommunity' telegram_token = '1395164117:AAGmUsXuvPng9mwyWt...
def euler(): d = True x = 1 while d == True: x += 1 x_1 = str(x) x_2 = f"{2 * x}" x_3 = f"{3 * x}" x_4 = f"{4 * x}" x_5 = f"{5 * x}" x_6 = f"{6 * x}" if len(x_1) != len(x_6): continue sez1 = [] sez2 =...
def euler(): d = True x = 1 while d == True: x += 1 x_1 = str(x) x_2 = f'{2 * x}' x_3 = f'{3 * x}' x_4 = f'{4 * x}' x_5 = f'{5 * x}' x_6 = f'{6 * x}' if len(x_1) != len(x_6): continue sez1 = [] sez2 = [] sez3...
# Given a string s, return the longest palindromic substring in s. # # Example 1: # Input: s = "babad" # Output: "bab" # Note: "aba" is also a valid answer. # lets first check if s a palindrome def palindrome(s): mid = len(s) // 2 if len(s) % 2 != 0: if s[:mid] == s[:mid:-1]: return s ...
def palindrome(s): mid = len(s) // 2 if len(s) % 2 != 0: if s[:mid] == s[:mid:-1]: return s elif s[:mid] == s[:mid - 1:-1]: return s return '' def longest_palindrome(s): if palindrome(s) == s: return s longest = s[0] for i in range(0, len(s)): for...
def algo(load, plants): row = 0 produced = 0 names = [] p = [] for i in range(len(plants)): if row < len(plants): battery = plants.iloc[row, :] names.append(battery["name"]) if load > produced: temp = load - produced ...
def algo(load, plants): row = 0 produced = 0 names = [] p = [] for i in range(len(plants)): if row < len(plants): battery = plants.iloc[row, :] names.append(battery['name']) if load > produced: temp = load - produced if batt...
# note the looping - we set the initial value for x =10 and when the first for loop is # executed, it is evaluated at that time, so changing the variable x in the loop # does not effect that loop. Now the next time that for loop is executed at that # time the new value of x is used! x = 10 for i in range(0,x): pr...
x = 10 for i in range(0, x): print(i) x = 5 for i in range(0, x): print(i) x = 5 for i in range(0, x): for j in range(0, x): print(i, j) x = 3
# This is a variable concept ''' a = 10 print(a) print(type(a)) a = 10.33 print(a) print(type(a)) a = "New Jersey" print(a) print(type(a)) ''' #a = input() #print(a) name = input("Please enter your name : ") print("Your name is ",name) print(type(name)) number = int(input("Enter your number : ")) #Explicit type ...
""" a = 10 print(a) print(type(a)) a = 10.33 print(a) print(type(a)) a = "New Jersey" print(a) print(type(a)) """ name = input('Please enter your name : ') print('Your name is ', name) print(type(name)) number = int(input('Enter your number : ')) print('Your number is ', number) print(type(number))
def vowels(word): if (word[0] in 'AEIOU' or word[0] in 'aeiou'): if (word[len(word) - 1] in 'AEIOU' or word[len(word) - 1] in 'aeiou'): return 'First and last letter of ' + word + ' is vowel' else: return 'First letter of ' + word + ' is vowel' else: return 'Not a...
def vowels(word): if word[0] in 'AEIOU' or word[0] in 'aeiou': if word[len(word) - 1] in 'AEIOU' or word[len(word) - 1] in 'aeiou': return 'First and last letter of ' + word + ' is vowel' else: return 'First letter of ' + word + ' is vowel' else: return 'Not a vow...
dist = [] for num in range(1, 1000): if (num % 3 == 0) or (num % 5 == 0): dist.append(num) print(sum(dist))
dist = [] for num in range(1, 1000): if num % 3 == 0 or num % 5 == 0: dist.append(num) print(sum(dist))
add_init_container = [ { 'op': 'add', 'path': '/some/new/path', 'value': 'some-value', }, ]
add_init_container = [{'op': 'add', 'path': '/some/new/path', 'value': 'some-value'}]
def get_persistent_id(node_unicode_proxy, *args, **kwargs): return node_unicode_proxy def get_type(node, *args, **kwargs): return type(node) def is_exact_type(node, typename, *args, **kwargs): return isinstance(node, typename) def is_type(node, typename, *args, **kwargs): return typename in ['Tran...
def get_persistent_id(node_unicode_proxy, *args, **kwargs): return node_unicode_proxy def get_type(node, *args, **kwargs): return type(node) def is_exact_type(node, typename, *args, **kwargs): return isinstance(node, typename) def is_type(node, typename, *args, **kwargs): return typename in ['Transfo...
age = 20 if age >= 20 and age == 30: print('age == 30') elif age >= 20 or age == 30: print(' age >= 20 or age == 30') else: print('...')
age = 20 if age >= 20 and age == 30: print('age == 30') elif age >= 20 or age == 30: print(' age >= 20 or age == 30') else: print('...')
def namta(p=1): for i in range(1, 11): print(p, "x", i, "=", p*i) namta(5) namta()
def namta(p=1): for i in range(1, 11): print(p, 'x', i, '=', p * i) namta(5) namta()
num_waves = 2 num_eqn = 2 # Conserved quantities pressure = 0 velocity = 1
num_waves = 2 num_eqn = 2 pressure = 0 velocity = 1
# Defining our main object of interation game = [[0,0,0], [0,0,0], [0,0,0]] #printing a column index, printing a row index, now #we have a coordinate to make a move, like c2 def game_board(player=0, row=1, column=1, just_display=False): print(' 1 2 3') if not just_display: game[row...
game = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] def game_board(player=0, row=1, column=1, just_display=False): print(' 1 2 3') if not just_display: game[row][column] = player for (count, row) in enumerate(game, 1): print(count, row) game_board(just_display=True) game_board(player=1, row=2, col...
def function_2(x): return x[0]**2 + x[1]**2 def numerical_diff(f, x): h = 1e-4 return (f(x+h) - f(x-h)) / (2*h) def function_tmp1(x0): return x0*x0 + 4.0**2 def function_tmp2(x1): return 3.0**2.0 + x1*x1 print(numerical_diff(function_tmp1, 3.0)) print(numerical_diff(function_tmp2, 4.0))
def function_2(x): return x[0] ** 2 + x[1] ** 2 def numerical_diff(f, x): h = 0.0001 return (f(x + h) - f(x - h)) / (2 * h) def function_tmp1(x0): return x0 * x0 + 4.0 ** 2 def function_tmp2(x1): return 3.0 ** 2.0 + x1 * x1 print(numerical_diff(function_tmp1, 3.0)) print(numerical_diff(function_t...
JOBS_RAW = { 0: { "Name": "Farmer" }, 1: { "Name": "Baker" }, 2: { "Name": "Lumberjack" }, 3: { "Name": "Carpenter" } }
jobs_raw = {0: {'Name': 'Farmer'}, 1: {'Name': 'Baker'}, 2: {'Name': 'Lumberjack'}, 3: {'Name': 'Carpenter'}}
def work(x): x = x.split("cat ") #"cat " is a delimiter for the whole command dividing the line on two parts f = open(x[1], "r") #the second part is a filename or path (in the future) print(f.read()) #outputs the content of the specified file
def work(x): x = x.split('cat ') f = open(x[1], 'r') print(f.read())
num = int(input('Enter a number:')) count = 0 while num != 0: num //= 10 count += 1 print("Total digits are: ", count)
num = int(input('Enter a number:')) count = 0 while num != 0: num //= 10 count += 1 print('Total digits are: ', count)
class MetodoDeNewton(object): def __init__(self, f, f_derivada, x0, precisao=0.001, max_interacoes=15): self.__X = [x0] self.__interacoes = 0 while self.interacoes < max_interacoes: self.__X.append(self.X[-1] - f(self.X[-1]) / f_derivada(self.X[-1])) ...
class Metododenewton(object): def __init__(self, f, f_derivada, x0, precisao=0.001, max_interacoes=15): self.__X = [x0] self.__interacoes = 0 while self.interacoes < max_interacoes: self.__X.append(self.X[-1] - f(self.X[-1]) / f_derivada(self.X[-1])) self.__interacoe...
S = input() t = ''.join(c if c in 'ACGT' else ' ' for c in S) print(max(map(len, t.split(' '))))
s = input() t = ''.join((c if c in 'ACGT' else ' ' for c in S)) print(max(map(len, t.split(' '))))
# coding=utf-8 def point_inside(p, bounds): return bounds[3] <= p[0] <= bounds[1] and bounds[0] <= p[1] <= bounds[2]
def point_inside(p, bounds): return bounds[3] <= p[0] <= bounds[1] and bounds[0] <= p[1] <= bounds[2]
#Python Operators x = 9 y = 3 #Arithmetic operators print(x+y) #Addition print(x-y) #Subtraction print(x*y) #Multiplication print(x/y) #Division print(x%y) #Modulus print(x**y) #Exponentiation x = 9.191823 print(x//y) #Floor division #Assignment operators x = 9 x += 3 print(x) x = 9 x -= 3 print(x) x *= 3 print(x) x...
x = 9 y = 3 print(x + y) print(x - y) print(x * y) print(x / y) print(x % y) print(x ** y) x = 9.191823 print(x // y) x = 9 x += 3 print(x) x = 9 x -= 3 print(x) x *= 3 print(x) x /= 3 print(x) x **= 3 print(x) x = 9 y = 3 print(x == y) print(x != y) print(x > y) print(x < y) print(x >= y) print(x <= y)
# 2020.04.27 # https://leetcode.com/problems/add-two-numbers/submissions/ # works # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: def addTwoNumbers(...
class Listnode: def __init__(self, x): self.val = x self.next = None class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: list1 = [] list1.append(l1.val) mask = l1 while mask.next: if mask.next: list1.ap...
KNOWN_PATHS = [ "/etc/systemd/*", "/etc/systemd/**/*", "/lib/systemd/*", "/lib/systemd/**/*", "/run/systemd/*", "/run/systemd/**/*", "/usr/lib/systemd/*", "/usr/lib/systemd/**/*", ] KNOWN_DROPIN_PATHS = { "user.conf": [ "/etc/systemd/%unit%.d/*.conf", "/run/systemd/%unit%.d/...
known_paths = ['/etc/systemd/*', '/etc/systemd/**/*', '/lib/systemd/*', '/lib/systemd/**/*', '/run/systemd/*', '/run/systemd/**/*', '/usr/lib/systemd/*', '/usr/lib/systemd/**/*'] known_dropin_paths = {'user.conf': ['/etc/systemd/%unit%.d/*.conf', '/run/systemd/%unit%.d/*.conf', '/usr/lib/systemd/%unit%.d/*.conf', '/lib...
# Created by MechAviv # ID :: [101000010] # Ellinia : Magic Library sm.warp(101000000, 4)
sm.warp(101000000, 4)
class SubrectangleQueries: def __init__(self, rectangle: List[List[int]]): self.rectangle = rectangle def updateSubrectangle(self, row1: int, col1: int, row2: int, col2: int, newValue: int) -> None: self.row1, self.col1, self.row2, self.col2, self.newValue = row1, col1, row2, col2, newValue ...
class Subrectanglequeries: def __init__(self, rectangle: List[List[int]]): self.rectangle = rectangle def update_subrectangle(self, row1: int, col1: int, row2: int, col2: int, newValue: int) -> None: (self.row1, self.col1, self.row2, self.col2, self.newValue) = (row1, col1, row2, col2, newValu...
# 2nd Solution i = 4 d = 4.0 s = 'HackerRank ' a = int(input()) b = float(input()) c = input() print(i+a) print(d+b) print(s+c)
i = 4 d = 4.0 s = 'HackerRank ' a = int(input()) b = float(input()) c = input() print(i + a) print(d + b) print(s + c)
{ 'includes': [ 'common.gyp', 'amo.gypi', ], 'targets': [ { 'target_name': 'amo', 'product_name': 'amo', 'type': 'none', 'sources': [ '<@(source_code_amo)', ], 'dependencies': [ ] ...
{'includes': ['common.gyp', 'amo.gypi'], 'targets': [{'target_name': 'amo', 'product_name': 'amo', 'type': 'none', 'sources': ['<@(source_code_amo)'], 'dependencies': []}]}
def imprime_quadro(numeros): print('.' * (len(numeros) + 2)) maior_numero = max(numeros) numeros_traduzidos = [] for numero in numeros: numeros_traduzidos.append(['|' if n < numero else ' ' for n in range(maior_numero)][::-1]) for linha in zip(*numeros_traduzidos): print('.' + ''.join(linha) + '.') print('.' ...
def imprime_quadro(numeros): print('.' * (len(numeros) + 2)) maior_numero = max(numeros) numeros_traduzidos = [] for numero in numeros: numeros_traduzidos.append(['|' if n < numero else ' ' for n in range(maior_numero)][::-1]) for linha in zip(*numeros_traduzidos): print('.' + ''.joi...
# a, b = 10, 10 print(a == b) print(a is b) print(id(a), id(b)) a1 = [1, 2, 3, 4] b1 = [1, 2, 3, 4] print(a1 == b1) print(a1 is b1) print(id(a1), id(b1))
(a, b) = (10, 10) print(a == b) print(a is b) print(id(a), id(b)) a1 = [1, 2, 3, 4] b1 = [1, 2, 3, 4] print(a1 == b1) print(a1 is b1) print(id(a1), id(b1))
total = 0 media = 0.0 for i in range(6): num = float(input()) if num > 0.0: total += 1 media += num print('{} valores positivos'.format(total)) print('{:.1f}'.format(media/total))
total = 0 media = 0.0 for i in range(6): num = float(input()) if num > 0.0: total += 1 media += num print('{} valores positivos'.format(total)) print('{:.1f}'.format(media / total))
# http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0201.TXT JIS0201_map = { '20' : 0x0020, # SPACE '21' : 0x0021, # EXCLAMATION MARK '22' : 0x0022, # QUOTATION MARK '23' : 0x0023, # NUMBER SIGN '24' : 0x0024, # DOLLAR SIGN '25' : 0x0025, # PERCENT SIGN '26' : 0x0...
jis0201_map = {'20': 32, '21': 33, '22': 34, '23': 35, '24': 36, '25': 37, '26': 38, '27': 39, '28': 40, '29': 41, '2A': 42, '2B': 43, '2C': 44, '2D': 45, '2E': 46, '2F': 47, '30': 48, '31': 49, '32': 50, '33': 51, '34': 52, '35': 53, '36': 54, '37': 55, '38': 56, '39': 57, '3A': 58, '3B': 59, '3C': 60, '3D': 61, '3E':...
#it is collection of data and methods. class gohul: a=100 b=200 def func(self): print("Inside function") print(gohul.func(1)) object=gohul() print(object.a) print(object.b) print(object.func()) object1=gohul() print(object1.a)
class Gohul: a = 100 b = 200 def func(self): print('Inside function') print(gohul.func(1)) object = gohul() print(object.a) print(object.b) print(object.func()) object1 = gohul() print(object1.a)
class LandingPage: @staticmethod def get(): return 'Beautiful UI'
class Landingpage: @staticmethod def get(): return 'Beautiful UI'
class Peptide: def __init__(self, sequence, proteinID, modification, mass, isNterm): self.sequence = sequence self.length = len(self.sequence) self.proteinID = [proteinID] self.modification = modification self.massArray = self.getMassArray(mass) self.totalResidueMass = self.getTotalResidueMass() self.pm ...
class Peptide: def __init__(self, sequence, proteinID, modification, mass, isNterm): self.sequence = sequence self.length = len(self.sequence) self.proteinID = [proteinID] self.modification = modification self.massArray = self.getMassArray(mass) self.totalResidueMass...
#CMPUT 410 Lab1 by Chongyang Ye #This program allows add courses and #corresponding marks for a student #and count the average score class Student: courseMarks={} name= "" def __init__(self,name,family): self.name = name self.family = family def addCourseMark(self, course, m...
class Student: course_marks = {} name = '' def __init__(self, name, family): self.name = name self.family = family def add_course_mark(self, course, mark): self.courseMarks[course] = mark def average(self): grade = [] grade = self.courseMarks.values() ...
{ "targets": [{ "target_name": "defaults", "sources": [ ], "conditions": [ ['OS=="mac"', { "sources": [ "src/defaults.mm", "src/json_formatter.h", "src/json_formatter.cc" ], }] ], 'include_dirs': [ "<!@(node -p \"require('node-addon-a...
{'targets': [{'target_name': 'defaults', 'sources': [], 'conditions': [['OS=="mac"', {'sources': ['src/defaults.mm', 'src/json_formatter.h', 'src/json_formatter.cc']}]], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'libraries': [], 'dependencies': ['<!(node -p "require(\'node-addon-api\').gyp...
#!/usr/bin/env python # -*- encoding: utf-8; py-indent-offset: 4 -*- register_rule("agents/" + _("Agent Plugins"), "agent_config:nvidia_gpu", DropdownChoice( title = _("Nvidia GPU (Linux)"), help = _("This will deploy the agent plugin <tt>nvidia_gpu</tt> to collect GPU utilization values."), ...
register_rule('agents/' + _('Agent Plugins'), 'agent_config:nvidia_gpu', dropdown_choice(title=_('Nvidia GPU (Linux)'), help=_('This will deploy the agent plugin <tt>nvidia_gpu</tt> to collect GPU utilization values.'), choices=[(True, _('Deploy plugin for GPU Monitoring')), (None, _('Do not deploy plugin for GPU Monit...
#!/usr/bin/env python types = [ ("bool", "Bool", "strconv.FormatBool(bool(*%s))", "*%s == false"), ("uint8", "Uint8", "strconv.FormatUint(uint64(*%s), 10)", "*%s == 0"), ("uint16", "Uint16", "strconv.FormatUint(uint64(*%s), 10)", "*%s == 0"), ("uint32", "Uint32", "strconv.FormatUint(uint64(*%s), 10)", ...
types = [('bool', 'Bool', 'strconv.FormatBool(bool(*%s))', '*%s == false'), ('uint8', 'Uint8', 'strconv.FormatUint(uint64(*%s), 10)', '*%s == 0'), ('uint16', 'Uint16', 'strconv.FormatUint(uint64(*%s), 10)', '*%s == 0'), ('uint32', 'Uint32', 'strconv.FormatUint(uint64(*%s), 10)', '*%s == 0'), ('uint64', 'Uint64', 'strco...
class OriginEPG(): def __init__(self, fhdhr): self.fhdhr = fhdhr def update_epg(self, fhdhr_channels): programguide = {} for fhdhr_id in list(fhdhr_channels.list.keys()): chan_obj = fhdhr_channels.list[fhdhr_id] if str(chan_obj.number) not in list(programgui...
class Originepg: def __init__(self, fhdhr): self.fhdhr = fhdhr def update_epg(self, fhdhr_channels): programguide = {} for fhdhr_id in list(fhdhr_channels.list.keys()): chan_obj = fhdhr_channels.list[fhdhr_id] if str(chan_obj.number) not in list(programguide.key...
class TrieNode: def __init__(self): self.children = {} self.endOfString = False class Trie: def __init__(self): self.root = TrieNode() def insert(self, word): currNode = self.root for char in word: if char not in currNode.children: currN...
class Trienode: def __init__(self): self.children = {} self.endOfString = False class Trie: def __init__(self): self.root = trie_node() def insert(self, word): curr_node = self.root for char in word: if char not in currNode.children: cu...
def get_capabilities(): return [ "bogus_capability" ] def should_ignore_response(): return True
def get_capabilities(): return ['bogus_capability'] def should_ignore_response(): return True
class ExportModuleToFile(object): def __init__(self, **kargs): self.moduleId = kargs["moduleId"] if "moduleId" in kargs else None self.exportType = kargs["exportType"] if "exportType" in kargs else None
class Exportmoduletofile(object): def __init__(self, **kargs): self.moduleId = kargs['moduleId'] if 'moduleId' in kargs else None self.exportType = kargs['exportType'] if 'exportType' in kargs else None
class Preprocessor: def __init__(self, title): self.title = title def evaluate(self, value): return value
class Preprocessor: def __init__(self, title): self.title = title def evaluate(self, value): return value
s=input() li=list(map(int,s.split(' '))) while(li!=sorted(li)): n=(len(li)//2) for i in range(n): li.pop() print(li)
s = input() li = list(map(int, s.split(' '))) while li != sorted(li): n = len(li) // 2 for i in range(n): li.pop() print(li)
#!/usr/bin/env python3 #Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5. #Extras: #Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in...
list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] num = int(input('Enter a number for comparison: ')) print('numbers less than %d are: ' % num) print([element for element in list if element < num])
# # Example file for working with loops # def main(): x = 0 # define a while loop while (x<5): print(x) x+=1 # define a for loop for i in range(5): x -= 1 print(x) # use a for loop over a collection days = ["Mon","Tue","Wed",\ "Thurs","Fri","Sat","Sun"] for day in days: ...
def main(): x = 0 while x < 5: print(x) x += 1 for i in range(5): x -= 1 print(x) days = ['Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun'] for day in days: print(day) for day in days: if day == 'Wed': continue if day == 'Fri':...
def solution(S): hash1 = dict() count = 0 ans = -0 ans_final = 0 if(len(S)==1): print("0") pass else: for i in range(len(S)): #print(S[i]) if(S[i] in hash1): #print("T") value = hash1[S[i]] hash1[S[i]] = i if(value > i): ans = value - i count = 0 else: ans = i - va...
def solution(S): hash1 = dict() count = 0 ans = -0 ans_final = 0 if len(S) == 1: print('0') pass else: for i in range(len(S)): if S[i] in hash1: value = hash1[S[i]] hash1[S[i]] = i if value > i: ...
Size = (400, 400) Position = (0, 0) ScaleFactor = 1.0 ZoomLevel = 50.0 Orientation = 0 Mirror = 0 NominalPixelSize = 0.12237 filename = '' ImageWindow.Center = None ImageWindow.ViewportCenter = (1.4121498000000001, 1.2090156) ImageWindow.crosshair_color = (255, 0, 255) ImageWindow.boxsize = (0.1, 0.06) ImageWindow.box_...
size = (400, 400) position = (0, 0) scale_factor = 1.0 zoom_level = 50.0 orientation = 0 mirror = 0 nominal_pixel_size = 0.12237 filename = '' ImageWindow.Center = None ImageWindow.ViewportCenter = (1.4121498000000001, 1.2090156) ImageWindow.crosshair_color = (255, 0, 255) ImageWindow.boxsize = (0.1, 0.06) ImageWindow....
# Project Euler Problem 7- 10001st prime # https://projecteuler.net/problem=7 # Answer = 104743 def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True def prime_list(): prime_list = [] num = 2 while True: if is_prime(num): p...
def is_prime(num): for i in range(2, num): if num % i == 0: return False return True def prime_list(): prime_list = [] num = 2 while True: if is_prime(num): prime_list.append(num) if len(prime_list) == 10001: return prime_list[-1] ...
# Approach 2 - Greedy with Stack # Time: O(N) # Space: O(N) class Solution: def removeKdigits(self, num: str, k: int) -> str: num_stack = [] for digit in num: while k and num_stack and num_stack[-1] > digit: num_stack.pop() k -= 1 ...
class Solution: def remove_kdigits(self, num: str, k: int) -> str: num_stack = [] for digit in num: while k and num_stack and (num_stack[-1] > digit): num_stack.pop() k -= 1 num_stack.append(digit) final_stack = num_stack[:-k] if k els...
def get_keys(filename): with open(filename) as f: data = f.read() doc = data.split("\n") res = [] li = [] for i in doc: if i != "": li.append(i) else: res.append(li) li=[] return res if __name__=="__main__": filename = './input.txt' input = get_keys(filen...
def get_keys(filename): with open(filename) as f: data = f.read() doc = data.split('\n') res = [] li = [] for i in doc: if i != '': li.append(i) else: res.append(li) li = [] return res if __name__ == ...
expected_output = { "mac_table": { "vlans": { "100": { "mac_addresses": { "ecbd.1dff.5f92": { "drop": {"drop": True, "entry_type": "dynamic"}, "mac_address": "ecbd.1dff.5f92", }, ...
expected_output = {'mac_table': {'vlans': {'100': {'mac_addresses': {'ecbd.1dff.5f92': {'drop': {'drop': True, 'entry_type': 'dynamic'}, 'mac_address': 'ecbd.1dff.5f92'}, '3820.56ff.6f75': {'interfaces': {'Port-channel12': {'interface': 'Port-channel12', 'entry_type': 'dynamic'}}, 'mac_address': '3820.56ff.6f75'}, '58b...
package = FreeDesktopPackage('%{name}', 'pkg-config', '0.27', configure_flags=["--with-internal-glib"]) if package.profile.name == 'darwin': package.m64_only = True
package = free_desktop_package('%{name}', 'pkg-config', '0.27', configure_flags=['--with-internal-glib']) if package.profile.name == 'darwin': package.m64_only = True
def task_format(): return { "actions": ["black .", "isort ."], "verbosity": 2, } def task_test(): return { "actions": ["tox -e py39"], "verbosity": 2, } def task_fulltest(): return { "actions": ["tox --skip-missing-interpreters"], "verbosity": 2, ...
def task_format(): return {'actions': ['black .', 'isort .'], 'verbosity': 2} def task_test(): return {'actions': ['tox -e py39'], 'verbosity': 2} def task_fulltest(): return {'actions': ['tox --skip-missing-interpreters'], 'verbosity': 2} def task_build(): return {'actions': ['flit build'], 'task_de...
# Python Functions # Three types of functions # Built in functions # User-defined functions # Anonymous functions # i.e. lambada functions; not declared with def(): # Method vs function # Method --> function that is part of a class #can only access said method with an instance or object of said class # A s...
def straight_switch(item1, item2): return (item2, item1) class Switchclass(object): def method_switch(self, item1, item2): self.contents = (item2, item1) return self.contents instance = switch_class() print(instance.methodSwitch(1, 2)) stuff = list() print(dir(stuff))
# Copyright (c) OpenMMLab. All rights reserved. model = dict( type='DBNet', backbone=dict( type='mmdet.ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), init_cfg=dict(type='Pretrained...
model = dict(type='DBNet', backbone=dict(type='mmdet.ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='BN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet18'), norm_eval=False, style='caffe'), neck=dict(type='FPNC', in_channels=[2, 4...
for i in range(1, 6): for j in range(1, 6): if(i == 1 or i == 5): print(j, end="") elif(j == 6 - i): print(6 - i, end="") else: print(" ", end="") print()
for i in range(1, 6): for j in range(1, 6): if i == 1 or i == 5: print(j, end='') elif j == 6 - i: print(6 - i, end='') else: print(' ', end='') print()
# Fit image to screen height, optionally stretched horizontally def fit_to_screen(image, loaded_image, is_full_width): # Resize to fill height and width image_w, image_h = loaded_image.size target_w = image_w target_h = image_h image_ratio = float(image_w / image_h) if target_h > image.height: target_h ...
def fit_to_screen(image, loaded_image, is_full_width): (image_w, image_h) = loaded_image.size target_w = image_w target_h = image_h image_ratio = float(image_w / image_h) if target_h > image.height: target_h = image.height target_w = round(image_ratio * target_h) if is_full_width == ...
def setup_parser(common_parser, subparsers): parser = subparsers.add_parser("genotype", parents=[common_parser]) parser.add_argument( "-i", "--gram_dir", help="Directory containing outputs from gramtools `build`", dest="gram_dir", type=str, required=True, ) ...
def setup_parser(common_parser, subparsers): parser = subparsers.add_parser('genotype', parents=[common_parser]) parser.add_argument('-i', '--gram_dir', help='Directory containing outputs from gramtools `build`', dest='gram_dir', type=str, required=True) parser.add_argument('-o', '--genotype_dir', help="Dir...
#coding=utf-8 class Solution: def longestCommonPrefix(self, strs): res = "" strs.sort(key=lambda i: len(i)) # print(strs) for i in range(len(strs[0])): tmp = res + strs[0][i] # print("tmp=",tmp) for each in strs: if each.startsw...
class Solution: def longest_common_prefix(self, strs): res = '' strs.sort(key=lambda i: len(i)) for i in range(len(strs[0])): tmp = res + strs[0][i] for each in strs: if each.startswith(tmp) == False: return res res = t...
def da_sort(lst): count = 0 # replica = [x for x in lst] result = sorted(array) for char in lst: if char != result[0]: count += 1 else: result.pop(0) return count T = int(input()) for _ in range(T): k, n = map(int, input().split()) array...
def da_sort(lst): count = 0 result = sorted(array) for char in lst: if char != result[0]: count += 1 else: result.pop(0) return count t = int(input()) for _ in range(T): (k, n) = map(int, input().split()) array = [] if n % 10 == 0: iterange = n...
def netmiko_config(device, configuration=None, **kwargs): if configuration: output = device['nc'].send_config_set(configuration) else: output = "No configuration to send." return output
def netmiko_config(device, configuration=None, **kwargs): if configuration: output = device['nc'].send_config_set(configuration) else: output = 'No configuration to send.' return output
# x = 5 # # # def print_x(): # print(f'Print {x}') # # # print(x) # print_x() # # # def f1(): # def nested_f1(): # # nonlocal y # # y += 1 # y = 88 # ll.append(3) # # ll = [3] # z = 7 # print('From nested f1') # print(x) # print(y) # ...
def get_my_print(): count = 0 def my_print(x): nonlocal count count += 1 print(f'My ({count}): {x}') return my_print my_print = get_my_print() my_print('1') my_print('Pesho') my_print('Apples')
def get_int_value(text): text = text.strip() if len(text) > 1 and text[:1] == '0': second_char = text[1:2] if second_char == 'x' or second_char == 'X': # hexa-decimal value return int(text[2:], 16) elif second_char == 'b' or second_char == 'B': # binar...
def get_int_value(text): text = text.strip() if len(text) > 1 and text[:1] == '0': second_char = text[1:2] if second_char == 'x' or second_char == 'X': return int(text[2:], 16) elif second_char == 'b' or second_char == 'B': return int(text[2:], 2) else: ...
class AdvancedArithmetic(object): def divisorSum(n): raise NotImplementedError class Calculator(AdvancedArithmetic): def getDivisors(self, n): if n == 1: return [1] maximum, num = n, 2 result = [1, n] while num < maximum: if not n % num: ...
class Advancedarithmetic(object): def divisor_sum(n): raise NotImplementedError class Calculator(AdvancedArithmetic): def get_divisors(self, n): if n == 1: return [1] (maximum, num) = (n, 2) result = [1, n] while num < maximum: if not n % num: ...
class Node: def __init__(self, item, next=None): self.value = item self.next = next def linked_list_to_array(LList): item = [] if LList is None: return [] item = item + [LList.value] zz = LList while zz.next is not None: item = item + [zz.next.value] zz ...
class Node: def __init__(self, item, next=None): self.value = item self.next = next def linked_list_to_array(LList): item = [] if LList is None: return [] item = item + [LList.value] zz = LList while zz.next is not None: item = item + [zz.next.value] zz ...
# /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab : */ class d: def __init__(i, tag, txt, nl="", kl=None): i.tag, i.nl, i.kl, i.txt = tag, nl, kl, txt def __repr__(i): s="" if isinstance(i.txt,(list,tuple)): s = ''.join([str(x) for x in i.txt]) else: s = str(i.txt) kl = ...
class D: def __init__(i, tag, txt, nl='', kl=None): (i.tag, i.nl, i.kl, i.txt) = (tag, nl, kl, txt) def __repr__(i): s = '' if isinstance(i.txt, (list, tuple)): s = ''.join([str(x) for x in i.txt]) else: s = str(i.txt) kl = ' class="%s"' % i.kl i...
students = [ { "name": "John Doe", "age": 15, "sex": "male" }, { "name": "Jane Doe", "age": 12, "sex": "female" }, { "name": "Lockle Rory", "age": 18, "sex": "male" }, { "name": "Seyi Pedro", "age": 10, ...
students = [{'name': 'John Doe', 'age': 15, 'sex': 'male'}, {'name': 'Jane Doe', 'age': 12, 'sex': 'female'}, {'name': 'Lockle Rory', 'age': 18, 'sex': 'male'}, {'name': 'Seyi Pedro', 'age': 10, 'sex': 'female'}]
# 832 SLoC v = FormValidator( firstname=Unicode(), surname=Unicode(required="Please enter your surname"), age=Int(greaterthan(18, "You must be at least 18 to proceed"), required=False), ) input_data = { 'firstname': u'Fred', 'surname': u'Jones', 'age': u'21', } v.process(input_data) == {'age': 21, 'firstn...
v = form_validator(firstname=unicode(), surname=unicode(required='Please enter your surname'), age=int(greaterthan(18, 'You must be at least 18 to proceed'), required=False)) input_data = {'firstname': u'Fred', 'surname': u'Jones', 'age': u'21'} v.process(input_data) == {'age': 21, 'firstname': u'Fred', 'surname': u'Jo...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
def most_frequent_days(year): days=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] if year==2000: return ['Saturday', 'Sunday'] check=2000 if year>check: day=6 while check<year: check+=1 day+=2 if leap(check) else 1 if day%7==0: ...
def most_frequent_days(year): days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] if year == 2000: return ['Saturday', 'Sunday'] check = 2000 if year > check: day = 6 while check < year: check += 1 day += 2 if leap(check) ...