content
stringlengths
7
1.05M
def busca_linear_recursiva(elemento, l, idx=0): if elemento == l[idx]: return idx if idx == len(l)-1: return -1 return busca_linear_recursiva(elemento, l, idx + 1) def busca_linear(elemento, l): for i, e in enumerate(l): if elemento == e: return i return -1 if...
"""Card Games - Exercism Python Exercises""" def get_rounds(number): """ :param number: int - current round number. :return: list - current round and the two that follow. """ return [number, number + 1, number + 2] def concatenate_rounds(rounds_1, rounds_2): """ :param rounds_1: list -...
#Accept a list of words and return length of longest word. def long_word(word_list): word_len=[] for word in word_list: word_len.append((len(word),word)) word_len.sort() return word_len[-1][0], word_len[-1][1] word=long_word(["hai","everyone","bye"]) print("\nThe longest word is: ",wor...
# 5-5 Problems print(all([1, 2, abs(-3)-3])) print(chr(ord('a')) == 'a') x = [1, -2, 3, -5, 8, -3] print(list(filter(lambda val: val > 0, x))) x = hex(234) print(int(x, 16)) x = [1, 2, 3, 4] print(list(map(lambda a: a * 3, x))) x = [-8, 2, 7, 5, -3, 5, 0, 1] print(max(x) + min(x)) x = 17 / 3 pri...
"""https://code.google.com/codejam/contest/10284486/dashboard#s=p1&a=1""" def main(): T = int(input()) for i in range(1, T + 1): N, K, P = (int(s) for s in input().split()) A = [] B = [] C = [] for _ in range(K): a, b, c = (int(s) for s in input().split()) ...
n = int(input('Digite um numero: ')) print('O dobro de n é:', n**2 ) print('O triplo de n é: ', n ** 3 ) print('A raiz quadrada de n é:', n ** (1/2 )) print('A raiz quadrada de n é {:.3f}' .format(n ** (1/2)))
def get_max_profits(stock_prices): if len(stock_prices) < 2: raise ValueError("Getting a profit requires at least two prices") min_price = stock_prices[0] max_profit = stock_prices[1] - stock_prices[0] for current_time in range(1, len(stock_prices)): print(current_time, "currenttime") ...
""" Leetcode #1185 """ class Solution: # if we know that 1/1/1971 was Friday def dayOfTheWeek(self, day: int, month: int, year: int) -> str: isLeapYear = lambda x: 1 if x % 400 == 0 or (x % 4 == 0 and x % 100 != 0) else 0 months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] d...
# https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher PLAINTEXT = 'ATTACKATDAWN' KEY = 'LEMON' def vigenere_cipher_func(key, message): message = message.lower() key = key.lower() cipher_message = '' key_value = 0 for char in message: if ord(char) >= 97 and ord(char) < 134: mi...
princ = [[], []] valor = 0 for c in range(1,8): valor = int(input(f"Digite o {c}º valor: ")) if valor % 2 == 0: princ[0].append(valor) else: if valor % 2 != 0: princ[1].append(valor) princ[0].sort() princ[1].sort() print(f"Os números pares são: {princ[0]}") print(f"Os números ímp...
# # PySNMP MIB module SVRNTCLU-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SVRNTCLU-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:04:39 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,...
""" Placeholder test file. We'll add a bunch of tests here in later versions. """ def test_add(): """Placeholder test.""" pass
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 30 22:35:24 2021 @author: aboisvert """ #%% Part 1 """ As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: ea...
def iteritems(dictonary): pass class StringIO(object): pass
def dfs(node, parent, visited, tin, low, adj:list, timer,res): visited[node] = 1 timer += 1 tin[node] = low[node] = timer for it in adj[node]: if(it == parent): continue if(visited[it] == 0): dfs(it, node, visited, tin, low, adj, timer,res) low...
n1 = int(input('Digite qualquer numero: ')) a = n1 - 1 p = n1 + 1 print('O numero escolhido é {}, seu anterior é {}, e seu posterior é {}.'.format(n1, a, p))
r= int(input()) pi= 3.14159 sphere= (4/3)* pi* pow(r,3) print("VOLUME = %.3f" %sphere)
class CoreConstraintConstants: core_constraint_slots = ( "table", "constraint_name", "constraint_definition", "UNIQUE", "PRIMARY_KEY", "FOREIGN_KEY", "REFERENCES", "CHECK", "DEFAULT", "FOR" ) core_constraint_default_values = { "table": None, "constraint_name": None, ...
dis = int(input('Qual a Distância da Viagem: ')) if dis>=200: print(f'Vocâ pagará {dis*0.45}') else: print(f'Vocâ pagará {dis*0.50}')
# -*- coding: utf-8 -*- COMMIT_AUTHOR_NAME = 'Mimiron' COMMIT_AUTHOR_EMAIL = ''
class LookupBindingPropertiesAttribute(Attribute,_Attribute): """ Specifies the properties that support lookup-based binding. This class cannot be inherited. LookupBindingPropertiesAttribute() LookupBindingPropertiesAttribute(dataSource: str,displayMember: str,valueMember: str,lookupMember: str) """ d...
# # PySNMP MIB module IP-FORWARD-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/IP-FORWARD-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:17:45 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52) # ...
class InvalidSignatureError(Exception): """ User signature is not valid.""" class BadRequestError(Exception): """ Indicates a malformed request or missing parameters."""
# Declare any variables (as constants) that are or could be used anywhere in the application # TODO: Determine what a good fingerprint length is FINGERPRINT_LENGTH = 40
def multi(a,b): return a*b if __name__ == '__main__': print(multi(2,3))
class LayerShape: def __init__(self, *dims): self.dims = dims if len(dims) == 1: self.channels = dims[0] elif len(dims) == 2: self.channels = dims[0] self.height = dims[1] elif len(dims) == 3: self.channels = dims[0] self.he...
nota1 = float(input('Digite a primeira nota :')) nota2 = float(input('Digite a segunda nota:')) media = (nota1+nota2) / 2 print('A média é {:.1f}'.format(media)) if media < 5.0: print('Reprovado') elif media == 5.0 or media <= 6.9: print('Recuperação') elif media >= 7.0: print('Aprovado')
# Time: O(Log n) We performed a Binary Search # Space: O(1) class Solution: def findMin(self, nums): if len(nums) == 1: return nums[0] left = 0 right = len(nums) - 1 if nums[0] < nums[right]: return nums[0] while left <= right: m...
def foo_task(): print('Foo task is running...') print('Foo task completed.') return True def sum_task(arg_1: int, arg_2: int): print('Sum task is running...') result = arg_1 + arg_2 print('Sum task completed.') return result
#!/usr/bin/env python3 # Tax calculator # This program currently # only works with the hungarian tax def calcTax(cost, country='hungary'): countries = {'hungary' : 27} if country in countries.keys(): tax = (cost / 100) * countries[country] else: return "Country can't be found" retur...
""" Write code to add, search and remove items from an unsorted linked list. """ class LinkedList: def __init__(self): self.length = 0 self.head = None def add(self, cargo): _next = self.head self.head = Node(cargo, _next) self.length += 1 def search(self, value):...
def boarding_pass_row(seq): assert len(seq) == 7 # FBFBBFF seqb = seq.replace('F', '0').replace('B', '1') return int(seqb, 2) def boarding_pass_col(seq): assert len(seq) == 3 seqb = seq.replace('R', '1').replace('L', '0') return int(seqb, 2) def row_id(seq): row, col = boarding_pass_row(seq[:7]), boardin...
''' Details about this Python package. ''' __version__ = '1.1.0' __title__ = 'example-python' __author__ = 'Mahathir Almashor' __author_email__ = 'mahathir.almashor@data61.csiro.au' __description__ = 'Example Python repository for Cyber Security Cooperative Research Centre' __url__ = 'https://github.com/ma-al/example-...
# Create query to get call counts by complaint_type query = """ SELECT complaint_type, COUNT(*) FROM hpd311calls GROUP BY complaint_type; """ # Create data frame of call counts by issue calls_by_issue = pd.read_sql(query, engine) # Graph the number of calls for each housing issue calls_by_issue.plot.barh(x...
# coding=utf-8 # # @lc app=leetcode id=589 lang=python # # [589] N-ary Tree Preorder Traversal # # https://leetcode.com/problems/n-ary-tree-preorder-traversal/description/ # # algorithms # Easy (66.23%) # Likes: 226 # Dislikes: 35 # Total Accepted: 43.8K # Total Submissions: 64.8K # Testcase Example: '{"$id":"1"...
with open("day13.in") as f: lines = f.read().splitlines() dots = set() for i, line in enumerate(lines): if line == "": break x, y = line.split(",") dots.add((int(x), int(y))) # folds for line in lines[i+1:]: _, _, fold = line.split(" ") axis, num = fold.split("=") num = int(num...
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( num ) : series = [ 1 , 3 , 2 , - 1 , - 3 , - 2 ] ; series_index = 0 ; result = 0 ; for i in range (...
VALUE_INITIALIZED = 0 def test_owner_address(box, accounts): # verify that accounts[0] is contract owner assert accounts[0].address == box.owner() def test_value_after_contract_creation(box, accounts): # verify initialized value of box assert VALUE_INITIALIZED == box.retrieve()
"""Module that implements mocking Vega type coercing functions.""" type_coercing_functions = ['toBoolean', 'toDate', 'toNumber', 'toString'] error_message = ' is a mocking function that is not supposed to be called directly' def toBoolean(value): """Coerce the input value to a string. None values and empty stri...
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def preorder(self, root): """ :type root: Node :rtype: List[int] """ result = [] self.dfs_rec(ro...
# 调查 favorite_languages = {'jen': 'python', 'sarah': 'c'} investigate_names = ['jen', 'singi'] for name in investigate_names: if name in favorite_languages.keys(): print('thank you for invastigation.') else: print('please do this investigation.')
# This file creates custom rules to make tests can easily run under # certain environment(like inside a docker). # # For example: # # run_under_test( # name = "test_under_docker", # under = "//tools/docker:zookeper", # command = "//sometest", # data = [ # ], # args = [ # "--gtest_filter=abc", # ] # ) ...
# x = n^2 + an + b; |a| < 1000 and |b| < 1000 # b has to be odd, positive and prime as we are testing consecutive values for n # a has to be negative otherwise the difference between consecutive x's will be huge! def is_prime(num) : if (num <= 1) : return False if (num <= 3) : return True...
linz = '---' * 30 # This is the Procedual way of creating a GUI '''import tkinter def main(): #creates the main window main_window = tkinter.Tk() # Enters the Tkinter main loop tkinter.mainloop() # Calls the main function main() print(linz)''' linz = '---' * 30 # This is the Module way of creating a...
""" File: boggle.py Name: 鄭凱元 ---------------------------------------- This program will use 4*4 English letters to concatenate words, The method of concatenating letters can include all the surrounding neighbors, but you can only add once """ # This is the file name of the dictionary txt file # we will be checking if...
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) nlist = [[i,j,k] for i in range(0, x+1) for j in range(0, y+1) for k in range(0, z+1) if (i+j+k) > n or (i+j+k)< n] print(nlist)
""" Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print 'a...
# :coding: utf-8 # :copyright: Copyright (c) 2021 strack class StrackError(RuntimeError): """ Custom error class. """ def __init__(self, arg): self.args = arg
##Collect data: ''' #SMI: 2021/10/30 SAF: 308214 Standard Beamline 12-ID proposal: (CFN, 307961) create proposal: proposal_id( '2021_3', '307961_Dinca' ) #create the proposal id and folder %run -i /home/xf12id/.ipython/profile_collection/startup/users/30-user-Dinca2021C2B.py RE( shopen() ) # to...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not roo...
class Arithmetic: def __init__(self): self.value1 = 0 self.value2 = 0 def Accept(self, no1, no2): self.value1 = no1 self.value2 = no2 def Addition(self): result = self.value1 + self.value2 print("Addition is = ", result) def Subtraction(sel...
input = """####.#.##.###.#.#.##.#..###.#..#.#.#..##....#.###...##..###.##.#.#.#.##...##..#..#....#.#.##..#...## .##...##.##.######.#.#.##...#.#.#.#.#...#.##.#..#.#.####...#....#....###.#.#.#####....#.#.##.#.#.##. ###.##..#..#####.......#.########...#.####.###....###.###...#...####.######.#..#####.#.###....####.. ....#....
class Config(object) : #DETECTRON_URL = 'http://localhost/predictions' DETECTRON_URL = 'https://master-ainized-detectron2-gkswjdzz.endpoint.ainize.ai/predictions' #STANFORDNLP_URL = 'http://localhost:81/analyze' STANFORDNLP_URL = 'https://master-ainized-stanfordnlp-gkswjdzz.endpoint.ainize.ai/analyze'
""" From Kapil Sharma's lecture 11 Jun 2020 Given the head of a sll and a node, return its index (position). Assume that indexing starts at 0. Return -1 if index is not found. """ class Node: def __init__(self, data): self.data = data self.next = None def find_index(head, node): # Edge case...
# -*- coding: utf-8 -*- # AtCoder Beginner Contest def main(): n, a, b = list(map(int, input().split())) position = 0 for i in range(n): s, d = list(map(str, input().split())) if int(d) < a: d = a elif int(d) > b: d = b else: d = d ...
""" Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], targe...
class CFG: # Disease: _TARGET_R0 = 1.4 # before Test and Trace and Isolation DAYS_BEFORE_INFECTIOUS = 4 # t0 DAYS_INFECTIOUS_TO_SYMPTOMS = 2 # t1 DAYS_OF_SYMPTOMS = 5 # t2 PROB_SYMPTOMATIC = 0.6 # pS probability that an infected person develops actionable symptoms ...
getMappingUsageMetrics = [ { "names": [ "TotalBandwidth", "TotalHits", "HitRatio" ], "totals": [ "0.0", "0", "0.0" ], "type": "TOTALS" } ]
class Solution: def reverse(self, x: int) -> int: l = 0 val = 0 flag = 1 if x == 0: return x else: if x>0: val = x l = len(str(val)) else: val = -1*x l = len(str(val)) ...
class Solution: def oddCells(self, n: int, m: int, indices: list) -> int: row_operation = [False] * n col_operation = [False] * m for index in indices: row_id, col_id = index row_operation[row_id] = not row_operation[row_id] col_operation[col_id] = not co...
""" http://stackoverflow.com/questions/312443/#312464 """ def chunks(l, n): for i in range(0, len(l), n): yield l[i : i + n]
# FindControlUnderMouse() returns an existing control, not a new one, # so create this one by hand. f = Function(ExistingControlHandle, 'FindControlUnderMouse', (Point, 'inWhere', InMode), (WindowRef, 'inWindow', InMode), (SInt16, 'outPart', OutMode), ) functions.append(f) f = Function(ControlHandle, 'as_C...
print("Premier programme") nom = input("Donnez votre nom : ") print("Bonjour %s, comment vas-tu? " % nom)
def read_data(filename="data/input1.data"): with open(filename) as f: return f.read() def rot(l, i): offset = len(l) // 2 pos = (i+offset) % len(l) return l[pos] if l[pos] == l[i] else 0 if __name__ == "__main__": captcha = [int(x) for x in read_data()] captcha.append(captcha[0]) ...
""" appthwack.tests ~~~~~~~~~~~~~~~ Package which contains tests for the AppThwack client. """ __author__ = 'Andrew Hawker <andrew@appthwack.com>'
#################### version 1 ################################################# a = list(range(10)) # print(a, id(a)) res_1 = list(a) # print(res_1, id(res_1)) for i in a: if i in (3, 5): print(">>>", i, id(i)) res_1 = list(filter(lambda x: x != i, res_1)) # print(type(res_1), id(res_1))...
"""Given an integer, write a function to determine if it is a power of two.""" class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ if n == 1: return True num = 1 while num < n: num *= 2 if n / ...
def add_native_methods(clazz): def initPbuffer__long__long__boolean__int__int__(a0, a1, a2, a3, a4, a5): raise NotImplementedError() clazz.initPbuffer__long__long__boolean__int__int__ = initPbuffer__long__long__boolean__int__int__
class CompressString(object): def compress(self, string): if string is None or not string: return string result = '' prev_char = string[0] count = 0 for char in string: if char == prev_char: count += 1 else: ...
class Solution: def findErrorNums(self, nums): """ :type nums: List[int] :rtype: List[int] """ record = [0] * (len(nums) + 1) for num in nums: record[num] += 1 dup, miss = 0, 0 for idx, val in enumerate(record): if val ...
def solution(a): answer = 0 left_min = 1000000001 left_zero = [] reverse_a = a[::-1] right_zero = [] right_min = 1000000001 for i in range(len(a)): left_min = min(a[i], left_min) if left_min == a[i]: left_zero.append(1) else: left_zero.append...
data = ( ((-0.195090, 0.980785), (0.000000, 1.000000)), ((-0.382683, 0.923880), (-0.195090, 0.980785)), ((-0.555570, 0.831470), (-0.382683, 0.923880)), ((-0.707107, 0.707107), (-0.555570, 0.831470)), ((-0.831470, 0.555570), (-0.707107, 0.707107)), ((-0.923880, 0.382683), (-0.831470, 0.555570)), ((-0.980785, 0.195090), ...
sum = float(input()) counter_of_coins = 0 sum = int(sum*100) counter_of_coins += sum // 200 sum = sum % 200 counter_of_coins += sum // 100 sum = sum % 100 counter_of_coins += sum // 50 sum = sum % 50 counter_of_coins += sum // 20 sum = sum % 20 counter_of_coins += sum // 10 sum = sum % 10 counter_of_coins += sum // 5 ...
def validate_string(s): is_alpha_numeric = False is_alpha = False is_digits = False is_lowercase = False is_uppercase = False for letter in s: if letter.isalnum(): is_alpha_numeric = True if letter.isalpha(): is_alpha = True if letter.isdigit():...
""" Exceptions ========== """ class AuditEventException(BaseException): pass
class TestScheduleJobFileData: test_job_connection = { "Name": "TestIntegrationConnection", "ConnectorTypeName": "POSTGRESQL", "Host": "localhost", "Port": 5432, "Sid": "", "DatabaseName": "test_pdi_integration", "User": "postgres", "Password": "123456...
# -*- coding: utf-8 -*- """ Label mapping. Created on Tue May 15 22:00:00 2018 Author: Prasun Roy | CVPRU-ISICAL (http://www.isical.ac.in/~cvpr) GitHub: https://github.com/prasunroy/air-writing """ # English numerals map2ascii_en_numbers = { 0: 48, 1: 49, 2: 50, 3: 51, 4: 52, ...
def func(a, b=5, c=10): print('a equals {}, b equals {}, and c equals {}'.format(a, b, c)) func(3, 7) func(25, c=24) func(c=50, a=100)
# encoding: utf-8 # module termios # from /usr/lib/python3.5/lib-dynload/termios.cpython-35m-x86_64-linux-gnu.so # by generator 1.145 """ This module provides an interface to the Posix calls for tty I/O control. For a complete description of these calls, see the Posix or Unix manual pages. It is only available for thos...
def isPrime(number): if number > 1: for i in range(2, number): if (number % i) == 0: return False else: return True else: return False inputFile = open('test.txt') lines = inputFile.readlines() inputFile.close() pyramid = [] for i in lines: pr...
""" Descrição: Este programa lê duas listas e gera uma terceira com os elementos das duas primeiras. Autor:Henrique Joner Versão:0.0.1 Data:07/01/2019 """ #Inicialização de variáveis produto1 = [] produto2 = [] dados = [] #Entrada de dados ProdutoNome = input("Digite o nome do produto: ") ProdutoTipo = input("Di...
def verify(output): scopes = False fail = False for line in output.split('\n'): if scopes: if line.startswith(' '): name,size = [x.strip() for x in line.split('-')] if size != '0': print("unfreed memory in scope",name,":",size) ...
#!/usr/bin/env python # coding: utf-8 def write_tweet_tfile(file_to_populate, text): file_handler = open(file_to_populate,"a+") file_handler.writelines(text) file_handler.close() def strip_token(myword, chars_token): return myword.strip(chars_token)
class Person: def __init__(self, name, email): self.name = name self.email = email self.all_my_emails = [] def send_email(self, to_user, message): print(f"send from {self.name} with email {self.email}") print(f"sending to {to_user} message {message}") return Tr...
# # @lc app=leetcode.cn id=782 lang=python3 # # [782] 变为棋盘 # # @lc code=start class Solution: def movesToChessboard(self, board) -> int: # basic parameters define dimension = len(board) nfloor = dimension // 2 nceil = nfloor + 1 if dimension % 2 else nfloor # 1. check row ...
################################### # SIMPLETICKET CONFIGURATION FILE # ################################### ############################################### # Flask Development Environment Configuration # ############################################### # This is not used when using the WSGI mod for apache. # interface...
N = int(input()) while True: S = [[] for k in range(N)] S_len = [0 for k in range(N)] bigger_len = 0 for k in range(N): S[k] = input().split() S_len[k] = sum([len(w) for w in S[k]]) + len(S[k]) - 1 if S_len[k] > bigger_len: bigger_len = S_len[k] for k in range(N): print(' ' * (bigger_len - S_len[k])...
def Final_Product(Check_list): Prod = 1 for ele in Check_list: Prod *= ele return Prod def Product_Matrix(Test_list): Semi_Result = Final_Product( [element for ele in Test_list for element in ele]) return Semi_Result Test_list = [[1, 4, 5], [7, 3], [4], [46, 7, 3]] ...
"""Utility functions""" class BraceMessage(object): """Helper class that can be used to construct log messages with the new {}-string formatting syntax. NOTE: When using this helper class, one pays no signigicant performance penalty since the actual formatting only happens when (and if) the logge...
# -*- coding: utf-8 -*- """Copy of ArraysAndStrings.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1VTh-TFOWmq3uxbCvBrDfUnb6Zj5IGlG_ # Arrays and Strings 16Bits = 2Bytes 8Bit, 16Bit, 32Bit, 64Bit, 128Bit ``` [123, "hello" ] A = ["Hello", 232, 1...
data = { 'slug': 'car', 'name': 'CAR', 'description': 'Cordillera Administrative Region', 'provinces': { 'abra': { 'slug': 'abra', 'name': 'Abra', 'municipalities': { 'bangued': { 'slug': 'bangued', 'name...
lines = "" while True: cur_inp = input() lines += cur_inp + "\n" if cur_inp == '0': break result = tuple(lines.split())
# -*- coding: utf-8 -*- ''' File name: code\maximum_quadrilaterals\sol_538.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #538 :: Maximum quadrilaterals # # For more information see: # https://projecteuler.net/problem=538 # Problem Stat...
s = input() vowels = "AEIOU" kevin, stuart = 0, 0 for i in range(len(s)): if s[i] in vowels: kevin += len(s) - i else: stuart += len(s) - i if kevin > stuart: print("Kevin " + str(kevin)) elif stuart > kevin: print("Stuart " + str(stuart)) else: print("Draw")
x = 5 y = 10 z = 22 if x > y : print ('x is greater than y') elif x < z : print (' x is lesser than z')
def fatorial(numero): f = 1 for c in range(1, numero +1): f *= c return f
[ { 'date': '2020-01-01', 'description': 'Nouvel An', 'locale': 'fr-BE', 'notes': '', 'region': '', 'type': 'NF' }, { 'date': '2020-04-12', 'description': 'Pâques', 'locale': 'fr-BE', 'notes': '', 'region': '', '...
#!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills # adding x here makes it in scope x = 0 for i in range(1,25): # x is in scope x = i + x # x is now out of scope print(x)
# -*- coding: utf-8 -*- class ResourceUnavailable(Exception): """Exception representing a failed request to a resource""" def __init__(self, msg, http_response): Exception.__init__(self) self._msg = msg self._status = http_response.status_code def __str__(self): return "%...
# Archivo: funciones.py # Autor: Javier Garcia Algarra # Fecha: 27 de diciembre de 2017 # Descripción: Manejo simple de funciones # En programación no es buena práctica repetir código # Volvamos al ejemplo del bucle for. Queremos calcular la suma de los 10 primeros enteros print("Vamos a calcular la suma de los núm...