content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class SkilletLoaderException(BaseException): pass class LoginException(BaseException): pass class PanoplyException(BaseException): pass class NodeNotFoundException(BaseException): pass
class Skilletloaderexception(BaseException): pass class Loginexception(BaseException): pass class Panoplyexception(BaseException): pass class Nodenotfoundexception(BaseException): pass
MASTER = "127.0.0.1:7070" ROUTER = "127.0.0.1:8080" #MASTER = "11.3.146.195:443" #ROUTER = "11.3.146.195"
master = '127.0.0.1:7070' router = '127.0.0.1:8080'
def to_rna(dna_strand): rna = [] for nuc in dna_strand: if nuc == 'G': rna.append('C') elif nuc == 'C': rna.append('G') elif nuc == 'T': rna.append('A') elif nuc == 'A': rna.append('U') return "".join(rna)
def to_rna(dna_strand): rna = [] for nuc in dna_strand: if nuc == 'G': rna.append('C') elif nuc == 'C': rna.append('G') elif nuc == 'T': rna.append('A') elif nuc == 'A': rna.append('U') return ''.join(rna)
def in_test(a, b=None): if b in a or b is None: print('yaeeee') else: print('oops') a = [1, 2, 3] in_test(a, 1) in_test(a, 4) in_test(a, None)
def in_test(a, b=None): if b in a or b is None: print('yaeeee') else: print('oops') a = [1, 2, 3] in_test(a, 1) in_test(a, 4) in_test(a, None)
# # @lc app=leetcode.cn id=120 lang=python3 # # [120] triangle # None # @lc code=end
None
class Options: def __init__(self, args: list): assert isinstance(args, list) self.args = args def get(self, key: str, has_value: bool = True): assert isinstance(key, str) assert isinstance(has_value, bool) if has_value: if (key in self.args[:-1]) and (path_index := self.args[:-1].index(key)) and (val...
class Options: def __init__(self, args: list): assert isinstance(args, list) self.args = args def get(self, key: str, has_value: bool=True): assert isinstance(key, str) assert isinstance(has_value, bool) if has_value: if key in self.args[:-1] and (path_index...
# Created by MechAviv # Kinesis Introduction # Map ID :: 331002300 # School for the Gifted :: 1-1 Classroom sm.warpInstanceOut(331002000, 2)
sm.warpInstanceOut(331002000, 2)
# 2020.09.04 # Problem Statement: # https://leetcode.com/problems/add-binary/ class Solution: def addBinary(self, a: str, b: str) -> str: # make a to be the longer string if len(a) < len(b): a, b = b, a # do early return if a == "0": return b if...
class Solution: def add_binary(self, a: str, b: str) -> str: if len(a) < len(b): (a, b) = (b, a) if a == '0': return b if b == '0': return a answer = '' carrier = 0 for i in range(0, len(b)): answer = str((int(a[len(a) ...
def capitalize(string): ans = "" i = 0; while i < len(string): ans += string[i].upper() i += 1 while i < len(string) and ord(string[i]) > 64: ans += string[i] i += 1 while i<len(string) and (ord(string[i]) == 32 or ord(string[i]) == 9): ans += string[i] i += 1 return ans string = input() capital...
def capitalize(string): ans = '' i = 0 while i < len(string): ans += string[i].upper() i += 1 while i < len(string) and ord(string[i]) > 64: ans += string[i] i += 1 while i < len(string) and (ord(string[i]) == 32 or ord(string[i]) == 9): an...
names_scores = (('Amy',82,90),('John',33,64),('Zoe',91,94)) for x,y,z in names_scores: print(x) print(y,z) print('End')
names_scores = (('Amy', 82, 90), ('John', 33, 64), ('Zoe', 91, 94)) for (x, y, z) in names_scores: print(x) print(y, z) print('End')
# # PySNMP MIB module HP-SN-TRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-SN-MIBS # Produced by pysmi-0.3.4 at Wed May 1 13:36:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019,...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, value_range_constraint, constraints_intersection, constraints_union) ...
# secret key SECRET_KEY = 'djangosSecretKey' # development directory DEV_DIR = '/path/to/directory/' # private data PRIVATE_DATA_STREET = 'Examplestreet 1' PRIVATE_DATA_PHONE = '0123456789'
secret_key = 'djangosSecretKey' dev_dir = '/path/to/directory/' private_data_street = 'Examplestreet 1' private_data_phone = '0123456789'
# # PySNMP MIB module CISCO-SESS-BORDER-CTRLR-CALL-STATS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SESS-BORDER-CTRLR-CALL-STATS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:55:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ...
SECRET_KEY = 'test' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.sqlite', } } INSTALLED_APPS = [ 'nobot', ] NOBOT_RECAPTCHA_PRIVATE_KEY = 'privkey' NOBOT_RECAPTCHA_PUBLIC_KEY = 'pubkey'
secret_key = 'test' databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.sqlite'}} installed_apps = ['nobot'] nobot_recaptcha_private_key = 'privkey' nobot_recaptcha_public_key = 'pubkey'
# Problem0020 - Factorial digit sum # # https: // github.com/agileshaw/Project-Euler def digitSum(num): result = 0 while num: result, num = result + num % 10, num // 10 return result if __name__ == "__main__": factorial = 1 for i in range (1, 101): factorial *= i result = digit...
def digit_sum(num): result = 0 while num: (result, num) = (result + num % 10, num // 10) return result if __name__ == '__main__': factorial = 1 for i in range(1, 101): factorial *= i result = digit_sum(factorial) print('The factorial digit sum is: %d' % result)
class UserNotInGroupException(Exception): def __init__(self, message): self.message = f"user is not in group: {message}" class InvalidRangeException(Exception): def __init__(self, message): self.message = message class NoSuchGroupException(Exception): def __init__(self, message): ...
class Usernotingroupexception(Exception): def __init__(self, message): self.message = f'user is not in group: {message}' class Invalidrangeexception(Exception): def __init__(self, message): self.message = message class Nosuchgroupexception(Exception): def __init__(self, message): ...
WHATSAPP_CRYPT = ''' Utility for WhatsApp crypt databases decryption. Encrypted databases are usually located here: /sdcard/WhatsApp/Databases/ The `key` file must be obtained from the following location: /data/data/com.whatsapp/files/key (Must have root permissions to read this file) Supported crypt files with the ...
whatsapp_crypt = '\nUtility for WhatsApp crypt databases decryption.\n\nEncrypted databases are usually located here:\n/sdcard/WhatsApp/Databases/\n\nThe `key` file must be obtained from the following location:\n/data/data/com.whatsapp/files/key\n(Must have root permissions to read this file)\n\nSupported crypt files w...
def N(xi, i, enum): if enum == 1: if i == 1: return (2*xi-1)**2 if i == 2: return -2*xi*(3*xi-2) if i == 3: return 2*xi*xi if enum == 2: if i == 1: return (2*xi-2)*(xi-1) if i == 2: return -6*xi**2 +...
def n(xi, i, enum): if enum == 1: if i == 1: return (2 * xi - 1) ** 2 if i == 2: return -2 * xi * (3 * xi - 2) if i == 3: return 2 * xi * xi if enum == 2: if i == 1: return (2 * xi - 2) * (xi - 1) if i == 2: retu...
#!/usr/bin/python # coding=utf-8 # Copyright 2019 yaitza. All Rights Reserved. # # https://yaitza.github.io/ # # My Code hope to usefull for you. # =================================================================== __author__ = "yaitza" __date__ = "2019-03-29 16:29"
__author__ = 'yaitza' __date__ = '2019-03-29 16:29'
class Wiggle: def fixedStepParser(self, line): value = line.strip() start_position = self.stepIdx * self.parserConfig['step'] + self.parserConfig['start'] stop_position = start_position + self.parserConfig['span'] - 1 self.stepIdx += 1 for position in range(start_position, ...
class Wiggle: def fixed_step_parser(self, line): value = line.strip() start_position = self.stepIdx * self.parserConfig['step'] + self.parserConfig['start'] stop_position = start_position + self.parserConfig['span'] - 1 self.stepIdx += 1 for position in range(start_position,...
class Assignment: def __init__(self, member_id, date_time, _role): self.assignee_id = member_id self.target_role = _role self.assignment_date = date_time # def __eq__(self, other): # same_member_id = self.assignee_id == other.assignee_id # same_role = self.role == other...
class Assignment: def __init__(self, member_id, date_time, _role): self.assignee_id = member_id self.target_role = _role self.assignment_date = date_time
archivo = open("./004 EscribirLeerArchivoTexto/nombres.txt","r") nombres = [] for linea in archivo: linea = linea.replace("\n","") nombres.append(linea) archivo.close() print(nombres)
archivo = open('./004 EscribirLeerArchivoTexto/nombres.txt', 'r') nombres = [] for linea in archivo: linea = linea.replace('\n', '') nombres.append(linea) archivo.close() print(nombres)
style = {'base_mpl_style': 'ggplot', 'marketcolors' : {'candle': {'up': '#000000', 'down': '#ff0000'}, 'edge' : {'up': '#000000', 'down': '#ff0000'}, 'wick' : {'up': '#606060', 'down': '#606060'}, 'ohlc' : {'up': '#000000',...
style = {'base_mpl_style': 'ggplot', 'marketcolors': {'candle': {'up': '#000000', 'down': '#ff0000'}, 'edge': {'up': '#000000', 'down': '#ff0000'}, 'wick': {'up': '#606060', 'down': '#606060'}, 'ohlc': {'up': '#000000', 'down': '#ff0000'}, 'volume': {'up': '#6f6f6f', 'down': '#ff4040'}, 'vcedge': {'up': '#1f77b4', 'dow...
class Graph: def __init__(self, vertices): self.V = vertices self.graph = [[0 for i in range(self.V)] for j in range(self.V)] self.edges = [] def add_edge(self, src: int, dest: int, weight: int): self.graph[src][dest] = weight self.graph[dest][src] = weight self.edges.append([src,dest,...
class Graph: def __init__(self, vertices): self.V = vertices self.graph = [[0 for i in range(self.V)] for j in range(self.V)] self.edges = [] def add_edge(self, src: int, dest: int, weight: int): self.graph[src][dest] = weight self.graph[dest][src] = weight self...
''' Given a list of coins, find the minimum number of coins to get to a certain value For Example: coins={1,2,3} V=5 Output: 2 (3+2=5) Note: the list must always contain a coin of value 1, so in the worst case the output will be V*'coin 1' ''' def minCoin(coins, amount): return minCoin_(coins, amoun...
""" Given a list of coins, find the minimum number of coins to get to a certain value For Example: coins={1,2,3} V=5 Output: 2 (3+2=5) Note: the list must always contain a coin of value 1, so in the worst case the output will be V*'coin 1' """ def min_coin(coins, amount): return min_coin_(coins, am...
#APRENDIENDO INSTRUCCIONES EN PYTHON print("funciones basicas de python") print("-"*28) print("input:Ingresar Datos") print("print:Imprimir Datos") print("MIN: Menor Valor") print("ROUND:Redondear")
print('funciones basicas de python') print('-' * 28) print('input:Ingresar Datos') print('print:Imprimir Datos') print('MIN: Menor Valor') print('ROUND:Redondear')
{ 'targets': [{ 'target_name': 'bindings', 'sources': [ 'src/serialport.cpp' ], 'include_dirs': [ '<!(node -e "require(\'nan\')")' ], 'variables': { # Lerna seems to strips environment variables. Workaround: create `packages/bindings/GENERATE_COVERAGE_FILE` 'generate_co...
{'targets': [{'target_name': 'bindings', 'sources': ['src/serialport.cpp'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'variables': {'generate_coverage': '<!(test -e GENERATE_COVERAGE_FILE && echo "yes" || echo $GENERATE_COVERAGE)'}, 'conditions': [['OS=="win"', {'defines': ['CHECK_NODE_MODULE_VERSION'], 'sour...
# coding: utf-8 # Try POH # author: Leonarodne @ NEETSDKASU ############################################## def gs(*_): return input().strip() def gi(*_): return int(gs()) def gss(*_): return gs().split() def gis(*_): return list(map(int, gss())) def nmapf(n,f): return list(map(f, range(n))) def ngs(n): return nmapf...
def gs(*_): return input().strip() def gi(*_): return int(gs()) def gss(*_): return gs().split() def gis(*_): return list(map(int, gss())) def nmapf(n, f): return list(map(f, range(n))) def ngs(n): return nmapf(n, gs) def ngi(n): return nmapf(n, gi) def ngss(n): return nmapf(n, gs...
class Checker: def __init__(self, hin): super().__init__() self.hin = hin self.chain = [] def conv(self, kernel, stride=1, pad=0, dilation=1): self.chain.append([0, kernel, stride, pad, dilation, 0]) def convT(self, kernel, stride=1, pad=0, dilation=1, outpad=0): ...
class Checker: def __init__(self, hin): super().__init__() self.hin = hin self.chain = [] def conv(self, kernel, stride=1, pad=0, dilation=1): self.chain.append([0, kernel, stride, pad, dilation, 0]) def conv_t(self, kernel, stride=1, pad=0, dilation=1, outpad=0): ...
__all__ = [ 'responseclassify', 'responsemorph', 'text_input', 'text_input_classify', 'text_input_tamil', 'url_input', 'url_input_classify', 'api_imagecaption_request', 'api_imagecaption_response', 'api_ner_request', 'api_ner_request_1', 'api_ner_response', ...
__all__ = ['responseclassify', 'responsemorph', 'text_input', 'text_input_classify', 'text_input_tamil', 'url_input', 'url_input_classify', 'api_imagecaption_request', 'api_imagecaption_response', 'api_ner_request', 'api_ner_request_1', 'api_ner_response', 'api_qa_request', 'api_qa_request_1', 'api_qa_response', 'api_q...
class simpAngMo: def __init__(self, m, r, v): self.m = m self.r = r self.v = v def getAngVel(self): return str(self.v/self.r) + ' rad s^(-1)' def getCentAcc(self): return str(self.v**2/self.r) + ' m s^(-2)' def getCentAngAcc(self): return str(self.magnitud...
class Simpangmo: def __init__(self, m, r, v): self.m = m self.r = r self.v = v def get_ang_vel(self): return str(self.v / self.r) + ' rad s^(-1)' def get_cent_acc(self): return str(self.v ** 2 / self.r) + ' m s^(-2)' def get_cent_ang_acc(self): return ...
print( "Chocolate Chip Cookies" ) print( "1 cup butter, softened" ) print( "1 cup white sugar" ) print( "1 cup packed brown sugar" ) print( "2 eggs" ) print( "2 teaspoons vanilla extract" ) print( "3 cups all-purpose flour" ) print( "1 teaspoon baking soda" ) print( "2 teaspoons hot water" ) print( "0.5 teaspoons salt"...
print('Chocolate Chip Cookies') print('1 cup butter, softened') print('1 cup white sugar') print('1 cup packed brown sugar') print('2 eggs') print('2 teaspoons vanilla extract') print('3 cups all-purpose flour') print('1 teaspoon baking soda') print('2 teaspoons hot water') print('0.5 teaspoons salt') print('2 cups sem...
def part1(moves): h_pos = 0 depth = 0 for direction, unit in moves: if direction == 'forward': h_pos += int(unit) elif direction == 'up': depth -= int(unit) elif direction == 'down': depth += int(unit) return h_pos * depth def part2(moves):...
def part1(moves): h_pos = 0 depth = 0 for (direction, unit) in moves: if direction == 'forward': h_pos += int(unit) elif direction == 'up': depth -= int(unit) elif direction == 'down': depth += int(unit) return h_pos * depth def part2(moves): ...
''' You can find this exercise at the following website: https://www.practicepython.org/ 15. Reverse Word Order: Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type ...
""" You can find this exercise at the following website: https://www.practicepython.org/ 15. Reverse Word Order: Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type ...
# PySNMP SMI module. Autogenerated from smidump -f python RUCKUS-SCG-SYSTEM-MIB # by libsmi2pysnmp-0.1.3 # Python version sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0) # pylint:disable=C0302 mibBuilder = mibBuilder # pylint:disable=undefined-variable,used-before-assignment # Imports (...
mib_builder = mibBuilder (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, constraints_union, single_value_constraint, value_range_constraint...
def accumulate_left(func, acc, collection): if len(collection) == 0: return acc return accumulate_left(func, func(acc, collection[0]), collection[1:]) def accumulate_right(func, acc, collection): if len(collection) == 0: return acc return func(collection[0], accumulate_right(func, acc,...
def accumulate_left(func, acc, collection): if len(collection) == 0: return acc return accumulate_left(func, func(acc, collection[0]), collection[1:]) def accumulate_right(func, acc, collection): if len(collection) == 0: return acc return func(collection[0], accumulate_right(func, acc, ...
SCHEME = 'wss' HOSTS = ['localhost'] PORT = 8183 MESSAGE_SERIALIZER = 'goblin.driver.GraphSONMessageSerializer'
scheme = 'wss' hosts = ['localhost'] port = 8183 message_serializer = 'goblin.driver.GraphSONMessageSerializer'
TILEMAP = { "#": "pavement_1", "%": "pavement_2", " ": "road", "=": "road", "C": "road_corner", "T": "road_tint1", "&": "pavement_1", # precinct "$": "precinct_path", "E": "precinct_path_alt", "O": "ballot_box" } NO_ROUTING_TILES = [ "#", "%", "&" ] SELECTIVE_ROUTING_TILES ...
tilemap = {'#': 'pavement_1', '%': 'pavement_2', ' ': 'road', '=': 'road', 'C': 'road_corner', 'T': 'road_tint1', '&': 'pavement_1', '$': 'precinct_path', 'E': 'precinct_path_alt', 'O': 'ballot_box'} no_routing_tiles = ['#', '%', '&'] selective_routing_tiles = ['$']
'''A very simple program, showing how short a Python program can be! Authors: ___, ___ ''' print('Hello world!') #This is a stupid comment after the # mark
"""A very simple program, showing how short a Python program can be! Authors: ___, ___ """ print('Hello world!')
# # PySNMP MIB module HPN-ICF-PBR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-PBR-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:28:32 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
{ "targets": [ { "target_name" : "dsfmt_js_nv", "sources" : [ "src/main.cc", "dSFMT-src-2.2.3/dSFMT.c" ], "include_dirs": [ 'dSFMT-src-2.2.3' ], 'cflags' : [ '-fexceptions' ], 'cflags_cc' : [ '-fexceptions' ], 'defines' : [ 'DSFMT_MEXP=19937' ] } ] }
{'targets': [{'target_name': 'dsfmt_js_nv', 'sources': ['src/main.cc', 'dSFMT-src-2.2.3/dSFMT.c'], 'include_dirs': ['dSFMT-src-2.2.3'], 'cflags': ['-fexceptions'], 'cflags_cc': ['-fexceptions'], 'defines': ['DSFMT_MEXP=19937']}]}
nomecompleto = str(input('digite seu nome completo: ')) print(nomecompleto.upper()) print(nomecompleto.lower()) print(nomecompleto.capitalize()) print(nomecompleto.title()) print(nomecompleto.split()) print(nomecompleto.swapcase()) print(nomecompleto.find("i")) print(nomecompleto.count('a', 0, 16)) print(len(nomecomple...
nomecompleto = str(input('digite seu nome completo: ')) print(nomecompleto.upper()) print(nomecompleto.lower()) print(nomecompleto.capitalize()) print(nomecompleto.title()) print(nomecompleto.split()) print(nomecompleto.swapcase()) print(nomecompleto.find('i')) print(nomecompleto.count('a', 0, 16)) print(len(nomecomple...
class Solution: # @param {integer[]} height # @return {integer} def largestRectangleArea(self, height): areas = {} sorted_height = sorted(list(set(height))) lh = len(height) for i in range(lh): h = height[lh - 1 - i] areas[lh - 1 - i] = {} ...
class Solution: def largest_rectangle_area(self, height): areas = {} sorted_height = sorted(list(set(height))) lh = len(height) for i in range(lh): h = height[lh - 1 - i] areas[lh - 1 - i] = {} j = 0 while sorted_height[j] <= h: ...
def bubbleSort(alist): for passnum in range(len(alist)-1,0,-1): for i in range(passnum): if alist[i]>alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp alist = [36,38,30,31,38,43,55,38,37,30,48,41,33,25,34,43,37,40,36] bubbleSort(...
def bubble_sort(alist): for passnum in range(len(alist) - 1, 0, -1): for i in range(passnum): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i + 1] alist[i + 1] = temp alist = [36, 38, 30, 31, 38, 43, 55, 38, 37, 30, 48, 41, 33, 25, 3...
class HanaError(Exception): pass class HanaPluginError(HanaError): pass class InvalidPluginsDirectory(HanaError): pass class PluginNotFoundError(HanaPluginError): pass
class Hanaerror(Exception): pass class Hanapluginerror(HanaError): pass class Invalidpluginsdirectory(HanaError): pass class Pluginnotfounderror(HanaPluginError): pass
def compress(orginial_list): compressed_list = [] mark_X = True if orginial_list == []: return 0 if len(orginial_list) == 1: return 1 if len(orginial_list) > 1: count = 1 for i in range(len(orginial_list) - 1): begin_pointer = i if orginial_l...
def compress(orginial_list): compressed_list = [] mark_x = True if orginial_list == []: return 0 if len(orginial_list) == 1: return 1 if len(orginial_list) > 1: count = 1 for i in range(len(orginial_list) - 1): begin_pointer = i if orginial_lis...
class No: def __init__(self, chave): self.chave = chave self.esquerdo = None self.direito = None self.pai = None
class No: def __init__(self, chave): self.chave = chave self.esquerdo = None self.direito = None self.pai = None
''' Largest Palindrome of two N-digit numbers given N = 1, 2, 3, 4 ''' def largePali4digit(): answer = 0 for i in range(9999, 1000, -1): for j in range(i, 1000, -1): k = i * j s = str(k) if s == s[::-1] and k > answer: return i, j def largePali3dig...
""" Largest Palindrome of two N-digit numbers given N = 1, 2, 3, 4 """ def large_pali4digit(): answer = 0 for i in range(9999, 1000, -1): for j in range(i, 1000, -1): k = i * j s = str(k) if s == s[::-1] and k > answer: return (i, j) def large_pali3d...
# the for loop works based on a Iterable object # Iterable object is capable of returning values one at a time # regular for loop for i in range(5): print(i) for i in [1, 3, 5, 7]: print(i) for c in 'Hello': print(c) for i in [(1,2), (3,4), (5,6)]: print(i) # unpack the turple for i, j in [(1,2), (...
for i in range(5): print(i) for i in [1, 3, 5, 7]: print(i) for c in 'Hello': print(c) for i in [(1, 2), (3, 4), (5, 6)]: print(i) for (i, j) in [(1, 2), (3, 4), (5, 6)]: print(i, j) d = {'a': 1, 'b': 2, 'c': 3, 'd': 4} for k in d.keys(): print(f'{k} -> {d.get(k)}') for (k, v) in d.items(): ...
#Write a short Pyton function that takes a positive integer n and returns #the sum of the squares of all the positive integers smaller than n. def sigmaSquareN(n): list =[] sum = 0 for i in range(1,n): sum += i**2 if sum < n: print ('Sigma of squrae %d=%d'%(i,sum)) lis...
def sigma_square_n(n): list = [] sum = 0 for i in range(1, n): sum += i ** 2 if sum < n: print('Sigma of squrae %d=%d' % (i, sum)) list.append(sum) else: break return list n = int(input('Please input a positive integer')) if n >= 0: print(...
print('DOBRO TRIPLO RAIZ') n = int(input('Digite um numero: ')) print(f'DOBRO: {n * 2}') print(f'TRIPLO: {n * 3}') print(f'RAIZ: {n ** (1/2):.2f}')
print('DOBRO TRIPLO RAIZ') n = int(input('Digite um numero: ')) print(f'DOBRO: {n * 2}') print(f'TRIPLO: {n * 3}') print(f'RAIZ: {n ** (1 / 2):.2f}')
# Python3 program to find a triplet # that sum to a given value # returns true if there is triplet with # sum equal to 'sum' present in A[]. # Also, prints the triplet def find3Numbers(A, arr_size, sum): # Fix the first element as A[i] for i in range( 0, arr_size-2): # Fix the second element as A[j] for j in r...
def find3_numbers(A, arr_size, sum): for i in range(0, arr_size - 2): for j in range(i + 1, arr_size - 1): for k in range(j + 1, arr_size): if A[i] + A[j] + A[k] == sum: print('Triplet is', A[i], ', ', A[j], ', ', A[k]) return True retu...
t = int(input()) for __ in range(t): n, m = map(int, input().split()) inl = input().split() iml = input().split() amps = [] freqs = [] ampsm = [] freqsm = [] c = 0 for i in range(2*n): if i % 2 == 0: temp = int(inl[i]) amps.append(temp) else: freqs.append(inl[i]) for i in range(2*m): if i % 2 ...
t = int(input()) for __ in range(t): (n, m) = map(int, input().split()) inl = input().split() iml = input().split() amps = [] freqs = [] ampsm = [] freqsm = [] c = 0 for i in range(2 * n): if i % 2 == 0: temp = int(inl[i]) amps.append(temp) els...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def maxPathSum(self, root: TreeNode) -> int: self.res = float('-inf') def get_val(node): if not node: return 0 left = max(0,...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def max_path_sum(self, root: TreeNode) -> int: self.res = float('-inf') def get_val(node): if not node: return 0 left = max(0...
# %% [1480. Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array/) class Solution: def runningSum(self, nums: List[int]) -> List[int]: return itertools.accumulate(nums)
class Solution: def running_sum(self, nums: List[int]) -> List[int]: return itertools.accumulate(nums)
# Paint costs ############################## #### Problem Description ##### ############################## # You are getting ready to paint a piece of art. The canvas and brushes that you want to use will cost 40.00. Each color of paint that you buy is an additional 5.00. Determine how much money you will need based ...
paint_varieties = int(input()) canvas_brush_cost = 40 paint_cost = paintVarieties * 5 tax = 0.1 total = (canvasBrushCost + paintCost) * (1 + tax) print(round(total))
def add_new_objects(): for object_type, desc, position in new_objects: desc['position']=position objs_in_position = get_objects_by_coords(position) all_interactable = True for obj_in_position in objs_in_position: if not game_objects[obj_in_position]['interactable']: ...
def add_new_objects(): for (object_type, desc, position) in new_objects: desc['position'] = position objs_in_position = get_objects_by_coords(position) all_interactable = True for obj_in_position in objs_in_position: if not game_objects[obj_in_position]['interactable']: ...
#All Configurations FILE_DUPLICATE_NUM = 2 # how many replications stored FILE_CHUNK_SIZE = 1024*1024 # 1KB, the chunk size, will be larger when finishing debugging HEADER_LENGTH = 16 # header size SAVE_FAKE_LOG = False # for single point failure, will greatly reduce the performance IGNORE_LOCK = True # for test...
file_duplicate_num = 2 file_chunk_size = 1024 * 1024 header_length = 16 save_fake_log = False ignore_lock = True server_log_file_name = 'server_write_log' def name_local_to_remote(name): return name.replace('/', '[[') def name_remote_to_local(name): return name.replace('[[', '/')
# Day of Week That Is k Days Later # Days of the week are represented as three-letter strings. # "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" # Write a javaScript function solution that, given a string # S representing the day of the week and an integer K # (between 0 and 500), returns the day of the week that # is...
def k_days_later(s, k): days_of_week = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] remainder = k % 7 s_index = days_of_week.index(s) move_forward = remainder + s_index if move_forward < 7: return days_of_week[move_forward] else: correct_day_index = move_forward - 7 ...
class Accounts: def __init__(self, first_name, last_name, user_name, password): self.first_name = first_name self.last_name = last_name self.user_name = user_name self.password = password user_accounts = [] def save_account(self): ''' this is a save function...
class Accounts: def __init__(self, first_name, last_name, user_name, password): self.first_name = first_name self.last_name = last_name self.user_name = user_name self.password = password user_accounts = [] def save_account(self): """ this is a save function...
def pyramid_pattern(n): a = 2 * n-2 for i in range(0, n): for j in range(0, a): print(end=" ") a = a-1 for j in range(0, i+1): print("*", end=" ") print("\r") print(pyramid_pattern(10))
def pyramid_pattern(n): a = 2 * n - 2 for i in range(0, n): for j in range(0, a): print(end=' ') a = a - 1 for j in range(0, i + 1): print('*', end=' ') print('\r') print(pyramid_pattern(10))
#!/usr/bin/python3 if __name__ == "__main__": # open text file to read file = open('write_file.txt', 'a') # read a line from the file file.write('This is a line appended to the file\n') file.close() file = open('write_file.txt', 'r') data = file.read() print(data) file.close()
if __name__ == '__main__': file = open('write_file.txt', 'a') file.write('This is a line appended to the file\n') file.close() file = open('write_file.txt', 'r') data = file.read() print(data) file.close()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") load("@rules_jvm_external//:defs.bzl", "maven_install") load("@rules_jvm_external//:specs.bzl", "maven") def _clojure_toolchain(ctx): return [platform_common.ToolchainInfo( runtime = ctx.attr.classpath, ...
load('@rules_proto//proto:repositories.bzl', 'rules_proto_dependencies', 'rules_proto_toolchains') load('@rules_jvm_external//:defs.bzl', 'maven_install') load('@rules_jvm_external//:specs.bzl', 'maven') def _clojure_toolchain(ctx): return [platform_common.ToolchainInfo(runtime=ctx.attr.classpath, scripts={s.basen...
for c in range(0, 6): print('oi') for b in range (0, 6): print(b) print('fim') for b in range (6, 0, -1): print(b) print('fim') n= int(input('Digite um numero: ')) for c in range(0, n): print(c) print('fim') i = int(input('Inicio: ')) f = int(input('fim: ')) p = int(input('passos: ')...
for c in range(0, 6): print('oi') for b in range(0, 6): print(b) print('fim') for b in range(6, 0, -1): print(b) print('fim') n = int(input('Digite um numero: ')) for c in range(0, n): print(c) print('fim') i = int(input('Inicio: ')) f = int(input('fim: ')) p = int(input('passos: ')) for c in range(i, f...
gritos = 3 soma = 0 while gritos > 0: entrada = input() if entrada == 'caw caw': print(soma) soma = 0 gritos -= 1 continue entrada = int("".join(map(lambda x: '0' if x == '-' else '1', entrada)), 2) soma += entrada
gritos = 3 soma = 0 while gritos > 0: entrada = input() if entrada == 'caw caw': print(soma) soma = 0 gritos -= 1 continue entrada = int(''.join(map(lambda x: '0' if x == '-' else '1', entrada)), 2) soma += entrada
start_node = '0' end_node = '8' def a_star(start_node, end_node): open_set = set(start_node) closed_set = set() g = {} # Store distance from start node. parents = {} # Parents contain an adjacent map of all nodes. # Distance of start node from itself is zero g[start_node] = 0 parents[start_node] = start...
start_node = '0' end_node = '8' def a_star(start_node, end_node): open_set = set(start_node) closed_set = set() g = {} parents = {} g[start_node] = 0 parents[start_node] = start_node while len(open_set) > 0: n = None for v in open_set: if n == None or g[v] + heur...
data = open("day6.txt").read().split("\n\n") def part_one(): total = 0 for group in data: total += len(set(list(group.replace("\n", "")))) return total def part_two(): total = 0 for group in data: total += len(set.intersection(*map(set, group.split()))) return total print(p...
data = open('day6.txt').read().split('\n\n') def part_one(): total = 0 for group in data: total += len(set(list(group.replace('\n', '')))) return total def part_two(): total = 0 for group in data: total += len(set.intersection(*map(set, group.split()))) return total print(part_...
print() name = 'abc'.upper() def get_name(): name = 'def'.upper() print(f"inside: {name}") get_name() print(f"Outside: {name}") print() def get_name(): global name name = 'def'.upper() print(f"inside: {name}") get_name() print(f"Outside: {name}") def get_name(): global name #but ...
print() name = 'abc'.upper() def get_name(): name = 'def'.upper() print(f'inside: {name}') get_name() print(f'Outside: {name}') print() def get_name(): global name name = 'def'.upper() print(f'inside: {name}') get_name() print(f'Outside: {name}') def get_name(): global name print(f'inside...
# Read from a text file #Open the file, read the value and close the file f = open("output.txt","r") text=f.read() f.close() print(text)
f = open('output.txt', 'r') text = f.read() f.close() print(text)
botamusique = None playlist = None user = "" is_proxified = False dbfile = None db = None config = None bot_logger = None music_folder = "" tmp_folder = ""
botamusique = None playlist = None user = '' is_proxified = False dbfile = None db = None config = None bot_logger = None music_folder = '' tmp_folder = ''
class Solution: def postorderTraversal(self, root): if root is None: return [] traversal = [] root.parent = None node = root while node is not None: while (node.left is not None or node.right is not None): if node.left is...
class Solution: def postorder_traversal(self, root): if root is None: return [] traversal = [] root.parent = None node = root while node is not None: while node.left is not None or node.right is not None: if node.left is not None: ...
# _*_ coding=utf-8 _*_ __author__ = 'lib.o' max_title_length = 200 max_tags_length = 200 max_tag_length = 32 max_summary_length = 500 title = u"My blog" second_title = u"this is my blog" article_num_per_page = 25
__author__ = 'lib.o' max_title_length = 200 max_tags_length = 200 max_tag_length = 32 max_summary_length = 500 title = u'My blog' second_title = u'this is my blog' article_num_per_page = 25
class Entity: word = "" start = 0 end = 0 ent_type = "" def __init__(self, word, start, end, ent_type) : self.word = word self.start = start self.end = end self.ent_type = ent_type def __str__(self) : return self.word def __repr__(self) : ...
class Entity: word = '' start = 0 end = 0 ent_type = '' def __init__(self, word, start, end, ent_type): self.word = word self.start = start self.end = end self.ent_type = ent_type def __str__(self): return self.word def __repr__(self): retur...
#function within function def operator(op_text): def add_num(num1,num2): return num1+num2 def subtract_num(num1,num2): return num1-num2 if op_text == '+': return add_num elif op_text == '-': return subtract_num else: return None # driver code if __name__ == '__main__': add_fn=operator('...
def operator(op_text): def add_num(num1, num2): return num1 + num2 def subtract_num(num1, num2): return num1 - num2 if op_text == '+': return add_num elif op_text == '-': return subtract_num else: return None if __name__ == '__main__': add_fn = operator(...
iss_orbit_apogee = 417 * 1000 # Km to m iss_orbit_perigee = 401 * 1000 # Km to m earth_mu = 3.986e14 # m^3/s^-2 earth_r = 6.378e6 # m dist = earth_r + iss_orbit_perigee grav = earth_mu / dist**2 print(grav)
iss_orbit_apogee = 417 * 1000 iss_orbit_perigee = 401 * 1000 earth_mu = 398600000000000.0 earth_r = 6378000.0 dist = earth_r + iss_orbit_perigee grav = earth_mu / dist ** 2 print(grav)
class Compatibility(): def dir_ftp_to_windows(dir): return dir.replace("/", "\\") def dir_windows_to_ftp(dir): return dir.replace("\\", "/")
class Compatibility: def dir_ftp_to_windows(dir): return dir.replace('/', '\\') def dir_windows_to_ftp(dir): return dir.replace('\\', '/')
# Process sentence into array of acceptable words def ProcessSentence(width, sentence): pWords = [] for word in sentence.split(' '): if len(word) <= (width - 4): pWords.append(word) else: x = word while len(x) > (width - 4): pWords.append(x[:w...
def process_sentence(width, sentence): p_words = [] for word in sentence.split(' '): if len(word) <= width - 4: pWords.append(word) else: x = word while len(x) > width - 4: pWords.append(x[:width - 4]) x = x[width - 4:] ...
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def hasPathSum(self, root, sum): if root: return self.recursive(root, sum) return False def recursive(self, node,...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def has_path_sum(self, root, sum): if root: return self.recursive(root, sum) return False def recursive(self, node, _sum): if node.val == _su...
def test(): # only check that the code runs and nwbfile.identifier is in the last line of the solution assert "nwbfile.identifier" in __solution__.strip().splitlines()[-1], "Are you printing the session identifier?" __msg__.good("Well done!")
def test(): assert 'nwbfile.identifier' in __solution__.strip().splitlines()[-1], 'Are you printing the session identifier?' __msg__.good('Well done!')
x = 12 if x < 10: print("x is less than 10") elif x >= 10: print("x is greater than or equal to 10")
x = 12 if x < 10: print('x is less than 10') elif x >= 10: print('x is greater than or equal to 10')
# My Twitter App Credentials consumer_key = "" consumer_secret = "" access_token = "" access_token_secret = ""
consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = ''
def mostrar(nome): tam = len(nome) + 4 print('~'*tam) print(f' {nome}') print('~'*tam) #PRINT ESPECIAL mostrar('Boaventura') mostrar('Maria Laura')
def mostrar(nome): tam = len(nome) + 4 print('~' * tam) print(f' {nome}') print('~' * tam) mostrar('Boaventura') mostrar('Maria Laura')
# noinspection PyUnusedLocal # skus = unicode string def calculate_offers(bill, item, quantity, offers): bill = bill.copy() for offer, price in offers: bill[item]['offers'].append( {'items': quantity / offer, 'price': price} ) quantity = quantity % offer return bill, ...
def calculate_offers(bill, item, quantity, offers): bill = bill.copy() for (offer, price) in offers: bill[item]['offers'].append({'items': quantity / offer, 'price': price}) quantity = quantity % offer return (bill, quantity) def remove_free_items(skus): def remove_free_item(quantity, ...
PELVIS = 0 SPINE_NAVAL = 1 SPINE_CHEST = 2 NECK = 3 CLAVICLE_LEFT = 4 SHOULDER_LEFT = 5 ELBOW_LEFT = 6 WRIST_LEFT = 7 HAND_LEFT = 8 HANDTIP_LEFT = 9 THUMB_LEFT = 10 CLAVICLE_RIGHT = 11 SHOULDER_RIGHT = 12 ELBOW_RIGHT = 13 WRIST_RIGHT = 14 HAND_RIGHT = 15 HANDTIP_RIGHT = 16 THUMB_RIGHT = 17 HIP_LEFT = 18 KNEE_LEFT = 19 ...
pelvis = 0 spine_naval = 1 spine_chest = 2 neck = 3 clavicle_left = 4 shoulder_left = 5 elbow_left = 6 wrist_left = 7 hand_left = 8 handtip_left = 9 thumb_left = 10 clavicle_right = 11 shoulder_right = 12 elbow_right = 13 wrist_right = 14 hand_right = 15 handtip_right = 16 thumb_right = 17 hip_left = 18 knee_left = 19 ...
class intcode(): def __init__(self): self.instructionPointer = 0 self.memory = [] self.stopped = False def loadMemory(self, memList): self.memory = memList.copy() def loadProgram(self, programString): numbers = programString.split(",") self.memory = list(...
class Intcode: def __init__(self): self.instructionPointer = 0 self.memory = [] self.stopped = False def load_memory(self, memList): self.memory = memList.copy() def load_program(self, programString): numbers = programString.split(',') self.memory = list(ma...
# Problem: https://www.hackerrank.com/challenges/merge-the-tools/problem def merge_the_tools(string, k): num_sub = int(len(string)/k) for sub_num in range(num_sub): sub = string[sub_num*k:sub_num*k+k] sub_list, unique_sub_list = list(sub), [] [unique_sub_list.append(letter) for letter i...
def merge_the_tools(string, k): num_sub = int(len(string) / k) for sub_num in range(num_sub): sub = string[sub_num * k:sub_num * k + k] (sub_list, unique_sub_list) = (list(sub), []) [unique_sub_list.append(letter) for letter in sub_list if letter not in unique_sub_list] unique_su...
def adding_numbers(num1, num2, num3): print('Have to add three numbers') print('First Number = {}'.format(num1)) print('Second Number = {}'.format(num2)) print('Third Number = {}'.format(num3)) return num1 + num2 + num3 x = adding_numbers(10, 20, 30) print('The function returned a value of ...
def adding_numbers(num1, num2, num3): print('Have to add three numbers') print('First Number = {}'.format(num1)) print('Second Number = {}'.format(num2)) print('Third Number = {}'.format(num3)) return num1 + num2 + num3 x = adding_numbers(10, 20, 30) print('The function returned a value of {}'.forma...
''' >>> increments([1, 5, 7]) [2, 6, 8] >>> increments([0, 0, 0, 0, 0]) [1, 1, 1, 1, 1] >>> increments([0.5, 1.5, 1.75, 2.5]) [1.5, 2.5, 2.75, 3.5] >>> increments([570, 968, 723, 179, 762, 377, 845, 320, 475, 952, 680, 874, 708, 493, 901, 896, 164, 165, 404, 147, 917, 936, 205, 615, 518, 254, 856, 584, 287, 336,...
""" >>> increments([1, 5, 7]) [2, 6, 8] >>> increments([0, 0, 0, 0, 0]) [1, 1, 1, 1, 1] >>> increments([0.5, 1.5, 1.75, 2.5]) [1.5, 2.5, 2.75, 3.5] >>> increments([570, 968, 723, 179, 762, 377, 845, 320, 475, 952, 680, 874, 708, 493, 901, 896, 164, 165, 404, 147, 917, 936, 205, 615, 518, 254, 856, 584, 287, 336,...
def parallel(task_id, file_name, workers, parameters={}): response = { 'task_id': task_id, "user_output": "Command received", 'completed': True } responses.append(response) return
def parallel(task_id, file_name, workers, parameters={}): response = {'task_id': task_id, 'user_output': 'Command received', 'completed': True} responses.append(response) return
#First i1 = str(input()) for i in i1: print(i, end=" ") #Second i1 = "anant" for i in range(0,len(i1)): if i == len(i1) - 1: print(i1[i],end="") else: print(i1[i], end=" ") for i in range(0,3): x = input() print(x) #Third tuples = [ (-2.3391885553668246e-10, 8.473071450645254e-...
i1 = str(input()) for i in i1: print(i, end=' ') i1 = 'anant' for i in range(0, len(i1)): if i == len(i1) - 1: print(i1[i], end='') else: print(i1[i], end=' ') for i in range(0, 3): x = input() print(x) tuples = [(-2.3391885553668246e-10, 8.473071450645254e-10), (-2.91634014818891e-1...
img = tf.placeholder(tf.float32, [None, None, None, 3]) cost = tf.reduce_sum(...) my_img_summary = tf.summary.image("img", img) my_cost_summary = tf.summary.scalar("cost", cost)
img = tf.placeholder(tf.float32, [None, None, None, 3]) cost = tf.reduce_sum(...) my_img_summary = tf.summary.image('img', img) my_cost_summary = tf.summary.scalar('cost', cost)
class Stack: def __init__(self, name, service_list): self.name = name self.service_list = service_list def services(self): return [x.attrs() for x in self.service_list] def serializable(self): return { "name": self.name, "services": self.services() ...
class Stack: def __init__(self, name, service_list): self.name = name self.service_list = service_list def services(self): return [x.attrs() for x in self.service_list] def serializable(self): return {'name': self.name, 'services': self.services()}
class Message: EVENT = "event" MESSAGE = "message" UPDATE = "update" EPHEMERAL = "ephemeral"
class Message: event = 'event' message = 'message' update = 'update' ephemeral = 'ephemeral'
expected_output = { "software-information": { "package-information": [ {"comment": "EX Software Suite [18.2R2-S1]", "name": "ex-software-suite"}, { "comment": "FIPS mode utilities [18.2R2-S1]", "name": "fips-mode-utilities", }, ...
expected_output = {'software-information': {'package-information': [{'comment': 'EX Software Suite [18.2R2-S1]', 'name': 'ex-software-suite'}, {'comment': 'FIPS mode utilities [18.2R2-S1]', 'name': 'fips-mode-utilities'}, {'comment': 'Crypto Software Suite [18.2R2-S1]', 'name': 'crypto-software-suite'}, {'comment': 'O...
# reassign the dataframe to be the result of the following .loc # .loc[start_row:end_row, start_column:end_column] # .loc[:, "Under 5":"18 years"] will return all columns between and including df["age_bin_0-19"] = df.loc[:, 'Estimate Male Under 5':'Estimate Male 18'] df = DataFrame(np.random.rand(4,5), columns = li...
df['age_bin_0-19'] = df.loc[:, 'Estimate Male Under 5':'Estimate Male 18'] df = data_frame(np.random.rand(4, 5), columns=list('abcde')) df.loc[:, 'b':'d']
class Node: pass class ProgramNode(Node): def __init__(self, declarations): self.declarations = declarations class DeclarationNode(Node): pass class ExpressionNode(Node): pass class ClassDeclarationNode(DeclarationNode): def __init__(self, idx, features, parent, row , column): self...
class Node: pass class Programnode(Node): def __init__(self, declarations): self.declarations = declarations class Declarationnode(Node): pass class Expressionnode(Node): pass class Classdeclarationnode(DeclarationNode): def __init__(self, idx, features, parent, row, column): s...
a, b = map(int, input().split()) b -= 1 print(a * b + 1)
(a, b) = map(int, input().split()) b -= 1 print(a * b + 1)
#!/anaconda3/bin/python class ListNode: def __init__(self, x): self.val = x self.next = None class LeetCode_21_495(object): def mergeTwoLists(self, l1, l2): prehead = ListNode(-1) prev = prehead while l1 and l2: if l1.val <= l2.val: prev.ne...
class Listnode: def __init__(self, x): self.val = x self.next = None class Leetcode_21_495(object): def merge_two_lists(self, l1, l2): prehead = list_node(-1) prev = prehead while l1 and l2: if l1.val <= l2.val: prev.next = l1 ...
countries = [[('Finland', 'Helsinki')], [('Sweden', 'Stockholm')], [('Norway', 'Oslo')]] flatten = [p for p in countries for p in p] dictofcountries = [{'country': flatten[i][0].upper(), 'city': flatten[i][1].upper()} for i in range(len(flatten))] print(dictofcountries)
countries = [[('Finland', 'Helsinki')], [('Sweden', 'Stockholm')], [('Norway', 'Oslo')]] flatten = [p for p in countries for p in p] dictofcountries = [{'country': flatten[i][0].upper(), 'city': flatten[i][1].upper()} for i in range(len(flatten))] print(dictofcountries)
#!/usr/bin/env python3 # Modify the higher or lower program from this section to keep track of how # many times the user has entered the wrong number. If it is more than 3 # times, print "That must have been complicated." at the end, otherwise # print "Good job!" number = 7 guess = -1 count = 0 print("Guess the numb...
number = 7 guess = -1 count = 0 print('Guess the number!') while guess != number: guess = int(input('Is it... ')) count = count + 1 if guess == number: print('Hooray! You guessed it right!') elif guess < number: print("It's bigger... ") elif guess > number: print("It's not so...