content
stringlengths
7
1.05M
class RobotState: """ Interface a robot state must implement to be used with :py:class:`roboball2d.physics.rendering.pyglet_renderer.PygletRenderer` See : :py:class:`roboball2d.robot.default_robot_state.DefaultRobotState """ def __init__(self, robot_config, generalized_coordinates = None,...
# -*- coding: utf-8 -*- def main(): s = input() f = int(s[:2]) l = int(s[2:]) if 1 <= f <= 12 and 1 <= l <= 12: print('AMBIGUOUS') elif 1 <= l <= 12: print('YYMM') elif 1 <= f <= 12: print('MMYY') else: print('NA') if __name__ == '__main...
#!/usr/bin/env python # -*- coding: utf-8 -*- atoms = { 'C': 1, 'H': 4, 'O': 1, } bonds = { 'C-O': 1, 'C-H': 3, 'O-H': 1, } linear = False externalSymmetry = 1 spinMultiplicity = 2 opticalIsomers = 1 #confirmed energy = { 'M08SO': QchemLog('ch3oh.out'), } geometry = QchemLog('ch3oh....
A = 'A' B = 'B' C = 'C' D = 'D' state = {} action = None model = {A: None, B: None, C: None, D: None} # Initially ignorant RULE_ACTION = { 1: 'Suck', 2: 'Right', 3: 'NoOp' } rules = { (A, 'Dirty'):1, (B, 'Dirty'):1, (C, 'Dirty'):1, (D, 'Dirty'):1, (A, 'Clean'):2, (B, 'Clean'):2, ...
class Config(object): DEBUG = True TESTING = True # MySQL config MYSQL_DATABASE_HOST = 'localhost' MYSQL_DATABASE_PORT = 3306 MYSQL_DATABASE_USER = 'knoydart' MYSQL_DATABASE_PASSWORD = '7xGFGzF8BbzsJFCd' MYSQL_DATABASE_DB = 'knoydart' MYSQL_DATABASE_CHARSET = 'utf8' DATATAKER_H...
def part1(): values = [[int(i) if i.isnumeric() else i for i in i.split(" ")] for i in open("input.txt","r").read().split("\n")] depth = 0 horizontal = 0 for i in values: if i[0] == "up": depth -= i[1] elif i[0] == "down": depth += i[1] elif i[0] == "forw...
class Resources: class LoginPage: USERNAME_FIELD_PLACEHOLDER = "Username" PASSWORD_FIELD_PLACEHOLDER = "Password" LOGIN_BUTTON_TEXT = "Login" NON_EXISTING_USER_ERROR_TEXT = "Epic sadface: Username and password do not match any user in this service" MISSING_USERNAME_ERROR_TEX...
def fun(liczby): n = len(str(liczby)) dziel=1 tak = 10 suma = 0 cos = liczby for x in range(0,n): liczba=liczby%tak liczby-=liczba tak*=10 liczba/=dziel suma+=liczba dziel*=10 return int(suma) print(fun(545435433))
def largestNumber(n): ''' Given an integer n, return the largest number that contains exactly n digits. ''' return 10 ** n - 1 print(largestNumber(1)) print(largestNumber(5)) print(largestNumber(10))
class InitializationEventAttribute(Attribute, _Attribute): """ Specifies which event is raised on initialization. This class cannot be inherited. InitializationEventAttribute(eventName: str) """ def __init__(self, *args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for s...
# -*- coding: utf-8 -*- class Solution: def strStr(self, haystack, needle): return haystack.find(needle) if __name__ == '__main__': solution = Solution() assert 2 == solution.strStr('hello', 'll') assert -1 == solution.strStr('aaaaa', 'bba') assert 0 == solution.strStr('aaaaa', '')
PARAMS = { "default": { "folders": ["INBOX"], "csvdir": "./data", "outdir": "./trained", }, "suse-manager": { "folders": ["INBOX/suse-manager"], "csvdir": "./suse-manager-data", "outdir": "./suse-manager-trained", } }
class ArthurContextProperty(ArthurContext): """ Question: We want to find out which context a given word is part of. Possible calculations: 1. Calculate levenshtein distance of given word with all val_samples, then return key of the val_sample with smallest levenshtein distance. 2. If given t...
#!/usr/bin/python3 SYMBOL_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz12345678"+ \ "90 !?." LEN_SYM_TABLE = len(SYMBOL_TABLE) print("[+] Length of Symbol table is {}".format(LEN_SYM_TABLE)) def decrypt(c_message, key): plaintext = [] for ch in c_message: pos = SYMBOL_TABLE.find(ch) ...
def try_describe_request(command): if isinstance(command, list) and len(command) == 3: command_type = command[0] if command_type == 4: player_key = command[1] actions = command[2] # known action samples # [2, id, (target x, y), ?power] # [1...
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0 : return False elif x < 10: return True else: strx = str(x) i = 0 j = len(strx) - 1 while i < ...
# Day 10 - Search Insert Position # Naive class Solution: def searchInsert(self, nums: List[int], target: int) -> int: for i, num in enumerate(nums): if target <= num: return i return len(nums) # Binary Search class Solution: def searchInsert(self, nums: List[int], ...
class ListNode: def __init__(self, key=None, value=None): self.key = key self.value = value self.prev = None self.next = None class LRUCache: def __init__(self, capacity: int): self.capacity = capacity self.hashmap = {} # 新建两个节点 head 和 tail self....
# Copyright 2014 Rackspace # # 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 ...
class Parent: def __getitem__(self, idx): return 0 class Child(Parent): def index_super(self, idx): return super()[idx] kid = Child() print(f'kid[0]: {kid[0]}') print(f'kid.index_super(0): {kid.index_super(0)}')
def run_training_loop(): dataset_reader = build_dataset_reader() # These are a subclass of pytorch Datasets, with some allennlp-specific # functionality added. train_data, dev_data = read_data(dataset_reader) vocab = build_vocab(train_data + dev_data) model = build_model(vocab) # This is ...
class Solution: def peakIndexInMountainArray(self, arr): for i in range(1, len(arr)-1): if arr[i-1] < arr[i] > arr[i+1]: return i """ Success Details Runtime: 76 ms, faster than 62.35% of Python3 online submissions for Peak Index in a Mountain Array. Memory Usage: 15.4 MB, les...
n, m = [int(tmp) for tmp in input().split()] dic = {} for cnt in range(n): k, v = [tmp for tmp in input().split()] dic[k] = v words = input().split() for word in words: if word in dic: print(dic[word], end=' kachal! ') else: print(end='kachal! ')
def is_superset(A, B, count): if A == B or len(A) < len(B): count = count elif A.issuperset(B): count = count + 1 return count if __name__ == "__main__": A = set(map(int, input().split())) # Set A elements n = int(input()) # no. of other sets count = 0 for i in range(n): ...
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- def go() : return {"id":10, "sequence":"chen"} def go2(a,b,c): return str({"id":b, "sequence":"chen"}) print('chen')
# Starting values (of global variables) def get_response(text): print("") print(text) selection = input() return selection class CoffeeMachine: def __init__(self, w, m, b, c, dollars): self.water = w self.milk = m self.beans = b self.cups = c self.money = do...
def encryptRailFence(text, key): rail = [['\n' for i in range(len(text))] for j in range(key)] dir_down = False row, col = 0, 0 for i in range(len(text)): if (row == 0) or (row == key - 1): dir_down = not dir_down rail[row][col] = text[i] col += 1 if dir_down: row += 1 else: row -= 1 res...
'''3. Altere o exercício anterior para que a string copiada alterne entre letras maiúsculas e minúsculas Exemplo: se o usuário digitar "latex" o programa deve imprimir "LaTeX".''' frase = 'latex' frase1 = list(frase) nova_frase = [] for i in range(len(frase1)): if i%2==0: nova_frase.append(frase1[i].uppe...
array_a = [1, 2, 3, 5] array_b = [4, 6, 7, 8] def merge(array1, array2): idx_a = 0 idx_b = 0 len_a = len(array1) len_b = len(array2) res = [] while True: if array1[idx_a] > array2[idx_b]: res.append(array2[idx_b]) idx_b += 1 else: res.append(...
class Scenario: def __init__(self, start, end, mmap, dvmap, tc_id: int, park=None, side=0): self.start = start self.end = end self.map = mmap self.ID = str(tc_id) self.park = park self.dvmap = dvmap self.side = side def __str__(self): return str(s...
#!/usr/bin/env python # -*- coding: utf-8 -*- styles_test_suite = { "name": "Border styles tests", "scenarios": [ { "name": "basic border style", "args": ["-b", "basic", "--header=0"], "input": '''\ 1,2 3,4 5,6 ''' , "output": '''\ +---+---+ | 1 | 2 | +---+---+ | 3 | 4 | | 5 | 6 | +---+---+ ''' }, { "name": "basic2 b...
# coding=utf8 # Copyright 2018 JDCLOUD.COM # # 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 ...
""" entradas contraseña-->c-->int salidas acceso permitido-->str clave invalida-->str """ while True: c=int(input("")) #entradas if(c==2002): print("Acesso permitido") #salidas break else: print("Senha invalida") #salidas
# # All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or # its licensors. # # For complete copyright and license terms please see the LICENSE at the root of this # distribution (the "License"). All use of this software is governed by the License, # or, if provided, by the license below or th...
# Loops # Loops are repeating segments of code, and come in two types, while and for. Lets start with a "for" loop. # "for" loops can be expressed in the following manner: for i in range(0, 9): print(i) # For loops work by repeating until the loop has executed a specific number of times, or until all v...
# Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... # # You may assume the input array always has a valid answer. def wiggleSort(nums): nums.sort() mid = (len(nums) + 1) // 2 left, right = nums[:mid], nums[mid:] nums[::2] = left[::-1] nums[1::2] = right[::-1...
""" File: weather_master.py Name: HJ ----------------------- This program should implement a console program that asks weather data from user to compute the average, highest, lowest, cold days among the inputs. Output format should match what is shown in the sample run in the Assignment 2 Handout. """ QUIT = -100 de...
""" LC 127 A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words differs by a single letter. Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList...
l = [1,2,3,4,5] print(l) def mul_by2(num): return num*2 for result in map(mul_by2,l): print(result)
new_npc_stats = { 'base_stats': { 'vit': 4, 'dex': 4, 'str': 4, 'int': 4, 'agility': 8, 'toughness': 9, }, 'stats': { 'max_hp': 'from vit', # vit*hp_per_vit + lvl*hp_per_lvl 'max_mana': 'from int?', 'armor': 'from str and toughness', ...
"""Custom shna errors.""" class ShnaError(Exception): """Custom shna exception class.""" pass
#합 '''n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. 첫째 줄에 n (1 ≤ n ≤ 10,000)이 주어진다. 1부터 n까지 합을 출력한다.''' a = input() a = int(a) result = 0 for i in range(1,a+1): result += i print(result) #################################### b = input() b = int(b) result = int(((b+1)*b)/2) print(result)
#Create a function that accept a name and return reverse of this def reverse_name(a): reverse = "" for i in a: reverse = i + reverse return reverse name = input("Enter the NAME ") result = reverse_name(name) print("\nThe Reverse name is", result.title())
print('=' * 12 + 'Desafio 93' + '=' * 12) jogador = dict() jogador['Nome'] = input('Digite o nome do jogador: ') jogador['Gols'] = list() partidas = int(input(f'Quantas partidas {jogador["Nome"]} jogou? ')) total = 0 for c in range(partidas): qtde = int(input(f'Gols na partida {c + 1}: ')) total += qtde jog...
class InvalidInputsError(Exception): """ Raised during :class:`Service`'s :meth:`service_clean` method. Encapsulates both field_errors and non_field_errors into a single entity. :param dictionary errors: :class:`Services`'s ``errors`` dictionary :param dictionary non_field_errors: :class:`Serv...
""" Ethereum Constantinople Hardfork ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The Seventh Ethereum hardfork. """ MAINNET_FORK_BLOCK = 7280000 CHAIN_ID = 1
""" DESAFIO 095: Aprimorando os Dicionários Aprimore o DESAFIO 093 para que ele funcione com vários jogadores, incluindo um sistema de visualização de detalhes do aproveitamento de cada jogador. """ div = '-' * 35 div2 = '-' * 44 jogador = dict() jogadores = list() qtdgols = list() totgols = 0 while True: print(di...
""" 0796. Rotate String We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after one shift on A. Return True if and only if A can become B after some number of shifts on A. Exampl...
def generate(n, diff, left, right): if n > 9: return if n and (2 * abs(diff) <= n): if n == 1: generate(n - 1, diff, left, "0" + right) generate(n - 1, diff, left, "1" + right) if left != "": generate(n - 2, diff, left + "0", right + "0") generat...
#!/usr/bin/python3 # coding=utf-8 class LoopNotFoundError(Exception): def __init__(self, message): super().__init__(message)
class Solution: def balancedStringSplit(self, s: str) -> int: l=0 r=1 k=0 while r<len(s)+1: print(s[l:r]) if s[l:r].count("L") == s[l:r].count("R"): k=k+1 l=r r=r+1 r=r+1 return k
def for_c(): """ Lower case Alphabet letter 'c' pattern using Python for loop""" for row in range(4): for col in range(4): if col==0 and row%3!=0 or col>0 and row%3==0: print('*', end = ' ') else: ...
# Zaimplementować funkcję factorial(n: int) -> int, która zwróci silnię wartości przekazanej w parametrze def factorial(n: int): if n==0: return 1 else: return n*factorial(n-1) print(factorial(5))
class Solution: def climbStairs(self, n: int) -> int: dp = [0] * (n + 1) dp[0] = 1 weights = [1, 2] for i in range(n + 1): for j in weights: if i >= j: dp[i] += dp[i-j] return dp[n]
def _first_available(color_list): """ (https://en.wikipedia.org/wiki/Greedy_coloring) Return smallest non-negative integer not in the given list of colors. :param color_list: List of neighboring nodes colors :type color_list: list of int :rtype: int """ color_set = set(color_list) c...
########################################### # Glyph position table for buzzard.py ########################################### # TYPEFACE: Roboto # All glyphs' y-min is set on the baseline # All glyphs' x-pos is monospace default # Entries in this table are complex numbers # where the real component is added to the # x...
class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: marked = [False] * len(nums) ans = [] self.dfs(sorted(nums), marked, [], ans) return ans def dfs(self, nums, marked, path, ans): if len(path) == len(nums): ans.append(list(path))...
def hasFront(arr,r,c,i,j): if(i-1 >= 0): return arr[i-1][j] == arr[i][j] return False def hasBack(arr,r,c,i,j): if(i+1 < r): return arr[i+1][j] == arr[i][j] return False def hasLR(arr,r,c,i,j): if(j+1 < c): if(arr[i][j+1] == arr[i][j]): return True if(j-1 >=...
__author__ = 'Xavier Bruhiere' __copyright__ = 'Xavier Bruhiere' __licence__ = 'Apache 2.0' __version__ = '0.0.2'
class Sim: def __init__(self, fish: list[int]): self.fish = fish def step(self): fish = self.fish for i in range(len(self.fish)): if fish[i] == 0: fish.append(8) fish[i] = 7 fish[i] -= 1 if __name__ == "__main__": with open("...
""" 1 3 5 1 3 3 5 | arr[L..R] > s | L R --------------- l r -------- """ n, r = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] def two_pointer(arr,k): l = 0 N = len(arr) count =...
# Uses python3 def get_change_naive(m): count = m // 10 m %= 10 count += m // 5 m %= 5 count += m // 1 return count def get_change_greedy(m): #write your code here change, count = 0, 0 coins = [1, 5, 10] index = len(coins) - 1 while change < m: while (change <= m and ...
""" :mod:`refcount` =============== A simple library for providing a reference counter with optional acquire/release callbacks as well as access protection to reference counted values. .. moduleauthor:: Paul Mundt <paul.mundt@adaptant.io> """ # pylint: disable=unnecessary-pass class UnderflowEx...
class Solution: def rangeSumBST(self, root, L, R): return self.inorder(root, 0, L, R) def inorder(self,root, value, L, R): if root: value = self.inorder(root.left, value, L, R) if root.val >= L and root.val <= R: value += root.val value = self...
# def make_multiple(n): # def multiply(x): # print(f'{x} * {n} is ', x * n) # return multiply # times_three = make_multiple(3) # times_five = make_multiple(5) # del make_multiple # times_three(10) # == make_multiple(3)(10) # print('Closure of make_multiple', make_multiple.__closure__) # print('Cl...
# 최초 답안 # 코드를 보면 말도 안되는 수준 ^^;; def check_pal(n): num = str(n) for i in range(len(num)//2): if num[i] == num[len(num)-1-i]: pass else: return False print(num) return True def reverse(n): s = '' num = str(n) for ch in reversed(num): s += ch ...
macro_caller = ''' <div class="table"> <a id="calling_table"></a> <p class="title">Calling Table</p> <div class="table-contents"> <table frame="box" rules="all"> <thead> </thead> <tbody> ...
class Levenshtein: """ The Levenshtein distance between two strings: source, target Methods: constructor(source, target, costs): initialises data attributes and calculates distances and backtrace distance(): returns the minimum edit distance for the two strings edit_ops(): returns a li...
# encoding: utf-8 # module apt_inst # from /usr/lib/python3/dist-packages/apt_inst.cpython-35m-x86_64-linux-gnu.so # by generator 1.145 """ Functions for working with ar/tar archives and .deb packages. This module provides useful classes and functions to work with archives, modelled after the 'TarFile' class in the 't...
# Support code class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next # Problem code def connect(root): if not root: return None connect_helper...
def parse(): with open('day09/input.txt') as f: lines = f.readlines() arr = [] for line in lines: a = [] for c in line.strip(): a.append(int(c)) arr.append(a) return arr arr = parse() h = len(arr) w = len(arr[0]) def wave(xx: int, yy: int) -> int: ...
n = float(input('massa da substancia em gramas: ')) meiavida = n tempo = 0 while meiavida >= 0.05: meiavida *= 0.5 tempo +=50 print('para q a substancia de massa {}g atinja 0.05g , levou {:.0f}s'.format(n,tempo))
# # PySNMP MIB module Juniper-DISMAN-EVENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-DISMAN-EVENT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:51:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
class Tape(object): blank_symbol = " " def __init__(self, tape_string=""): self.__tape = dict((enumerate(tape_string))) # last line is equivalent to the following three lines: # self.__tape = {} # for i in range(len(tape_string)): # self.__tape[i] = i...
sunny = [ " \\ | / ", " - O - ", " / | \\ " ] partial_clouds = [ " \\ /( ) ", " - O( )", " / ( ) ", ] clouds = [ " ( )()_ ", " ( ) ", " ( )() " ] night = [ " . * ", " * . O ", " . . * . " ] drizzle = [ " ' ' '", " ' ...
# File type alias FileType = str # Constants IMAGE: FileType = "IMAGE" AUDIO: FileType = "AUDIO"
a=10 b=5 print(a+b) print("addition")
# system functions for the effects of time on a player def raise_hunger(db, messenger, object): print('HUNGER for {0}'.format(object['entity'])) if object['hunger'] >= 9: # player is going to die, so let's just skip the database # TODO: don't do this, and let an event driven system pick up p...
DOMAIN = 'https://example.com' # (route, [querie string keys]) # queries must be emtpy list if it has no query strings. ROUTES = [ ('/exercise', ['page', 'date']), ('/homework', ['date']), ] # { query string key: [query string values ]} QUERIES = { 'page': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'date': ['20...
## use memoization to implement dynamic programming...!!! def solve(i,arr,dp): ## parameter(index of array, input array, define dp table..) if i <= -1: return 0 if dp[i] != -1: return dp[i] ## recursive calls op1 = arr[i] + solve(i-2,arr,dp) op2 = solve(i-1,arr,dp) ## get maximum from both recursive calls....
class Solution: def validUtf8(self, data: List[int]) -> bool: p = 0 while p < len(data): b = self._get_binary(data[p]) one = 0 for c in b: if c == '1': one += 1 else: break if one ...
def largest_palindrome_product(): values = { "first": 0, "second": 0, "product": 0 } for first in range(1000): for second in range(1000): product = first * second product_string = str(product) if product_string == product_string[::-1]: if first + secon...
#Faça um programa que leia o nome completo de uma pessoa, mostrando em seguida o primeiro e o último nome separadamente. n = input('Qual seu nome todo:').strip() e = n.split() print('Seu primeiro nome é:', e[0]) f = n.rfind(' ') + 1 print('Seu ultimo nome é:', n[f:])
# Copyright 2003 by Bartek Wilczynski. All rights reserved. # This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """ Parser and code for dealing with the standalone version of AlignAce, a motif search pro...
tmp = max(x, y) x = min(x, y) y = tmp tmp = max(y, z) y = min(y, z) z = tmp tmp = max(x, y) x = min(x, y) y = tmp
def fib(n, k, a=0, b=1): if n == 0: return 1 if n == 1: return b return fib(n - 1, k, b * k, a + b) print(fib(31, 2))
#We need to calculate all multiples of 3 and 5 that are lesser than given number N #My initial attempt wasnt great so i took help from this wonderful article https://medium.com/@TheZaki/project-euler-1-multiples-of-3-and-5-c24cb64071b0 : N = 10 def sum(n, k): d = n // k return k * (d * (d+1)) // 2 def test(n)...
# # PySNMP MIB module HPN-ICF-IPSEC-MONITOR-V2-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-IPSEC-MONITOR-V2-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:27:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python vers...
# You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: # struct Node { # int val; # Node *left; # Node *right; # Node *next; # } # Populate each next pointer to point to its next right node. If there is no n...
while 1: while 1: while 1: break break break
class Edge: def __init__(self, src, dest, cost, vertex1, vertex2, wasser_cost=0): self.src = src self.dest = dest self.cost = cost self.vertex1 = vertex1 self.vertex2 = vertex2 self.wasser_cost = wasser_cost
# Alexis Cumpstone # Created: 2019 #This program extracts the coded word from the given string and prints, on #one line, the word in all uppercase, all lowercase and in reverse. encoded = "absbpstokyhopwok" #Extract every 4th character from the string to form the 4 letter word decoded = encoded[3::4] wordAllUpper =...
#!/usr/bin/python3 def no_c(my_string): str = "" for i in my_string[:]: if i != 'c' and i != 'C': str += i return (str)
# Funktion: max def list_max(my_list): result = my_list[0] for i in range(1, len(my_list)): wert = my_list[i] if wert > result: result = wert return result # Liste l1 = [-2, 1, -10] l2 = [-20, 123, 22] # Funktionsaufruf l1_max = list_max(l1) l2_max = list_max(l2)
''' +------+-------+----------------+ | Item | Price | Special offers | +------+-------+----------------+ | A | 50 | 3A for 130 | | B | 30 | 2B for 45 | | C | 20 | | | D | 15 | | +------+-------+----------------+ ''' def get_skus(): return { '...
## @package fib # # @author cognocoder. # Fibonacci glued between Python and C++. ## Fibonacci list. # @param n specifies the size of the list. # @returns Returns a Fibonacci list with n elements. # @throws ValeuError for negative values of n. # @see {@link #fib.ifib ifib}, {@link #fib.bfib bfib}. def fib(n): try...
class console: def log(*args, **kwargs): print(*args, **kwargs) console.log("Hello World")
# Number of terms till which the sequence needs to be printed n = int(input()) a, b = 1, 1 count = 0 # We need to first check if the number is prime or not def ifprime(n): if n> 1: for i in range(2, n// 2 + 1): if (n % i) == 0: return False else: return True...
def c(sr=False, sy=False, e=False): """ -> Cores vermelha e amarela :param sr: start red(começo vermelho) :param sy: start yellow(começo amarelo) :param e: end(fim) :return: codigo de começo e fim de cor """ if sr: return '\033[0;31m' if sy: return '\033[0;33m' if...
class A(object): __doc__ = 16 print(A.__doc__) # <ref>