content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
LANGUAGES = ['Auto', 'Afrikaans', 'Albanian', 'Amharic', 'Arabic', 'Armenian', 'Azerbaijani', 'Basque', 'Belarusian', 'Bengali', 'Bosnian', 'Bulgarian', 'Catalan', 'Cebuano', 'Chichewa', 'Chinese (Simplified)', 'Chinese (Traditional)', 'Corsican', 'Croatian', 'Czech', 'Danish', 'Dutch', 'English', 'Esperanto'...
languages = ['Auto', 'Afrikaans', 'Albanian', 'Amharic', 'Arabic', 'Armenian', 'Azerbaijani', 'Basque', 'Belarusian', 'Bengali', 'Bosnian', 'Bulgarian', 'Catalan', 'Cebuano', 'Chichewa', 'Chinese (Simplified)', 'Chinese (Traditional)', 'Corsican', 'Croatian', 'Czech', 'Danish', 'Dutch', 'English', 'Esperanto', 'Estonia...
n = int(input()) if n%2!=0: print('Weird') elif 2<n<=5 and n%2==0: print('Not Weird') elif 6<n<=20 and n%2==0: print('Weird') elif n>20 and n%2==0: print('Not Weird')
n = int(input()) if n % 2 != 0: print('Weird') elif 2 < n <= 5 and n % 2 == 0: print('Not Weird') elif 6 < n <= 20 and n % 2 == 0: print('Weird') elif n > 20 and n % 2 == 0: print('Not Weird')
expected_output = { "interface": { "FastEthernet2/1/1.2": { "ethernet_vlan": {2: {"status": "up"}}, "status": "up", "destination_address": { "10.2.2.2": { "default_path": "active", "imposed_label_stack": "{16}", ...
expected_output = {'interface': {'FastEthernet2/1/1.2': {'ethernet_vlan': {2: {'status': 'up'}}, 'status': 'up', 'destination_address': {'10.2.2.2': {'default_path': 'active', 'imposed_label_stack': '{16}', 'next_hop': 'point2point', 'output_interface': 'Serial2/0/2', 'tunnel_label': 'imp-null', 'vc_id': {'1002': {'vc_...
class InvalidResponseException(Exception): def __init__(self, message): self.message = f'Request was not success: {message}' super()
class Invalidresponseexception(Exception): def __init__(self, message): self.message = f'Request was not success: {message}' super()
# Contents: # Ahoy! (or Should I Say Ahoyay!) # Input! # Check Yourself! # Check Yourself... Some More # Ay B C # Word Up # Move it on Back # Ending Up # Testing, Testing, is This Thing On? print("### Ahoy! (or Should I Say Ahoyay!) ###") print("Pig Latin") print("### Input! ###") original = input("Enter a word: ") ...
print('### Ahoy! (or Should I Say Ahoyay!) ###') print('Pig Latin') print('### Input! ###') original = input('Enter a word: ') print('### Check Yourself! ###') print('### Check Yourself... Some More ###') print('### Ay B C ###') pyg = 'ay' print('### Word Up ###') print('### Move it on Back ###') print('### Ending Up #...
# Write a programme to find sum of cubes of first n natural numbers. n = int(input('Input : ')) sumofcubes = sum([x*x*x for x in [*range(1, n+1)]]) print('Output: ', sumofcubes)
n = int(input('Input : ')) sumofcubes = sum([x * x * x for x in [*range(1, n + 1)]]) print('Output: ', sumofcubes)
Bin_Base=['0','1'] Oct_Base=['0', '1', '2', '3', '4', '5', '6', '7'] Hex_Base=['0', '1', '2', '3', '4', '5', '6', '7','8','9','A','B','C','D','E','F'] def BinTesting(n): n=str(n) for digit in n: if digit in Bin_Base: continue else: return False return True def OctTest...
bin__base = ['0', '1'] oct__base = ['0', '1', '2', '3', '4', '5', '6', '7'] hex__base = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'] def bin_testing(n): n = str(n) for digit in n: if digit in Bin_Base: continue else: return False r...
### tutorzzz tutorzzzURL = 'https://tutorzzz.com/tutorzzz/orders/assignList' tutorzzzCookie = 'SESSION_TUTOR=581fb89c-88c6-4942-a735-d082bf1a29db' tutorzzzReqBody = {"pageNumber":1,"pageSize":20,"sortField":"id","order":"desc"} openIDList = ['ouZ_Ys2FvyLlOk9o-B8oZOnme5n4', 'ouZ_Ys2uzq8fijTerZziXI69jVVY'] appID = 'wxe...
tutorzzz_url = 'https://tutorzzz.com/tutorzzz/orders/assignList' tutorzzz_cookie = 'SESSION_TUTOR=581fb89c-88c6-4942-a735-d082bf1a29db' tutorzzz_req_body = {'pageNumber': 1, 'pageSize': 20, 'sortField': 'id', 'order': 'desc'} open_id_list = ['ouZ_Ys2FvyLlOk9o-B8oZOnme5n4', 'ouZ_Ys2uzq8fijTerZziXI69jVVY'] app_id = 'wxe7...
def loadfile(name): numbers = [] f = open(name, "r") for x in f: for number in x.split(","): number = int(number) numbers.append(number) return numbers def caculateTravelLinear(numbers, endpoint): travel = 0 for number in numbers: distance = endpoint - nu...
def loadfile(name): numbers = [] f = open(name, 'r') for x in f: for number in x.split(','): number = int(number) numbers.append(number) return numbers def caculate_travel_linear(numbers, endpoint): travel = 0 for number in numbers: distance = endpoint - ...
#!/usr/bin/env python3 def import_input(path): with open(path, encoding='utf-8') as infile: return [int(n) for n in infile.read().split()] banks = import_input("input.txt") class Redistributor: def __init__(self, banks): self._banks = banks def redistribute(self, i): blocks = s...
def import_input(path): with open(path, encoding='utf-8') as infile: return [int(n) for n in infile.read().split()] banks = import_input('input.txt') class Redistributor: def __init__(self, banks): self._banks = banks def redistribute(self, i): blocks = self._banks[i] self...
# https://leetcode.com/problems/search-a-2d-matrix ''' Runtime Complexity: O(logNM) Space Complexity: O(1) ''' def search_matrix(matrix, target): rows, columns = len(matrix), len(matrix[0]) start, end = 0, rows * columns - 1 while start <= end: middle = (start + end) // 2 number = matrix[...
""" Runtime Complexity: O(logNM) Space Complexity: O(1) """ def search_matrix(matrix, target): (rows, columns) = (len(matrix), len(matrix[0])) (start, end) = (0, rows * columns - 1) while start <= end: middle = (start + end) // 2 number = matrix[middle // columns][middle % columns] ...
class PaginatorFactory(object): def __init__(self, http_client): self.http_client = http_client def make(self, uri, data=None, union_key=None): return Paginator(self.http_client, uri, data, union_key) class Paginator(object): def __init__(self, http_client, uri, data=None, union_key=None)...
class Paginatorfactory(object): def __init__(self, http_client): self.http_client = http_client def make(self, uri, data=None, union_key=None): return paginator(self.http_client, uri, data, union_key) class Paginator(object): def __init__(self, http_client, uri, data=None, union_key=None...
# Time: 93 ms # Memory: 12 KB n = int(input()) apy = list(map(int, input().split())) apx = list(map(int, input().split())) apset = set(apy[1:] + apx[1:]) # n*(n+1)//2 is 1 + 2 + 3... n # https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF if sum(apset) == n*(n+1)//2: print('I become the guy.') else: print...
n = int(input()) apy = list(map(int, input().split())) apx = list(map(int, input().split())) apset = set(apy[1:] + apx[1:]) if sum(apset) == n * (n + 1) // 2: print('I become the guy.') else: print('Oh, my keyboard!')
class Solution(object): def isBadVersion(self, num): return True def firstBadVersion(self, n): left, right = 1, n while left <= right: mid = left + (right - left)/2 if self.isBadVersion(mid): right = mid - 1 else: left ...
class Solution(object): def is_bad_version(self, num): return True def first_bad_version(self, n): (left, right) = (1, n) while left <= right: mid = left + (right - left) / 2 if self.isBadVersion(mid): right = mid - 1 else: ...
#mengubah atau konversi tipe data data = 20 print(data) #konversi ke float dataFloat = float(data) print(dataFloat) print(type(dataFloat)) #konversi sting dataStr = str(data) print(dataStr) print(type(dataStr))
data = 20 print(data) data_float = float(data) print(dataFloat) print(type(dataFloat)) data_str = str(data) print(dataStr) print(type(dataStr))
#Solution 1 def search_and_insert(nums, target): for i in range(0, len(nums)): if target == nums[i]: return i elif target <nums[i]: return i return i+1 #Solution 2 def search_and_insert2(nums, target): start_index = 0 half_index = len(nums)//2 end_index = len(nums) while True: ...
def search_and_insert(nums, target): for i in range(0, len(nums)): if target == nums[i]: return i elif target < nums[i]: return i return i + 1 def search_and_insert2(nums, target): start_index = 0 half_index = len(nums) // 2 end_index = len(nums) while Tr...
t = int(input()) answer = [] for a in range(t): n = int(input()) if(n%4 == 0): answer.append("YES") else: answer.append("NO") for b in answer: print(b)
t = int(input()) answer = [] for a in range(t): n = int(input()) if n % 4 == 0: answer.append('YES') else: answer.append('NO') for b in answer: print(b)
# when creating a function it can return nothing or it can return a value like so # the return value can be any data type you wish including custom class you've made (see Object-oriented-programming file 1) #main return nothing def main(): result = sum(1, 5) print(result) # sum returns a inter or float depeni...
def main(): result = sum(1, 5) print(result) def sum(*argv): total = 0 for arg in argv: total += arg return total if __name__ == '__main__': main()
class Airport: def __init__(self, code, lat, lng, airportName): self.code = code self.lat = lat self.lng = lng self.name = airportName self.flightCategory = None self.isCalculated = False
class Airport: def __init__(self, code, lat, lng, airportName): self.code = code self.lat = lat self.lng = lng self.name = airportName self.flightCategory = None self.isCalculated = False
def gcd(a,b = None): if b != None: if a % b == 0: return b else: return gcd( b, a % b) else: for i in range(len(a)): a[0] = gcd(a[0],a[i]) return a[0] print(gcd([18,12, 6])) print(gcd(9, 12))
def gcd(a, b=None): if b != None: if a % b == 0: return b else: return gcd(b, a % b) else: for i in range(len(a)): a[0] = gcd(a[0], a[i]) return a[0] print(gcd([18, 12, 6])) print(gcd(9, 12))
#!/usr/bin/env python3 # Copyright 20 # Python provides the open() function for opening file # open() opens the file in read-only default mode. def main(): # open the file - open() returns a file object. It takes the file name and opens that file and returns # a file object. The file object itself is a iterato...
def main(): f = open('lines.txt', 'w') for line in f: print(line.rstrip()) if __name__ == '__main__': main()
#{ #Driver Code Starts #Initial Template for Python 3 # } Driver Code Ends #User function Template for python3 # Function to count even and odd # c_e : variable to store even count # c_o : variable to store odd count def count_even_odd(n, arr): c_e = 0 c_o = 0 pair = list() # your cod...
def count_even_odd(n, arr): c_e = 0 c_o = 0 pair = list() for i in range(0, n): if arr[i] % 2 == 0: c_e += 1 else: c_o += 1 pair.append(c_e) pair.append(c_o) return pair def main(): testcases = int(input()) while testcases > 0: size_ar...
print(''' Exponent code Exponent code ''') print(''' def answer2(number, power): result=1 for index in range(power): result=result * number return result print(answer2(3,2)) ''') print(''' ''') def answer2(number, power): result=1 for index in range(power): result=...
print('\nExponent code\nExponent code\n') print('\ndef answer2(number, power):\n result=1\n for index in range(power):\n result=result * number\n return result\nprint(answer2(3,2))\n') print('\n\n') def answer2(number, power): result = 1 for index in range(power): result = result * numb...
# test output stream only print('begin') for i in range(1, 5): # CHANGED FROM 20 TO 1,5 print('Spam!' * i) print('end')
print('begin') for i in range(1, 5): print('Spam!' * i) print('end')
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def glm_repository(): maybe( http_archive, name = "glm", urls = [ "https://github.com/g-truc/glm/archive/6ad79aae3eb5bf809c30bf1168171e9e55857e45.z...
load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def glm_repository(): maybe(http_archive, name='glm', urls=['https://github.com/g-truc/glm/archive/6ad79aae3eb5bf809c30bf1168171e9e55857e45.zip'], sha256='9a147a2b58df9fc30ec494468f6b...
min_computer_fish_size = 0.25 max_computer_fish_size = 3.7 min_computer_fish_speed = 100 max_computer_fish_speed = 500 player_fish_speed = 400 player_start_size = min_computer_fish_size*1.2 player_win_size = max_computer_fish_size*1.2 player_start_size_acceleration_time_constant = 0.13 player_final_size_acceleration_...
min_computer_fish_size = 0.25 max_computer_fish_size = 3.7 min_computer_fish_speed = 100 max_computer_fish_speed = 500 player_fish_speed = 400 player_start_size = min_computer_fish_size * 1.2 player_win_size = max_computer_fish_size * 1.2 player_start_size_acceleration_time_constant = 0.13 player_final_size_acceleratio...
# # PySNMP MIB module CISCO-COMMON-ROLES-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-COMMON-ROLES-EXT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:36:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, constraints_union, value_range_constraint, value_size_constraint) ...
class ServerCommands(dict): def __init__(self): super().__init__() self.update({ '!connect': 'on_client_connect', '!disconnect': 'on_client_disconnect' }) def register_command(self, command, callback_name): self[command] = callback_name def remove_co...
class Servercommands(dict): def __init__(self): super().__init__() self.update({'!connect': 'on_client_connect', '!disconnect': 'on_client_disconnect'}) def register_command(self, command, callback_name): self[command] = callback_name def remove_command(self, command): try...
# Get input N, M = map(int, input().split()) # N - the number of restaurants, M - the number of pho restaurants pho = list(map(int, input().split())) # A list of the pho restaurants phos = [False for x in range(N)] leaves = [True for x in range(N)] paths = [[] for x in range(N)] nodes = [False for x in range(N)] tota...
(n, m) = map(int, input().split()) pho = list(map(int, input().split())) phos = [False for x in range(N)] leaves = [True for x in range(N)] paths = [[] for x in range(N)] nodes = [False for x in range(N)] total = 0 ind = [x for x in range(N)] dists = [1 for x in range(N)] maxdist = 0 def mark(curr, prev): if phos[...
#entrada while True: n = int(input()) if n == 0: break for i in range(0, n): planeta, anoRecebida, tempo = str(input()).split() anoRecebida = int(anoRecebida) tempo = int(tempo) #processamento if i == 0: primeira = anoRecebida - tempo ...
while True: n = int(input()) if n == 0: break for i in range(0, n): (planeta, ano_recebida, tempo) = str(input()).split() ano_recebida = int(anoRecebida) tempo = int(tempo) if i == 0: primeira = anoRecebida - tempo first_planet = planeta ...
# # PySNMP MIB module CISCO-WAN-CES-PORT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-CES-PORT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:20:20 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint) ...
class Frame: def __init__(self, resume: int, store: int, locals_: list, arguments: list): self.stack = [] self.locals = [] for i in range(len(locals_)): self.locals.append(locals_[i]) if len(arguments) > i: self.locals[i] == arguments[i] self.a...
class Frame: def __init__(self, resume: int, store: int, locals_: list, arguments: list): self.stack = [] self.locals = [] for i in range(len(locals_)): self.locals.append(locals_[i]) if len(arguments) > i: self.locals[i] == arguments[i] self....
#will ask the user for their age and then it will #tell them how many months that age equals to user_age = input("Enter your age : ") years = int(user_age) months = years * 12 print(f"Your age, {years}, equals to {months} months.")
user_age = input('Enter your age : ') years = int(user_age) months = years * 12 print(f'Your age, {years}, equals to {months} months.')
a = [_.split('\t') for _ in open('a.txt', 'r').read().split('\n')] b = [_.split('\t') for _ in open('b.txt', 'r').read().split('\n')] for _ in range(len(a)): for a_, b_ in zip(a[_], b[_]): print(a_, b_, end='\t', sep='\t') print('')
a = [_.split('\t') for _ in open('a.txt', 'r').read().split('\n')] b = [_.split('\t') for _ in open('b.txt', 'r').read().split('\n')] for _ in range(len(a)): for (a_, b_) in zip(a[_], b[_]): print(a_, b_, end='\t', sep='\t') print('')
#function -->mehgiclude sebuah nilai didalam fungsi def input_barang(nama,harga): print("Nama Barang:", nama) print("Harga Barang", harga) a=input("masukan nama barang:") b=input("masukan harga barang") input_barang(a,b)
def input_barang(nama, harga): print('Nama Barang:', nama) print('Harga Barang', harga) a = input('masukan nama barang:') b = input('masukan harga barang') input_barang(a, b)
#!/usr/bin/python3 class Bash_DB: def __init(self, Parent): self.Controller = Parent def Create_DB(self, DB_Type): if DB_Type.DB_Stack == "LAMP": self.Controller.Bash_Script.subprocess.call("./Sensor_Database/LAMP_Server/LAMP_Setup.sh")
class Bash_Db: def __init(self, Parent): self.Controller = Parent def create_db(self, DB_Type): if DB_Type.DB_Stack == 'LAMP': self.Controller.Bash_Script.subprocess.call('./Sensor_Database/LAMP_Server/LAMP_Setup.sh')
# @desc This is a code that determines whether a number is positive, negative, or just 0 # @desc by Merrick '23 def positive_negative(x): if x > 0: return "pos" elif x == 0: return "0" else: return "neg" def main(): print(positive_negative(5)) print(positive_negative(-1)) ...
def positive_negative(x): if x > 0: return 'pos' elif x == 0: return '0' else: return 'neg' def main(): print(positive_negative(5)) print(positive_negative(-1)) print(positive_negative(0)) print(positive_negative(21)) print(positive_negative(-100)) if __name__ ==...
__all__ = [ 'resp', 'user' ]
__all__ = ['resp', 'user']
# ------------------------------------------------ EASTER EGG ------------------------------------------------ # Congratulations on finding this file! Please use the following methods below to decrypt the given cipher. def decrypt(cipher, multiple): text = "" for idx, ch in enumerate(cipher): if ch.isa...
def decrypt(cipher, multiple): text = '' for (idx, ch) in enumerate(cipher): if ch.isalpha(): shift = multiple * idx % 26 new_char = ord(ch) + shift if newChar > ord('z'): new_char -= 26 text += chr(newChar) return text def encrypt(text, m...
while True: n = int(input()) if n == -1: break s = 0 last = 0 for i in range(n): a,b=map(int,input().split()) s += a*(b-last) last = b print(s,"miles")
while True: n = int(input()) if n == -1: break s = 0 last = 0 for i in range(n): (a, b) = map(int, input().split()) s += a * (b - last) last = b print(s, 'miles')
no_of_adults = float(input()) no_of_childrens = float(input()) total_passenger_cost = 0 service_tax = 7/100 discount = 10/100 rate_per_adult = no_of_adults * 37550.0 + service_tax rate_per_children = no_of_childrens * (37550.0/3.0) + service_tax total_passenger_cost = (rate_per_adult + rate_per_children) - discount ...
no_of_adults = float(input()) no_of_childrens = float(input()) total_passenger_cost = 0 service_tax = 7 / 100 discount = 10 / 100 rate_per_adult = no_of_adults * 37550.0 + service_tax rate_per_children = no_of_childrens * (37550.0 / 3.0) + service_tax total_passenger_cost = rate_per_adult + rate_per_children - discount...
class Status(object): SHUTTING_DOWN = 'Shutting Down' RUNNING = 'Running' class __State(object): def __init__(self): self._shutting_down = False def set_to_shutting_down(self): self._shutting_down = True def is_shutting_down(self): return self._shutting_down @propert...
class Status(object): shutting_down = 'Shutting Down' running = 'Running' class __State(object): def __init__(self): self._shutting_down = False def set_to_shutting_down(self): self._shutting_down = True def is_shutting_down(self): return self._shutting_down @propert...
class DynGraph(): def node_presence(self, nbunch=None): raise NotImplementedError("Not implemented") def add_interaction(self,u_of_edge,v_of_edge,time): raise NotImplementedError("Not implemented") def add_interactions_from(self, nodePairs, times): raise NotImplementedError("Not i...
class Dyngraph: def node_presence(self, nbunch=None): raise not_implemented_error('Not implemented') def add_interaction(self, u_of_edge, v_of_edge, time): raise not_implemented_error('Not implemented') def add_interactions_from(self, nodePairs, times): raise not_implemented_error...
def get_sql(company, conn, gl_code, start_date, end_date, step): # start_date = '2018-02-28' # end_date = '2018-03-01' # step = 1 sql = ( "WITH RECURSIVE dates AS " f"(SELECT CAST('{start_date}' AS {conn.constants.date_cast}) AS op_date, " f"{conn.constants.func_prefix}da...
def get_sql(company, conn, gl_code, start_date, end_date, step): sql = f"""WITH RECURSIVE dates AS (SELECT CAST('{start_date}' AS {conn.constants.date_cast}) AS op_date, {conn.constants.func_prefix}date_add('{start_date}', {step - 1}) AS cl_date UNION ALL SELECT {conn.constants.func_prefix}date_add(cl_date, 1) AS o...
class ListNode: def __init__(self, x): self.val = x self.next = None def __str__(self): curr = self vals = [] while curr: vals.append(curr.val) curr = curr.next return str(vals) @classmethod def from_list(cls, vals): head ...
class Listnode: def __init__(self, x): self.val = x self.next = None def __str__(self): curr = self vals = [] while curr: vals.append(curr.val) curr = curr.next return str(vals) @classmethod def from_list(cls, vals): head...
num1 = int(input()) num2 = int(input()) num3 = int(input()) if num1 == num2 and num2 == num3: print("yes") else: print("no") print("let's see", end="") print("?")
num1 = int(input()) num2 = int(input()) num3 = int(input()) if num1 == num2 and num2 == num3: print('yes') else: print('no') print("let's see", end='') print('?')
# Copyright (c) 2012-2018 SoftBank Robotics. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the COPYING file. def test_simple(qipy_action, record_messages): qipy_action.add_test_project("a_lib") qipy_action.add_test_project("big_project") qipy_acti...
def test_simple(qipy_action, record_messages): qipy_action.add_test_project('a_lib') qipy_action.add_test_project('big_project') qipy_action.add_test_project('foomodules') qipy_action('list') assert record_messages.find('\\*\\s+a') assert record_messages.find('\\*\\s+big_project')
# Copyright Alexander Baranin 2016 Logging = None EngineCore = None def onLoad(core): global EngineCore EngineCore = core global Logging Logging = EngineCore.loaded_modules['engine.Logging'] Logging.logMessage('TestFIFOModule1.onLoad()') EngineCore.schedule_FIFO(run1, 10) EngineCore.sche...
logging = None engine_core = None def on_load(core): global EngineCore engine_core = core global Logging logging = EngineCore.loaded_modules['engine.Logging'] Logging.logMessage('TestFIFOModule1.onLoad()') EngineCore.schedule_FIFO(run1, 10) EngineCore.schedule_FIFO(run2, 30) def on_unload(...
''' Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 668966489504...
""" Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 668966489504...
#!/usr/bin/env python # -*- coding: utf-8; py-indent-offset:4 -*- ############################################################################### # Copyright (C) 2020 Daniel Rodriguez # Use of this source code is governed by the MIT License ###############################################################################...
__all__ = [] def _generate(cls, bases, dct, **kwargs): grps = dct.get('group', ()) or getattr(cls, 'group', ()) if isinstance(grps, str): grps = (grps,) cls.group = grps
#! /usr/bin/python3 # product.py -- This script prints out a product and it's price. # Author -- Prince Oppong Boamah<regioths@gmail.com> # Date -- 10th September, 2015 class Product: def __init__(self, name): self.name = name def __str__(self): return self.name # The program starts runn...
class Product: def __init__(self, name): self.name = name def __str__(self): return self.name p = product('Lenovo') p.price = '2000gh cedis or 400 pounds or 600 dollars to be precise.' print('p is a %s' % p.__class__) print('This is a Laptop called %s and the price is %s' % (p.name, p.price))
# constantly ask the user for new names and phone numbers # to add to the phone book, then save them phone_book = {}
phone_book = {}
key_words = ["Trending", "Fact", "Reason", "Side Effect", "Index", "Stock", "ETF"] knowledge_graph_dict = { "Value Investing": {}, "Risk Management": {}, "Joe Biden": { "Tax Increase Policy": { "Tech Company": { "Trending": "Negative", }, "Corpora...
key_words = ['Trending', 'Fact', 'Reason', 'Side Effect', 'Index', 'Stock', 'ETF'] knowledge_graph_dict = {'Value Investing': {}, 'Risk Management': {}, 'Joe Biden': {'Tax Increase Policy': {'Tech Company': {'Trending': 'Negative'}, 'Corporate Tax': {'Trending': 'Negative'}, 'Capital Gain Tax': {'Trending': 'Negative'}...
# encoding: utf-8 ''' @author: developer @software: python @file: run8.py @time: 2021/7/28 22:35 @desc: ''' str1 = input() str2 = input() output_str1 = str2[0:2] + str1[2:] output_str2 = str1[0:2] + str2[2:] print(output_str1) print(output_str2)
""" @author: developer @software: python @file: run8.py @time: 2021/7/28 22:35 @desc: """ str1 = input() str2 = input() output_str1 = str2[0:2] + str1[2:] output_str2 = str1[0:2] + str2[2:] print(output_str1) print(output_str2)
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def tomlplusplus_repository(): maybe( http_archive, name = "tomlplusplus", urls = [ "https://github.com/marzer/tomlplusplus/archive/v2.5.0.zip", ...
load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def tomlplusplus_repository(): maybe(http_archive, name='tomlplusplus', urls=['https://github.com/marzer/tomlplusplus/archive/v2.5.0.zip'], sha256='887dfb7025d532a3485e1269ce5102d9e62...
#! /usr/bin/env python3 # hjjs.py - write some HJ J-sequences EXTENSION = ".hjjs.txt" MODE = "w" J_MAX = 2 ** 32 - 1 def i22a(f, m): n = 0 js = [] while True: j = 2 ** (2 * n + m) - 2 ** n if j > J_MAX: break js.append(j) n += 1 print(*js, file = f) for m in range(10): with open...
extension = '.hjjs.txt' mode = 'w' j_max = 2 ** 32 - 1 def i22a(f, m): n = 0 js = [] while True: j = 2 ** (2 * n + m) - 2 ** n if j > J_MAX: break js.append(j) n += 1 print(*js, file=f) for m in range(10): with open('i22a' + str(m) + EXTENSION, MODE) as f...
# This should be subclassed within each # class that gets registered with the API class BaseContext: def __init__(self, instance=None, serial=None): pass def serialized(self): return () def instance(self, global_context): return None # This is actually very different from a contex...
class Basecontext: def __init__(self, instance=None, serial=None): pass def serialized(self): return () def instance(self, global_context): return None class Globalcontext: def __init__(self, universes, network): self.universes = universes self.network = netw...
def pageCount(n, p): print(min(p//2,n//2-p//2)) if __name__ == '__main__': n = int(input()) p = int(input()) pageCount(n, p)
def page_count(n, p): print(min(p // 2, n // 2 - p // 2)) if __name__ == '__main__': n = int(input()) p = int(input()) page_count(n, p)
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def pseudoPalindromicPaths (self, root: TreeNode) -> int: self.a = [0] * 10 self.count = 0 ...
class Solution: def pseudo_palindromic_paths(self, root: TreeNode) -> int: self.a = [0] * 10 self.count = 0 self.dfs(root, []) return self.count def dfs(self, root, path): if root is None: return self.a[root.val] += 1 if root.left is None and...
class FLAGS: data_url = "" data_dir = None background_volume = 0.1 background_frequency = 0 silence_percentage = 10.0 unknown_percentage = 10.0 time_shift_ms = 0 use_custom_augs = False testing_percentage = 10 validation_percentage = 10 sample_rate = 16000 clip_duration_ms = 1000 window_size_ms = 30 wi...
class Flags: data_url = '' data_dir = None background_volume = 0.1 background_frequency = 0 silence_percentage = 10.0 unknown_percentage = 10.0 time_shift_ms = 0 use_custom_augs = False testing_percentage = 10 validation_percentage = 10 sample_rate = 16000 clip_duration_m...
class Solution: def shuffle(self, nums: List[int], n: int) -> List[int]: returnList = [0] * len(nums) temp = 0 for i in range(0,n): returnList[temp] = nums[i] returnList[temp+1] = nums[n] n+=1 temp+=2 return returnList ...
class Solution: def shuffle(self, nums: List[int], n: int) -> List[int]: return_list = [0] * len(nums) temp = 0 for i in range(0, n): returnList[temp] = nums[i] returnList[temp + 1] = nums[n] n += 1 temp += 2 return returnList
def get_player_score(): score = [] for i in range(0, 5): while True: try: s = float(input('Enter golf scores between 78 and 100: ')) if 78 <= s <= 100: score.append(s) break raise ValueError e...
def get_player_score(): score = [] for i in range(0, 5): while True: try: s = float(input('Enter golf scores between 78 and 100: ')) if 78 <= s <= 100: score.append(s) break raise ValueError e...
# Unneeded charting code that was removed from a jupyter notebook. Stored here as an example for later # Draws a chart with the total area of multiple protin receptors at each time step tmpdf = totals65.loc[(totals65['Receptor'].isin(['M1', 'M5', 'M7', 'M22', 'M26'])) & (totals65['Experiment Step...
tmpdf = totals65.loc[totals65['Receptor'].isin(['M1', 'M5', 'M7', 'M22', 'M26']) & (totals65['Experiment Step'] == '-nl-post')] pal = ['black', 'blue', 'red', 'orange', 'green'] g = sns.FacetGrid(tmpdf, col='Time Point', col_wrap=3, size=5, ylim=(0, 100), xlim=(0, 100), palette=pal, hue='Receptor', hue_order=['M1', 'M5...
with open("pattern.txt") as file: inputs = file.readlines() BUFFER = 10 ITERATIONS = 50_000_000_000 state = '.' * BUFFER + "..##.#######...##.###...#..#.#.#..#.##.#.##....####..........#..#.######..####.#.#..###.##..##..#..#" + '.' * 102 gives_empty = {line[:5] for line in inputs if line[-2] == '.'} pattern_ite...
with open('pattern.txt') as file: inputs = file.readlines() buffer = 10 iterations = 50000000000 state = '.' * BUFFER + '..##.#######...##.###...#..#.#.#..#.##.#.##....####..........#..#.######..####.#.#..###.##..##..#..#' + '.' * 102 gives_empty = {line[:5] for line in inputs if line[-2] == '.'} pattern_iterations...
all_sales = dict() try: with open(".\\.\\sales.csv") as file: for line in file: string_args = line.split() string_date = string_args[0] string_price = string_args[1].split(",") price = all_sales[string_date] all_sales[string_date] = price + string...
all_sales = dict() try: with open('.\\.\\sales.csv') as file: for line in file: string_args = line.split() string_date = string_args[0] string_price = string_args[1].split(',') price = all_sales[string_date] all_sales[string_date] = price + string_...
# Copyright (c) 2017, 2018 Jae-jun Kang # See the file LICENSE for details. class Config(object): heartbeat_interval = 5 # in seconds class Coroutine(object): default_timeout = 60 # in seconds
class Config(object): heartbeat_interval = 5 class Coroutine(object): default_timeout = 60
__all__ = ( "__title__", "__summary__", "__uri__", "__download_url__", "__version__", "__author__", "__email__", "__license__",) __title__ = "gpxconverter" __summary__ = ("gpx to csv converter. it supports waypoint elements except " "extensions. Values in extensions will be ignored.") __ur...
__all__ = ('__title__', '__summary__', '__uri__', '__download_url__', '__version__', '__author__', '__email__', '__license__') __title__ = 'gpxconverter' __summary__ = 'gpx to csv converter. it supports waypoint elements except extensions. Values in extensions will be ignored.' __uri__ = 'https://github.com/linusyoung/...
def count(s, t, loc, lst): return sum([(loc + dist) >= s and (loc + dist) <= t for dist in lst]) def countApplesAndOranges(s, t, a, b, apples, oranges): print(count(s, t, a, apples)) print(count(s, t, b, oranges))
def count(s, t, loc, lst): return sum([loc + dist >= s and loc + dist <= t for dist in lst]) def count_apples_and_oranges(s, t, a, b, apples, oranges): print(count(s, t, a, apples)) print(count(s, t, b, oranges))
# Ticket numbers usually consist of an even number of digits. # A ticket number is considered lucky if the sum of the first # half of the digits is equal to the sum of the second half. # # Given a ticket number n, determine if it's lucky or not. # # Example # # For n = 1230, the output should be # isLucky(n) = true; # ...
n = 239017 (firstpart, secondpart) = (str(n)[:len(str(n)) // 2], str(n)[len(str(n)) // 2:]) n1 = sum(map(int, firstpart)) n2 = sum(map(int, secondpart)) print(n1, n2)
f = open('input.txt') data = [int(num) for num in f.read().split("\n")[:-1]] for i, num1 in enumerate(data): for num2 in data[i+1:]: if num1 + num2 == 2020: print(num1 * num2)
f = open('input.txt') data = [int(num) for num in f.read().split('\n')[:-1]] for (i, num1) in enumerate(data): for num2 in data[i + 1:]: if num1 + num2 == 2020: print(num1 * num2)
print("Welcome to Alexander's Tic-Tac-Toe Game", "\n") board = [" "for i in range(9)] def cls(): print('\n'*20) def printBoard(): row1 = "|{}|{}|{}|".format(board[0], board[1], board[2]) row2 = "|{}|{}|{}|".format(board[3], board[4], board[5]) row3 = "|{}|{}|{}|".format(board[6], board[7], board[8]...
print("Welcome to Alexander's Tic-Tac-Toe Game", '\n') board = [' ' for i in range(9)] def cls(): print('\n' * 20) def print_board(): row1 = '|{}|{}|{}|'.format(board[0], board[1], board[2]) row2 = '|{}|{}|{}|'.format(board[3], board[4], board[5]) row3 = '|{}|{}|{}|'.format(board[6], board[7], board[8...
# We want to make a row of bricks that is goal inches long. We have a number # of small bricks (1 inch each) and big bricks (5 inches each). Return True # if it is possible to make the goal by choosing from the given bricks. # This is a little harder than it looks and can be done without any loops. # make_bricks(3, 1...
def make_bricks(small, big, goal): num_fives = goal // 5 num_ones = goal - 5 * num_fives if num_fives <= big and num_ones <= small: return True elif num_fives >= big and goal - 5 * big <= small: return True else: return False print(make_bricks(3, 1, 8)) print(make_bricks(3, 1...
burgers=[] quan=[] def PrintHead(): print(" ABC Burgers") print(" Pakistan Road,Karachi") print("=====================================") # Data Entry: rates = {"cheese": 110, "zinger": 160, "abc special": 250, "chicken": 120} # Front-End: def TakeInputs(): b = input("Burger Type:")....
burgers = [] quan = [] def print_head(): print(' ABC Burgers') print(' Pakistan Road,Karachi') print('=====================================') rates = {'cheese': 110, 'zinger': 160, 'abc special': 250, 'chicken': 120} def take_inputs(): b = input('Burger Type:').lower() if b not ...
cql = { "and": [ {"lte": [{"property": "eo:cloud_cover"}, "10"]}, {"gte": [{"property": "datetime"}, "2021-04-08T04:39:23Z"]}, { "or": [ {"eq": [{"property": "collection"}, "landsat"]}, {"lte": [{"property": "gsd"}, "10"]}, ] },...
cql = {'and': [{'lte': [{'property': 'eo:cloud_cover'}, '10']}, {'gte': [{'property': 'datetime'}, '2021-04-08T04:39:23Z']}, {'or': [{'eq': [{'property': 'collection'}, 'landsat']}, {'lte': [{'property': 'gsd'}, '10']}]}, {'lte': [{'property': 'id'}, 'l8_12345']}]} cql_multi = {'and': [{'lte': [{'property': 'eo:cloud_c...
class AnnotaVO: def __init__(self): self._entry = None self._label = None self._points = None self._kind = None @property def points(self): return self._points @points.setter def points(self, value): self._points = value @property def entry(...
class Annotavo: def __init__(self): self._entry = None self._label = None self._points = None self._kind = None @property def points(self): return self._points @points.setter def points(self, value): self._points = value @property def entry...
# Accounts USER_DOES_NOT_EXIST = 1000 INCORRECT_PASSWORD = 1001 USER_INACTIVE = 1002 INVALID_SIGN_UP_CODE = 1030 SOCIAL_DOES_NOT_EXIST = 1100 INCORRECT_TOKEN = 1101 TOKEN_ALREADY_IN_USE = 1102 SAME_PASSWORD = 1200 # Common FORM_ERROR = 9000
user_does_not_exist = 1000 incorrect_password = 1001 user_inactive = 1002 invalid_sign_up_code = 1030 social_does_not_exist = 1100 incorrect_token = 1101 token_already_in_use = 1102 same_password = 1200 form_error = 9000
names = ["kara", "jackie", "Theophilus"] for name in names: print(names) print("\n") for index in range(len(names)): print(names[index])
names = ['kara', 'jackie', 'Theophilus'] for name in names: print(names) print('\n') for index in range(len(names)): print(names[index])
''' Python name attribute Every module in Python has a special variable called name. The value of the nsme attribute is set '''
""" Python name attribute Every module in Python has a special variable called name. The value of the nsme attribute is set """
people = [ ('Alice', 32), # one tuple ('Bob', 51), # another tuple ('Carol', 15), ('Dylan', 5), ('Erin', 25), ('Frank', 48) ] i= 0 yuanzu = (' ', 999) while i < len(people): if people[i][1] <= yuanzu[1]: yuanzu = people[i] i += 1 print('Youngest person: {}, {} years old. '.format(yuanzu[0], yuanzu[1])) ...
people = [('Alice', 32), ('Bob', 51), ('Carol', 15), ('Dylan', 5), ('Erin', 25), ('Frank', 48)] i = 0 yuanzu = (' ', 999) while i < len(people): if people[i][1] <= yuanzu[1]: yuanzu = people[i] i += 1 print('Youngest person: {}, {} years old. '.format(yuanzu[0], yuanzu[1])) print(people(people[i][1] == ...
#!/usr/bin/env python ''' Description: these are the default parameters to use for processing secrets data Author: Rachel Kalmar ''' # ------------------------------------ # # Set defaults for parameters to be used in secretReaderPollyVoices datapath_base = '/Users/kalmar/Documents/code/secrets/secrets_data/' # Whe...
""" Description: these are the default parameters to use for processing secrets data Author: Rachel Kalmar """ datapath_base = '/Users/kalmar/Documents/code/secrets/secrets_data/' mp3path_base = '/Users/kalmar/Documents/code/secrets/audio/' shuffle_secrets = False speak = True ssml = True whisper_freq = 0.15 mp3_paddi...
a = "0,0,0,0,0,0" b = "0,-1,-2,0" c = "-1,-3,-4,-1,-2" d = "qwerty" e = ",,3,,4" f = "1,2,v,b,3" g = "0,7,0,2,-12,3,0,2" h = "1,3,-2,1,2" def sum_earnings(str_earn): next_value = 0 total = 0 neg_sum = 0 if any(char.isalpha() for char in str_earn): return 0 for s in str_earn.split(','...
a = '0,0,0,0,0,0' b = '0,-1,-2,0' c = '-1,-3,-4,-1,-2' d = 'qwerty' e = ',,3,,4' f = '1,2,v,b,3' g = '0,7,0,2,-12,3,0,2' h = '1,3,-2,1,2' def sum_earnings(str_earn): next_value = 0 total = 0 neg_sum = 0 if any((char.isalpha() for char in str_earn)): return 0 for s in str_earn.split(','): ...
def main(): n, k = map(int, input().split()) l = [] for i in range(n): a, b = map(int, input().split()) l.append((a, b)) l.sort() prev = 0 for i in range(n): prev += l[i][1] if k <= prev: print(l[i][0]) break if __name__ == '__mai...
def main(): (n, k) = map(int, input().split()) l = [] for i in range(n): (a, b) = map(int, input().split()) l.append((a, b)) l.sort() prev = 0 for i in range(n): prev += l[i][1] if k <= prev: print(l[i][0]) break if __name__ == '__main__': ...
class Solution: def minimumLength(self, s: str) -> int: if len(s)==1: return 1 i=0 j=len(s)-1 while i<j: if s[i]!=s[j]: break temp = s[i] while i<=j and s[i]==temp: i+=1 while j>=i and s[j]==t...
class Solution: def minimum_length(self, s: str) -> int: if len(s) == 1: return 1 i = 0 j = len(s) - 1 while i < j: if s[i] != s[j]: break temp = s[i] while i <= j and s[i] == temp: i += 1 wh...
# set declaration myfruits = {"Apple", "Banana", "Grapes", "Litchi", "Mango"} mynums = {1, 2, 3, 4, 5} # Set printing before removing print("Before remove() method...") print("fruits: ", myfruits) print("numbers: ", mynums) # Removing the elements from the sets elerem = myfruits.remove('Apple') elerem = myfruits.remo...
myfruits = {'Apple', 'Banana', 'Grapes', 'Litchi', 'Mango'} mynums = {1, 2, 3, 4, 5} print('Before remove() method...') print('fruits: ', myfruits) print('numbers: ', mynums) elerem = myfruits.remove('Apple') elerem = myfruits.remove('Litchi') elerem = myfruits.remove('Mango') elerem = mynums.remove(1) elerem = mynums....
# CPU: 0.05 s amounts = list(map(int, input().split())) ratios = list(map(int, input().split())) n = min(amounts[x] / ratios[x] for x in range(3)) for amount, ratio in zip(amounts, ratios): print(amount - ratio * n, end=" ")
amounts = list(map(int, input().split())) ratios = list(map(int, input().split())) n = min((amounts[x] / ratios[x] for x in range(3))) for (amount, ratio) in zip(amounts, ratios): print(amount - ratio * n, end=' ')
COUNTRIES = [ "US", "IL", "IN", "UA", "CA", "AR", "SG", "TW", "GB", "AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LK", "LV", "LT", "LU", "MT", "NL", "P...
countries = ['US', 'IL', 'IN', 'UA', 'CA', 'AR', 'SG', 'TW', 'GB', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LK', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'NZ', 'AU', 'BF', 'BO', 'BR', 'BZ', 'CI', 'CL', 'CO', 'DO', 'EC', 'GE', 'GH', 'GY', '...
x = 1 y = 10 # Checks if one value is equal to another if x == 1: print("x is equal to 1") # Checks if one value is NOT equal to another if y != 1: print("y is not equal to 1") # Checks if one value is less than another if x < y: print("x is less than y") # Checks if one value is greater ...
x = 1 y = 10 if x == 1: print('x is equal to 1') if y != 1: print('y is not equal to 1') if x < y: print('x is less than y') if y > x: print('y is greater than x') if x >= 1: print('x is greater than or equal to 1') if x == 1 and y == 10: print('Both values returned true') if x < 45 or y < 5: ...
# general configuration LOCAL_OTP_PORT = 8088 # port for OTP to use, HTTPS will be served on +1 TEMP_DIRECTORY = "mara-ptm-temp" PROGRESS_WATCHER_INTERVAL = 5 * 60 * 1000 # milliseconds JVM_PARAMETERS = "-Xmx8G" # 6-8GB of RAM is good for bigger graphs # itinerary filter parameters CAR_KMH = 50 CAR_TRAVEL_FACTOR = ...
local_otp_port = 8088 temp_directory = 'mara-ptm-temp' progress_watcher_interval = 5 * 60 * 1000 jvm_parameters = '-Xmx8G' car_kmh = 50 car_travel_factor = 1.4 allowed_transit_modes = ['WALK', 'BUS', 'TRAM', 'SUBWAY', 'RAIL'] max_walk_distance = 1000 otp_parameters_template = '&'.join(['fromPlace=1:{origin}', 'toPlace=...
class Solution: # @param s, a string # @param dict, a set of string # @return a boolean def wordBreak(self, s, dict): if not dict: return False n = len(s) res = [False] * n for i in xrange(0, n): if s[:i+1] in dict: res[i] = True ...
class Solution: def word_break(self, s, dict): if not dict: return False n = len(s) res = [False] * n for i in xrange(0, n): if s[:i + 1] in dict: res[i] = True if not True in res: return False i = 0 while i...
diccionario= {91: 95} a=91 if a==91: a=diccionario.get(91) print(a)
diccionario = {91: 95} a = 91 if a == 91: a = diccionario.get(91) print(a)
arquivo = open('linguagens.txt', 'r') num = int(input("Numero de linguagens: ")) count=0 for linha in arquivo: if count<num: print(linha.rstrip('\n')) count += 1 else: break arquivo.close()
arquivo = open('linguagens.txt', 'r') num = int(input('Numero de linguagens: ')) count = 0 for linha in arquivo: if count < num: print(linha.rstrip('\n')) count += 1 else: break arquivo.close()
#!/usr/bin/env python3 # coding:utf-8 class Solution: def StrToInt(self, s): if s == '': return 0 string = s.strip() num = 0 start = 0 symbol = 1 if string[0] == '+': start += 1 elif string[0] == '-': start += 1 ...
class Solution: def str_to_int(self, s): if s == '': return 0 string = s.strip() num = 0 start = 0 symbol = 1 if string[0] == '+': start += 1 elif string[0] == '-': start += 1 symbol = -1 for i in range(...
fit2_lm = sm.ols(formula="y ~ age + np.power(age, 2) + np.power(age, 3)",data=diab).fit() poly_predictions = fit2_lm.get_prediction(predict_df).summary_frame() poly_predictions.head()
fit2_lm = sm.ols(formula='y ~ age + np.power(age, 2) + np.power(age, 3)', data=diab).fit() poly_predictions = fit2_lm.get_prediction(predict_df).summary_frame() poly_predictions.head()
scores = [("Rodney Dangerfield", -1), ("Marlon Brando", 1), ("You", 100)] # list of tuples for person in scores: name = person[0] score = person[1] print("Hello {}. Your score is {}.".format(name, score)) origPrice = float(input('Enter the original price: $')) discount = float(input('Enter discount perce...
scores = [('Rodney Dangerfield', -1), ('Marlon Brando', 1), ('You', 100)] for person in scores: name = person[0] score = person[1] print('Hello {}. Your score is {}.'.format(name, score)) orig_price = float(input('Enter the original price: $')) discount = float(input('Enter discount percentage: ')) new_pric...
def find_loop(root): S = root F = root # set up first meeting while True: # if there is no loop, we will detect it if S is None or F is None: return None # advance slow and fast pointers S = S.next_node F = F.next_node.next_node if S is F: ...
def find_loop(root): s = root f = root while True: if S is None or F is None: return None s = S.next_node f = F.next_node.next_node if S is F: break s = root while True: s = S.next_node f = F.next_node if S is F: ...
''' Assume that two variables, varA and varB, are assigned values, either numbers or strings. Write a piece of Python code that evaluates varA and varB, and then prints out one of the following messages: "string involved" if either varA or varB are strings "bigger" if varA is larger than varB "equal" if varA is equ...
""" Assume that two variables, varA and varB, are assigned values, either numbers or strings. Write a piece of Python code that evaluates varA and varB, and then prints out one of the following messages: "string involved" if either varA or varB are strings "bigger" if varA is larger than varB "equal" if varA is equ...
def __create_snap_entry(marker, entry_no, l): # use parse_roll() to create search entry node = [] x = [] for i in range(len(l)-1): if len(l) == 2 and abs(l[i] - l[i+1]) == 2: # if only two balls on the row x += [[l[i], 1]] elif abs(l[i] - l[i+1]) > 1: ...
def __create_snap_entry(marker, entry_no, l): node = [] x = [] for i in range(len(l) - 1): if len(l) == 2 and abs(l[i] - l[i + 1]) == 2: x += [[l[i], 1]] elif abs(l[i] - l[i + 1]) > 1: x += [[l[i], 1]] x += [[l[i + 1], -1]] for item in x: node....
ls = list() for _ in range(5): ls.append(input()) res = list() for i in range(len(ls)): if 'FBI' in ls[i]: res.append(str(i + 1)) if len(res) == 0: print('HE GOT AWAY!') else: print(' '.join(res))
ls = list() for _ in range(5): ls.append(input()) res = list() for i in range(len(ls)): if 'FBI' in ls[i]: res.append(str(i + 1)) if len(res) == 0: print('HE GOT AWAY!') else: print(' '.join(res))
matriz = [[], [], []] for c in range(0, 3): linha0 = matriz[0].append(int(input(f'Digite um valor para [0, {c}]: '))) for c in range(0, 3): linha1 = matriz[1].append(int(input(f'Digite um valor para [1, {c}]: '))) for c in range(0, 3): linha2 = matriz[2]. append(int(input(f'Digite um valor para [2, {c}]: ')...
matriz = [[], [], []] for c in range(0, 3): linha0 = matriz[0].append(int(input(f'Digite um valor para [0, {c}]: '))) for c in range(0, 3): linha1 = matriz[1].append(int(input(f'Digite um valor para [1, {c}]: '))) for c in range(0, 3): linha2 = matriz[2].append(int(input(f'Digite um valor para [2, {c}]: '))...
class NCSBase: def train(self, X, y): pass def scores(self, X, y, cp): pass def score(self, x, labels): pass class NCSBaseRegressor: def train(self, X, y): pass def coeffs(self, X, y, cp): pass def coeffs_n(self, x): pass
class Ncsbase: def train(self, X, y): pass def scores(self, X, y, cp): pass def score(self, x, labels): pass class Ncsbaseregressor: def train(self, X, y): pass def coeffs(self, X, y, cp): pass def coeffs_n(self, x): pass