content
stringlengths
7
1.05M
def saddle_points(matrix): if not all(len(row) == len(matrix[0]) for row in matrix): raise ValueError("Rows have different length!") _rot_mat = zip(*matrix[::1]) return set([ (row,i) for row in range(len(matrix)) for i,x in enumerate(matrix[row]) if x == max(matrix[row])]) & set([ (i,row) for row ...
# -*- coding: utf-8 -*- """ @author: Dr Michael GUEDJ Algorithmique -- TP4 -- Boucles "Pour" """ # 1 def dix(): for i in range(10): print(i) # 2 def n_premiers_entiers(n): for i in range(n): print(i) # 3 def n_premiers_entiers_carre(n): for i in r...
# Create empty list: empty = [] print("empty_list: ", empty ) # Create list of fruits: fruits = ["apple", "banana", "strawberry", "banana", "orange"] print("fruits: ", fruits) # Create list of numbers: numbers = [1,2,3,4,5] # Indexing from start to end: print(numbers[0], numbers[1], numbers[2], numbers[3], numbers[4...
# -*- coding: utf-8 -*- # Copyright 2019 Cohesity Inc. class UpgradePhysicalServerAgentsRequest(object): """Implementation of the 'Upgrade Physical Server Agents Request.' model. Specifies a request to upgrade the Cohesity agents on one or more Physical Servers registered on the Cohesity Cluster. A...
# If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per mile), # then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again, # what time do I get home for breakfast? sec_in_1m = 60 left_home_at_in_sec = 6 * 3600 + 52 * 60 total_journey_in_sec = (2 * 8 * sec_in_1m + 2 * 15) + (3 * 7 * sec_in_...
""" Pipeline for processing the Chile VMS data """ __version__ = '4.1.0' __author__ = 'Enrique Tuya' __email__ = 'enrique@globalfishingwatch.org' __source__ = 'https://github.com/GlobalFishingWatch/pipe-vms-chile' __license__ = """ Copyright 2022 Global Fishing Watch Inc. Authors: Enrique Tuya <enrique@globalfishing...
# Copyright 2013 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditi...
# Databricks notebook source # MAGIC %md-sandbox # MAGIC # MAGIC <div style="text-align: center; line-height: 0; padding-top: 9px;"> # MAGIC <img src="https://databricks.com/wp-content/uploads/2018/03/db-academy-rgb-1200px.png" alt="Databricks Learning" style="width: 600px"> # MAGIC </div> # COMMAND ---------- # M...
# -*- coding: utf-8 -*- """ Created on Fri Jun 4 09:31:28 2021 @author: dsd """ if __name__ == '__main__': wrd = input("Введите предложение: ") smb = input("Введите символ: ") cout = wrd.count(smb) while cout > 0: print(smb) cout =- 1
""" The purpose of the prototype DMA Performance Measurement application is to measures mode-independent trip-based traveler mobility and system productivity by taking trip or trajectory based vehicle input and aggregating that information into system wide performance measures. The DMA Performance Measurement appl...
def solution(): T = int(input()) for t in range(1, T+1): solve(t) def solve(t): m = int(input()) c = list(map(int, input().split(' '))) c[0] = -c[0] # Newton's method, not well, binary is good f = lambda x: sum([e*x**(m-i) for i,e in enumerate(c)]) ef = lambda x: sum([(m-i)*e*x**...
class destination(object): planet = 1 debris = 2 moon = 3 def coordinates(galaxy, system, position=None, dest=destination.planet): return [galaxy, system, position, dest] class mission(object): attack = 1 transport = 3 park = 4 park_ally = 5 spy = 6 colonize = 7 recycle =...
""" 1) The conditional probability distribution is using a measurement to restrict the likely value of one of the variables. If there is correlation, this will also affect what we know (conditionally) about the other! However, the marginal probability *only* depends on the direction along which we are margina...
""" 系统中的常量 """ # ############在后台管理中需要使用的常量############# # 在修改基础数据页面,前端v-model需要的key BASE_DATA_KEY = { "Locus_tags": 'locus_tags', "TSS_ID": 'tss_id', "Chromosome": 'chromosome', "Strand": 'strand', "Position": 'position', "Distances to start codon": 'distance', "Locus_tag": 'locus_tag', ...
class Solution: def intToRoman(self, num: int) -> str: M = ["", "M", "MM", "MMM"] C = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"] X = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"] I = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"] ...
# coding=utf-8 """ @project : formula-manager @ide : PyCharm @file : __init__.py @author : illusion @desc : @create : 2021/8/8 11:13 上午:54 """
helpstring = "voice <nick>" arguments = ["self", "info", "args"] minlevel = 3 def main(connection, info, args) : """Voices a user""" for person in args[1:] : connection.rawsend("MODE %s +v %s\n" % (info["channel"], person))
# # PySNMP MIB module CISCO-ZS-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ZS-EXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:21:44 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
class Solution: def minCostClimbingStairs(self, cost: List[int]) -> int: n = len(cost) dp = [cost[0], cost[1], 0] for i in range(2, n): dp[i % 3] = cost[i] + min(dp[(i - 1) % 3], dp[(i - 2) % 3]) return min(dp[(n - 1) % 3], dp[(n - 2) % 3])
""" Do not import anything from the rest of Kolibri in this module, it's crucial that it can be loaded without the settings/configuration/django stack! """
# Copyright (c) 2018 PrimeVR # All rights Reserved ############################################################################### # print helpers ############################################################################### CHILL_WHITE = '\x1b[0;37;40m' CHILL_PURPLE = '\x1b[0;35;40m' CHILL_LIGHT_BLUE = '\x1b[0;36;4...
#%% """ - Search in Rotated Sorted Array - https://leetcode.com/problems/search-in-rotated-sorted-array/ - Medium Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If found in th...
def jonSnowParents(dad, mom): if dad == 'Rhaegar Targaryen' and mom == 'Lyanna Stark': return 'Jon Snow you deserve the throne' return 'Jon Snow, you know nothing'
""" Test Suite for UMAP to ensure things are working as expected. The test suite comprises multiple testing modules, including multiple test cases related to a specific set of UMAP features under test. Backend ------- pytest is the reference backend for testing environment and execution, also integrating with pre-exi...
# -*- coding: utf-8 -*- """This module contains the Food Ordering Blueprint Application""" NLP_CONFIG = { "resolve_entities_using_nbest_transcripts": [], "system_entity_recognizer": {}, } INTENT_MODEL_CONFIG = { "model_type": "text", "model_settings": {"classifier_type": "logreg"}, "param_selection...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 9. Вводится число экзаменов N ≤ 20. # Напечатать фразу Мы успешно сдали N экзаменов, согласовав слово "экзамен" с числом N. if __name__ == '__main__': N = input("Введите N число: ") ending = "" if N.isnumeric(): for x in ['0', '5', '6', ...
if node.os != 'ubuntu' and node.os != 'raspbian': raise Exception('{} {} is not supported by this bundle'.format(node.os, node.os_version)) pkg_apt = {} files = {} actions = { } if node.metadata.get('grub', {}).get('enabled', False): pkg_apt['grub2-common'] = {} actions['update-grub'] = { 'comm...
# 461. Hamming Distance easy # The Hamming distance between two integers is the number of positions at which the corresponding bits are different. # # Given two integers x and y, calculate the Hamming distance. # # Note: # 0 ≤ x, y < 231. # # Example: # # Input: x = 1, y = 4 # # Output: 2 # # Explanation: # 1 (0 0 0...
""" aiida_nanotech_empa AiiDA plugin containing plugins/work chains developed at nanotech@surfaces group from Empa. """ __version__ = "0.4.1"
class FileSystemInfo(MarshalByRefObject,ISerializable): """ Provides the base class for both System.IO.FileInfo and System.IO.DirectoryInfo objects. """ def Delete(self): """ Delete(self: FileSystemInfo) Deletes a file or directory. """ pass def GetObjectData(self,info,context): """ GetObj...
# coding=utf-8 """ Helper methods to access xml elements """ def get_module_name(module): return next(module.iter("ModuleName")).text def get_module_tracked_methods(module): return next(module.iter("TrackedMethods")) def get_module_classes(module): return next(module.iter("Classes")) def get_module_...
def myif(test, trueval, falseval): if test: return trueval else: return falseval myif(True, "hello", "goodbye")
def apply_async(func, args, *, callback): result = func(*args) callback(result) def print_result(result): print('Got:', result) def add(x, y): return (x + y) apply_async(add, (2, 3), callback=print_result) apply_async(add, ("hello", "world"), callback=print_result) def make_handler(): sequence ...
class Solution: def __init__(self): self.dic_no_circle = {} def rob_no_circle(self, nums: List[int], start, end) -> int: n = len(nums) if (start,end) in self.dic_no_circle: return self.dic_no_circle[start,end] if n == 0: return 0 if n == 1: ...
#!/usr/bin/env python # vim: set ts=4 sw=4 et smartindent ignorecase fileencoding=utf8: REDMINE_URL = None REDMINE_KEY = None # 何日前になったら通知するか REDMINE_DAYS = 7 # 見るプロジェクトのID。リスト指定([1,2,...]全プロジェクトの場合は空([]) PROJECT_ID = [] # 参照するTrackerID。全部の場合はNone TRACKER_ID = None # Slack Incoming Webhook URL SLACK_URL = None # ...
# t = True # count= 0 # sum = 0 # while t==True: # x = int(input()) # if x >=0: # count+=1 # sum+=x # if x<0: # t = False # print(sum) # print(f'{sum/count:.2f}') t = True count= 0 sum = 0 while t==True: x = int(input()) if x<=0: t = False else: ...
class Files(object): def __init__(self): return @staticmethod def save_output(filename, content): try: with open('./' + filename, 'w') as out_file: out_file.write('\n'.join(content) + '\n') out_file.close() except IOError as err: p...
# (c) 2019 Alexander Korzun # This file is licensed under the MIT license. See LICENSE file class Posinfo(object): """ Represents a position in the source code (column and row) """ def __init__(self, row, col): """ Constructor Arguments: row - row, indexed from 1 ...
#!/usr/bin/env python3 '''This is Example module''' print("useless script")
class Node: def __init__(self, x): self.val = x self.next = None def __str__(self): string = "[" node = self while node: string += "{} ->".format(node.val) node = node.next string += "None]" return string def get_nodes(values): ...
common_urls_http = [ 'http://www.youtube.com' 'http://www.facebook.com' 'http://www.baidu.com' 'http://www.yahoo.com' 'http://www.amazon.com' 'http://www.wikipedia.org' 'http://www.qq.com' 'http://www.google.co.in' 'http://www.twitter.com' 'http://www.live.com' 'http://www.taobao.com' 'http://www.bing.com' ...
# Implement a quicksort items = [20, 6, 8, 53, 56, 23, 87, 41, 49, 19] def quickSort(dataset, first, last): if first < last: # calculate the split point pivotIdx = partition(dataset, first, last) # now sort the two partitions quickSort(dataset, first, pivotIdx-1) quickSo...
FOUND_PYTORCH = True # TODO check using code CONFIG = "config_file" BASELOGFOLDER = 'base_log_folder' SEED = 'seed' DEVICE = None
def is_palindrome(n): s, r = str(n), str(n)[::-1] return s == r def solve(d): n, m, largest = 10 ** (d - 1), 10 ** d, 0 for i in range(n, m): for j in range(i + 1, m): p = i * j if largest < p and is_palindrome(p): largest = p return largest # d = 2 ...
# TC: O(n) | SC: O(n) def solution_1(price): profit = [0]*len(price) # right to left max_price = price[-1] for i in range(len(price)-2, -1, -1): if price[i] > max_price: max_price = price[i] profit[i] = max(profit[i+1], (max_price-price[i])) # left to right min_pric...
input_string = input('Please input a number: ') if input_string.isnumeric(): print('The number is accepted') else: print('The input is invalid')
input() S=input() dot=S.count(".") ans=dot sharp=0 for s in S: if s=="#":sharp+=1 else:dot-=1 ans=min(ans,sharp+dot) print(ans)
# Project Quex (http://quex.sourceforge.net); License: MIT; # (C) 2005-2020 Frank-Rene Schaefer; #_______________________________________________________________________________ __debug_recursion_depth = -1 __debug_output_enabled_f = False # True / False def __debug_print(msg, msg2="", msg3=""): global __debug_...
dollar_bill = 10 if dollar_bill < 1000: print('bill exist') else: print ('bill does not exist') # dollar_bill = 1000 # # if dollar_bill < 800: # print ('bill exist') # else: # print ('bill does not exist') # # dollar_bill = 1000 # if dollar_bill > 500: # print ('bill exist') # else: # print ('b...
def abc() : print('a') print('b') print('c') def get_vat(price) : percent = 0.1 return price*percent p = 1000 answer = get_vat(p) print(answer)
class CreateOrderController: def __init__(self, create_order_use_case): self.create_order_use_case = create_order_use_case def route(self, body): if body is not None: consumed_in = body["consumed_in"] if "consumed_in" in body else None table = body["table"] if "table" ...
################################################################## # this function will print any AST that follows the # # (TYPE [, child1, child2,...]) # # tuple format for tree nodes. def dumpast(node): _dumpast(node) print('') def _dumpast(node, level=0): if isinstance(node, tuple): inden...
class FlameLabel(QtWidgets.QLabel): """ Custom Qt Flame Label Widget For different label looks set label_type as: 'normal', 'background', or 'outline' To use: label = FlameLabel('Label Name', 'normal', window) """ def __init__(self, label_name, label_type, parent_window, *args, **kwargs)...
#Faça um programa que mostre os n termos da Série a seguir: #o S = 1/1 + 2/3 + 3/5 + 4/7 + 5/9 + ... + n/m. #Imprima no final a soma da série. n=int(input("Informe o termo N que deseja visualizar: ")) serie=[] serie_attN=[] serie_attV=[] cima=1 baixo=1 serie.append(cima) serie.append(baixo) for c in range(1,n): c...
""" This module provides a wrapper for dict and list items that exposes dict entries as it's attributes - Example:: # import from obj import to_obj # initialize object = to_obj({ 'foo': 'bar' }) array = to_obj([{ 'baz': 'qux' }]) # provides accessors object.foo # provdes deep ...
print('- '*27) si = float(input('Digite o sálario atual do funcionário: R$')) ap = int(input('Digite o aumento em porcentagem (apenas números): ')) print('') vap = si * (ap/100) # valor aumento porcentagem vf = si + vap # valor final # print('O valor do sálario R${:.2f}, teve um aumento ...
#Made by Piotr Łądkowski def sudoku_empty(sudoku): for row in sudoku: for element in row: if type(element) is not int: return False return True def solve_sudoku(sudoku): initPossibles = [1, 2, 3, 4, 5, 6, 7, 8, 9] sudoku = sudoku[:] solved = False while not...
def read_passports(): with open('input.txt') as fh: lines = fh.readlines() pp_chunks = [] chunk = "" for li in range(len(lines)): if lines[li].strip(): chunk += lines[li].strip() + " " else: pp_chunks.append(chunk) chunk = "" # I...
""" Copyright (c) 2014-2015 F-Secure See LICENSE for details """
#Brian Condon # 28/02/18 Week 5 formatting exercise # prints the headings # opens the data file print("petal length, petal width, sepal length, sepal width") with open("data/iris.csv") as data_file: # loops through the data file # prints and formats the data using the line split for line in data_file: ...
classification_file = open('classifications.csv') new_class_file = open('new_class.csv', mode='w') new_class_file.write(classification_file.readline()) for line in classification_file: line = line.strip().split(',') new_class_file.write(line[0] + ',') new_class_file.write(('1' if line[1] == 'True' else '0') + '\n')
class Solution: def scoreOfParentheses(self, S): stack, res = [], 0 for c in S: if c == "(": stack.append(0) else: add = 2 * stack.pop() or 1 if stack: stack[-1] += add else: ...
#!/usr/bin/python #template collection _file = open("basic_template.html") basic_template = _file.read() index = "<br><p>Welcome to this beautiful library at this nice day.</p><p>Today it is the <i><?= date ?></i>. On the left you can see the interactive menu with all the functions you need. </p><p>If you need any as...
nome = str(input('Qual o seu nome?')).upper().strip() if nome == 'RAI': print ('\033[31mVocê tem um nome muito lindo!') elif nome == 'PEDRO' or nome == 'MARIA' or nome == 'LUCAS' or nome == 'JOÃO': print('Seu nome é bem popular no Brasil!') elif nome in 'LUANA, KIANA, YUUKA, PATRICIA': print('Belo nome') el...
# Colors (Fixed Color Graph Indices) # Returns (red, green, blue, opacity) colors = [ "EEEEEE", # White (1, n) "FF0000", # Red (i, s) "00FF00", # Green (j, t) "0000FF", # Blue (k, u) "DDDDDD", # Gray (L, N) "00FFFF", # Cyan (I, S) "FF00FF", # Magenta (J, T) "FFFF00", # Yellow (K, U) "CCCCCC"...
def set_default(default_dict, result_dict): """Sets default values for a dictionary recursively. :param default_dict: The template dictionary to use to set values :param result_dict: The dictionary to load the template values into :rtype: dict """ # Iterate through default values ...
# HEAD # DataType - Strings with Sequence/Tuples behaviour # DESCRIPTION # Describes how strings behave as a list or a sequence # Strings can be referenced per character using indexes like lists # String indexing also starts from 0/Zero # Strings can be looped like lists # RESOURCES # name = 'Zophie' print(name[0]) ...
APPLICATION_NAME = "Actuator Updater" APP_AUTHOR_DIR = "FarSite" APP_NAME_DIR = "ActuatorUpdater" # MENU_DISCONNECTED = "Connect to site..." MENU_DISCONNECTED = "Connect/disconnect" MENU_CONNECTED = "Disconnect from site"
''' This is a first name / last name dictionary & retrieval system Try this: 1. Add your name 2. Use the difflib tricks in Challenge0 to match SIMILAR names (instead of exact names) ''' database = { 'Luke':'Skywalker', 'Leia':'Skywalker', 'Han':'Solo', 'Chewie':'Chewb...
pkgname = "icu" pkgver = "70.1" pkgrel = 0 build_wrksrc = "source" build_style = "gnu_configure" configure_args = [ "--with-data-packaging=archive", "--enable-static", ] make_cmd = "gmake" hostmakedepends = ["gmake", "pkgconf"] checkdepends = ["python"] pkgdesc = "Robust and fully-featured Unicode libraries" ma...
def intersection(start_i, end_i, start_j, end_j): i0 = max(start_i, start_j) i1 = min(end_i, end_j) if i0 >= i1: return 0 else: return i1 - i0 def percentage_intervention(doc, shot_start, shot_end): interventions = doc.getElementsByTagName("Intervention") case_size = shot_end -...
# -*- Python -*- # Copyright 2017-2021 The Verible Authors. # # 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 applicab...
def factorial(x): """This is a recursive function to find the factorial of an integer""" if x == 1: return 1 else: return (x * factorial(x-1)) num = 3 print("The factorial of", num, "is", factorial(num))
# -------------- #Code starts here #Function to check for palindrome def palindrome_check(num): num=str(num) return (num[::-1]==num) #Function to find the smallest palindrome def palindrome(num): while(1): num=num+1 if palindrome_check(num): return num ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 9 14:35:41 2018 @author: misskeisha """ passw = input() if (any(x.isupper() for x in passw) and any(x.islower() for x in passw) and (passw.isalnum() == False) and len(passw) >= 8) and any(x.isdigit() for x in passw): print('good password') el...
class ChainingTimeStampF1D: def __init__(self): pass def __call__(self, inter): pass class Curvature2DAngleF0D: def __init__(self): pass def __call__(self, it): pass class Curvature2DAngleF1D: def __init__(self, integration_type=IntegrationType.MEAN): ...
def bubblesort(A): for i in range(len(A)): for k in range(len(A) - 1, i, -1): if (A[k] < A[k - 1]): swap(A,k,k-1) def swap(A,x,y): temp = A[x] A[x] = A[y] A[y] = temp A= [534,689,235,124,525,216,134,356] bubblesort(A) print(A)
BACKGROUND = "red" FONT_NAME = "Consolas" FONT_SIZE = 19 DEFAULT_FONT = (FONT_NAME, FONT_SIZE) HEADER_FONT = (FONT_NAME, int(FONT_SIZE*1.3))
'''Developed by Jakub21 in June 2018 License: MIT Python version: 3.6.5 ''' class Chunk: '''Chunk Class Contains methods inherited by ProvGroup and Province classes ''' def __init__(self, parent, name, type): '''Constructor''' self.parent, self.name, self.type = parent, name, type ...
# -*- coding: utf-8 -*- # ***************************************************************************** # NICOS, the Networked Instrument Control System of the MLZ # Copyright (c) 2009-2022 by the NICOS contributors (see AUTHORS) # # This program is free software; you can redistribute it and/or modify it under # the t...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"log_it": "00_tspecscores.ipynb", "tsi": "00_tspecscores.ipynb", "spm": "00_tspecscores.ipynb", "zscore": "00_tspecscores.ipynb", "tau": "00_tspecscores.ipynb", "t...
class Sample(): """ A sample for a song, composed of slices (parts). """ def __init__(self, slices, song, size, index): self.slices = slices self.song = song self.size = size self.index = index class Slice(): """ A sample of the smallest size, used to construct ...
n = int(input()) s = set(map(int, input().split())) for x in range(int(input())): method, *args = input().split() getattr(s, method)(*map(int, args)) print(sum(s))
# Copyright (c) 2011 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'includes': [ 'mini_chromium/build/common.gypi', ], 'targets': [ { 'target_name': 'csfde', 'type': 'executable', 'include_dirs': ...
''' Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its level order traversal as: [ [3], [9,20], [15,7] ] ''' # Definition for a binary tree...
""" Faça um programa que calcula a associação em paralelo de dois resistores R1 e R2 fornecidos pelo usuário via teclado. O programa fica pedindo estes valores e calculando até que o usuário entre com um valor para resistência igual a zero R = (R1 * R2)/(R1 + R2) """ while True: r1 = flo...
""" Version information for `pip-audit`. """ __version__ = "1.1.1"
# model model = Model() i1 = Input("op1", "TENSOR_QUANT8_ASYMM", "{3,4}, 0.5f, 1") # a vector of input k = Int32Scalar("k", 2) i2 = Output("op2", "TENSOR_QUANT8_ASYMM", "{3,2}, 0.5f, 1") # values of output i3 = Output("op3", "TENSOR_INT32", "{3,2}") # indexes of output model = model.Operation("TOPK_V2", i1, k).To([i2, ...
def memmove(data, dest, src, n): '''Copy data in the array from ``src`` to ``dest``. Like ``memmove(3)`` in C, the source and destination may overlap. Arguments: data (list): The list being manipulated. dest (int): The destination index of the copy. src (int...
def insertion_sort(arr): for i in range(len(arr)): cursor = arr[i] pos = i while pos > 0 and arr[pos - 1] > cursor: arr[pos] = arr[pos - 1] pos = pos - 1 arr[pos] = cursor return arr a = insertion_sort([3, 2, 5, 4, 1, 0]) print(a)
''' Juan Ivan Medina Martinez Exercise 5.6 ''' def stepLife(yourAge): if isinstance(yourAge,int): if(yourAge>=0): if(yourAge<2): print("Yo are an baby.") elif(4>yourAge>=2): print("You are an toddler.") elif(13>yourAge>=4): ...
class TestUser(object): """Wraps a user data dictionary.""" # Private attributes: # dict<basestring, mixed> _data - The data dictionary. def __init__(self, data): self._data = data def favorite_food(self): return self._data['favoriteFood']
for i in range(10): n=int(input()) if(n< 1): n = 1 print("X[%d] = %d" % (i, n))
class GithubRequest(): def clone(self): raise NotImplementedError() def auth(self): raise NotImplementedError() def execute(self): raise NotImplementedError()
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"h3.libh3.experimentalH3ToLocalIj.restype": "00_core.ipynb", "h3.libh3.experimentalH3ToLocalIj.argtypes": "00_core.ipynb", "local_ij_delta": "00_core.ipynb", "local_ij_delta_to_clas...
#!/usr/bin/env python ###################################################################################### ## Copyright (c) 2010-2011 The Department of Arts and Culture, ## ## The Government of the Republic of South Africa. ## ## ...
class Datacenter(object): def __init__(self, name=None, location=None, # pylint: disable=unused-argument description=None, volumes=None, servers=None, lans=None, loadbalancers=None): """ The Datacenter class initializer. :param name: The data center name.. :ty...
#!/usr/bin/python coins = [1,5,6,8] target = 51 def cons(e, xs): ys = xs.copy() ys.append(e) return ys # DP solution find the least number of coins for a given total # minCoins[i] is list of coins needed to make i # O(c * y) compared to O(c ^ n) def search(): minCoins = [[]] * (target + 1) for i ...
print("Strings, (c) Verloka Vadim 2018\n\n\n") S1 = "example" S2 = "string" print(S1 + " " + S2) print(S1 * 2) #exampleexample print("Lenght - " + str(len(S1))) #len - длина строки print(S1[0]) #строка как масив символов print(S1[1]) print(S1[2]) print(S1[3]) print(S1[4...
#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2016 Google Inc. All rights reserved. # # 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/LICENS...