content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# In the code below, you can see a program that creates a full # name from the first and last names for several people. name_1 = "John" last_name_1 = "Lennon" full_name_1 = name_1 + " " + last_name_1 name_2 = "Hermione" last_name_2 = "Granger" full_name_2 = name_2 = " " + last_name_2 # Wouldn't it be much easier if ...
name_1 = 'John' last_name_1 = 'Lennon' full_name_1 = name_1 + ' ' + last_name_1 name_2 = 'Hermione' last_name_2 = 'Granger' full_name_2 = name_2 = ' ' + last_name_2 def create_full_name(name, last_name): return name + ' ' + last_name
metadata = { 'protocolName': 'Station C; Randox Pathway - 24 Samples', 'author': 'Chaz <chaz@opentrons.com; Anton <acjs@stanford.edu>', 'source': 'COVID-19 Project', 'apiLevel': '2.2' } # Protocol constants PCR_LABWARE = 'opentrons_96_aluminumblock_nest_wellplate_100ul' '''PCR labware definition is bas...
metadata = {'protocolName': 'Station C; Randox Pathway - 24 Samples', 'author': 'Chaz <chaz@opentrons.com; Anton <acjs@stanford.edu>', 'source': 'COVID-19 Project', 'apiLevel': '2.2'} pcr_labware = 'opentrons_96_aluminumblock_nest_wellplate_100ul' 'PCR labware definition is based on anonymous plate. May need to change....
SECRET_KEY = 'test' CACHES = { 'default': { 'BACKEND': 'django_memcached_consul.memcached.MemcachedCache', 'TIMEOUT': 60, 'CONSUL_TTL': 60, # Alt cache will be used if consul is unreachable 'CONSUL_ALT_TTL': 3600, 'CONSUL_CACHE': 'consul-memcached', 'CONSUL_H...
secret_key = 'test' caches = {'default': {'BACKEND': 'django_memcached_consul.memcached.MemcachedCache', 'TIMEOUT': 60, 'CONSUL_TTL': 60, 'CONSUL_ALT_TTL': 3600, 'CONSUL_CACHE': 'consul-memcached', 'CONSUL_HOST': 'consul.organization.com', 'CONSUL_PORT': 8500, 'CONSUL_SERVICE': 'memcached-service'}, 'consul-memcached':...
def create_types_message(types, full = False): msg = f"\nAvailable {'scripts and types' if full else 'types'}\n\n" for i, type_ in enumerate(types): msg += f"{i}. {type_['name']}\n" if full: msg += f"\t{type_['description']}\n" for i, script in enumerate(type_['scripts'])...
def create_types_message(types, full=False): msg = f"\nAvailable {('scripts and types' if full else 'types')}\n\n" for (i, type_) in enumerate(types): msg += f"{i}. {type_['name']}\n" if full: msg += f"\t{type_['description']}\n" for (i, script) in enumerate(type_['script...
input = [] with open('input.txt') as f: for line in f: input += [ int(x) for x in line.strip().split(',') ] op = { 1: lambda a,b: a+b, 2: lambda a,b: a*b} def solve(m, noun, verb): m[1] = noun m[2] = verb pc = 0 while True: o, a, b, d = m[pc:pc+4] if o == 99: b...
input = [] with open('input.txt') as f: for line in f: input += [int(x) for x in line.strip().split(',')] op = {1: lambda a, b: a + b, 2: lambda a, b: a * b} def solve(m, noun, verb): m[1] = noun m[2] = verb pc = 0 while True: (o, a, b, d) = m[pc:pc + 4] if o == 99: ...
# if any of the values evaluates to true # returns true print (any([0,0,0,1])) #True widget_one = '' widget_two = '' widget_three = 'button' widgets_exist = any([widget_one, widget_two, widget_three]) print (widgets_exist) #True
print(any([0, 0, 0, 1])) widget_one = '' widget_two = '' widget_three = 'button' widgets_exist = any([widget_one, widget_two, widget_three]) print(widgets_exist)
first = "http://www.clpig.org/magnet/" last = ".html" url = "http://www.clpig.org/magnet/AE2616045992C6C63B1D22B0A78EC8876DE60ACA.html" print(url[len(first):-len(last)])
first = 'http://www.clpig.org/magnet/' last = '.html' url = 'http://www.clpig.org/magnet/AE2616045992C6C63B1D22B0A78EC8876DE60ACA.html' print(url[len(first):-len(last)])
'''Miles To Kilometers''' def milesToKilo(miles): #My Conversion Factor return miles*1.60934 def milesToKiloTest(): #Converts 1 Mile to Kilomters print('Testing 1 Mile') if milesToKilo(1) == 1.60934: print('Correct') else: print('Wrong!!') #Converts 10 Mile to Kilomters print('Tes...
"""Miles To Kilometers""" def miles_to_kilo(miles): return miles * 1.60934 def miles_to_kilo_test(): print('Testing 1 Mile') if miles_to_kilo(1) == 1.60934: print('Correct') else: print('Wrong!!') print('Testing 10 Miles') if miles_to_kilo(10) == 16.0934: print('Correct...
CODE_TEMPLATES = {'python3': ''' import json ${HELPER_CODE} ${SOLUTION} if __name__ == '__main__': print(json.dumps(${TEST_CASE})) ''' }
code_templates = {'python3': "\nimport json\n${HELPER_CODE}\n\n${SOLUTION}\n\nif __name__ == '__main__':\n print(json.dumps(${TEST_CASE}))\n"}
R, C, K = map(int, input().split()) n = int(input()) r_list = [0 for _ in range(R)] c_list = [0 for _ in range(C)] points = [] for i in range(n): r, c = map(int, input().split()) r_list[r-1] += 1 c_list[c-1] += 1 points.append((r-1, c-1)) r_count = [0 for _ in range(K+1)] c_count = [0 for _ in range(K...
(r, c, k) = map(int, input().split()) n = int(input()) r_list = [0 for _ in range(R)] c_list = [0 for _ in range(C)] points = [] for i in range(n): (r, c) = map(int, input().split()) r_list[r - 1] += 1 c_list[c - 1] += 1 points.append((r - 1, c - 1)) r_count = [0 for _ in range(K + 1)] c_count = [0 for ...
tc = int(input()) inn = out = 0 for pos in range (0,tc): n = int(input()) if 10 <= n <= 20: inn += 1; else: out += 1 print ("%d in\n%d out" %(inn,out))
tc = int(input()) inn = out = 0 for pos in range(0, tc): n = int(input()) if 10 <= n <= 20: inn += 1 else: out += 1 print('%d in\n%d out' % (inn, out))
load( "@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive" ) def _maybe(repo_rule, name, **kwargs): if name not in native.existing_rules(): repo_rule(name = name, **kwargs) def repositories(): _maybe( # native.http_archive, http_archive, name = "com_github_gfl...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def _maybe(repo_rule, name, **kwargs): if name not in native.existing_rules(): repo_rule(name=name, **kwargs) def repositories(): _maybe(http_archive, name='com_github_gflags_gflags', sha256='6e16c8bc91b1310a44f3965e616383dbda48f83e8...
FILE = "data/Clothing_Store.csv" OUT = "data/Preprocessed.csv" # Names of attributes columns = ["CUSTOMER_ID", "ZIP_CODE", "TOTAL_VISITS", "TOTAL_SPENT", "AVRG_SPENT_PER_VISIT", "HAS_CREDIT_CARD", "PSWEATERS", "PKNIT_TOPS", "PKNIT_DRES", "PBLOUSES", "PJACKETS", "PCAR_PNTS", "PCAS_PNTS", "PSHIRTS", ...
file = 'data/Clothing_Store.csv' out = 'data/Preprocessed.csv' columns = ['CUSTOMER_ID', 'ZIP_CODE', 'TOTAL_VISITS', 'TOTAL_SPENT', 'AVRG_SPENT_PER_VISIT', 'HAS_CREDIT_CARD', 'PSWEATERS', 'PKNIT_TOPS', 'PKNIT_DRES', 'PBLOUSES', 'PJACKETS', 'PCAR_PNTS', 'PCAS_PNTS', 'PSHIRTS', 'PDRESSES', 'PSUITS', 'POUTERWEAR', 'PJEWEL...
# # Source: https://github.com/aimacode/aima-python/blob/master/utils.py # def is_in(elt, seq): """Similar to (elt in seq), but compares with 'is', not '=='.""" return any(x is elt for x in seq)
def is_in(elt, seq): """Similar to (elt in seq), but compares with 'is', not '=='.""" return any((x is elt for x in seq))
class Solution: def solveNQueens(self, n: int) -> List[List[str]]: """ :type n: int :rtype: int """ ans = [0] * n aans = [] def solve(n, cur_id, left, straight, right): nonlocal ans if cur_id == n + 1: lst = [("." * ans[...
class Solution: def solve_n_queens(self, n: int) -> List[List[str]]: """ :type n: int :rtype: int """ ans = [0] * n aans = [] def solve(n, cur_id, left, straight, right): nonlocal ans if cur_id == n + 1: lst = ['.' * a...
def func1(): pass def func2(): pass x = lambda x: x() x(func1) x(func2)
def func1(): pass def func2(): pass x = lambda x: x() x(func1) x(func2)
### The Config ### # Name of the Gym environment for the agent to learn & play ENV_NAME = 'BreakoutDeterministic-v4' # Loading and saving information. # If LOAD_FROM is None, it will train a new agent. # If SAVE_PATH is None, it will not save the agent LOAD_FROM = None SAVE_PATH = 'breakout-saves' LOAD_REPLAY_BUFFER ...
env_name = 'BreakoutDeterministic-v4' load_from = None save_path = 'breakout-saves' load_replay_buffer = True write_tensorboard = True tensorboard_dir = 'tensorboard/' use_per = False priority_scale = 0.7 clip_reward = True total_frames = 30000000 max_episode_length = 18000 frames_between_eval = 100000 eval_length = 10...
sequence_of_elements = input().split() count_moves = 0 command = input() while not command == "end": count_moves += 1 index1 = int(command.split()[0]) index2 = int(command.split()[1]) if index1 == index2 or index1 < 0 or index2 < 0 or index1 >= len(sequence_of_elements) or index2 >= len(sequence_of_elem...
sequence_of_elements = input().split() count_moves = 0 command = input() while not command == 'end': count_moves += 1 index1 = int(command.split()[0]) index2 = int(command.split()[1]) if index1 == index2 or index1 < 0 or index2 < 0 or (index1 >= len(sequence_of_elements)) or (index2 >= len(sequence_of_e...
#!/usr/bin/env python x = int(input("Enter a number to know it factorial:-")) def fact(x): if x > 1: return x * fact(x -1) return 1 print("------+++++++++++++++++++++++++++------") print("The factorial of entered number is: {}\n\n".format(fact(x))) print("------Counting permutation------\n") print("T...
x = int(input('Enter a number to know it factorial:-')) def fact(x): if x > 1: return x * fact(x - 1) return 1 print('------+++++++++++++++++++++++++++------') print('The factorial of entered number is: {}\n\n'.format(fact(x))) print('------Counting permutation------\n') print('The formular is: -- n!/(...
""" Statistics module """ def mean(x): return float(sum(x))/len(x) def median(x): y = copy.copy(x) y.sort() n = len(y) if n % 2: # Odd return y[n/2] else: # even return 0.5*(y[n/2]+y[n/2-1])
""" Statistics module """ def mean(x): return float(sum(x)) / len(x) def median(x): y = copy.copy(x) y.sort() n = len(y) if n % 2: return y[n / 2] else: return 0.5 * (y[n / 2] + y[n / 2 - 1])
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'chromium_code': 1, }, 'targets': [ { 'target_name': 'accessibility', 'type': '<(component)', 'dependencies...
{'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'accessibility', 'type': '<(component)', 'dependencies': ['../../base/base.gyp:base', '../gfx/gfx.gyp:gfx'], 'defines': ['ACCESSIBILITY_IMPLEMENTATION'], 'sources': ['ax_enums.h', 'ax_node.cc', 'ax_node_data.cc', 'ax_node_data.h', 'ax_node.h', 'ax_serializ...
""" Homework 2 Due Feb 21, 2022 CSCE 421 Simon Schoenbeck This is an additional file for processing the intension constraints. """ function_names = ['neg', 'abs', 'add', 'sub', 'mul', 'div', 'mod', 'pow', 'min', 'max', 'eq', 'ne', 'ge', 'gt', 'le', 'lt', 'not', 'and', 'or', 'xor', 'iff', 'if'] # In...
""" Homework 2 Due Feb 21, 2022 CSCE 421 Simon Schoenbeck This is an additional file for processing the intension constraints. """ function_names = ['neg', 'abs', 'add', 'sub', 'mul', 'div', 'mod', 'pow', 'min', 'max', 'eq', 'ne', 'ge', 'gt', 'le', 'lt', 'not', 'and', 'or', 'xor', 'iff', 'if'] def f_neg(args) -> int:...
class marrentill_tar_config(): SCRIPT_NAME = "MARRENTILL TAR MAKING SCRIPT 0.1v"; BUTTON = [ ]; CHATBOX = [ ".\\resources\\method\\marrentill_tar\\chatbox\\yes.png", ]; FUNCTION = [ ".\\resources\\method\\marrentill_tar\\function\\make_marrentill_tar.png", ]; INTERF...
class Marrentill_Tar_Config: script_name = 'MARRENTILL TAR MAKING SCRIPT 0.1v' button = [] chatbox = ['.\\resources\\method\\marrentill_tar\\chatbox\\yes.png'] function = ['.\\resources\\method\\marrentill_tar\\function\\make_marrentill_tar.png'] interface = [] item = ['.\\resources\\item\\inven...
''' icmplib ~~~~~~~ A powerful library for forging ICMP packets and performing ping and traceroute. https://github.com/ValentinBELYN/icmplib :copyright: Copyright 2017-2021 Valentin BELYN. :license: GNU LGPLv3, see the LICENSE for details. ~~~~~~~ This program is free softwa...
""" icmplib ~~~~~~~ A powerful library for forging ICMP packets and performing ping and traceroute. https://github.com/ValentinBELYN/icmplib :copyright: Copyright 2017-2021 Valentin BELYN. :license: GNU LGPLv3, see the LICENSE for details. ~~~~~~~ This program is free softwa...
##Introduction #---------------------------------------Say "Hello, World!" With Python----------------------------------------------------- print("Hello, World!") #------------------------------------------------Python If-Else------------------------------------------------------------- num = int(input()) ...
print('Hello, World!') num = int(input()) n = num % 2 if n == 0 and 2 <= num <= 5: print('Not Weird') elif n == 0 and 6 <= num <= 20: print('Weird') elif n == 0 and num > 20: print('Not Weird') elif num % 2 != 0: print('Weird') if __name__ == '__main__': a = int(input()) b = int(input()) pri...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 7 03:28:20 2021 @author: ike """ # avoid __init__ imports to save memory, import as needed
""" Created on Fri May 7 03:28:20 2021 @author: ike """
def for_Opposite_pattern_of_Two_Normal_and_Reverse_Isosceles_triangles(): """ pattern for :Opposite_pattern_of_Two_Normal_and_Reverse_Isosceles_triangles using for loop""" for i in range(4): for j in range(7): if i==0 or j==3 or i==1 and j%6!=0 or i==2 and j in (2,4): p...
def for__opposite_pattern_of__two__normal_and__reverse__isosceles_triangles(): """ pattern for :Opposite_pattern_of_Two_Normal_and_Reverse_Isosceles_triangles using for loop""" for i in range(4): for j in range(7): if i == 0 or j == 3 or (i == 1 and j % 6 != 0) or (i == 2 and j in (2, 4)): ...
#link: https://leetcode.com/problems/intersection-of-two-arrays/submissions/ class Solution(object): def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ s1,s2 = set(nums1), set(nums2) if len(s...
class Solution(object): def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ (s1, s2) = (set(nums1), set(nums2)) if len(s1) < len(s2): return self.set_intersection(s1, s2) else: ...
''' Author: Sam Gerendasy This module returns a list of free and busy time blocks from a given list of calendar entries, between a given start and end date, and furthermore, between a given start and end time. ''' def freeBusyTimes(eSet, startingBounds, endingBounds): ''' eSet is an array of entrie...
""" Author: Sam Gerendasy This module returns a list of free and busy time blocks from a given list of calendar entries, between a given start and end date, and furthermore, between a given start and end time. """ def free_busy_times(eSet, startingBounds, endingBounds): """ eSet is an array of entries. sta...
""" Create a list, seqList, of N empty sequences, where each sequence is indexed from 0 to N-1. The elements within each of the N sequences also use 0-indexing. Create an integer, lastAns, and initialize it to 0. The types of queries that can be performed on your list of sequences (seqList) are described below: 1] Quer...
""" Create a list, seqList, of N empty sequences, where each sequence is indexed from 0 to N-1. The elements within each of the N sequences also use 0-indexing. Create an integer, lastAns, and initialize it to 0. The types of queries that can be performed on your list of sequences (seqList) are described below: 1] Quer...
# Copyright (C) 2007-2012 Red Hat # see file 'COPYING' for use and warranty information # # policygentool is a tool for the initial generation of SELinux policy # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the ...
te_types = '\ntype TEMPLATETYPE_var_lib_t;\nfiles_type(TEMPLATETYPE_var_lib_t)\n' te_rules = '\nmanage_dirs_pattern(TEMPLATETYPE_t, TEMPLATETYPE_var_lib_t, TEMPLATETYPE_var_lib_t)\nmanage_files_pattern(TEMPLATETYPE_t, TEMPLATETYPE_var_lib_t, TEMPLATETYPE_var_lib_t)\nmanage_lnk_files_pattern(TEMPLATETYPE_t, TEMPLATETYPE...
{ "targets": [ { "target_name": "bmp183", "sources": [ "SPIDevice.cpp", "DataManip.cpp", "Bmp183Drv.cpp", "Bmp183Node.cpp" ], "cflags": ["-std=c++11", "-Wall"], } ] }
{'targets': [{'target_name': 'bmp183', 'sources': ['SPIDevice.cpp', 'DataManip.cpp', 'Bmp183Drv.cpp', 'Bmp183Node.cpp'], 'cflags': ['-std=c++11', '-Wall']}]}
# !/usr/bin/env python3 ####################################################################################### # # # Program purpose: Check if a string is numeric. # # Program Author : Happi...
if __name__ == '__main__': user_str = input('Enter sample string: ') try: data = float(user_str) except (ValueError, TypeError) as error: print(f'\nNot numeric:\n\n{error}')
sys.stdout = open("1-num.txt", "w") data = "1234567890" for a in data: print(a) sys.stdout.close()
sys.stdout = open('1-num.txt', 'w') data = '1234567890' for a in data: print(a) sys.stdout.close()
mxsum = 0 count = 0 with open("17.txt", "r") as f: l = f.readlines() for i in range(len(l)-1): if (int(l[i]) % 3 == 0) or (int(l[i+1]) % 3 == 0): count += 1 mxsum = max(mxsum, int(l[i]) + int(l[i+1])) print(count, mxsum)
mxsum = 0 count = 0 with open('17.txt', 'r') as f: l = f.readlines() for i in range(len(l) - 1): if int(l[i]) % 3 == 0 or int(l[i + 1]) % 3 == 0: count += 1 mxsum = max(mxsum, int(l[i]) + int(l[i + 1])) print(count, mxsum)
def update_all(g, mpdfg, msg_params=(), reduce_params=(), update_params=()): updated = mpdfg.forward(g.DGLGraph, g.ndata, g.edata, g.ntype_data, g.etype_data, *msg_params, *reduce_params, *update_params) for key in updated: g.ndata[key] = updated[key]
def update_all(g, mpdfg, msg_params=(), reduce_params=(), update_params=()): updated = mpdfg.forward(g.DGLGraph, g.ndata, g.edata, g.ntype_data, g.etype_data, *msg_params, *reduce_params, *update_params) for key in updated: g.ndata[key] = updated[key]
def linearSearch(array,value): for i in range(len(array)): if array[i]==value: return i return -1 arr=[20,30,40,50,90] print(linearSearch(arr,30))
def linear_search(array, value): for i in range(len(array)): if array[i] == value: return i return -1 arr = [20, 30, 40, 50, 90] print(linear_search(arr, 30))
def generate_mysql_command(loginpath=None, user=None, password=None, host=None, port=None, socket=None, no_header=True): mysqlcomm = "mysql " if loginpath is not None: mysqlcomm += " --login-path={}".format(loginpath) else: mysqlcomm += " --user={}".format(user) if password is not N...
def generate_mysql_command(loginpath=None, user=None, password=None, host=None, port=None, socket=None, no_header=True): mysqlcomm = 'mysql ' if loginpath is not None: mysqlcomm += ' --login-path={}'.format(loginpath) else: mysqlcomm += ' --user={}'.format(user) if password is not No...
msg_0 = "Enter an equation" msg_1 = "Do you even know what numbers are? Stay focused!" msg_2 = "Yes ... an interesting math operation. You've slept through all classes, haven't you?" msg_3 = "Yeah... division by zero. Smart move..." msg_4 = "Do you want to store the result? (y / n):" msg_5 = "Do you want to continue ca...
msg_0 = 'Enter an equation' msg_1 = 'Do you even know what numbers are? Stay focused!' msg_2 = "Yes ... an interesting math operation. You've slept through all classes, haven't you?" msg_3 = 'Yeah... division by zero. Smart move...' msg_4 = 'Do you want to store the result? (y / n):' msg_5 = 'Do you want to continue ca...
class Truth: ''' The __bool__ method is prefered over __len__ in python. ''' def __bool__(self): return True def __len__(self): return 0 if __name__ == "__main__": X = Truth() if X: print("Yes!");
class Truth: """ The __bool__ method is prefered over __len__ in python. """ def __bool__(self): return True def __len__(self): return 0 if __name__ == '__main__': x = truth() if X: print('Yes!')
#!/usr/bin/env python # coding: utf-8 # # Counting Inversions # # The number of *inversions* in a disordered list is the number of pairs of elements that are inverted (out of order) in the list. # # Here are some examples: # - [0,1] has 0 inversions # - [2,1] has 1 inversion (2,1) # - [3, 1, 2, 4] has 2 inv...
def count_inversions(arr): pass def count_inversions(arr): start_index = 0 end_index = len(arr) - 1 output = inversion_count_func(arr, start_index, end_index) return output def inversion_count_func(arr, start_index, end_index): if start_index >= end_index: return 0 mid_index = star...
# -*- coding: utf-8 -*- class InvalidFieldException(Exception): pass class PreconditionFailException(Exception): pass class ItemNotFoundException(Exception): pass class ProductAlreadyExistsException(Exception): pass
class Invalidfieldexception(Exception): pass class Preconditionfailexception(Exception): pass class Itemnotfoundexception(Exception): pass class Productalreadyexistsexception(Exception): pass
class Calculator: def __init__(self, a, b): self.a = a self.b = b def sum(self): return self.a + self.b def mul(self): return self.a * self.b def div(self): return self.a / self.b def sub(self): return self.a - self.b class Circle: pi = 3.14...
class Calculator: def __init__(self, a, b): self.a = a self.b = b def sum(self): return self.a + self.b def mul(self): return self.a * self.b def div(self): return self.a / self.b def sub(self): return self.a - self.b class Circle: pi = 3.141...
# -*- coding: utf-8 -*- """ Main command group for WaterAccounting Collect's CLI. """ # import logging # from pkg_resources import iter_entry_points # import sys # # from click_plugins import with_plugins # import click # import cligj
""" Main command group for WaterAccounting Collect's CLI. """
#!/usr/bin/env python3 def coord(x, y, x0, y0): dx = x - x0 dy = y - y0 if dx == 0 or dy == 0: return 'divisa' if dx > 0 and dy > 0: return 'NE' if dx < 0 and dy > 0: return 'NO' if dx > 0 and dy < 0: return 'SE' if dx < 0 and dy < 0: return 'SO' d...
def coord(x, y, x0, y0): dx = x - x0 dy = y - y0 if dx == 0 or dy == 0: return 'divisa' if dx > 0 and dy > 0: return 'NE' if dx < 0 and dy > 0: return 'NO' if dx > 0 and dy < 0: return 'SE' if dx < 0 and dy < 0: return 'SO' def main(): while True:...
#!/usr/bin/env python3 def main(): for i in range(1, 11): for j in range(1, 11): print('{0:4d}'.format(i * j), end="") print() if __name__ == "__main__": main()
def main(): for i in range(1, 11): for j in range(1, 11): print('{0:4d}'.format(i * j), end='') print() if __name__ == '__main__': main()
""" The MIT License Copyright 2020 Adewale Azeez <azeezadewale98@gmail.com>. """ def type_of(arg): return def is_string(arg): return isinstance(arg, str) def is_int(arg): return isinstance(arg, int) def is_number(arg): return is_int(arg) def is_char(arg): return isinstance(arg, str) a...
""" The MIT License Copyright 2020 Adewale Azeez <azeezadewale98@gmail.com>. """ def type_of(arg): return def is_string(arg): return isinstance(arg, str) def is_int(arg): return isinstance(arg, int) def is_number(arg): return is_int(arg) def is_char(arg): return isinstance(arg, str) and...
scripted_localisation_functions = [ "GetName", "GetNameDef", "GetAdjective", "GetAdjectiveCap", "GetLeader", "GetRulingParty", "GetRulingIdeology", "GetRulingIdeologyNoun", "GetPartySupport", "GetLastElection", "GetManpower", "GetFactionName", "GetFlag", "GetNameW...
scripted_localisation_functions = ['GetName', 'GetNameDef', 'GetAdjective', 'GetAdjectiveCap', 'GetLeader', 'GetRulingParty', 'GetRulingIdeology', 'GetRulingIdeologyNoun', 'GetPartySupport', 'GetLastElection', 'GetManpower', 'GetFactionName', 'GetFlag', 'GetNameWithFlag', 'GetCommunistParty', 'GetDemocraticParty', 'Get...
#2.uzdevums def get_common_elements(seq1,seq2,seq3): return tuple(set(seq1) & set(seq2) & set(seq3)) print(get_common_elements("abcd",['a','b', 'd'],('b','c', 'd'))) ### 2. Task with STAR #### Common elements def get_common_elements(*seq1): if len(seq1) == 0: return () common_set = set(...
def get_common_elements(seq1, seq2, seq3): return tuple(set(seq1) & set(seq2) & set(seq3)) print(get_common_elements('abcd', ['a', 'b', 'd'], ('b', 'c', 'd'))) def get_common_elements(*seq1): if len(seq1) == 0: return () common_set = set(seq1[0]) for seq_n in seq1[1:]: common_set = comm...
try: reversed except: print("SKIP") raise SystemExit # argument to fromkeys has no __len__ d = dict.fromkeys(reversed(range(1))) #d = dict.fromkeys((x for x in range(1))) print(d)
try: reversed except: print('SKIP') raise SystemExit d = dict.fromkeys(reversed(range(1))) print(d)
# # @lc app=leetcode id=646 lang=python3 # # [646] Maximum Length of Pair Chain # class Solution: def findLongestChain(self, pairs: List[List[int]]) -> int: if not pairs: return 0 pairs.sort(key=lambda x: x[1]) prev = - sys.maxsize - 1 count = 0 for idx in range...
class Solution: def find_longest_chain(self, pairs: List[List[int]]) -> int: if not pairs: return 0 pairs.sort(key=lambda x: x[1]) prev = -sys.maxsize - 1 count = 0 for idx in range(len(pairs)): if pairs[idx][0] > prev: prev = pairs[id...
whunparams = { "NUM_FEATURES": 104, "FOLDER": 'effort/', "HUMAN_WEIGHT": 1.5, "RECURSION_LIMIT": 5000, "BUDGET": "zero", }
whunparams = {'NUM_FEATURES': 104, 'FOLDER': 'effort/', 'HUMAN_WEIGHT': 1.5, 'RECURSION_LIMIT': 5000, 'BUDGET': 'zero'}
# Remote run directory [Default is abaverify_temp] # Command line run directory will override the value specified here if both are provided #remote_run_directory = 'abaverify_temp' # Add files to copy to the remote [Default is empty list] # Paths relative to /tests directory local_files_to_copy_to_remote = ['CompDam....
local_files_to_copy_to_remote = ['CompDam.parameters'] file_extensions_to_copy_to_local = ['.dat', '.inp', '.msg', '.odb', '.sta', '.py'] copy_results_to_local = True environment_file_name = 'abaqus_v6.env'
def search(arr, l, h, val): if h < l: return -1 m = int(l + (h - l) / 2) if val < arr[m]: return search(arr, l, m - 1, val) elif arr[m] < val: return search(arr, m + 1, h, val) return m arr = [ 2, 3, 4, 10, 40 ] assert 3 == search(arr, 0, len(arr) - 1, 10) assert 0 == search(arr, 0, len(arr) ...
def search(arr, l, h, val): if h < l: return -1 m = int(l + (h - l) / 2) if val < arr[m]: return search(arr, l, m - 1, val) elif arr[m] < val: return search(arr, m + 1, h, val) return m arr = [2, 3, 4, 10, 40] assert 3 == search(arr, 0, len(arr) - 1, 10) assert 0 == search(ar...
number = int(input()) if number == int(1): print ("Monday") if number == int(2): print ("Tuesday") if number == int(3): print ("Wednesday") if number == int(4): print ("Thursday") if number == int(5): print ("Friday") if number == int(6): print ("Saturday") if number == int(7): print ("Sunda...
number = int(input()) if number == int(1): print('Monday') if number == int(2): print('Tuesday') if number == int(3): print('Wednesday') if number == int(4): print('Thursday') if number == int(5): print('Friday') if number == int(6): print('Saturday') if number == int(7): print('Sunday') if ...
N,M=map(int,input().split()) AB=[list(map(int,input().split())) for i in range(N)] AB.sort() ans=0 count=0 for i in range(N): count=M-AB[i][1] if count>=0: ans+=AB[i][0]*AB[i][1] M=count else: ans+=AB[i][0]*M break print(ans)
(n, m) = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(N)] AB.sort() ans = 0 count = 0 for i in range(N): count = M - AB[i][1] if count >= 0: ans += AB[i][0] * AB[i][1] m = count else: ans += AB[i][0] * M break print(ans)
# # PySNMP MIB module ZYXEL-RADIUS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-RADIUS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:45:29 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, value_size_constraint, constraints_union, single_value_constraint) ...
""" leetcode # 341 flattern list to a single list """ final_array = [] def flattern_list(nestedList): for obj in nestedList: if isinstance(obj, int): final_array.append(obj) else: flattern_list(obj) flattern_list([[1,1],2,[3],[1,2,3],[],4,5,[6,[7,[8,[9]]]]]) print(final_a...
""" leetcode # 341 flattern list to a single list """ final_array = [] def flattern_list(nestedList): for obj in nestedList: if isinstance(obj, int): final_array.append(obj) else: flattern_list(obj) flattern_list([[1, 1], 2, [3], [1, 2, 3], [], 4, 5, [6, [7, [8, [9]]]]]) pri...
# if , elif , else . ladder. in python # enter use your age and check your age status. #age = int(input("Enter your age\n")) ''' if (age>=18): print("You are young") elif(age<18): print("You are child") ''' # logical operators. ''' if(age<=18 and age<60): print("You can drive") elif(age<18 and age>16):...
""" if (age>=18): print("You are young") elif(age<18): print("You are child") """ '\nif(age<=18 and age<60):\n print("You can drive")\nelif(age<18 and age>16):\n print("Apply after 18") \nelse:\n print("You are kid now") \n \nif (18>20 or 18>10):\n print(True)\n\n ' a = None if a is None...
# import time def calculate_pull(startStates: dict, outcomes: dict): newStates = dict() for state, startOdds in startStates.items(): for (newState, jumpOdds) in outcomes[state]: if newState not in newStates: newStates[newState] = 0 newStates[newState] += startOd...
def calculate_pull(startStates: dict, outcomes: dict): new_states = dict() for (state, start_odds) in startStates.items(): for (new_state, jump_odds) in outcomes[state]: if newState not in newStates: newStates[newState] = 0 newStates[newState] += startOdds * jumpO...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"Explore": "00_explore.ipynb"} modules = ["explore.py"] doc_url = "https://aayushmnit.github.io/mlcookbooks/" git_url = "https://github.com/aayushmnit/mlcookbooks/tree/master/" def custom_doc_links(name):...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'Explore': '00_explore.ipynb'} modules = ['explore.py'] doc_url = 'https://aayushmnit.github.io/mlcookbooks/' git_url = 'https://github.com/aayushmnit/mlcookbooks/tree/master/' def custom_doc_links(name): return None
class Solution: def longestDecomposition(self, text: str) -> int: if not text: return 0 for k in range(1, 1 + len(text)//2): if text[:k] == text[-k:]: return 2 + self.longestDecomposition(text[k:-k]) return 1 text = "ghiabcdefhelloadamhelloabcdefghi"...
class Solution: def longest_decomposition(self, text: str) -> int: if not text: return 0 for k in range(1, 1 + len(text) // 2): if text[:k] == text[-k:]: return 2 + self.longestDecomposition(text[k:-k]) return 1 text = 'ghiabcdefhelloadamhelloabcdefgh...
""" data.py PURPOSE: This file defines the data for training from genius as well as code for collecting the initial data """
""" data.py PURPOSE: This file defines the data for training from genius as well as code for collecting the initial data """
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: directions = [(-1, 0), (0, -1), (1, 0), (0, 1)] rows = len(board) cols = len(board[0]) def helper(board, visited, remaining, curr_x, curr_y): visited.add((curr_x, curr_y)) if not r...
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: directions = [(-1, 0), (0, -1), (1, 0), (0, 1)] rows = len(board) cols = len(board[0]) def helper(board, visited, remaining, curr_x, curr_y): visited.add((curr_x, curr_y)) if not rem...
s = input() mountains = [] prev = 0 for i in range(len(s) - 1): if s[i:i + 2] == "><": mountains.append(s[prev:i + 1]) prev = i + 1 mountains.append(s[prev:]) ans = 0 for m in mountains: lt = m.count("<") gt = m.count(">") if lt > gt: lt, gt = gt, lt ans += (1 + gt) * gt // 2 + (1...
s = input() mountains = [] prev = 0 for i in range(len(s) - 1): if s[i:i + 2] == '><': mountains.append(s[prev:i + 1]) prev = i + 1 mountains.append(s[prev:]) ans = 0 for m in mountains: lt = m.count('<') gt = m.count('>') if lt > gt: (lt, gt) = (gt, lt) ans += (1 + gt) * gt ...
rules = {} lines = [l.strip() for l in open('in', 'r').readlines()] rule_lines = lines[:lines.index('')] message_lines = lines[lines.index('') + 1:] for line in rule_lines: rule_id, rule = line.split(':') rule = rule.strip() rules[rule_id] = rule rules['8'] = '42 | 42 8' rules['11'] = '42 31 | 42 11 31'...
rules = {} lines = [l.strip() for l in open('in', 'r').readlines()] rule_lines = lines[:lines.index('')] message_lines = lines[lines.index('') + 1:] for line in rule_lines: (rule_id, rule) = line.split(':') rule = rule.strip() rules[rule_id] = rule rules['8'] = '42 | 42 8' rules['11'] = '42 31 | 42 11 31' ...
# Direction Game locations = { 1: "Road", 2: "Hill", 3: "Building", 4: "Valley", 5: "Forest", } exits = [ {"Q": 0}, {"W": 2, "E": 3, "N": 5, "S": 4, "Q": 0}, {"N": 5, "Q": 0}, {"W": 1, "Q": 0}, {"N": 1, "W": 2, "Q": 0}, {"W": 2, "S": 1, "Q": 0} ] loc = 1 while True: av...
locations = {1: 'Road', 2: 'Hill', 3: 'Building', 4: 'Valley', 5: 'Forest'} exits = [{'Q': 0}, {'W': 2, 'E': 3, 'N': 5, 'S': 4, 'Q': 0}, {'N': 5, 'Q': 0}, {'W': 1, 'Q': 0}, {'N': 1, 'W': 2, 'Q': 0}, {'W': 2, 'S': 1, 'Q': 0}] loc = 1 while True: available_exits = ', '.join(exits[loc].keys()) print(locations[loc]...
TOKEN = 'NTgxMTM2MjEwMTY0OTczNTgx.XOa3bg.ho7aMEIDEL2gHCHWvRgwOuumbRQ' class Votehelper: def __init__(self): # All possible Main Menu options self._all_options = { 1: 'Get the EU Parliament election date.', 2: 'Check eligibility to vote in the EU Parliament elections.', ...
token = 'NTgxMTM2MjEwMTY0OTczNTgx.XOa3bg.ho7aMEIDEL2gHCHWvRgwOuumbRQ' class Votehelper: def __init__(self): self._all_options = {1: 'Get the EU Parliament election date.', 2: 'Check eligibility to vote in the EU Parliament elections.', 3: 'My voting options.', 4: 'My identity.', 5: 'Erase my information.'...
# -*- coding: utf-8 -*- """ Created on Thu Aug 4, 2016 Modified Mon Dec 12, 2016 @author: Kirby Urner Show how entering a context triggers the __enter__ tripwire. On __exit__ you may set off the emergency buzzer (return False), or not (return True) """ class CodeCastle: def __init__(self): self.me...
""" Created on Thu Aug 4, 2016 Modified Mon Dec 12, 2016 @author: Kirby Urner Show how entering a context triggers the __enter__ tripwire. On __exit__ you may set off the emergency buzzer (return False), or not (return True) """ class Codecastle: def __init__(self): self.me = 'I will be your guide' ...
# hash state, action def hash_state_action(state, action): return state + "|" + str(action) # reverse hashing state-action to state, action def reverse_hashing_state_action(hashing_state_action): state , action = hashing_state_action.split("|") #state = reverse_hashing_state(state) action = int(action...
def hash_state_action(state, action): return state + '|' + str(action) def reverse_hashing_state_action(hashing_state_action): (state, action) = hashing_state_action.split('|') action = int(action) return (state, action) def get_max_action(state, q_value_function, maze_env): max_action = None ...
# Time: O(n) # Space: O(1) # Say you have an array for which the ith element is the price of a given stock on day i. # # Design an algorithm to find the maximum profit. You may complete as # many transactions as you like (ie, buy one and sell one share of the # stock multiple times) with the following restrictions: #...
class Solution(object): def max_profit(self, prices): """ :type prices: List[int] :rtype: int """ if not prices: return 0 (buy, sell, cool_down) = ([0] * 2, [0] * 2, [0] * 2) buy[0] = -prices[0] for i in xrange(1, len(prices)): ...
url = 'https://docs.google.com/forms/d/e/1FAIpQLSd-qJkd_S-6zeEQZuHPE5qInuByzQzQsYtb4PG4NeqkTWUC-g' user_agent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36' maps = 'maps_RU/' log_path = 'logs/'
url = 'https://docs.google.com/forms/d/e/1FAIpQLSd-qJkd_S-6zeEQZuHPE5qInuByzQzQsYtb4PG4NeqkTWUC-g' user_agent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36' maps = 'maps_RU/' log_path = 'logs/'
operations = { "average": lambda seq: sum(seq) / len(seq), "total": sum, #lambda seq: sum(seq) "top": max #lambda seq: max(seq) } students = [ {"name": "Kamran", "grades": (67, 90, 95, 100)}, {"name": "Ali", "grades": (56, 78, 80, 90)} ] for student in students: name = student["name"] grades = student[...
operations = {'average': lambda seq: sum(seq) / len(seq), 'total': sum, 'top': max} students = [{'name': 'Kamran', 'grades': (67, 90, 95, 100)}, {'name': 'Ali', 'grades': (56, 78, 80, 90)}] for student in students: name = student['name'] grades = student['grades'] operation = input("Enter 'average', 'total'...
OCTICON_HEART_FILL = """ <svg class="octicon octicon-heart-fill" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.655 14.916L8 14.25l.345.666a.752.752 0 01-.69 0zm0 0L8 14.25l.345.666.002-.001.006-.003.018-.01a7.643 7.643 0 00.31-.17 22.08 22.08 0 003.433-2....
octicon_heart_fill = '\n<svg class="octicon octicon-heart-fill" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.655 14.916L8 14.25l.345.666a.752.752 0 01-.69 0zm0 0L8 14.25l.345.666.002-.001.006-.003.018-.01a7.643 7.643 0 00.31-.17 22.08 22.08 0 003.433-2.41...
def add_native_methods(clazz): def setOption__java_lang_String__java_lang_String__(a0, a1, a2): raise NotImplementedError() def getOption__java_lang_String__(a0, a1): raise NotImplementedError() clazz.setOption__java_lang_String__java_lang_String__ = setOption__java_lang_String__java_lang_...
def add_native_methods(clazz): def set_option__java_lang__string__java_lang__string__(a0, a1, a2): raise not_implemented_error() def get_option__java_lang__string__(a0, a1): raise not_implemented_error() clazz.setOption__java_lang_String__java_lang_String__ = setOption__java_lang_String__j...
def concat(s1,s2): return s1 + " "+ s2 s = concat("John", "Doe") print(s)
def concat(s1, s2): return s1 + ' ' + s2 s = concat('John', 'Doe') print(s)
class Film: def __init__(self, imdbid, title, year, duration, rating, format, known_as): self.imdbid = imdbid self.title = title self.year = year self.duration = duration self.rating = rating self.format = format self.known_as = known_as
class Film: def __init__(self, imdbid, title, year, duration, rating, format, known_as): self.imdbid = imdbid self.title = title self.year = year self.duration = duration self.rating = rating self.format = format self.known_as = known_as
# dict object with special methods d = {} d.__setitem__('2', 'two') print(d.__getitem__('2')) d.__delitem__('2') print(d) print("PASS")
d = {} d.__setitem__('2', 'two') print(d.__getitem__('2')) d.__delitem__('2') print(d) print('PASS')
i=0 sum=0 while i<1000: if(i%3==0) or (i%5==0): sum=sum+i; i=i+1 print(sum);
i = 0 sum = 0 while i < 1000: if i % 3 == 0 or i % 5 == 0: sum = sum + i i = i + 1 print(sum)
class Solution: def minCostToMoveChips(self, position: List[int]) -> int: e=0 o=0 for i in position: if i%2==0: e=e+1 else: o=o+1 return min(e,o)
class Solution: def min_cost_to_move_chips(self, position: List[int]) -> int: e = 0 o = 0 for i in position: if i % 2 == 0: e = e + 1 else: o = o + 1 return min(e, o)
# Copyright 2017 - ZTE Corporation # # 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 wr...
class Webhook(object): url = 'v1/webhook/' def __init__(self, api): self.api = api def list(self, all_tenants=False): """Get webhook list""" params = dict(all_tenants=all_tenants) return self.api.get(self.url, params=params).json() def show(self, id): """Show s...
# Classes - Graph classes ''' Graph class Uses a distionary to store vertices in the format vertex_name and vertex_object To add a new vertex to the graph, we first check if the object passed in is a vertex object, then ckeck if it already exists in the graph. If both checks pass, then we add the vertex to the graph...
""" Graph class Uses a distionary to store vertices in the format vertex_name and vertex_object To add a new vertex to the graph, we first check if the object passed in is a vertex object, then ckeck if it already exists in the graph. If both checks pass, then we add the vertex to the graph's vertices dictionary. ...
""" Python switch style flow! """ a = 4 def num_to_str(num): num_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five'} return num_dict[num] num_in_str = num_to_str(a) print(f'a in string is {num_in_str}') # by checking a given value in a dictionary, we can do what is equivalent # to the following! ...
""" Python switch style flow! """ a = 4 def num_to_str(num): num_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five'} return num_dict[num] num_in_str = num_to_str(a) print(f'a in string is {num_in_str}') if a is 1: print('a in string is one') elif a is 2: print('a in string is two') elif a is ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def hasPathSum(self, root: TreeNode, target: int) -> bool: if not root: return False if not root.left and not root.right:...
class Solution: def has_path_sum(self, root: TreeNode, target: int) -> bool: if not root: return False if not root.left and (not root.right): return root.val == target return any((self.hasPathSum(child, target - root.val) for child in (root.left, root.right)))
""" BFS vs DFS for Binary Tree What are BFS and DFS for Binary Tree? A Tree is typically traversed in two ways: Breadth First Traversal (Or Level Order Traversal) Depth First Traversals Inorder Traversal (Left-Root-Right) Preorder Traversal (Root-Left-Right) Postorder Traversal (Left-Right-Root) """ class Solution(...
""" BFS vs DFS for Binary Tree What are BFS and DFS for Binary Tree? A Tree is typically traversed in two ways: Breadth First Traversal (Or Level Order Traversal) Depth First Traversals Inorder Traversal (Left-Root-Right) Preorder Traversal (Root-Left-Right) Postorder Traversal (Left-Right-Root) """ class Solution...
# # Licensed to Big Data Genomics (BDG) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The BDG licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this fil...
""" ====== models ====== .. currentmodule:: bdgenomics.adam.models .. autosummary:: :toctree: _generate/ ReferenceRegion """ class Referenceregion: """ Represents a contiguous region of the reference genome. """ def __init__(self, referenceName, start, end): """ Represents a con...
#!/usr/bin/python3 """ Miniconf version file. """ # The semantic version of Miniconf. __version__ = '0.1.0'
""" Miniconf version file. """ __version__ = '0.1.0'
# AutoTransform # Large scale, component based code modification library # # Licensed under the MIT License <http://opensource.org/licenses/MIT> # SPDX-License-Identifier: MIT # Copyright (c) 2022-present Nathan Rockenbach <http://github.com/nathro> # @black_format """The package for handling CLI invocation for AutoT...
"""The package for handling CLI invocation for AutoTransform. Uses commands with subparser args on the main script."""
def enQueue(i): lst.append(i) def deQueue(): return lst.pop(0) lst = ['a','b','c','d','e'] enQueue('t') enQueue('g') enQueue('h') print(lst) d = deQueue() print(d) d = deQueue() print(d) d = deQueue() print(d) d = deQueue() print(d) d = deQueue() print(d) print(lst)
def en_queue(i): lst.append(i) def de_queue(): return lst.pop(0) lst = ['a', 'b', 'c', 'd', 'e'] en_queue('t') en_queue('g') en_queue('h') print(lst) d = de_queue() print(d) d = de_queue() print(d) d = de_queue() print(d) d = de_queue() print(d) d = de_queue() print(d) print(lst)
def name(name_class, slug, name, desc="", order=0, **kwargs): # create if it doesn't exist, set name and desc obj, created = name_class.objects.get_or_create(slug=slug) if created: obj.name = name obj.desc = desc obj.order = order for k, v in kwargs.iteritems(): s...
def name(name_class, slug, name, desc='', order=0, **kwargs): (obj, created) = name_class.objects.get_or_create(slug=slug) if created: obj.name = name obj.desc = desc obj.order = order for (k, v) in kwargs.iteritems(): setattr(obj, k, v) obj.save() return ...
def reverse_string(s="hello"): s_reverse = s[::-1] return s_reverse print(reverse_string())
def reverse_string(s='hello'): s_reverse = s[::-1] return s_reverse print(reverse_string())
# generated from catkin/cmake/template/pkg.context.pc.in CATKIN_PACKAGE_PREFIX = "" PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/shams3049/catkin_ws/src/simtrack/interface/include".split(';') if "/home/shams3049/catkin_ws/src/simtrack/interface/include" != "" else [] PROJECT_CATKIN_DEPENDS = "low_level_vision;pose_estimati...
catkin_package_prefix = '' project_pkg_config_include_dirs = '/home/shams3049/catkin_ws/src/simtrack/interface/include'.split(';') if '/home/shams3049/catkin_ws/src/simtrack/interface/include' != '' else [] project_catkin_depends = 'low_level_vision;pose_estimation;cv_bridge'.replace(';', ' ') pkg_config_libraries_with...
class PathDoesNotExist(Exception): def __init__(self, name) -> None: msg = f"The path '{name}' does not exist" super().__init__(msg) class ModuleDoesNotExist(Exception): def __init__(self, name) -> None: msg = f"The module '{name}' does not exist" super().__init__(msg) class ...
class Pathdoesnotexist(Exception): def __init__(self, name) -> None: msg = f"The path '{name}' does not exist" super().__init__(msg) class Moduledoesnotexist(Exception): def __init__(self, name) -> None: msg = f"The module '{name}' does not exist" super().__init__(msg) class ...
class Node(): def __init__(self, value): self.value = value self.leftchild = None self.rightchild = None class Tree(): def __init__(self, value): self.root = Node(value) self.height = -1 self.values = [value] self.element = 0 self.links = [self.r...
class Node: def __init__(self, value): self.value = value self.leftchild = None self.rightchild = None class Tree: def __init__(self, value): self.root = node(value) self.height = -1 self.values = [value] self.element = 0 self.links = [self.root...
#zip: zip(*iterables) #built-in iterables (like: list, string, dict), or user-defined iterables lang=['python','java','c'] creators=['guido','james','denis'] for lang,creators in zip(lang,creators): print(lang,creators)
lang = ['python', 'java', 'c'] creators = ['guido', 'james', 'denis'] for (lang, creators) in zip(lang, creators): print(lang, creators)
# -*- coding: utf-8 -*- ''' In this config file the parameters for later use in all the scripts are stored ''' CONFIG = { 'folder':'data/deviceX/', # set folder where calibration data will be stored 'filenameCalib':'dataE_calib', # name of file for calibration data aquisition 'filename...
""" In this config file the parameters for later use in all the scripts are stored """ config = {'folder': 'data/deviceX/', 'filenameCalib': 'dataE_calib', 'filenameTols': 'data_tols'}
####### One More Day's Config File ####### Lytes - Laitanayoola@gmail.com ####### Add More Youtube Channels If You Want A Bigger Pool To Pick From source = ['https://www.youtube.com/channel/UCa10nxShhzNrCE1o2ZOPztg', 'https://www.youtube.com/channel/UCCvVpbYRgYjMN7mG7qQN0Pg', 'https://www.youtube.com/channel/UCj_Y-x...
source = ['https://www.youtube.com/channel/UCa10nxShhzNrCE1o2ZOPztg', 'https://www.youtube.com/channel/UCCvVpbYRgYjMN7mG7qQN0Pg', 'https://www.youtube.com/channel/UCj_Y-xJ2DRDGP4ilfzplCOQ', 'https://www.youtube.com/channel/UCS34YVeqtFViWRB3jc3o2FQ', 'https://www.youtube.com/channel/UCRrCiR_F-olJgMClfsl7YAg', 'https://w...
TASK_NORMALIZE = { "cifar10": { "mean": (0.49139968, 0.48215841, 0.44653091), "std": (0.24703223, 0.24348513, 0.26158784), }, "cifar100": { "mean": (0.50707516, 0.48654887, 0.44091784), "std": (0.26733429, 0.25643846, 0.27615047), }, "mnist": {"mean": [0.1307], "std":...
task_normalize = {'cifar10': {'mean': (0.49139968, 0.48215841, 0.44653091), 'std': (0.24703223, 0.24348513, 0.26158784)}, 'cifar100': {'mean': (0.50707516, 0.48654887, 0.44091784), 'std': (0.26733429, 0.25643846, 0.27615047)}, 'mnist': {'mean': [0.1307], 'std': [0.3081]}} task_num_class = {'cifar10': 10, 'cifar100': 10...
def run_command(): response = '__Book of Spells__' spells = { 'convert': 'Convert magic ore into mana.', 'teleport': 'Teleport up to 10 tiles away.', 'heal': 'Heal 10 health.', } response = '__Spell Book__' for command, description in spells.items(): response += '\...
def run_command(): response = '__Book of Spells__' spells = {'convert': 'Convert magic ore into mana.', 'teleport': 'Teleport up to 10 tiles away.', 'heal': 'Heal 10 health.'} response = '__Spell Book__' for (command, description) in spells.items(): response += '\n**{}**: `{}`'.format(command, d...
def letter_queue(commands): queue = [] for i in commands: temp = i.split() if temp[0].strip() == 'PUSH': queue.append(temp[1].strip()) elif temp[0].strip() == 'POP': queue = queue[1:] return ''.join(queue) if __name__ == '__main__': # These "asserts" usi...
def letter_queue(commands): queue = [] for i in commands: temp = i.split() if temp[0].strip() == 'PUSH': queue.append(temp[1].strip()) elif temp[0].strip() == 'POP': queue = queue[1:] return ''.join(queue) if __name__ == '__main__': assert letter_queue(['P...