content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
occurrence = int(input()) city = {} for i in range(occurrence): strike = input() if strike in city: city[strike] += 1 else: city[strike] = 0 strike_counter = 0 for v in city.values(): strike_counter += v if strike_counter > 0: print('1') else: print('0')
occurrence = int(input()) city = {} for i in range(occurrence): strike = input() if strike in city: city[strike] += 1 else: city[strike] = 0 strike_counter = 0 for v in city.values(): strike_counter += v if strike_counter > 0: print('1') else: print('0')
class CohereObject(): def __str__(self) -> str: contents = '' exclude_list = ['iterator'] for k in self.__dict__.keys(): if k not in exclude_list: contents += f'\t{k}: {self.__dict__[k]}\n' output = f'cohere.{type(self).__name__} {{\n{contents}}}' ...
class Cohereobject: def __str__(self) -> str: contents = '' exclude_list = ['iterator'] for k in self.__dict__.keys(): if k not in exclude_list: contents += f'\t{k}: {self.__dict__[k]}\n' output = f'cohere.{type(self).__name__} {{\n{contents}}}' r...
class Producto: def __init__(self, nombre, descripcion, precio, stock, codigo): self.nombre = nombre self.descripcion = descripcion self.precio = precio self.stock = stock self.codigo = codigo
class Producto: def __init__(self, nombre, descripcion, precio, stock, codigo): self.nombre = nombre self.descripcion = descripcion self.precio = precio self.stock = stock self.codigo = codigo
# The number of nook purchase price periods PRICE_PERIOD_COUNT = 12 # Alternating 'AM' 'PM' labels PRICE_TODS = [["AM", "PM"][i % 2] for i in range(PRICE_PERIOD_COUNT)] PRICE_DAYS = ["Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"] PRICE_PERIODS = [x for x in range(PRICE_PERIOD_COUNT)] # The y range of price graphs PRICE...
price_period_count = 12 price_tods = [['AM', 'PM'][i % 2] for i in range(PRICE_PERIOD_COUNT)] price_days = ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'] price_periods = [x for x in range(PRICE_PERIOD_COUNT)] price_y_lim = [0, 701] label_size = 16
# Litkowski Norbert # Cw.1 # Python # McCulloch-Pitts neuron def f(weights, inputs, m): x = float(0) for i in range(m): x += (weights[i] * inputs[i]) if x >= 0: return 1 else: return 0 def and_gate(): inputs = [] weights = [float(0.3), float(0.3), float(-0.5)] m ...
def f(weights, inputs, m): x = float(0) for i in range(m): x += weights[i] * inputs[i] if x >= 0: return 1 else: return 0 def and_gate(): inputs = [] weights = [float(0.3), float(0.3), float(-0.5)] m = 3 print('\nAND gate\n') x = input('Input 1: ') y = in...
def bubble_sort(mass, cmp = lambda a, b: a - b): len_mass= len(mass) for i in range(len_mass, 0, -1): need = False for j in range(1, i): if cmp(mass[j-1], mass[j]) > 0: mass[j-1], mass[j] = mass[j], mass[j-1] need = True if not need: break ...
def bubble_sort(mass, cmp=lambda a, b: a - b): len_mass = len(mass) for i in range(len_mass, 0, -1): need = False for j in range(1, i): if cmp(mass[j - 1], mass[j]) > 0: (mass[j - 1], mass[j]) = (mass[j], mass[j - 1]) need = True if not need: ...
class Room: #Initialises a room. Do not change the function signature (line 2) def __init__(self, name): self.name = name self.quest = None self.north = None self.south = None self.east = None self.west = None #Returns the room's name. def get_name(self): return self.name #Returns a string containi...
class Room: def __init__(self, name): self.name = name self.quest = None self.north = None self.south = None self.east = None self.west = None def get_name(self): return self.name def get_short_desc(self): if self.quest == None: ...
CALIB_FILE_NAME = "calib.p" PERSPECTIVE_FILE_NAME = "projection.p" VIDEO_SIZE = 1280, 720 ORIGINAL_SIZE = 1280, 720 MODEL_SIZE = 608., 608. UNWARPED_SIZE = 500, 600
calib_file_name = 'calib.p' perspective_file_name = 'projection.p' video_size = (1280, 720) original_size = (1280, 720) model_size = (608.0, 608.0) unwarped_size = (500, 600)
class PipConfigurationError(Exception): pass
class Pipconfigurationerror(Exception): pass
# Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. # Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case # https://www.codew...
def count_bits(n): bitcount = 0 while n > 0: bitcount += n % 2 n = int(n / 2) return bitcount
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
def create_user(app, username, role): appbuilder = app.appbuilder role_admin = appbuilder.sm.find_role(role) tester = appbuilder.sm.find_user(username=username) if not tester: appbuilder.sm.add_user(username=username, first_name=username, last_name=username, email=f'{username}@fab.org', role=rol...
class Field(object): def __init__(self, name, column_type, primary_key, default): self.name = name self.column_type = column_type self.primary_key = primary_key self.default = default def __str__(self): return '<%s, %s:%s>' % (self.__class__.__name__, self.column_type, ...
class Field(object): def __init__(self, name, column_type, primary_key, default): self.name = name self.column_type = column_type self.primary_key = primary_key self.default = default def __str__(self): return '<%s, %s:%s>' % (self.__class__.__name__, self.column_type, ...
def Rotate(arr): temp = [] for i in range(len(arr)): for j in range(0, len(arr)): if i != j and i < j: arr[i][j], arr[j][i] = arr[j][i], arr[i][j] for l in arr: l.reverse() print(l) arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Rotate(arr)
def rotate(arr): temp = [] for i in range(len(arr)): for j in range(0, len(arr)): if i != j and i < j: (arr[i][j], arr[j][i]) = (arr[j][i], arr[i][j]) for l in arr: l.reverse() print(l) arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] rotate(arr)
# coding: utf-8 lib_common = { 'uri': 'common', 'type': 'config', 'cxxflags': [ '-std=c++11', ], 'source_base_dir': 'd:/lib/ogre', 'install_dirs_map': { }, } def dyn_common(lib, context): c = context versions = c.parseFile( 'OgreMain/include/OgrePrerequ...
lib_common = {'uri': 'common', 'type': 'config', 'cxxflags': ['-std=c++11'], 'source_base_dir': 'd:/lib/ogre', 'install_dirs_map': {}} def dyn_common(lib, context): c = context versions = c.parseFile('OgreMain/include/OgrePrerequisites.h', '^\\s*#define\\s+(OGRE_VERSION_\\S+)\\s+(.+)') c.setVar('OGRE_VERSI...
ReLU [[-0.426116, -1.36682, 1.82537, -0.359894, 0.781783], [0.0141898, -1.74668, 2.10078, 0.199607, -0.625995], [0.236925, -0.387744, 0.335238, -0.0708328, -0.872241], [0.189836, 1.80645, 0.228501, 1.39699, -1.70341], [3.36428, -0.00959754, -0.02829, -0.00182374, -0.00321689], [-0.00116646, -1.30479, -0.646313, 0.38497...
ReLU [[-0.426116, -1.36682, 1.82537, -0.359894, 0.781783], [0.0141898, -1.74668, 2.10078, 0.199607, -0.625995], [0.236925, -0.387744, 0.335238, -0.0708328, -0.872241], [0.189836, 1.80645, 0.228501, 1.39699, -1.70341], [3.36428, -0.00959754, -0.02829, -0.00182374, -0.00321689], [-0.00116646, -1.30479, -0.646313, 0.38497...
class MyCalendarThree: def __init__(self): self.times = [] def book(self, start, end): bisect.insort(self.times, (start, 1)) bisect.insort(self.times, (end, -1)) res = cur = 0 for _, x in self.times: cur += x res = max(res, cur) return re...
class Mycalendarthree: def __init__(self): self.times = [] def book(self, start, end): bisect.insort(self.times, (start, 1)) bisect.insort(self.times, (end, -1)) res = cur = 0 for (_, x) in self.times: cur += x res = max(res, cur) return ...
# A programming coach has n students to teach. We know that n is divisible by 3. Let's assume that # all students are numbered from 1 to n, inclusive. Before the university programming championship # the coach wants to split all students into groups of three. For some pairs of students we know that # they want to be on...
def dfs(graph, u, visited, actual_team): if not visited[u]: actual_team.append(u) visited[u] = True for v in range(len(graph)): if not visited[v] and graph[u][v] == 1: dfs(graph, v, visited, actual_team) def coach(n, m, T): graph = [[0] * n for _ in range(n)] for i in ra...
ALPACA_END_POINT = 'https://paper-api.alpaca.markets' ALPACA_API_KEY = 'PK45PMO9M1JFIAWKW1X1' ALPACA_SECRET_KEY = 'l6nOaQQvgPqE98MhKjXkrZFvoKPl6ikJ7inBrEed' POLYGON_ALPACA_WS = 'wss://alpaca.socket.polygon.io/stocks' # POLYGON_API_KEY = 'jrQpup0rXAdbYrIRXUTOI8bZ1BkQlJiR' POLYGON_API_KEY = 'PK45PMO9M1JFIAWKW1X1'
alpaca_end_point = 'https://paper-api.alpaca.markets' alpaca_api_key = 'PK45PMO9M1JFIAWKW1X1' alpaca_secret_key = 'l6nOaQQvgPqE98MhKjXkrZFvoKPl6ikJ7inBrEed' polygon_alpaca_ws = 'wss://alpaca.socket.polygon.io/stocks' polygon_api_key = 'PK45PMO9M1JFIAWKW1X1'
class Solution: def countVowelPermutation(self, n: int) -> int: mod = 10**9 + 7 dp = [[0] * 5 for _ in range(n)] for j in range(5): dp[0][j] = 1 for i in range(1, n): dp[i][0] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][4]) % mod dp[i][1] = (dp[i-1][0]...
class Solution: def count_vowel_permutation(self, n: int) -> int: mod = 10 ** 9 + 7 dp = [[0] * 5 for _ in range(n)] for j in range(5): dp[0][j] = 1 for i in range(1, n): dp[i][0] = (dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][4]) % mod dp[i][1] = (dp...
# -*- coding: utf-8 -*- # AtCoder Beginner Contest if __name__ == '__main__': n = int(input()) a = list(map(int, input().split())) count = 0 # See: # https://beta.atcoder.jp/contests/abc100/submissions/2675457 for ai in a: while ai % 2 == 0: ai //= 2 ...
if __name__ == '__main__': n = int(input()) a = list(map(int, input().split())) count = 0 for ai in a: while ai % 2 == 0: ai //= 2 count += 1 print(count)
# -*- coding: utf-8 -*- class RabbitmqClientError(Exception): pass class RabbitmqConnectionError(RabbitmqClientError): pass class QueueNotFoundError(RabbitmqClientError): pass
class Rabbitmqclienterror(Exception): pass class Rabbitmqconnectionerror(RabbitmqClientError): pass class Queuenotfounderror(RabbitmqClientError): pass
def login(): return 'login info' a = 18 num1 = 30 num2 = 10 num2 = 20
def login(): return 'login info' a = 18 num1 = 30 num2 = 10 num2 = 20
A, B, C = map(int, input().split()) if (A*B*C) % 2 == 0: print(0) else: abc = [A, B, C] abc.sort() print(abc[0] * abc[1])
(a, b, c) = map(int, input().split()) if A * B * C % 2 == 0: print(0) else: abc = [A, B, C] abc.sort() print(abc[0] * abc[1])
class BaseUIHandler(object): def handle_first_run(self): pass def init(self): raise NotImplementedError('No UI handler specified!') return False def start(self): return 1
class Baseuihandler(object): def handle_first_run(self): pass def init(self): raise not_implemented_error('No UI handler specified!') return False def start(self): return 1
Encoding = {\ ['e']: '000', ['\0x20']: '1111', ['t']: '1100', ['a']: '10111', ['o']: '1000', ['n']: '0111', ['i']: '0110', ['s']: '0100', ['r']: '0011', ['h']: '11011', ['l']: '10101', ['d']: '10010', ['c']: '00101', ['u']: '111001', ['m']: '110101', ['f']: '101001', ['p']: '101000', ['g']: '100111', ['y']: '010110', [...
encoding = {['e']: '000', ['\x00x20']: '1111', ['t']: '1100', ['a']: '10111', ['o']: '1000', ['n']: '0111', ['i']: '0110', ['s']: '0100', ['r']: '0011', ['h']: '11011', ['l']: '10101', ['d']: '10010', ['c']: '00101', ['u']: '111001', ['m']: '110101', ['f']: '101001', ['p']: '101000', ['g']: '100111', ['y']: '010110', [...
product = { "name":"book", "quan":3, "price":4.25, } person ={ "name":"zoy", "first_name":"mol", "age":39, } print(type(product)) print(dir(product)) print(product) #Obtener los indices o llaves del diccionario print(product.keys()) print(product.values()) print(product.items()) tienda = [ ...
product = {'name': 'book', 'quan': 3, 'price': 4.25} person = {'name': 'zoy', 'first_name': 'mol', 'age': 39} print(type(product)) print(dir(product)) print(product) print(product.keys()) print(product.values()) print(product.items()) tienda = [{'name': 'chair', 'price': 150}, {'name': 'soap', 'price': 10}, {'fifi': '8...
# coding=utf-8 ver_info = {"major": 1, "alias": "Config", "minor": 0} cfg_ver_min = 2 cfg_ver_active = 2
ver_info = {'major': 1, 'alias': 'Config', 'minor': 0} cfg_ver_min = 2 cfg_ver_active = 2
class DataHeader: def __init__(self, name, data_type, vocab_file=None, vocab_mode="read"): self.name = name self.data_type = data_type self.vocab_file = vocab_file self.vocab_mode = vocab_mode
class Dataheader: def __init__(self, name, data_type, vocab_file=None, vocab_mode='read'): self.name = name self.data_type = data_type self.vocab_file = vocab_file self.vocab_mode = vocab_mode
def parse_data(): with open('2019/01/input.txt') as f: data = f.read() return [int(num) for num in data.splitlines()] def part_one(data): return sum(mass // 3 - 2 for mass in data) def part_two(data): total = 0 for num in data: while (num := num // 3 - 2) > 0: total ...
def parse_data(): with open('2019/01/input.txt') as f: data = f.read() return [int(num) for num in data.splitlines()] def part_one(data): return sum((mass // 3 - 2 for mass in data)) def part_two(data): total = 0 for num in data: while (num := (num // 3 - 2)) > 0: total...
# greatest common divisor def gcd(a, b): while b: a, b = b, a % b return a # lowest common multiple def lcm(a, b): return (a * b) // gcd(a, b)
def gcd(a, b): while b: (a, b) = (b, a % b) return a def lcm(a, b): return a * b // gcd(a, b)
fname = input("Enter file name: ") if len(fname) < 1: fname = "mbox-short.txt" fh = open(fname) count = 0 def handle_line(line): tokens = line.split(' ') print(tokens[1]) count += 1 for line in fh: if (line.startswith("From:")): continue if (not line.startswith("From")): continue handle_line(...
fname = input('Enter file name: ') if len(fname) < 1: fname = 'mbox-short.txt' fh = open(fname) count = 0 def handle_line(line): tokens = line.split(' ') print(tokens[1]) count += 1 for line in fh: if line.startswith('From:'): continue if not line.startswith('From'): continue ...
#for i in range (1,11): # print ("%d * 5 = %d" %(i,i*5)) # Printing Pattern for i in range (1,5): for j in range (0,i): print ( " * ", end = '' ) print ('') #NExt line # For - Else loop for i in range (5,1,-1): for j in range(0,i): print ( " * ", end = '' ) print ('') #...
for i in range(1, 5): for j in range(0, i): print(' * ', end='') print('') for i in range(5, 1, -1): for j in range(0, i): print(' * ', end='') print('') for i in range(50, 100, 2): print(i) else: print(' No breaks') print(' Values') i = 10 while i < 25: print(i) i = i + ...
# Shared constants SEGMENT_LEN = 3 # duration per spectrogram in seconds FMIN = 30 # min frequency FMAX = 12500 # max frequency SAMPLING_RATE = 44100 WIN_LEN = 2048 # FFT window length BINARY_SPEC_HEIGHT = 32 # binary classifier spectrogram height SPEC_HEIGHT = 128 # no...
segment_len = 3 fmin = 30 fmax = 12500 sampling_rate = 44100 win_len = 2048 binary_spec_height = 32 spec_height = 128 spec_width = 384 ignore_file = 'data/ignore.txt' classes_file = 'data/classes.txt' ckpt_path = 'data/ckpt' binary_ckpt_path = 'data/binary_classifier_ckpt'
def get_input(): puzzle_input = open('./python/inputday01.txt', 'r').read() return puzzle_input.split('\n')[:-1] def get_fuel_required(module_mass=0): return (module_mass//3)-2 def get_fuel_required_for_fuel(fuel_volume=0): fuel_volume_required = (fuel_volume // 3)-2 if fuel_volume_required <= 0: ...
def get_input(): puzzle_input = open('./python/inputday01.txt', 'r').read() return puzzle_input.split('\n')[:-1] def get_fuel_required(module_mass=0): return module_mass // 3 - 2 def get_fuel_required_for_fuel(fuel_volume=0): fuel_volume_required = fuel_volume // 3 - 2 if fuel_volume_required <= 0...
SUBLIST = 0 SUPERLIST = 1 EQUAL = 2 UNEQUAL = 3 def sublist(list_one, list_two): one_chars = map(str, list_one) two_chars = map(str, list_two) list_one_str = ",".join(one_chars) + "," list_two_str = ",".join(two_chars) + "," if list_one_str == list_two_str: return 2 elif list_one_str ...
sublist = 0 superlist = 1 equal = 2 unequal = 3 def sublist(list_one, list_two): one_chars = map(str, list_one) two_chars = map(str, list_two) list_one_str = ','.join(one_chars) + ',' list_two_str = ','.join(two_chars) + ',' if list_one_str == list_two_str: return 2 elif list_one_str in...
# 285. Inorder Successor in BST # Runtime: 68 ms, faster than 85.36% of Python3 online submissions for Inorder Successor in BST. # Memory Usage: 18.1 MB, less than 79.18% of Python3 online submissions for Inorder Successor in BST. # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): #...
class Solution: def inorder_successor(self, root: TreeNode, p: TreeNode) -> TreeNode: stack = [] find_p = False while root or stack: while root: stack.append(root) root = root.left node = stack.pop() if find_p: ...
# -*- coding: utf-8 -*- class ArchiveService: def get_service_name(self): return 'DEFAULT' def submit(self, url): pass class ArchiveException(Exception): pass
class Archiveservice: def get_service_name(self): return 'DEFAULT' def submit(self, url): pass class Archiveexception(Exception): pass
def reverse(st): st = st.split() st.reverse() st2 = ' '.join(st) return st2
def reverse(st): st = st.split() st.reverse() st2 = ' '.join(st) return st2
class HyperParameter: def __init__(self, num_batches, batch_size, epoch, learning_rate, hold_prob, epoch_to_report=100): self.num_batches = num_batches self.batch_size = batch_size self.epoch = epoch self.learning_rate = learning_rate self.hold_prob = hold_prob, self....
class Hyperparameter: def __init__(self, num_batches, batch_size, epoch, learning_rate, hold_prob, epoch_to_report=100): self.num_batches = num_batches self.batch_size = batch_size self.epoch = epoch self.learning_rate = learning_rate self.hold_prob = (hold_prob,) se...
# This project created by urhoba # www.urhoba.net #region DB Settings class DBSettings: sqliteDB = "db.urhoba" #endregion #region Mail Settings class MailSettings: fromMail = "ahmetbohur@urhoba.net" fromPassword = "" smtpHost = "smtp.yandex.com" smtpPort = 465 #endregion #region Download Settings...
class Dbsettings: sqlite_db = 'db.urhoba' class Mailsettings: from_mail = 'ahmetbohur@urhoba.net' from_password = '' smtp_host = 'smtp.yandex.com' smtp_port = 465 class Downloadsettings: music_folder = 'songs' video_folder = 'videos' class Telegramsettings: telegram_api = ''
__author__ = 'Chintalagiri Shashank' __email__ = 'shashank@chintal.in' __version__ = '0.2.9'
__author__ = 'Chintalagiri Shashank' __email__ = 'shashank@chintal.in' __version__ = '0.2.9'
{ 'targets': [ { 'target_name': 'rulesjs', 'sources': [ 'src/rulesjs/rules.cc' ], 'include_dirs': ["<!(node -e \"require('nan')\")"], 'dependencies': [ 'src/rules/rules.gyp:rules' ], 'defines': [ '_GNU_SOURCE' ], 'cflags': [ '-Wall', '-O3' ] } ] }
{'targets': [{'target_name': 'rulesjs', 'sources': ['src/rulesjs/rules.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'dependencies': ['src/rules/rules.gyp:rules'], 'defines': ['_GNU_SOURCE'], 'cflags': ['-Wall', '-O3']}]}
# Generate key with openssl rand -hex 32 JWT_SECRET_KEY = "46e5c95a2d980476afb2d679b37bb2c8990c25b4ea1075514f67f62f77daf306" JWT_ALGORITHM = "HS256" JWT_EXPIRATION_MINUTES = 15 # TODO: Move to environment variables DB_HOST = 'localhost' DB_NAME = 'bookstore' DB_USER = 'postgres' DB_PASSWORD = 'postgres' DB_PORT = 5432...
jwt_secret_key = '46e5c95a2d980476afb2d679b37bb2c8990c25b4ea1075514f67f62f77daf306' jwt_algorithm = 'HS256' jwt_expiration_minutes = 15 db_host = 'localhost' db_name = 'bookstore' db_user = 'postgres' db_password = 'postgres' db_port = 5432 redis_url = 'redis://localhost' test = True test_db_host = 'localhost' test_db_...
class Difference: def __init__(self, a): self.__elements = a self.maximumDifference = 0 def computeDifference(self): max_num = max(self.__element) min_num = min(self.__element) self.maximumDifference = max_num - min_num if self.maximumDifference < 0: ...
class Difference: def __init__(self, a): self.__elements = a self.maximumDifference = 0 def compute_difference(self): max_num = max(self.__element) min_num = min(self.__element) self.maximumDifference = max_num - min_num if self.maximumDifference < 0: ...
t = int(input()) output = [] for _ in range(t): p, a, b, c = [int(x) for x in input().split()] if a >= p: minimum = a - p elif p % a == 0: minimum = 0 else: minimum = a - (p % a) if b >= p: minimum = min(minimum, b - p) elif p % b == 0: minimum = 0 els...
t = int(input()) output = [] for _ in range(t): (p, a, b, c) = [int(x) for x in input().split()] if a >= p: minimum = a - p elif p % a == 0: minimum = 0 else: minimum = a - p % a if b >= p: minimum = min(minimum, b - p) elif p % b == 0: minimum = 0 els...
n=int(input());r="" for i in range(1,n+1): s=input().strip() if s=="5 6" or s=="6 5": r+="Case "+str(i)+": Sheesh Beesh\n" else: a=[int(k) for k in s.split()] a.sort(reverse=True) if a[0]==a[1]: if a[0]==1: r+="Case "+str(i)+": Habb Yakk\n" ...
n = int(input()) r = '' for i in range(1, n + 1): s = input().strip() if s == '5 6' or s == '6 5': r += 'Case ' + str(i) + ': Sheesh Beesh\n' else: a = [int(k) for k in s.split()] a.sort(reverse=True) if a[0] == a[1]: if a[0] == 1: r += 'Case ' + s...
def order(data): # new_data = [] for i in range(len(data)): for j in range(len(data) - 1): if (data[j] > data[j + 1]): temp_data_j = data[j] data[j] = data[j + 1] data[j + 1] = temp_data_j return data
def order(data): for i in range(len(data)): for j in range(len(data) - 1): if data[j] > data[j + 1]: temp_data_j = data[j] data[j] = data[j + 1] data[j + 1] = temp_data_j return data
# %% [markdown] ''' # How to install NVIDIA GPU driver and CUDA on ubuntu ''' # %% [markdown] ''' This post is intended to describe how to install NVIDIA GPU driver and CUDA on ubuntu. I have myself a GTX 560M with ubuntu 18.04. ''' # %% [markdown] ''' ## Requirements Before installing, we will first need to find th...
""" # How to install NVIDIA GPU driver and CUDA on ubuntu """ '\nThis post is intended to describe how to install NVIDIA GPU driver and CUDA on ubuntu. \nI have myself a GTX 560M with ubuntu 18.04.\n' '\n## Requirements\n\nBefore installing, we will first need to find the different version that your GPU support in the...
#!/usr/bin/env python3 def clean_up(): try: raise KeyboardInterrupt finally: print('Goodbye, world!') def divide(x, y): try: result = x / y except ZeroDivisionError: print("division by zero!") else: print("result is", result) finally: print("exe...
def clean_up(): try: raise KeyboardInterrupt finally: print('Goodbye, world!') def divide(x, y): try: result = x / y except ZeroDivisionError: print('division by zero!') else: print('result is', result) finally: print('executing finally clause') i...
# Just a simple time class # that stores time in 24 hour format # and displays in period time (AM/PM) class SimpleTime: def __init__(self, hour, minute, period): # assertions for checking assert(hour > 0 and hour <= 12) assert(minute >= 0 and minute < 60) assert(period == "AM" or per...
class Simpletime: def __init__(self, hour, minute, period): assert hour > 0 and hour <= 12 assert minute >= 0 and minute < 60 assert period == 'AM' or period == 'PM' self._minute = minute if period == 'AM': self._hour = hour % 12 else: self._h...
class BytesIntEncoder: @staticmethod def encode(s: str) -> int: return int.from_bytes(s.encode(), byteorder='big') @staticmethod def decode(i: int) -> str: return i.to_bytes(((i.bit_length() + 7) // 8), byteorder='big').decode()
class Bytesintencoder: @staticmethod def encode(s: str) -> int: return int.from_bytes(s.encode(), byteorder='big') @staticmethod def decode(i: int) -> str: return i.to_bytes((i.bit_length() + 7) // 8, byteorder='big').decode()
def castleTowers(n, ar): occurrences_map = {} max_item = -1 for item in ar: if item > max_item: max_item = item if item in occurrences_map: occurrences_map[item] += 1 else: occurrences_map[item] = 1 return occurrences_map[max_item] if __na...
def castle_towers(n, ar): occurrences_map = {} max_item = -1 for item in ar: if item > max_item: max_item = item if item in occurrences_map: occurrences_map[item] += 1 else: occurrences_map[item] = 1 return occurrences_map[max_item] if __name__...
def countMinOperations(target, n): result = 0 while (True): zero_count = 0 i = 0 while (i < n): if ((target[i] & 1) > 0): break elif (target[i] == 0): zero_count += 1 i += 1 if (zero_count == n): ...
def count_min_operations(target, n): result = 0 while True: zero_count = 0 i = 0 while i < n: if target[i] & 1 > 0: break elif target[i] == 0: zero_count += 1 i += 1 if zero_count == n: return result ...
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/home/pi/catkin_ws/src/mobrob_util/msg/ME439SensorsRaw.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439SensorsProcessed.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439WheelSpeeds.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439MotorCommands.msg;/home...
messages_str = '/home/pi/catkin_ws/src/mobrob_util/msg/ME439SensorsRaw.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439SensorsProcessed.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439WheelSpeeds.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439MotorCommands.msg;/home/pi/catkin_ws/src/mobrob_util/msg/ME439WheelAngles.ms...
# # Find the one food that is eaten by only one animal. # # The animals table has columns (name, species, birthdate) for each individual. # The diet table has columns (species, food) for each food that a species eats. # QUERY = ''' select diet.food, count(animals.name) as num from animals, diet where animals.s...
query = '\nselect diet.food, count(animals.name) as num from animals, diet where animals.species = diet.species group by diet.food having num = 1\n'
class EmployeeTaskLink: def __init__(self, linkID, empID, taskID): self.linkID = linkID self.empID = empID self.taskID = taskID def get_employee(self, list): for emp in list: if emp.empID == self.empID: return emp def get_task(self, list): ...
class Employeetasklink: def __init__(self, linkID, empID, taskID): self.linkID = linkID self.empID = empID self.taskID = taskID def get_employee(self, list): for emp in list: if emp.empID == self.empID: return emp def get_task(self, list): ...
def findDecision(obj): #obj[0]: Passanger, obj[1]: Time, obj[2]: Coupon, obj[3]: Gender, obj[4]: Age, obj[5]: Children, obj[6]: Education, obj[7]: Occupation, obj[8]: Bar, obj[9]: Coffeehouse, obj[10]: Restaurant20to50, obj[11]: Direction_same, obj[12]: Distance # {"feature": "Age", "instances": 34, "metric_value": 0....
def find_decision(obj): if obj[4] <= 4: if obj[0] <= 1: if obj[6] <= 4: if obj[1] <= 1: return 'False' elif obj[1] > 1: if obj[12] <= 1: if obj[7] > 1: return 'False' ...
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. class Constants: SYS_BOOLEAN: str = "boolean" SYS_BOOLEAN_TRUE: str = "boolean-true" SYS_BOOLEAN_FALSE: str = "boolean-false"
class Constants: sys_boolean: str = 'boolean' sys_boolean_true: str = 'boolean-true' sys_boolean_false: str = 'boolean-false'
t = int(input()) while t: A, B = map(int, input().split()) c = 1 while(c>0): if(c%2==0): B -= c else: A -= c if(A<0): print("Bob") break if(B<0): print("Limak") break c += 1 t = t-1
t = int(input()) while t: (a, b) = map(int, input().split()) c = 1 while c > 0: if c % 2 == 0: b -= c else: a -= c if A < 0: print('Bob') break if B < 0: print('Limak') break c += 1 t = t - 1
## Uppercase is BOLT # to use: from utils.beautyfy import * def red(string): return '\033[1;91m {}\033[00m'.format(string) def RED(string): return '\033[1;91m {}\033[00m'.format(string) def yellow(string): return '\033[93m {}\033[00m'.format(string) def YELLOW(string): return '\033[1;93m {}\033[00m'...
def red(string): return '\x1b[1;91m {}\x1b[00m'.format(string) def red(string): return '\x1b[1;91m {}\x1b[00m'.format(string) def yellow(string): return '\x1b[93m {}\x1b[00m'.format(string) def yellow(string): return '\x1b[1;93m {}\x1b[00m'.format(string) def blue(string): return '\x1b[94m {}\x1...
# Time: O(n log n); Space: O(1) def ship_within_days(weights, days): low = max(weights) high = sum(weights) min_capacity = high while low <= high: mid = low + (high - low) // 2 cur_days, cur_daily_weight = 1, 0 for w in weights: if cur_daily_weight + w > mid: ...
def ship_within_days(weights, days): low = max(weights) high = sum(weights) min_capacity = high while low <= high: mid = low + (high - low) // 2 (cur_days, cur_daily_weight) = (1, 0) for w in weights: if cur_daily_weight + w > mid: cur_days += 1 ...
# config.py DEBUG = True DBHOST = '130.211.198.107' DBPASS = "gregb00th" DBPORT = 3306 DBUSER = 'root' DBNAME = 'baseball_2018' CLOUDSQL_PROJECT = "Baseball-2018" CLOUDSQL_INSTANCE = "personalwebsite-165915:us-central1:baseball-2018" CLOUD_STORAGE_BUCKET = 'analytics_data_extraction' MAX_CONTENT_LENGTH = 8...
debug = True dbhost = '130.211.198.107' dbpass = 'gregb00th' dbport = 3306 dbuser = 'root' dbname = 'baseball_2018' cloudsql_project = 'Baseball-2018' cloudsql_instance = 'personalwebsite-165915:us-central1:baseball-2018' cloud_storage_bucket = 'analytics_data_extraction' max_content_length = 8 * 1024 * 1024 allowed_ex...
def get_certified_by(filing_data: dict): user_id = filing_data.get('u_user_id') if user_id: first_name = filing_data.get('u_first_name') middle_name = filing_data.get('u_middle_name') last_name = filing_data.get('u_last_name') if first_name or middle_name or last_name: ...
def get_certified_by(filing_data: dict): user_id = filing_data.get('u_user_id') if user_id: first_name = filing_data.get('u_first_name') middle_name = filing_data.get('u_middle_name') last_name = filing_data.get('u_last_name') if first_name or middle_name or last_name: ...
file_path = '/esdata/test/11.log' with open(file_path, 'w') as file: num = 1000 val = 0 while val <= num: file.write("{:x}\n".format(val).zfill(12)) val += 1
file_path = '/esdata/test/11.log' with open(file_path, 'w') as file: num = 1000 val = 0 while val <= num: file.write('{:x}\n'.format(val).zfill(12)) val += 1
load_modules = { ########### Attacker 'uds_engine_auth_baypass': { 'id_command': 0x71 }, 'gen_ping' : {}, 'uds_tester_ecu_engine':{ 'id_uds': 0x701, 'uds_shift': 0x08, 'uds_key':'' }, 'hw_TCP2CAN': {'port': 1111, 'mode': 'client', 'address':'127.0....
load_modules = {'uds_engine_auth_baypass': {'id_command': 113}, 'gen_ping': {}, 'uds_tester_ecu_engine': {'id_uds': 1793, 'uds_shift': 8, 'uds_key': ''}, 'hw_TCP2CAN': {'port': 1111, 'mode': 'client', 'address': '127.0.0.1', 'debug': 3}, 'hw_TCP2CAN~1': {'port': 1112, 'mode': 'client', 'address': '127.0.0.1', 'debug': ...
# More indentation included to distinguish this from the rest. def server( host='localhost', port=443, secure=True, username='admin', password='admin'): return locals() # Aligned with opening delimiter. connection = server(host='localhost', port=443, secure=True, username='admi...
def server(host='localhost', port=443, secure=True, username='admin', password='admin'): return locals() connection = server(host='localhost', port=443, secure=True, username='admin', password='admin') connection = server(host='localhost', port=443, secure=True, username='admin', password='admin') connection = serv...
# yacon.definitions.py # # This file contains common values that aren't usually changed per # installation and therefore shouldn't go in the django settings file # max length of slugs SLUG_LENGTH = 25 # max length of title TITLE_LENGTH = 50 # bleach constants ALLOWED_TAGS = [ 'a', 'address', 'b', 'br...
slug_length = 25 title_length = 50 allowed_tags = ['a', 'address', 'b', 'br', 'blockquote', 'code', 'div', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'img', 'i', 'li', 'ol', 'p', 'pre', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'thead', 'tr', 'td', 'u', 'ul'] allowed_attributes = {'a': ['href', '...
''' Break statement '''
""" Break statement """
#greatest among 3 a=int(input("Enter no:")) b=int(input("Enter no:")) c=int(input("Enter no:")) if a>b: if a>c: print(a) else: print(c) else: if b>c: print(b) else: print(c)
a = int(input('Enter no:')) b = int(input('Enter no:')) c = int(input('Enter no:')) if a > b: if a > c: print(a) else: print(c) elif b > c: print(b) else: print(c)
# -*- coding: utf-8 -*- def file_decrypt(data,mode,storetype): return data
def file_decrypt(data, mode, storetype): return data
# not yet finished H, M = input().split() H, M = int(H), int(M) N = int(input()) m = N % 60 H += N // 60 H %= 24 M = m # for _ in range(N): # M += 1 # if M == 60: # M = 0 # H += 1 # if H == 24: # H = 0 print(H, M)
(h, m) = input().split() (h, m) = (int(H), int(M)) n = int(input()) m = N % 60 h += N // 60 h %= 24 m = m print(H, M)
def starify_pval(pval): if pval > 0.05: return "" else: if pval <= 0.001: return "***" if pval <= 0.01: return "**" if pval <= 0.05: return "*"
def starify_pval(pval): if pval > 0.05: return '' else: if pval <= 0.001: return '***' if pval <= 0.01: return '**' if pval <= 0.05: return '*'
codes = { "reset": "\u001b[0m", "black": "\u001b[30m", "red": "\u001b[31m", "green": "\u001b[32m", "light_yellow": "\u001b[93m", "yellow": "\u001b[33m", "yellow_background": "\u001b[43m", "blue": "\u001b[34m", "purple": "\u001b[35m", "cyan": "\u001b[36m", "white": "\u001b[37m...
codes = {'reset': '\x1b[0m', 'black': '\x1b[30m', 'red': '\x1b[31m', 'green': '\x1b[32m', 'light_yellow': '\x1b[93m', 'yellow': '\x1b[33m', 'yellow_background': '\x1b[43m', 'blue': '\x1b[34m', 'purple': '\x1b[35m', 'cyan': '\x1b[36m', 'white': '\x1b[37m', 'bold': '\x1b[1m', 'unbold': '\x1b[21m', 'underline': '\x1b[4m',...
################################################################################ # Copyright: Tobias Weber 2020 # # Apache 2.0 License # # This file contains code related to all breadp module # ################################################################################ class ChecksNotRunException(Exception): ...
class Checksnotrunexception(Exception): pass
# # PySNMP MIB module LIGO-GENERIC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/LIGO-GENERIC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:56:36 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union, constraints_intersection, value_size_constraint, value_range_constraint) ...
class Solution: def bitwiseComplement(self, N: int) -> int: if N == 0: return 1 ret = i = 0 while N: ret |= (((N & 1) ^ 1) << i) i += 1 N >>= 1 return ret
class Solution: def bitwise_complement(self, N: int) -> int: if N == 0: return 1 ret = i = 0 while N: ret |= (N & 1 ^ 1) << i i += 1 n >>= 1 return ret
# table definition table = { 'table_name' : 'ap_pmt_batch', 'module_id' : 'ap', 'short_descr' : 'Ap batch of payments', 'long_descr' : 'Ap batch of payments by due date', 'sub_types' : None, 'sub_trans' : None, 'sequence' : None, 'tree_params' : None, 'roll...
table = {'table_name': 'ap_pmt_batch', 'module_id': 'ap', 'short_descr': 'Ap batch of payments', 'long_descr': 'Ap batch of payments by due date', 'sub_types': None, 'sub_trans': None, 'sequence': None, 'tree_params': None, 'roll_params': None, 'indexes': None, 'ledger_col': 'ledger_row_id', 'defn_company': None, 'data...
# Given a binary tree, return all root-to-leaf paths. # # Note: A leaf is a node with no children. # # Example: # # Input: # # 1 # / \ # 2 3 # \ # 5 # # Output: ["1->2->5", "1->3"] # # Explanation: All root-to-leaf paths are: 1->2->5, 1->3 # Definition for a binary tree node. class TreeNode: def __i...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None def binary_tree_paths(root_node: TreeNode) -> [str]: paths = [] if not root_node: return paths return get_path(root_node, '', paths) def get_path(node: TreeNode, path: str, paths: [s...
a=input() b=a[::-1] if a==b: print("yes") else: print("no")
a = input() b = a[::-1] if a == b: print('yes') else: print('no')
def getBMR(weightLBS, heightINCHES, age): weightKG = weightLBS*.453592 heightCM = heightINCHES*2.54 BMR = 10*weightKG+.25*heightCM-5*age+5 return BMR
def get_bmr(weightLBS, heightINCHES, age): weight_kg = weightLBS * 0.453592 height_cm = heightINCHES * 2.54 bmr = 10 * weightKG + 0.25 * heightCM - 5 * age + 5 return BMR
n = int(input("Please Enter a value for N:\n")) count = 0 sum = 0 while count <= n : sum = sum+count count +=1 print("Sum of N natural numbers: " + str(sum))
n = int(input('Please Enter a value for N:\n')) count = 0 sum = 0 while count <= n: sum = sum + count count += 1 print('Sum of N natural numbers: ' + str(sum))
# integer = int(input("Please fill number:")) integer = 12 result = tuple() for i in range(0,integer,2 ): result = result + (i,) print(result)
integer = 12 result = tuple() for i in range(0, integer, 2): result = result + (i,) print(result)
APIS = { 'apis', 'keyvaluemaps', 'targetservers', 'caches', 'developers', 'apiproducts', 'apps', 'userroles', } class Struct: def __init__(self, **entries): self.__dict__.update(entries) def __repr__(self): return f"{self.__dict__}" def empty_snapshot(): r...
apis = {'apis', 'keyvaluemaps', 'targetservers', 'caches', 'developers', 'apiproducts', 'apps', 'userroles'} class Struct: def __init__(self, **entries): self.__dict__.update(entries) def __repr__(self): return f'{self.__dict__}' def empty_snapshot(): return struct(apis={}, keyvaluemaps=...
# Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases GDAL_LIBRARY_PATH = "/Applications/Postgres.app/Contents/Versions/9.4/lib/libgdal.dylib" GEOS_LIBRARY_PATH = "/Applications/Postgres.app/Contents/Versions/9.4/lib/libgeos_c.dylib" DATABASES = { 'default': { 'ENGINE': 'django.contr...
gdal_library_path = '/Applications/Postgres.app/Contents/Versions/9.4/lib/libgdal.dylib' geos_library_path = '/Applications/Postgres.app/Contents/Versions/9.4/lib/libgeos_c.dylib' databases = {'default': {'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'tor_nodes_map', 'USER': '', 'PASSWORD': '', 'HOST': ''...
INTERACTIVE_TEXT_BUTTON_ACTION = "doTextButtonAction" INTERACTIVE_IMAGE_BUTTON_ACTION = "doImageButtonAction" INTERACTIVE_BUTTON_PARAMETER_KEY = "param_key" def _respons_text_card(type,title,text): return { 'actionResponse': {'type': type}, "cards": [ { ...
interactive_text_button_action = 'doTextButtonAction' interactive_image_button_action = 'doImageButtonAction' interactive_button_parameter_key = 'param_key' def _respons_text_card(type, title, text): return {'actionResponse': {'type': type}, 'cards': [{'header': {'title': title, 'subtitle': 'City of Edmonton chatb...
data = ''' Letters : abcdefghijklmnopqurtuvwxyz Capital Letters : ABCDEFGHIJKLMNOPQRSTUVWXYZ Numbers : 1234567890 Words : regular expresion Need to be escaped Meta Characters : . ^ $ * + ? { } [ ] \ | ( ) Websites : qaviton.com yonadavking.com idangay.com Phone Numbers: ...
data = "\nLetters : abcdefghijklmnopqurtuvwxyz\nCapital Letters : ABCDEFGHIJKLMNOPQRSTUVWXYZ\nNumbers : 1234567890\nWords : regular expresion \nNeed to be escaped\nMeta Characters : . ^ $ * + ? { } [ ] \\ | ( )\nWebsites : qaviton.com yonadavking.com idangay.com\n\nPhone Num...
class PipelineNode(object): def __init__(self, module_path, params): self.module_path = module_path self.params = params
class Pipelinenode(object): def __init__(self, module_path, params): self.module_path = module_path self.params = params
if __name__ == "__main__": filename = "ecm_flash_attempt2.in" f = open(filename) arr = [] i = 0 f2 = open(filename + ".dat", "w") for line in f: line = line.strip() pieces = line.split(',') can_data = pieces[3] idh = can_data[0:5].replace(' '...
if __name__ == '__main__': filename = 'ecm_flash_attempt2.in' f = open(filename) arr = [] i = 0 f2 = open(filename + '.dat', 'w') for line in f: line = line.strip() pieces = line.split(',') can_data = pieces[3] idh = can_data[0:5].replace(' ', '').strip() ...
def login(): result = auth_jwt.jwt_token_manager() if result and "token" in result: response.headers["x-gg-userid"] = auth.user_id return result def register(): request.vars.email = request.vars.username request.vars.password = db.auth_user.password.validate(request.vars.password)[0] re...
def login(): result = auth_jwt.jwt_token_manager() if result and 'token' in result: response.headers['x-gg-userid'] = auth.user_id return result def register(): request.vars.email = request.vars.username request.vars.password = db.auth_user.password.validate(request.vars.password)[0] re...
class Solution: def largestAltitude(self, gain: List[int]) -> int: max_alt = 0 curr = 0 for alt in gain: curr += alt if max_alt < curr: max_alt = curr return max_alt
class Solution: def largest_altitude(self, gain: List[int]) -> int: max_alt = 0 curr = 0 for alt in gain: curr += alt if max_alt < curr: max_alt = curr return max_alt
fields = 'Incorrect some fields' login = 'Incorrect password or login' location = 'Incorrect location' wrong = 'Something goes wrong. Maybe some fields are incorrect. Please connect with administrations' load = 'not loaded' change = 'Somefing change on site. Please connect with administrations' not_found = 'Article not...
fields = 'Incorrect some fields' login = 'Incorrect password or login' location = 'Incorrect location' wrong = 'Something goes wrong. Maybe some fields are incorrect. Please connect with administrations' load = 'not loaded' change = 'Somefing change on site. Please connect with administrations' not_found = 'Article not...
class Color: def __init__(self, red, green, blue): self.red = red self.green = green self.blue = blue def get_color(self): return self.red, self.green, self.blue class BlockColor: darkblue = Color(0, 0, 139) yellow = Color(255, 255, 0) green = Color(0, 128, 0) ...
class Color: def __init__(self, red, green, blue): self.red = red self.green = green self.blue = blue def get_color(self): return (self.red, self.green, self.blue) class Blockcolor: darkblue = color(0, 0, 139) yellow = color(255, 255, 0) green = color(0, 128, 0) ...
''' Pattern: Enter a number: 5 E E D E D C E D C B E D C B A E D C B E D C E D E ''' print('Alphabet Pattern: ') number_rows = int(input("Enter a number: ")) for row in range(1,number_rows+1): for column in range(1,row+1): print(chr(65+number_rows-column),end=" ") print() fo...
""" Pattern: Enter a number: 5 E E D E D C E D C B E D C B A E D C B E D C E D E """ print('Alphabet Pattern: ') number_rows = int(input('Enter a number: ')) for row in range(1, number_rows + 1): for column in range(1, row + 1): print(chr(65 + number_rows - column), end=' ') print() for row in...
# You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into ...
class Solution: def rob(self, nums: List[int]) -> int: if len(nums) == 0: return 0 if len(nums) < 3: return max(nums) nums[1] = max(nums[0], nums[1]) for i in range(2, len(nums)): nums[i] = max(nums[i] + nums[i - 2], nums[i - 1]) return nu...
# python3 def lps(pattern): pattern = '#'+pattern length = len(pattern) table = [0 for i in range(length)] table[1] = 0 for i in range(2, length): j = table[i-1] while pattern[j+1] != pattern[i] and j>0: j = table[j] if pattern[j+1...
def lps(pattern): pattern = '#' + pattern length = len(pattern) table = [0 for i in range(length)] table[1] = 0 for i in range(2, length): j = table[i - 1] while pattern[j + 1] != pattern[i] and j > 0: j = table[j] if pattern[j + 1] == pattern[i]: tabl...
#!/usr/bin/env python # coding: utf-8 # In[6]: def Secant(f,a,b,nMax,epsilon): fa=f(a) fb=f(b) if abs(fa) > abs(fb): atemp = a fatemp = fa a = b b = atemp fa = fb fb = fatemp return None print(0,a,fa) print(1,b,fb) for n in range(2,nMax)...
def secant(f, a, b, nMax, epsilon): fa = f(a) fb = f(b) if abs(fa) > abs(fb): atemp = a fatemp = fa a = b b = atemp fa = fb fb = fatemp return None print(0, a, fa) print(1, b, fb) for n in range(2, nMax): if abs(fa) > abs(fb): ...
#grade of steel a=int(input("Hardness:")) b=float(input("Carbon content:")) c=int(input("Tensile strength:")) if a>50 and b<0.7 and c>5600: print("10") elif a>50 and b<0.7: print("9") elif b<0.7 and c>5600: print("8") elif a>50 and c>5600: print("7") elif a>50 or b<0.7 or c>5600: print(...
a = int(input('Hardness:')) b = float(input('Carbon content:')) c = int(input('Tensile strength:')) if a > 50 and b < 0.7 and (c > 5600): print('10') elif a > 50 and b < 0.7: print('9') elif b < 0.7 and c > 5600: print('8') elif a > 50 and c > 5600: print('7') elif a > 50 or b < 0.7 or c > 5600: pri...
def format_inequality_result_string(and_or_expr): result = [] if and_or_expr.__class__.__name__ == 'Or': if not and_or_expr.args: raise ValueError('Recieved empty Or expression. Dafk?') for expr in and_or_expr.args: # TODO: This will fail when dealing with more complex bo...
def format_inequality_result_string(and_or_expr): result = [] if and_or_expr.__class__.__name__ == 'Or': if not and_or_expr.args: raise value_error('Recieved empty Or expression. Dafk?') for expr in and_or_expr.args: result.append(expr.args) elif and_or_expr.__class__...
n = int(input()) M=[] m = input().split() for i in range(n -1): for j in range(i+1,n): if int(m[i])<int(m[j]): M.append(m[j]) break if len(M) < i+1: M.append('*') M.append('*') m2 = ' '.join(M) print(m2)
n = int(input()) m = [] m = input().split() for i in range(n - 1): for j in range(i + 1, n): if int(m[i]) < int(m[j]): M.append(m[j]) break if len(M) < i + 1: M.append('*') M.append('*') m2 = ' '.join(M) print(m2)
# Function to calculate the # electricity bill def calculateBill(units): # Condition to find the charges # bar in which the units consumed # is fall if (units <= 150): return units * 5.50; elif (151<=units<=300): return ((150* 5.50...
def calculate_bill(units): if units <= 150: return units * 5.5 elif 151 <= units <= 300: return 150 * 5.5 + (units - 150) * 6 elif 301 <= units <= 500: return 150 * 5.5 + 150 * 6 + (units - 300) * 6.5 elif units > 500: return 150 * 5.5 + 150 * 6 + 150 * 6.5 + (units - 450...