content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Ex083.2 """Create a program where the user types any espression that uses parentheses. Your application should analyze where the expression passed has open and closed parentheses in the correct order.""" list = [] temp = [] expression = str(input('\033[32mType a expression: \033[m')) for c in expression: if c =...
"""Create a program where the user types any espression that uses parentheses. Your application should analyze where the expression passed has open and closed parentheses in the correct order.""" list = [] temp = [] expression = str(input('\x1b[32mType a expression: \x1b[m')) for c in expression: if c == '(': ...
jogador = {} lista = [] total = 0 jogador['Nome'] = input('Nome do jogador: ') quantidade = int(input('Quantas partidas {} jogou ? '.format(jogador['Nome']))) for i in range(0, quantidade): gol_quantidade = int(input('Quantos gols na partida {} ? '.format(i + 1))) total += gol_quantidade lista.append(gol_qu...
jogador = {} lista = [] total = 0 jogador['Nome'] = input('Nome do jogador: ') quantidade = int(input('Quantas partidas {} jogou ? '.format(jogador['Nome']))) for i in range(0, quantidade): gol_quantidade = int(input('Quantos gols na partida {} ? '.format(i + 1))) total += gol_quantidade lista.append(gol_qu...
def my_sum(*args): # *args = 1, 2, 3 print(type(args)) print(args) return sum(args) def my_sum_2(args): # args = [1, 2, 3] return sum(args) print(my_sum(1, 2, 3)) # a # my_sum([1, 2, 3]) # b # my_sum_2(1, 2, 3) # c print(my_sum_2([1, 2, 3])) # d _, *args = 0, 1, 2, 3 args_2 = [1, 2, 3]...
def my_sum(*args): print(type(args)) print(args) return sum(args) def my_sum_2(args): return sum(args) print(my_sum(1, 2, 3)) print(my_sum_2([1, 2, 3])) (_, *args) = (0, 1, 2, 3) args_2 = [1, 2, 3] print(args) print(args_2)
"""Views for WillPress. "An Excellent Blog Engine" Copyright (c) 2021 by William Ellison. This program is licensed under the terms of the Do What the Fuck You Want To Public License, version 2 or later, as described in the COPYING file at the root of this distribution. William Ellison <waellison@gmail.com> October ...
"""Views for WillPress. "An Excellent Blog Engine" Copyright (c) 2021 by William Ellison. This program is licensed under the terms of the Do What the Fuck You Want To Public License, version 2 or later, as described in the COPYING file at the root of this distribution. William Ellison <waellison@gmail.com> October ...
#!/usr/bin/python3 def Encrypt(K, P): cipher = [] for letter in P: cipher.append(chr((ord(letter) - 65 + K) % 26 + 65)) return "".join(cipher) def disp(K): for i in range(0, 25): print(chr(i + 65), end=" ") print() for i in range(0, 25): print(chr((i + K) % 26 + 65),...
def encrypt(K, P): cipher = [] for letter in P: cipher.append(chr((ord(letter) - 65 + K) % 26 + 65)) return ''.join(cipher) def disp(K): for i in range(0, 25): print(chr(i + 65), end=' ') print() for i in range(0, 25): print(chr((i + K) % 26 + 65), end=' ') print() ...
sample = { "asset": { "ancestors": [ "projects/163454223397", "organizations/673763744309" ], "assetType": "compute.googleapis.com/Instance", "name": "//compute.googleapis.com/projects/sc-vice-test/zones/us-central1-a/instances/instance-1", "resource":...
sample = {'asset': {'ancestors': ['projects/163454223397', 'organizations/673763744309'], 'assetType': 'compute.googleapis.com/Instance', 'name': '//compute.googleapis.com/projects/sc-vice-test/zones/us-central1-a/instances/instance-1', 'resource': {'data': {'allocationAffinity': {'consumeAllocationType': 'ANY_ALLOCATI...
smile_dict = [b"\xF0\x9F\x98\x81", b"\xF0\x9F\x98\x82", b"\xF0\x9F\x98\x83", b"\xF0\x9F\x98\x84", b"\xF0\x9F\x98\x85", b"\xF0\x9F\x98\x86", b"\xF0\x9F\x98\x89", b"\xF0\x9F\x98\x8A", b"\xF0\x9F\x98\x8B", b"\xF0\x9F\x98\x8C", b"\xF0\x9F\x98\x8D", b"\xF0\x9F\x98\x8F", b"\xF0\x9F\x98\x92", b"\xF0\x9F\x98\x93",...
smile_dict = [b'\xf0\x9f\x98\x81', b'\xf0\x9f\x98\x82', b'\xf0\x9f\x98\x83', b'\xf0\x9f\x98\x84', b'\xf0\x9f\x98\x85', b'\xf0\x9f\x98\x86', b'\xf0\x9f\x98\x89', b'\xf0\x9f\x98\x8a', b'\xf0\x9f\x98\x8b', b'\xf0\x9f\x98\x8c', b'\xf0\x9f\x98\x8d', b'\xf0\x9f\x98\x8f', b'\xf0\x9f\x98\x92', b'\xf0\x9f\x98\x93', b'\xf0\x9f\x...
# Code generated by font-to-py.py. # Font: dsm.ttf version = '0.26' def height(): return 21 def max_width(): return 12 def hmap(): return True def reverse(): return False def monospaced(): return False def min_ch(): return 32 def max_ch(): return 126 _font =\...
version = '0.26' def height(): return 21 def max_width(): return 12 def hmap(): return True def reverse(): return False def monospaced(): return False def min_ch(): return 32 def max_ch(): return 126 _font = b'\x0c\x00\x00\x00|\x00\xfe\x00\x87\x00\x03\x00\x03\x00\x07\x00\x0e\x00\x1c\x...
# CPU: 0.42 s ids = set() for _ in range(int(input())): ids.add(int(input())) m = 1 while True: reduced_ids = set() for id_ in ids: reduced_id = id_ % m if reduced_id not in reduced_ids: reduced_ids.add(reduced_id) else: break else: break m += 1 print(m)
ids = set() for _ in range(int(input())): ids.add(int(input())) m = 1 while True: reduced_ids = set() for id_ in ids: reduced_id = id_ % m if reduced_id not in reduced_ids: reduced_ids.add(reduced_id) else: break else: break m += 1 print(m)
""" |-------------------------------------------| | Problem 2: Write a program to convert | | temperature in Celsius to Fahrenheit | | & vice versa | |-------------------------------------------| | Approach: | | We use the formula ...
""" |-------------------------------------------| | Problem 2: Write a program to convert | | temperature in Celsius to Fahrenheit | | & vice versa | |-------------------------------------------| | Approach: | | We use the formula ...
_item_fullname_='mdtraj.Topology' def is_mdtraj_Topology(item): item_fullname = item.__class__.__module__+'.'+item.__class__.__name__ return _item_fullname_==item_fullname
_item_fullname_ = 'mdtraj.Topology' def is_mdtraj__topology(item): item_fullname = item.__class__.__module__ + '.' + item.__class__.__name__ return _item_fullname_ == item_fullname
# -*- coding: utf-8 -*- # author: @RShirohara __version__ = "0.1.1" __doc__ = f""" tegaki v{__version__} Released under MIT License. https://github.com/RShirohara/handwriting_detection """
__version__ = '0.1.1' __doc__ = f'\ntegaki v{__version__}\nReleased under MIT License.\nhttps://github.com/RShirohara/handwriting_detection\n'
# Find the Runner-Up Score or Finding second largest number n = int(input()) arr = list(map(int, input().split())) l = max(arr) for i in range(n): if l == max(arr): arr.remove(max(arr)) print(max(arr))
n = int(input()) arr = list(map(int, input().split())) l = max(arr) for i in range(n): if l == max(arr): arr.remove(max(arr)) print(max(arr))
class Solution: def findMedianSortedArrays(self, A: List[int], B: List[int]) -> float: def helper(A, B, k): if not A or not B: return (A or B)[k] else: ia, ib = len(A) // 2, len(B) // 2 ma, mb = A[ia], B[ib] if k > ia + ...
class Solution: def find_median_sorted_arrays(self, A: List[int], B: List[int]) -> float: def helper(A, B, k): if not A or not B: return (A or B)[k] else: (ia, ib) = (len(A) // 2, len(B) // 2) (ma, mb) = (A[ia], B[ib]) ...
""" Profile ../profile-datasets-py/div83/068.py file automaticaly created by prof_gen.py script """ self["ID"] = "../profile-datasets-py/div83/068.py" self["Q"] = numpy.array([ 2.83917200e+00, 3.51202800e+00, 4.81389700e+00, 6.13220200e+00, 6.51049800e+00, 6.51553800e+00, 6.5143...
""" Profile ../profile-datasets-py/div83/068.py file automaticaly created by prof_gen.py script """ self['ID'] = '../profile-datasets-py/div83/068.py' self['Q'] = numpy.array([2.839172, 3.512028, 4.813897, 6.132202, 6.510498, 6.515538, 6.514338, 6.368879, 6.117763, 6.077253, 6.097473, 5.899725, 5.639368, 5....
"""Apparently you can't monkey-patch Curses windows, so we've got to have this stupid module instead.""" def movedown(window, rows=1, x=None): current_y, current_x = window.getyx() window.move(current_y+rows, x if x is not None else current_x) def movex(window, new_x): current_y = window.getyx()[0] wi...
"""Apparently you can't monkey-patch Curses windows, so we've got to have this stupid module instead.""" def movedown(window, rows=1, x=None): (current_y, current_x) = window.getyx() window.move(current_y + rows, x if x is not None else current_x) def movex(window, new_x): current_y = window.getyx()[0] ...
def translate(message): """ A dumb translator which does not actually translate anything. :param message: The message. :return: A translated message (dummy: actually, the same message). """ return message
def translate(message): """ A dumb translator which does not actually translate anything. :param message: The message. :return: A translated message (dummy: actually, the same message). """ return message
while True: try: l = int(input()) except EOFError: break lesmas = map(int, input().split()) maior = max(lesmas) if maior < 10: print(1) elif maior >= 10 and maior < 20: print(2) else: print(3)
while True: try: l = int(input()) except EOFError: break lesmas = map(int, input().split()) maior = max(lesmas) if maior < 10: print(1) elif maior >= 10 and maior < 20: print(2) else: print(3)
# Module to flatten a list def flatten(array, flattened=[]): for value in array: if(isinstance(value, list)): flatten(value, flattened) else: flattened.append(value) return flattened
def flatten(array, flattened=[]): for value in array: if isinstance(value, list): flatten(value, flattened) else: flattened.append(value) return flattened
class ComicException(Exception): pass class PathResolutionException(ComicException): """ A path given to a COMIC template tag contained variables that could not be resolved """
class Comicexception(Exception): pass class Pathresolutionexception(ComicException): """ A path given to a COMIC template tag contained variables that could not be resolved """
# -*- coding: utf-8 -*- """ Apache2 License Notice Copyright 2018 Alex Barry Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable ...
""" Apache2 License Notice Copyright 2018 Alex Barry Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writi...
class BaseAgent(object): def __init__(self, config): self.device = config.device self.num_actions = config.action_dim self.observation_dim = config.observation_dim self.discount_factor = config.discount_factor self.grad_clip_val = config.grad_clip_val self.batch_siz...
class Baseagent(object): def __init__(self, config): self.device = config.device self.num_actions = config.action_dim self.observation_dim = config.observation_dim self.discount_factor = config.discount_factor self.grad_clip_val = config.grad_clip_val self.batch_size...
inp = input("please enter the text") print("The original string : " + inp) res = [int(i) for i in inp.split() if i.isdigit()] # this basically makes a list of all the numbers for i in res: if len(str(i))==10: print("the phone number in the text is:" + str(i))
inp = input('please enter the text') print('The original string : ' + inp) res = [int(i) for i in inp.split() if i.isdigit()] for i in res: if len(str(i)) == 10: print('the phone number in the text is:' + str(i))
### Static Array Sequence Implementation # Static array has fixed size and can't grow or shrink. # Static array has a O(1) constant time for get_at and set_at operations. # Static array has a O(n) time for insert and delete operations at the back of the array. # Reference implementation: MIT Introduction to Algorith...
class Array_Seq: def __init__(self): self.A = [] self.size = 0 def __len__self(self): return self.size def __iter__(self): yield from self.A def build(self, X): self.A = [a for a in X] self.size = len(X) def get_at(self, i): return self.A[...
# This sample tests the case where super() is used within a metaclass # __init__ method. class Metaclass(type): def __init__(self, name, bases, attrs): super().__init__(name, bases, attrs)
class Metaclass(type): def __init__(self, name, bases, attrs): super().__init__(name, bases, attrs)
__author__ = 'studentmac' def make_negative( number ): if number >0: number *=-1 return number
__author__ = 'studentmac' def make_negative(number): if number > 0: number *= -1 return number
# -*- coding: utf-8 -*- """ Solution to Project Euler problem 389 - Platonic Dice Author: Jaime Liew https://github.com/jaimeliew1/Project_Euler_Solutions An unbiased single 4-sided die is thrown and its value, T, is noted. T unbiased 6-sided dice are thrown and their scores are added together. The sum, C, is noted. ...
""" Solution to Project Euler problem 389 - Platonic Dice Author: Jaime Liew https://github.com/jaimeliew1/Project_Euler_Solutions An unbiased single 4-sided die is thrown and its value, T, is noted. T unbiased 6-sided dice are thrown and their scores are added together. The sum, C, is noted. C unbiased 8-sided dice ...
{ "targets": [ { "target_name": "rsvg", "sources": [ "src/Rsvg.cc", "src/Enums.cc", "src/Autocrop.cc" ], "variables": { "packages": "librsvg-2.0 cairo-png cairo-pdf cairo-svg", "libraries": "<!(pkg-config --libs-only-l <(packages))", "ldflags": "<!(pkg-config --libs-only-L --libs-...
{'targets': [{'target_name': 'rsvg', 'sources': ['src/Rsvg.cc', 'src/Enums.cc', 'src/Autocrop.cc'], 'variables': {'packages': 'librsvg-2.0 cairo-png cairo-pdf cairo-svg', 'libraries': '<!(pkg-config --libs-only-l <(packages))', 'ldflags': '<!(pkg-config --libs-only-L --libs-only-other <(packages))', 'cflags': '<!(pkg-c...
#!/usr/bin/python class me: # initialization routine def __init__(self, foo): self.myvar = foo def getval(self): return self.myvar # this is an instance of the "me" class my = me("this") # my instantiation/assignment allows access to getval method x = my.getval() print(x)
class Me: def __init__(self, foo): self.myvar = foo def getval(self): return self.myvar my = me('this') x = my.getval() print(x)
# OpenWeatherMap API Key weather_api_key = "48ae7399e76d973a4b9ac9efe89908a3" # Google API Key g_key = "AIzaSyBrlKm1v_NyDl4nT9LOZWE5s_sQa2D5Hoc"
weather_api_key = '48ae7399e76d973a4b9ac9efe89908a3' g_key = 'AIzaSyBrlKm1v_NyDl4nT9LOZWE5s_sQa2D5Hoc'
height=list(map(int,input().split())) height def trapped_water(h): n=len(h) total=0 for i in range(1,n-1): left=h[i] for j in range(i): left=max(h[j],left) right=h[i] for j in range(i+1,n): right=max(h[j],right) total+=min(left,right)-h[i] return total print(trapped...
height = list(map(int, input().split())) height def trapped_water(h): n = len(h) total = 0 for i in range(1, n - 1): left = h[i] for j in range(i): left = max(h[j], left) right = h[i] for j in range(i + 1, n): right = max(h[j], right) total +=...
a=((1, 1, 1, 1), # matrix A # (2, 4, 8, 16), (3, 9, 27, 81), (4, 16, 64, 256)) b=(( 4 , -3 , 4/3., -1/4. ), # matrix B # (-13/3., 19/4., -7/3., 11/24.), ( 3/2., -2. , 7/6., -1/4. ), ( -1/6., 1/4., -1/6., 1/24.)) def MatrixMul( mtx_a, mtx_b): tpos_b = list(zip(...
a = ((1, 1, 1, 1), (2, 4, 8, 16), (3, 9, 27, 81), (4, 16, 64, 256)) b = ((4, -3, 4 / 3.0, -1 / 4.0), (-13 / 3.0, 19 / 4.0, -7 / 3.0, 11 / 24.0), (3 / 2.0, -2.0, 7 / 6.0, -1 / 4.0), (-1 / 6.0, 1 / 4.0, -1 / 6.0, 1 / 24.0)) def matrix_mul(mtx_a, mtx_b): tpos_b = list(zip(*mtx_b)) rtn = [[sum((ea * eb for (ea, eb...
# # PySNMP MIB module HPN-ICF-WEB-AUTHENTICATION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-WEB-AUTHENTICATION-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:42:05 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection, constraints_union) ...
COLORS = { 'darkest_blue': '#111111', 'background_blue': '#0C172D', 'text_green': '#54F041', 'dev_purple': '#ab52c5', 'loc_pink': '#f6c6fa', 'great_depression_red': '#C90705', 'walter_white': '#FFFFFF' }
colors = {'darkest_blue': '#111111', 'background_blue': '#0C172D', 'text_green': '#54F041', 'dev_purple': '#ab52c5', 'loc_pink': '#f6c6fa', 'great_depression_red': '#C90705', 'walter_white': '#FFFFFF'}
class Order: Clayful = None name = 'Order' path = 'orders' @staticmethod def config(clayful): Order.Clayful = clayful return Order @staticmethod def accept_refund(*args): return Order.Clayful.call_api({ 'model_name': Order.name, 'method_name': 'accept_refund', 'http_method': ...
class Order: clayful = None name = 'Order' path = 'orders' @staticmethod def config(clayful): Order.Clayful = clayful return Order @staticmethod def accept_refund(*args): return Order.Clayful.call_api({'model_name': Order.name, 'method_name': 'accept_refund', 'http_...
def neighboors(active, x, y, width, height): number = 0 for i in range(-1, 2): for j in range(-1, 2): #Skip the choosen block if 0 <= x+i < width and 0 <= y+j < height: if i == 0 and j == 0: pass elif active[x+i][y+j] == 1: ...
def neighboors(active, x, y, width, height): number = 0 for i in range(-1, 2): for j in range(-1, 2): if 0 <= x + i < width and 0 <= y + j < height: if i == 0 and j == 0: pass elif active[x + i][y + j] == 1: number += 1 ...
''' --- Day 10: Balance botValues --- You come upon a factory in which many robots are zooming around handing small microchips to each other. Upon closer examination, you notice that each bot only proceeds when it has two microchips, and once it does, it gives each one to a different bot or puts it in a marked "outpu...
""" --- Day 10: Balance botValues --- You come upon a factory in which many robots are zooming around handing small microchips to each other. Upon closer examination, you notice that each bot only proceeds when it has two microchips, and once it does, it gives each one to a different bot or puts it in a marked "outpu...
#conjunto de cartas class Card: def __init__(self,suit,value): super().__init__() self.suit =suit self.value = value #reescribimos la salida al imprimir def __repr__(self): return " of ".join((self.value,self.suit))
class Card: def __init__(self, suit, value): super().__init__() self.suit = suit self.value = value def __repr__(self): return ' of '.join((self.value, self.suit))
#!/usr/bin/python filename = input("Please enter your file name: ") with open(filename, 'r') as f: lines = f.readlines() l = list(line.rstrip('\n') for line in lines) measurements_count = 0 while len(l) != 1: if l[0] < l[1]: measurements_count += 1 del(l[0]) else: print(f"There are {measurements_count} measur...
filename = input('Please enter your file name: ') with open(filename, 'r') as f: lines = f.readlines() l = list((line.rstrip('\n') for line in lines)) measurements_count = 0 while len(l) != 1: if l[0] < l[1]: measurements_count += 1 del l[0] else: print(f'There are {measurements_count} measurmen...
class BasePlugin: name = None description = None package_name = None class ExportPlugin(BasePlugin): format_type = None def format(self): raise NotImplementedError() def help(self): return f"For help check the official documentation for '{self.package_name}' plugin."
class Baseplugin: name = None description = None package_name = None class Exportplugin(BasePlugin): format_type = None def format(self): raise not_implemented_error() def help(self): return f"For help check the official documentation for '{self.package_name}' plugin."
""" Module that defines the mappings for CSV rows, variable names in code and DHIS2 UIDs set_order: used to set certain Verbal Autopsy properties before others (dependants). needs to be an integer. csv_name: CSV column name if none => there is no column in the CSV for this property example: Age in Days dhis_uid: DH...
""" Module that defines the mappings for CSV rows, variable names in code and DHIS2 UIDs set_order: used to set certain Verbal Autopsy properties before others (dependants). needs to be an integer. csv_name: CSV column name if none => there is no column in the CSV for this property example: Age in Days dhis_uid: DHI...
''' A builder design pattern is a type of design pattern in which large complex objects are created without letting end user know about the complexity fo teh objects E.g: In the example below teh document object is made up of text,image, line, table objects but the end used is not aware of creation of all these obje...
""" A builder design pattern is a type of design pattern in which large complex objects are created without letting end user know about the complexity fo teh objects E.g: In the example below teh document object is made up of text,image, line, table objects but the end used is not aware of creation of all these obje...
#Jackknife reduction templates for NIRC2 and OSIRIS pipelines. #Author: Sean Terry def jackknife(): """ Do the Jackknife data reduction. """ ########## # # NIRC2 Format # ########## ########## # Ks-band reduction ########## # Nite 1 target = 'MB07192' sci_file...
def jackknife(): """ Do the Jackknife data reduction. """ target = 'MB07192' sci_files1 = list(range(173, 177 + 1)) sky_files1 = list(range(206, 215 + 1)) ref_src1 = [385.0, 440.0] sky.makesky(sky_files1, 'nite1', 'ks', instrument=nirc2) data.clean(sci_files1, 'nite1', 'ks', refSrc1,...
# -*- coding: utf-8 -*- class Data: def __init__(self, d): seqs = tuple, list, set, frozenset for i, j in d.items(): if isinstance(j, dict): setattr(self, i, Data(j)) elif isinstance(j, seqs): setattr(self, i, type(j)(Data(sj) if isinstance(sj...
class Data: def __init__(self, d): seqs = (tuple, list, set, frozenset) for (i, j) in d.items(): if isinstance(j, dict): setattr(self, i, data(j)) elif isinstance(j, seqs): setattr(self, i, type(j)((data(sj) if isinstance(sj, dict) else sj for...
#! /usr/bin/env python3 days = int(input("Enter days:")) months = days // 30 days = days % 30 print("Months = {} Days = {}".format(months, days))
days = int(input('Enter days:')) months = days // 30 days = days % 30 print('Months = {} Days = {}'.format(months, days))
# # PySNMP MIB module CISCO-ITP-TC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ITP-TC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:46:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_intersection, constraints_union, value_range_constraint, value_size_constraint) ...
nums = [1, 2, 3, 4, 5] for num in nums: print(num+1) print('-------------') for i in range(3): print(i)
nums = [1, 2, 3, 4, 5] for num in nums: print(num + 1) print('-------------') for i in range(3): print(i)
class Node: def __init__(self, data: int): self.data: int = data self.next: Node = None class LinkedList: def __init__(self, head: Node = None): self.head = head def push(self, data: int): node = Node(data) if not self.head: self.head = node el...
class Node: def __init__(self, data: int): self.data: int = data self.next: Node = None class Linkedlist: def __init__(self, head: Node=None): self.head = head def push(self, data: int): node = node(data) if not self.head: self.head = node else...
# <html><body><pre> # RLinterface module """ This module provides a standard interface for computational experiments with reinforcement-learning agents and environments. The interface is designed to facilitate comparison of different agent designs and their application to different problems (environments). See http...
""" This module provides a standard interface for computational experiments with reinforcement-learning agents and environments. The interface is designed to facilitate comparison of different agent designs and their application to different problems (environments). See http://abee.cs.ualberta.ca:7777/rl-twiki/bin/vi...
def convert(file_1, file_2, file_out): def read_origin(file_in): # Dumps from sfrolov are raw arrays of bytes strictly following the internal address space of 1/2 of BRP unit. return file_in.read() if file_in is not None else bytes(2048) def write_derivative(bytes_4096, file_out): s = ...
def convert(file_1, file_2, file_out): def read_origin(file_in): return file_in.read() if file_in is not None else bytes(2048) def write_derivative(bytes_4096, file_out): s = bytes_4096.hex('\t').expandtabs(2) file_out.write(''.join([s[i:i + 8 * 4].strip() + '\n' for i in range(0, len(...
def binSearchClosest(list, key): if list==[]: return None elif len(list)==1: return 0 left=0; right=len(list)-1 # binary search while left<right: mid = (left + right) // 2 if list[mid]==key: # found return mid elif list[mid]>key: righ...
def bin_search_closest(list, key): if list == []: return None elif len(list) == 1: return 0 left = 0 right = len(list) - 1 while left < right: mid = (left + right) // 2 if list[mid] == key: return mid elif list[mid] > key: right = mid -...
harmonization_table = { "Trees": ["Trees", "CEO_Trees", "GO_Trees"], "Shrubland": ["Shrubland", "CEO_Shrubland", "GO_Shrub"], "Grassland": ["Grassland", "CEO_Grassland", "GO_Grass"], "Cropland": ["Cropland", "CEO_Cropland", "GO_Cultivated"], "Built-up": ["Built-up", "CEO_BuiltUp", "GO_BuiltUp"], ...
harmonization_table = {'Trees': ['Trees', 'CEO_Trees', 'GO_Trees'], 'Shrubland': ['Shrubland', 'CEO_Shrubland', 'GO_Shrub'], 'Grassland': ['Grassland', 'CEO_Grassland', 'GO_Grass'], 'Cropland': ['Cropland', 'CEO_Cropland', 'GO_Cultivated'], 'Built-up': ['Built-up', 'CEO_BuiltUp', 'GO_BuiltUp'], 'Barren': ['Barren / Spa...
""" talking clock returns word version of 24hour time wisemonkey oranbusiness@gmail.com 20181219 github.com/wisehackermonkey run tests with command python -m nose """ hour_names = ["twelve","one","two","three","four","five","six","seven", "eight","nine","ten","eleven","twelve","thirteen","fourteen", "fifteen","sixt...
""" talking clock returns word version of 24hour time wisemonkey oranbusiness@gmail.com 20181219 github.com/wisehackermonkey run tests with command python -m nose """ hour_names = ['twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fi...
#!/usr/bin/env python # coding: utf-8 _JOINT_NAMES_1 = [ 'Waist', 'Torso', 'Neck', 'Head', 'LeftShoulder', 'LeftElbow', 'LeftWrist', 'LeftHand', 'RightShoulder', 'RightElbow', 'RightWrist', 'RightHand', 'LeftHip', 'LeftKnee', 'LeftAnkle', 'LeftFoot', 'RightHip', 'RightKnee', 'RightAnkle', 'RightFoo...
_joint_names_1 = ['Waist', 'Torso', 'Neck', 'Head', 'LeftShoulder', 'LeftElbow', 'LeftWrist', 'LeftHand', 'RightShoulder', 'RightElbow', 'RightWrist', 'RightHand', 'LeftHip', 'LeftKnee', 'LeftAnkle', 'LeftFoot', 'RightHip', 'RightKnee', 'RightAnkle', 'RightFoot'] _articulated_figure_angles_1 = {'rshldr_theta': ('RightS...
F_BOIL_TEMP = 212.0 F_FREEZE_TEMP = 32.0 C_BOIL_TEMP = 100.0 C_FREEZE_TEMP = 0.0 F_RANGE = F_BOIL_TEMP - F_FREEZE_TEMP C_RANGE = C_BOIL_TEMP - C_FREEZE_TEMP F_C_RATIO = C_RANGE / F_RANGE def ftoc(f_temp): "Convert Fahrenheit temperature <f_temp> to Celsius and return it." c_temp = (f_temp - F_FREEZE_TEMP) * F_...
f_boil_temp = 212.0 f_freeze_temp = 32.0 c_boil_temp = 100.0 c_freeze_temp = 0.0 f_range = F_BOIL_TEMP - F_FREEZE_TEMP c_range = C_BOIL_TEMP - C_FREEZE_TEMP f_c_ratio = C_RANGE / F_RANGE def ftoc(f_temp): """Convert Fahrenheit temperature <f_temp> to Celsius and return it.""" c_temp = (f_temp - F_FREEZE_TEMP) ...
class Solution: def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ dict_s = {} dict_t = {} for c in s: if c not in dict_s: dict_s[c] = 1 else: dict_s[c] += 1 for c...
class Solution: def is_anagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ dict_s = {} dict_t = {} for c in s: if c not in dict_s: dict_s[c] = 1 else: dict_s[c] += 1 for c...
S = input() t = 0 for i in range(0, len(S), 5): if S[i:i + 5] == '(^^*)': t += 1 print(t, len(S) // 5 - t)
s = input() t = 0 for i in range(0, len(S), 5): if S[i:i + 5] == '(^^*)': t += 1 print(t, len(S) // 5 - t)
""" Insert sort O(n**2) """ def insert_sort(a): n = len(a) for top in range(1, n): k = top while k > 0 and a[k-1] > a[k]: a[k], a[k-1] = a[k-1], a[k] k -= 1 return a def test_insert_sort(): """ Tests """ assert(insert_sort([3, 2, 5, 7, 3, 4, 7, 0, 3, 1, ...
""" Insert sort O(n**2) """ def insert_sort(a): n = len(a) for top in range(1, n): k = top while k > 0 and a[k - 1] > a[k]: (a[k], a[k - 1]) = (a[k - 1], a[k]) k -= 1 return a def test_insert_sort(): """ Tests """ assert insert_sort([3, 2, 5, 7, 3, 4, 7, 0...
class DotDict(dict): """A class that extends dict to allow accessing keys as attributes.""" def __init__(self, *args, **kwargs): """Initalize the DotDict. This method does nothing other that initialize the parent dict with the passed args and kwargs. """ super...
class Dotdict(dict): """A class that extends dict to allow accessing keys as attributes.""" def __init__(self, *args, **kwargs): """Initalize the DotDict. This method does nothing other that initialize the parent dict with the passed args and kwargs. """ super(...
class BasePayload(object): _name = "Default" _code = None _activated = False _conf = None _stager_path = "" def setHandler(self, IP, PORT): d = dict() d['SERVER'] = IP d['PORT'] = PORT self.setCode(d) def setActivated(self, status): ...
class Basepayload(object): _name = 'Default' _code = None _activated = False _conf = None _stager_path = '' def set_handler(self, IP, PORT): d = dict() d['SERVER'] = IP d['PORT'] = PORT self.setCode(d) def set_activated(self, status): self._activated...
n = int(input()) registered_users = dict() for i in range(n): command = input() tokens = command.split(' ') action = tokens[0] if action == 'register': username = tokens[1] licence_plate = tokens[2] if username not in registered_users: registered_users[usern...
n = int(input()) registered_users = dict() for i in range(n): command = input() tokens = command.split(' ') action = tokens[0] if action == 'register': username = tokens[1] licence_plate = tokens[2] if username not in registered_users: registered_users[username] = lic...
# How do you read and write to a specific file : # We have a few different ways to do that using a file stream : # To open a file, you create a stream object # we determine the file name and the mode, most of time we leave the buffer_size ti the default stream = open(file_name, mode, buffer_size) # Modes : # r - Rea...
stream = open(file_name, mode, buffer_size) print(stream.readable()) print(stream.readable(1)) print(stream.readline()) stream.close() stream = open('output.txt', 'wt') stream.write('H') stream.writelines(['ello', 'World']) stream.write('\n') names = ['Ali', 'Hani'] stream.writelines(names) stream.close() stream = open...
number_employee = int(input('')) hours = int(input()) value_work_hour = float(input()) salary = hours * value_work_hour print('NUMBER = {}'.format(number_employee)) print('SALARY = U$ {:.2f}'.format(salary))
number_employee = int(input('')) hours = int(input()) value_work_hour = float(input()) salary = hours * value_work_hour print('NUMBER = {}'.format(number_employee)) print('SALARY = U$ {:.2f}'.format(salary))
# dummy request object class DummyReq: # constructor def __init__(self,env,): # environ self.subprocess_env = env # header self.headers_in = {} # content-length if self.subprocess_env.has_key('CONTENT_LENGTH'): self.headers_in["content-length"] = self....
class Dummyreq: def __init__(self, env): self.subprocess_env = env self.headers_in = {} if self.subprocess_env.has_key('CONTENT_LENGTH'): self.headers_in['content-length'] = self.subprocess_env['CONTENT_LENGTH'] def get_remote_host(self): if self.subprocess_env.has_...
#!/usr/bin/env python3 """Enumerates primes using the sieve of Eratosthenes. Verification: [0009](https://onlinejudge.u-aizu.ac.jp/status/users/hamukichi/submissions/1/0009/judge/4571021/Python3) """ def sieve_of_eratosthenes(end): """Enumerates prime numbers below the given integer `end`. Returns (as a tu...
"""Enumerates primes using the sieve of Eratosthenes. Verification: [0009](https://onlinejudge.u-aizu.ac.jp/status/users/hamukichi/submissions/1/0009/judge/4571021/Python3) """ def sieve_of_eratosthenes(end): """Enumerates prime numbers below the given integer `end`. Returns (as a tuple): - `is_prime`: ...
class Person(object): def __init__(self, fn, ln): self.first_name = fn self.last_name = ln
class Person(object): def __init__(self, fn, ln): self.first_name = fn self.last_name = ln
""" Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are u...
""" Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are u...
class Solution: def minCostToMoveChips(self, chips: List[int]) -> int: count = [0] * 2 for chip in chips: count[chip % 2] += 1 return min(count[0], count[1])
class Solution: def min_cost_to_move_chips(self, chips: List[int]) -> int: count = [0] * 2 for chip in chips: count[chip % 2] += 1 return min(count[0], count[1])
#!/usr/bin/env python # encoding: utf-8 """ symmetric_tree.py Created by Shengwei on 2014-07-04. """ # https://oj.leetcode.com/problems/symmetric-tree/ # tags: medium, tree, recursion """ Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is ...
""" symmetric_tree.py Created by Shengwei on 2014-07-04. """ '\nGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).\n\nFor example, this binary tree is symmetric:\n\n 1\n / 2 2\n / \\ / 3 4 4 3\nBut the following is not:\n 1\n / 2 2\n \\ 3 3\nNot...
""" .. _compas_fea.app: ******************************************************************************** app ******************************************************************************** .. module:: compas_fea.app The compas_fea package PyQt and Vtk application. app === .. currentmodule:: compas_fea.app.app :...
""" .. _compas_fea.app: ******************************************************************************** app ******************************************************************************** .. module:: compas_fea.app The compas_fea package PyQt and Vtk application. app === .. currentmodule:: compas_fea.app.app :...
test = { 'name': 'q2_1', 'points': 1, 'suites': [ { 'cases': [ { 'code': r""" >>> prof_names.num_columns 2 """, 'hidden': False, 'locked': False }, { 'code': r""" >>> prof_names.num_rows 71 ...
test = {'name': 'q2_1', 'points': 1, 'suites': [{'cases': [{'code': '\n >>> prof_names.num_columns\n 2\n ', 'hidden': False, 'locked': False}, {'code': '\n >>> prof_names.num_rows\n 71\n ', 'hidden': False, 'locked': False}, {'code': '\n >>> # Make sure tha...
print("Welcome to the professor quality calculator by MillenniumWare!") print("Follow the prompts below to calculate how good your professor is!!!") print("************************") print("") name = input("Enter your professor's name! >") print("") print("On a scale of 1-5 (1 being horrible, 2 tolerable, 3 adequ...
print('Welcome to the professor quality calculator by MillenniumWare!') print('Follow the prompts below to calculate how good your professor is!!!') print('************************') print('') name = input("Enter your professor's name! >") print('') print('On a scale of 1-5 (1 being horrible, 2 tolerable, 3 adequate, 4...
""" Remove Duplicates from Sorted List II Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2->3, return 2->3. """ class ListNode(object): def __init__(self, x): ...
""" Remove Duplicates from Sorted List II Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2->3, return 2->3. """ class Listnode(object): def __init__(self, x): ...
def convert_fasta_to_string(filename): """Takes a genome FASTA and outputs a string of that genome Args: filename: fasta file Returns: string of the genome sequence """ assert filename.split('.')[-1] == 'fasta' # assert correct file type with open(filename) as f: sequenc...
def convert_fasta_to_string(filename): """Takes a genome FASTA and outputs a string of that genome Args: filename: fasta file Returns: string of the genome sequence """ assert filename.split('.')[-1] == 'fasta' with open(filename) as f: sequence = ''.join(f.read().split('...
# -*- coding: utf-8 -*- """ Created on Sat Jan 27 16:27:44 2018 @author: positiveoutlier Guess the Number Game! The user thinks of an integer between 0 (inclusive) and 100 (not inclusive). The computer makes guesses, and the user will give it input - is its guess too high or too low? Using bisection search, the com...
""" Created on Sat Jan 27 16:27:44 2018 @author: positiveoutlier Guess the Number Game! The user thinks of an integer between 0 (inclusive) and 100 (not inclusive). The computer makes guesses, and the user will give it input - is its guess too high or too low? Using bisection search, the computer will guess the use...
""" 49. How to filter every nth row in a dataframe? """ """ Difficulty Level: L1 """ """ From df, filter the 'Manufacturer', 'Model' and 'Type' for every 20th row starting from 1st (row 0). """ """ Input """ """ df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/Cars93_miss.csv') """
""" 49. How to filter every nth row in a dataframe? """ '\nDifficulty Level: L1\n' "\nFrom df, filter the 'Manufacturer', 'Model' and 'Type' for every 20th row starting from 1st (row 0).\n" '\nInput\n' "\ndf = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/Cars93_miss.csv')\n"
""" # Gallery .. include:: ../gallery/legend/README.md .. include:: ../gallery/colorbar/README.md .. include:: ../gallery/subplots/README.md """
""" # Gallery .. include:: ../gallery/legend/README.md .. include:: ../gallery/colorbar/README.md .. include:: ../gallery/subplots/README.md """
def test_empty(): """ I should learn how to write tests """ pass
def test_empty(): """ I should learn how to write tests """ pass
class Solution(object): def atMostNGivenDigitSet(self, D, N): B = len(D) # bijective-base B S = str(N) K = len(S) A = [] # The largest valid number in bijective-base-B. for c in S: if c in D: A.append(D.index(c) + 1) else: ...
class Solution(object): def at_most_n_given_digit_set(self, D, N): b = len(D) s = str(N) k = len(S) a = [] for c in S: if c in D: A.append(D.index(c) + 1) else: i = bisect.bisect(D, c) A.append(i) ...
""" 0528. Random Pick with Weight Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight. Note: 1 <= w.length <= 10000 1 <= w[i] <= 10^5 pickIndex will be called at most 10000 times. Example 1: Input: ["...
""" 0528. Random Pick with Weight Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight. Note: 1 <= w.length <= 10000 1 <= w[i] <= 10^5 pickIndex will be called at most 10000 times. Example 1: Input: ["...
#!/usr/bin/python3 def check(dx,dy): f=open("input","r") l=f.readlines() l=[l.strip('\n\r') for l in l] x=0 y=0 c=0 while(y<len(l)): if l[y][x]=='#': c+=1 x+=dx if x>=len(l[0]): x-=len(l[0]) y+=dy return (c) ...
def check(dx, dy): f = open('input', 'r') l = f.readlines() l = [l.strip('\n\r') for l in l] x = 0 y = 0 c = 0 while y < len(l): if l[y][x] == '#': c += 1 x += dx if x >= len(l[0]): x -= len(l[0]) y += dy return c print('1: ' + str(...
Import("env") # Access to global construction environment build_tag = env['PIOENV'] # Dump construction environment (for debug purpose) # print(env.Dump()) # Rename binary according to environnement/board # ex: firmware_esp32dev.bin or firmware_nodemcuv2.bin env.Replace(PROGNAME="firmware_%s" % build_tag)
import('env') build_tag = env['PIOENV'] env.Replace(PROGNAME='firmware_%s' % build_tag)
class Solution: def findRepeatedDnaSequences(self, s: str) -> List[str]: res = set() dic = {} for i in range(len(s)): temp = s[i:i+10] if temp not in dic: dic[temp]=1 else: res.add(temp) return res ...
class Solution: def find_repeated_dna_sequences(self, s: str) -> List[str]: res = set() dic = {} for i in range(len(s)): temp = s[i:i + 10] if temp not in dic: dic[temp] = 1 else: res.add(temp) return res
def make_exchange_name(namespace, exchange_type, extra=""): return "{}.{}".format(namespace, exchange_type) if not extra else "{}.{}@{}".format(namespace, exchange_type, extra) def make_channel_name(namespace, exchange_type): return "channel_on_{}.{}".format(namespace, exchange_type) def make_queue_name...
def make_exchange_name(namespace, exchange_type, extra=''): return '{}.{}'.format(namespace, exchange_type) if not extra else '{}.{}@{}'.format(namespace, exchange_type, extra) def make_channel_name(namespace, exchange_type): return 'channel_on_{}.{}'.format(namespace, exchange_type) def make_queue_name(names...
""" Test that the game controller is implemented properly. """ # Unit tests for the functions in tetris_controller require an interactive # form of testing like mock patch or event injection. We have verified that # the controller interacts with the game in an error-free manner, and that the # functions it calls run p...
""" Test that the game controller is implemented properly. """
def build_model(): pass def save_model(): pass def load_model(model_path): pass def load_best_model(): pass
def build_model(): pass def save_model(): pass def load_model(model_path): pass def load_best_model(): pass
# Databricks notebook source print("hello world") # COMMAND ---------- print("let's make some changes and commit!") # COMMAND ----------
print('hello world') print("let's make some changes and commit!")
#!/usr/bin/env python # test print('test!')
print('test!')
N = int(input()) V = list(map(int, input().split())) V.sort() v_sum = (V[0]+V[1]) / (2**(len(V)-1)) for i in range(2, len(V)): v_sum += V[i] / (2**(len(V)-i)) print(v_sum)
n = int(input()) v = list(map(int, input().split())) V.sort() v_sum = (V[0] + V[1]) / 2 ** (len(V) - 1) for i in range(2, len(V)): v_sum += V[i] / 2 ** (len(V) - i) print(v_sum)
class KeyValue: def __init__(self, key: None, value: None): self.key = key self.value = value class HashMap: def __init__(self, size:int = 11): self.size: int = size self.items: list = [None] * self.size self.length: int = 0 def put(self, key, value): keyVal...
class Keyvalue: def __init__(self, key: None, value: None): self.key = key self.value = value class Hashmap: def __init__(self, size: int=11): self.size: int = size self.items: list = [None] * self.size self.length: int = 0 def put(self, key, value): key_v...
class EllysTSP: def getMax(self, places): c = places.count('C') v = len(places) - c return 2 * min(c, v) + min(abs(c-v), 1)
class Ellystsp: def get_max(self, places): c = places.count('C') v = len(places) - c return 2 * min(c, v) + min(abs(c - v), 1)
students = [] def get_students_titlecase(): students_titlecase = [] for student in students: students_titlecase = student.title() return students_titlecase def print_students_titlecase(): student_titlecase = get_students_titlecase() print(students_titlecase) def add_student(name, student_id=223): student...
students = [] def get_students_titlecase(): students_titlecase = [] for student in students: students_titlecase = student.title() return students_titlecase def print_students_titlecase(): student_titlecase = get_students_titlecase() print(students_titlecase) def add_student(name, student_...
def posicionesAdyacentes2(self,fila,columna,mapa): retorno=[] #Norte if(fila>=1 and (mapa[fila-1][columna]!="W" and mapa[fila-1][columna]!="X")): retorno.append([fila-1,columna]) #Este if(columna<=10 and (mapa[fila][columna+1]!="W" and mapa[fila][columna+1]!="X")): ...
def posiciones_adyacentes2(self, fila, columna, mapa): retorno = [] if fila >= 1 and (mapa[fila - 1][columna] != 'W' and mapa[fila - 1][columna] != 'X'): retorno.append([fila - 1, columna]) if columna <= 10 and (mapa[fila][columna + 1] != 'W' and mapa[fila][columna + 1] != 'X'): retorno.appe...
for t in range(int(input())): a, b, threshold = map(int, input().split()) steps = 0 while a <= threshold and b <= threshold: if a < b: a += b else: b += a steps += 1 print(steps)
for t in range(int(input())): (a, b, threshold) = map(int, input().split()) steps = 0 while a <= threshold and b <= threshold: if a < b: a += b else: b += a steps += 1 print(steps)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def folly_deps(with_gflags = 1, with_syslibs = 0): if with_gflags: maybe( http_archive, name = "com_github_gflags_gflags", sha256 = "34af2f...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') def folly_deps(with_gflags=1, with_syslibs=0): if with_gflags: maybe(http_archive, name='com_github_gflags_gflags', sha256='34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc49...
n = int(input().strip()) x = [int(i) for i in input().strip().split(' ')] w = [int(i) for i in input().strip().split(' ')] s = sum([x[i]*w[i] for i in range(0,n)]) wmean = s/sum(w) print("{:0.1f}".format(wmean))
n = int(input().strip()) x = [int(i) for i in input().strip().split(' ')] w = [int(i) for i in input().strip().split(' ')] s = sum([x[i] * w[i] for i in range(0, n)]) wmean = s / sum(w) print('{:0.1f}'.format(wmean))
# Solution-1 - Lisa Murray # User needs to enter integer number = input("Please enter a positive integer:") # Number needs to be converted from string format to number format, and add 1 to inclued the number chosen num2 = int(number) + 1 # Creating variable for sum sum = 0 # create loop to loop through all numbers ...
number = input('Please enter a positive integer:') num2 = int(number) + 1 sum = 0 for i in range(num2): sum += i print(sum)
words = ('Oi', 'eu', 'aprendo', 'Python', 'pelo', 'Curso', 'em', 'video') for p in words: print(f'\nNa palavra {p.upper()} temos ', end='') for letra in p: if letra.lower() in 'aeiou': print(letra, end=' ')
words = ('Oi', 'eu', 'aprendo', 'Python', 'pelo', 'Curso', 'em', 'video') for p in words: print(f'\nNa palavra {p.upper()} temos ', end='') for letra in p: if letra.lower() in 'aeiou': print(letra, end=' ')
# Event: LCCS Python Fundamental Skills Workshop # Date: May 2018 # Author: Joe English, PDST # eMail: computerscience@pdst.ie # Purpose: A program to calculate the average height of 5 people # Version: 1.0 (This program contains deliberate errors) print("Average height calculator") print("====================...
print('Average height calculator') print('=========================') h1 = int(input('Enter first height (cm): ')) h2 = int(input('Enter second height (cm): ')) h3 = int(input('Enter third height (cm): ')) h4 = int(input('Enter fourth height (cm): ')) h5 = int(input('Enter fifth height (cm): ')) avg_heigth = h1 + h2 + ...
class Solution: # @param word1 & word2: Two string. # @return: The minimum number of steps. def minDistance(self, word1, word2): # write your code here if word1 == word2: return 0 if len(word1) == 0: return len(word2) if len(word2) == 0: re...
class Solution: def min_distance(self, word1, word2): if word1 == word2: return 0 if len(word1) == 0: return len(word2) if len(word2) == 0: return len(word1) (m, n) = (len(word1), len(word2)) d = [[0 for j in xrange(n + 1)] for i in xrange...