content
stringlengths
7
1.05M
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] list = [] num = int(input('check wich number is smaller than : ')) for x in a: if x < num: list.append(x) # print(x) print(list)
# Write a function named combine_sort that has two parameters named lst1 and lst2. # The function should combine these two lists into one new list and sort the result. Return the new sorted list. #print(combine_sort([4, 10, 2, 5], [-10, 2, 5, 10])) def combine_sort(lst1, lst2): new_lst = lst1 + lst2 return sor...
# 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 ...
input_line_number = 0 lines = [] def input(): global input_line_number input_line_number += 1 return lines[input_line_number - 1] def solution(): # Solution starts here number_of_lines = int(input()) for i in range(0, number_of_lines): full_name = input() # Find the location ...
#Faça um Programa que peça uma data no formato dd/mm/aaaa e determine se a mesma é uma data válida. dia = int(input("Digite o dia [dd]: ")) mes = int(input("Digite o mês [mm]: ")) ano = int(input("Digite o ano [aaaa]: ")) meses_com_trinta_dias = [2,4,6,9,11] #data começa como True e vai passando por validações data_...
# 104. Maximum Depth of Binary Tree """ Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, v...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 26 20:46:03 2018 @author: daniel cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4. Given this implementation of cons: ...
# Allows for easier debugging and unit testing. For example in dev mode functions don't expect a Flask request input. DEV_MODE = False KEYFILE = 'keyfile.json'
class BrokenLinkWarning(UserWarning): """ Raised when a group has a key with a None value. """ pass
L = [] def get_num(n): while n > 0: L.insert(0, n % 10) n = n // 10 while True: temp = input('Input a num: ') if temp.isdigit(): get_num(int(temp)) break else: print('', end='') # while True: # try: # temp = input("Input a num: ") # get_num...
class MacroError(Exception): def __init__(self, msg: str, filepath: str, ctx=None): super().__init__() if ctx: self.line = ctx.start.line # 错误出现位置 self.column = ctx.start.column else: self.line = 0 self.column = 0 self.filepath = filep...
elements = [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43] l=len(elements) i=0 sum_even=0 sum_odd=0 average_even=0 average_odd=0 while i<l: if elements[i]%2==0: sum_even=sum_even+elements[i] average_even+=1 else: sum_odd=sum_odd+elements[i] average_odd+=1 i+=1 print(sum_even//ave...
""" Session related utilities """ def session(self): """ Simple function that will be bound to the current request object to make the session retrievable inside a handler """ # Returns a session using the default cookie key. return self.session_store.get_session()
# for local # It's probably helpful for us to demonstrate what the URL should be, etc. SECRET_KEY = b'keycloak' # http, not https for some reason SERVER_URL = "http://keycloak-idp:8080/auth/" ADMIN_USERNAME = "admin" ADMIN_PASS = "admin" REALM_NAME = "master" # created in keycloak per https://github.com/keycloak/keyc...
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. def print_hi(iname): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {iname}') # Pres...
"""Consts for the integration.""" DOMAIN = "sleep_as_android" DEVICE_MACRO: str = "%%%device%%%" DEFAULT_NAME = "SleepAsAndroid" DEFAULT_TOPIC_TEMPLATE = "SleepAsAndroid/%s" % DEVICE_MACRO DEFAULT_QOS = 0 DEFAULT_ALARM_LABEL = "" CONF_ALARMS = "alarms" CONF_ALARM_TIME_FMT = "%H:%M" CONF_ALARM_DATE_FMT = "%Y-%m-%d" C...
pi=22/7 r=float(input("enter radius of circle")) Area=pi*r*r print("Area of circle:%f",Area)
def upload(task_id, file_id, remote_path): global responses remote_path = remote_path.replace("\\", "") upload = { 'action': "upload", 'file_id': file_id, 'chunk_size': 512000, 'chunk_num': 1, 'full_path': "", 'task_id': task_id, } res = send(upload,...
#!/usr/bin/env python def constructCDS(features, coordinates): exonCoordinates = [coordinates[featureIndex] for featureIndex in range(len(features)) if features[featureIndex][1] == "e"] cdsMap = {} cdsStart = 1 for exonCoord in exonCoordinates: exonStart, exonEnd = exonCoord cdsEnd = c...
class CodeParser(): #Parsing variables SPEED = 0 ANGLE = 0 lineNum = 0 #Parsing libraries (or "keywords") PORTS = ["THROTTLE", "TURN"] #Initialize the CodeParser def __init__(self, path): self.SPEED = 0 self.ANGLE = 0 #Open racer file racer = open(path, ...
# If we want to find the shortest path or any path between 2 nodes # BFS works better # Breadth-First search needs a Queue class Node: def __init__(self, val): self.val = val self.left = None self.right = None def __str__(self): return "Node: {} Left: {} Right:{}".format(self.v...
testcases = int(input().strip()) for test in range(testcases): string = input().strip() length = len(string) half_length = length // 2 if length % 2: print(-1) continue letters1 = [0] * 26 letters2 = [0] * 26 ascii_a = ord('a') ascii_string = [ord(c) - ascii_a for c in...
w, h, k = list(map(int, input().split())) c=0 for i in range(k): c = c+ ( (h-4*i)*2 +( w - 2-4*i)*2) print(c)
""" TEMAS: - IDE - Estructura básica de un programa. Main Procedural Función print - Variables y constantes Variables Constantes Tipos de datos Función type """ def main(): # Variables y constantes # Esta es una variable edad_alumno = 20 # Esta es una constante NOM...
t = int(input()) h = (t // 3600) % 24 m1 = t // 60 % 60 // 10 m2 = t // 60 % 60 % 10 s1 = t % 60 // 10 s2 = t % 10 print(h, ":", m1, m2, ":", s1, s2, sep="")
class Solution: def sumRootToLeaf(self, root: TreeNode) -> int: def sumRootToLeaf(r, s): li, x = [n for n in [r.left, r.right] if n], (s << 1) + r.val return x if not li else sum(sumRootToLeaf(n, x) for n in li) return sumRootToLeaf(root, 0)
class SymbolTable: def __init__(self): self.table = {'SP': 0, 'LCL': 1, 'ARG': 2, 'THIS': 3, 'THAT': 4, 'R0': 0, 'R1': 1, 'R2': 2, 'R3': 3, 'R4': 4, 'R5': 5, 'R6': 6, 'R7': 7, 'R8': 8, 'R9': 9, 'R10': 10, 'R11': 11, 'R12': 12, 'R13': 13, 'R14': 14, ...
""" stormdrain events SD_bounds_updated Bounds have changed. Typically this happens in response to axes limits changing on a plot, or filtering criteria on a dataset changing. SD_reflow_start and SD_reflow_done These events, which often should follow a SD_bounds_updated event, is used to trigger a reflow of dataset...
A,B = map(int, input().split()) #A,B = 4, 10 if A > B : print('>') elif A < B : print('<') else: print('==')
# @Time: 2022/4/13 11:29 # @Author: chang liu # @Email: chang_liu_tamu@gmail.com # @File:LFU.py class Node: def __init__(self, key=None, val=None): self.val = val self.key = key self.f = 1 self.left = None self.right = None class DLL: def __init__(self): self....
# -*- coding: utf-8 -*- # @Time: 2020/7/16 11:36 # @Author: GraceKoo # @File: interview_7.py # @Desc: https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&rp=1&ru=%2Fta%2Fcoding-interviews&qr # u=%2Fta%2Fcoding-interviews%2Fquestion-ranking class Solution: def fib(self, N: int) -> int: ...
#!/usr/bin/python3 def square_matrix_simple(matrix=[]): if matrix: new = [] for rows in matrix: new.append([n ** 2 for n in rows]) return new
# Adaptive Card Design Schema for a sample form. # To learn more about designing and working with buttons and cards, # checkout https://developer.webex.com/docs/api/guides/cards BUSY_CARD_CONTENT = { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.2", ...
""" This Module is not yet correct!! """ class TypedCollectionCreator(object): """ Class enforcing that the iterable only contains elements of the given type (or subclasses) at initialisation. That is, checks in the __new__ function that only elements of the given dtype are contained in the given seq...
# Map by afffsdd # A map with four corners, with bots spawning in each of them. # flake8: noqa # TODO: Format this file. {'spawn': [(1, 1), (14, 1), (15, 1), (16, 1), (17, 1), (1, 2), (1, 3), (1, 4), (17, 14), (17, 15), (17, 16), (1, 17), (2, 17), (3, 17), (4, 17), (17, 17)], 'obstacle': [(0, 0), (1, 0), (2, 0), (3, 0)...
class Node(object): """docstring for Node""" def __init__(self, item, left, right): super(Node, self).__init__() self.item = item self.left = left self.right = right def getChild(self, direction): if (direction > 0): return self.left else: ...
#!/usr/bin/env python # -*- coding: utf-8 -*- def cudasolve(A, b, tol=1e-3, normal=False, regA = 1.0, regI = 0.0): """ Conjugate gradient solver for dense system of linear equations. Ax = b Returns: x = A^(-1)b If the system is normal, then it solves (regA*A'A +regI*I)x= b ...
# MACRO - calculate precision and recall for every class, # then take their weigted sum and calculate ONE f1 score # MICRO - calculate f1 scores for each class and take their weighted sum def f1_score(precision, recall): f = 0 if precision + recall == 0 \ else 2 * precision * recall / (precision + recall) ...
""" pyPasswordValidator. Password validator """ __version__ = "0.1.3.1" __author__ = 'Jon Duarte' __credits__ = 'iHeart Media'
name = "harry" print(name[0]) # List names = ["Harry", "Ron", "Hermione"] print(names[0]) # Tuples coordinateX = 10.0 coordinateY = 20.0 coordinate = (10.0,20.0) print(coordinate)
#!/usr/bin/env python print (' ') nome = input('Digite seu nome: ') #Mensagem print (' ') print (f'Seja bem-vindo Sr(a) {nome}, Obrigado por vir!') print (' ')
# 폰켓몬 def solution(nums): n = -1 cnt = 0 nums.sort() for i in range(len(nums)): if n != nums[i]: n = nums[i] cnt += 1 if cnt == len(nums) // 2: break return cnt
#latin square num=int(input("Enter the number of rows:=")) for i in range(1,num+1): r=i #set the first roew element for j in range(1,num+1): print(r,end='\t') if r==num: r=1 else: r=r+1 print()
if (isWindVpDefined == 1): evapoTranspiration = evapoTranspirationPenman else: evapoTranspiration = evapoTranspirationPriestlyTaylor
#!/usr/bin/env python class ShapeGrid(object): """ Generic shape grid interface. Should be subclassed by specific shapes. """ def __init__(self): pass def create_grid(self, layer, extent, num_across=10): raise NotImplementedError('Provided by each subclass of ShapeGrid.')
# -*- coding: utf-8 -*- """ Created on Sun Jan 10 22:57:00 2021 @author: Dragneel """ #%% Tree structure ''' The following Family Tree will be used P1 -- / \ --- \ / \ P11 P12 + P13 --- ...
def add_time(start: str, duration: str, day: str = None) -> str: days = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') start_lst = list(map(int, start[:-3].split(':'))) duration_lst = list(map(int, duration.split(':'))) total_min = start_lst[1] + duration_lst[1] extr...
#! /usr/bin/env python3 # Type of variable: Number a, b = 5, 10 print(a, b) a, b = b, a print(a, b) # Type of variable: List myList = [1, 2, 3, 4, 5] print("Initial Array :", myList) myList[0], myList[1] = myList[1], myList[0] print("Swapped Array :", myList)
def up_egcd(m,n): #Assume m>n if n>m: m,n=n,m if m%n==0: return n else: return up_egcd(n,m%n) print(up_egcd(int(input('Number 1\n')),int(input('Number 2\n'))))
class AbstractRecurrentNeuralNetworkBuilder(object): """Build a recurrent neural network according to specified the input/output dimensions and number of unrolled steps. """ DEFAULT_VARIABLE_SCOPE = "recurrent_neural_network" def __init__(self, tensors, mixtur...
inp = open('input.txt').read().split(", ") # Reading file coord = (0, 0) # Setting original coordinates p_dir = 0 # Setting original direction (north) seen = set() for instr in inp: dir = instr[0] step = int(instr[1:]) if dir == "R": p_dir = p_dir + 1 if p_dir == 4: p_dir = 0...
# Problem : https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/submissions/ # Ref : https://youtu.be/wuzTpONbd-0 # 2 transactions only class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ n = len(prices) ...
def test_it(binbb, repos_cfg): """Test just the first one""" expected_words = ("Fields Values Branch Name Author" " TimeStamp Commit ID Message").split() for account_name, rep_cfg in repos_cfg.items(): for repo_name in rep_cfg.keys(): bbcmd = ["repo", "branch", "-a"...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 功能实现:将一个整数转换为它的罗马数字表示形式。接受1到3999之间的值(包括两个值)。 解读: 创建一个以(罗马值,整数)的形式包含元组的查找列表。 使用for循环在查找时遍历值。 使用divmod()用余数更新num,将罗马数字表示形式添加到结果中。 """ def to_roman_numeral(num): lookup = [ (1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (1...
"""Rotate a matrix by 90 degrees.""" def rotate_in_place(matrix): """ Modify and return the original matrix. rotated 90 degrees clockwise in place. """ try: n = len(matrix) m = len(matrix[0]) for i in range(n//2): for j in range(i, m-1-i): ii, j...
# @Title: 1比特与2比特字符 (1-bit and 2-bit Characters) # @Author: KivenC # @Date: 2018-07-12 21:25:38 # @Runtime: 32 ms # @Memory: N/A class Solution(object): def isOneBitCharacter(self, bits): """ :type bits: List[int] :rtype: bool """ k = 0 while k < len(bits)-1: ...
class Human(object): def __init__(self, world=None, age=20): self.maxAge = 50 self.age = age self.alive = True self.world = world def update(self): self.age += 1 if self.age > self.maxAge: self.alive = False def get_age(self): return sel...
def import_class(path): """ Import a class from a dot-delimited module path. Accepts both dot and colon seperators for the class portion of the path. ex:: import_class('package.module.ClassName') or import_class('package.module:ClassName') """ if ':' in path: ...
answerDict = { "New York" : "albany", "California" : "sacramento", "Alabama" : "montgomery", "Ohio": "columbus", "Utah": "salt lake city" } def checkAnswer(answer): resultsDict = {} for k,v in answer.items(): if answerDict[k] == v: resultsDict[k] = True else: resultsDict...
# this will create a 60 GB dummy asset file for testing the upload via # the admin GUI. LARGE_FILE_SIZE = 60 * 1024**3 # this is 60 GB with open("xxxxxxl_asset_file.zip", "wb") as dummy_file: dummy_file.seek(int(LARGE_FILE_SIZE) - 1) dummy_file.write(b"\0")
#!/usr/bin/python # Afficher les valeurs contenues dans le tableau def affiche_tab(tab): for i in range(len(tab)): print(tab[i], ' | ', sep='', end='') tab = [12, 18.5, 13.2, 8.75, 16, 15, 13.5, 12, 17] # print(tab) # I ❤ Python affiche_tab(tab)
class Solution: def calculate(self, s: str) -> int: stack = [] zero = ord('0') operand = 0 res = 0 sign = 1 for ch in s: if ch.isdigit(): operand = operand * 10 + ord(ch) - zero elif ch == '+': res += sign * oper...
#Replace all ‘0’ with ‘5’ in an input Integer def get_number(no): old=0 count=0 while(no!=0): numb=no%10 no /=10 if(numb==0): numb=5 old += numb * pow(10,count) count += 1 print(old) get_number(10120)
class libro: def __init__(self, titulo, autor, editor, ISBN, año): self.titulo= titulo self.autor= autor self.editor= editor self.ISBN=ISBN self.año= año def setTitulo(self,titulo): self.titulo=titulo def setAutor(self,autor): self.autor=autor ...
"""Assorted class utilities and tools""" class AttrDisplay: def __repr__(self): """ Get representation object. Returns ------- str Object representation. """ return "{}".format({key: value for key, value in self.__dict__.items() if not key.star...
#!/usr/bin/env python # -*- coding: utf-8 -*- # Requires python 3.6+ ####################################################################################################################### # Global variables # Can be reassigned by the settings from the configuration file ##############################################...
def swap(i, j, arr): temp = arr[i] arr[i] = arr[j] arr[j] = temp def quicksort(arr, low, high): if(low < high): p = partition(arr, low, high); quicksort(arr, low, p-1); quicksort(arr, p+1, high); def partition(arr, low, high): pivot = arr[low] i = low j = high while(i < j): while(arr[i] <= pivot and i...
""" © https://sudipghimire.com.np create a classes Rectangle, Circle and Box and add respective attributes eg.: radius, length, width, height for Rectangle, create methods to find out: perimeter area length of diagonal for Circle, create methods to find out: circumference area diameter for B...
expected_output = { "system_auth_control": False, "version": 3, "interfaces": { "Ethernet1/2": { "interface": "Ethernet1/2", "pae": "authenticator", "port_control": "not auto", "host_mode": "double host", "re_authentication": False, ...
# -*- coding: utf-8 -*- # From http://www.w3.org/WAI/ER/IG/ert/iso639.htm # ISO 639: 2-letter codes languages = { 'aa': 'afar', 'ab': 'abkhazian', 'af': 'afrikaans', 'am': 'amharic', 'ar': 'arabic', 'as': 'assamese', 'ay': 'aymara', 'az': 'azerbaijani', 'ba': 'bashkir', 'be': 'byelorussian', 'bg': 'bulgarian', 'bh': '...
class EDGARQueryError(Exception): """ This error is thrown when a query receives a response that is not a 200 response. """ def __str__(self): return "An error occured while making the query." class EDGARFieldError(Exception): """ This error is thrown when an invalid field is given to...
#FileExample2.py ----Writing data to file #opening file in write mode fp = open("info.dat",'w') #Writing data to file fp.write("Hello Suprit this is Python") #Check message print("Data Inserted to file Successfully!\nPlease Verify.")
class EnvVariableFile(object): T_WORK = '/ade/kgurupra_dte8028/oracle/work/build_run_robot1/../' VIEW_ROOT = '/ade/kgurupra_dte8028' BROWSERTYPE = 'firefox' ########################For OID info################################################ OID_HOST = 'slc06xgk.us.oracle.com' OID_PORT = '15635' OID_SSL_PORT =...
List_of_numbers = [5,10,15,20,25] for numbers in List_of_numbers: print (numbers **10) Values_list=[] Values_list.append(numbers **10) print(Values_list)
# 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 """ q...
q = 'a' while(q != 'q'): print("estou em looping") q = input("Insira algo> ") else: print("fim")
# -*- coding: utf-8 -*- """Collection of useful http error for the Api""" class GKJsonApiException(Exception): """Base exception class for unknown errors""" title = 'Unknown error' status = '500' source = None def __init__(self, detail, source=None, title=None, status=None, code=None, id_=None,...
# cnt = int(input()) # for i in range(cnt): # rep = int(input()) # arr = list(str(input())) # for j in range(len(arr)): # prt = arr[j] # for _ in range(rep): # print(prt,end="") # print() cnt = int(input()) for i in range(cnt): (rep,arr) = map(str,inpu...
""" This module holds the command class """ class Command(): """ This class has static methods to handle the minimum commands recommended by Telegram """ @staticmethod def help(): """ This static method returns the message for users '/help' call in chats """ ret...
class SwapUser: def __init__(self, exposure, collateral_perc, fee_perc): self.exposure = exposure self.collateral = collateral_perc self.collateral_value = collateral_perc * exposure self.fee = fee_perc * exposure self.is_active = True self.is_liquidated = ...
"""HTML related constants. """ SCRIPT_START_TAG: str = '<script type="text/javascript">' SCRIPT_END_TAG: str = '</script>'
class SquareGrid: def __init__(self, width, height): self.width = width self.height = height self.walls = [] def in_bounds(self, node_id): (x, y) = node_id return 0 <= x < self.width and 0 <= y < self.height def passable(self, node_id): return node_id not in...
#!/usr/bin/python2.7 # -*- coding: utf-8 -*- # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # 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 ...
# # PySNMP MIB module NETSCREEN-OSPF-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NETSCREEN-OSPF-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:10:23 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
# Tara O'Kelly - G00322214 # Emerging Technologies, Year 4, Software Development, GMIT. # Problem set: Python fundamentals # 8. Write a function that merges two sorted lists into a new sorted list. [1,4,6],[2,3,5] → [1,2,3,4,5,6]. l1 = [1,4,6] l2 = [2,3,5] #https://docs.python.org/3/howto/sorting.html print(sorted(l...
"""配置文件""" HELP = "help.txt" # 帮助文件地址 SQL = "sql.txt" # sql 文件保存地址 TITLE = "WP中文图片名修复工具" # 程序标题 SUCCESS_TITLE = "操作成功" # 成功标题 SUCCESS_MSG = "文件名已更改, 请在数据库中执行 {file} 中的语句".format(file=SQL) # 成功提示语 FAILED_TITLE = "操作失败" # 失败标题 FAILED_MSG = "更改失败, 请查看程序是否有该文件夹读取权限" # 失败提示语 INFO_TITLE = "提示" # 提示标题 INFO_...
test_dic = { "SERVICETYPE": { "SC": { "SITEVERSION": {"T33L": "1"} }, "EC": { "SITEVERSION": { "T33L": "1", "T31L": { "BROWSERVERSION": { "9.1": "1", "59.0": "1" ...
# # @lc app=leetcode id=977 lang=python3 # # [977] Squares of a Sorted Array # # @lc code=start class Solution: def sortedSquares(self, A: List[int]) -> List[int]: newls = [item * item for item in A] return sorted(newls) # @lc code=end
def get_firts_two_characters(string): # 6.1.A return string[:2] def get_last_three_characters(string): # 6.1.B return string[-3:] def print_every_two(string): # 6.1.C return string[::2] def reverse(string): # 6.1.D return string[::-1] def reverse_and_concact(string): # 6.1.D ...
#!/usr/bin/env python3 def stalinsort(x=[]): if x == []: return x for i in range(len(x)-1): if x[i] < x[i+1]: continue else: x.pop(i+1) return x
val = input('Digite algo para ver as informações: ') print('O tipo do valor digitado é {}'.format(type(val))) #Mostrando todas as opções num = val.isnumeric() alp = val.isalpha() alpNum = val.isalnum() low = val.islower() up = val.isupper() asc = val.isascii() dec = val.isdecimal() dig = val.isdigit() idn = val.isiden...
# -*- coding: utf-8 -*- """ Time penalties for Digiroad 2.0. Created on Thu Apr 26 13:50:03 2018 @author: Henrikki Tenkanen """ penalties = { # Rush hour penalties for different road types ('rt') 'r': { 'rt12' : 12.195 / 60, 'rt3' : 11.199 / 60, 'rt456...
# Author: thisHermit ASCENDING = 1 DESCENDING = 0 N = 5 def main(): input_array = [5, 4, 3, 2, 5] a = input_array.copy() # sort the array sort(a, N) # test and show assert a, sorted(input_array) show(a, N) def exchange(i, j, a, n): a[i], a[j] = a[j], a[i] def compare(i...
input_data = raw_input(">") upper_case_letters = [] lower_case_letter = [] for x in input_data: if str(x).isalpha() and str(x).isupper(): upper_case_letters.append(str(x)) elif str(x).isalpha() and str(x).islower(): lower_case_letter.append(str(x)) print("Upper case: " + str(len(upper_case_le...
# Test for breakage in the co_lnotab decoder locals() dict def foo(): locals() """ ...
""" General config file for Bot Server """ token = '<YOUR-BOT-TOKEN>' telegram_base_url = 'https://api.telegram.org/bot{}/' timeout = 100 model_download_url = '<MODEL-DOWNLOAD-URL>' model_zip = 'pipeline_models.zip' model_folder = '/pipeline_models' CELERY_RESULT_BACKEND = 'redis://localhost:6379/0' CELERY_BROKER_URL ...
''' While loop - it keeps looping while a given condition is valid ''' name = "Kevin" age = 24 letter_index = 0 while letter_index < len(name): print(name[letter_index]) letter_index = letter_index + 1 else: print("Finished with the while loop") ''' line 4 - we define the name with a string "Kevin" line 5 -...
# List transports = ["airplane", "car", "ferry"] modes = ["air", "ground", "water"] # Lists contain simple data (index based item) and can be edited after being assigned. # E.g. as transport types are not as limited as in this list, it can be updated by adding or removing. # Let's create a couple of functions for add...
class WordDictionary: def __init__(self): self.list=set() def add_word(self, word): self.list.add(word) def search(self, s): if s in self.list: return True for i in self.list: if len(i)!=len(s): continue flag=True ...
# Coastline harmonization with a landmask def coastlineHarmonize(maskFile, ds, outmaskFile, outDEM, minimum, waterVal=0): ''' This function is designed to take a coastline mask and harmonize elevation values to it, such that no elevation values that are masked as water cells will have elevation >0, ...