content
stringlengths
7
1.05M
########################################################## # Author: Raghav Sikaria # LinkedIn: https://www.linkedin.com/in/raghavsikaria/ # Github: https://github.com/raghavsikaria # Last Update: 31-5-2020 # Project: LeetCode May 31 Day 2020 Challenge - Day 31 ##########################################################...
"""Basic Sphinx configuration file for testing. We use ``confoverrides`` in the tests to provide the actual configuration. """ html_theme = "sphinxawesome_theme"
# vim: set fenc=utf8 ts=4 sw=4 et : class Plugin2(object): # pragma: no cover """Version 2 plugin interface.""" @staticmethod def help(): """Return a help string.""" pass def __init__(self, *args): """Called once during startup.""" pass def __deinit__(self): ...
# Pins [(606, 187), (331, 188), (469, 188), (188, 190), (549, 206), (397, 207), (243, 208), (483, 231), (312, 232), (401, 262)] #Pins [(605, 164), (186, 165), (471, 165), (549, 184), (395, 185), (241, 186), (484, 210), (401, 243)] mpins = [(606, 187), (331, 188), (469, 188), (188, 190), (549, 206), (397, 207), (243, ...
# Reserved words reserved = [ 'class', 'in', 'inherits', 'isvoid', 'let', 'new', 'of', 'not', 'loop', 'pool', 'case', 'esac', 'if', 'then', 'else', 'fi', 'while' ] tokens = [ 'COMMENTINLINE', 'DARROW', 'CLASS', 'IN', 'INHERITS', 'ISVOID', 'LET', 'NEW', 'OF', 'NOT', 'LOOP', 'POOL', 'CASE', 'ESAC', 'IF', '...
""" 13.机器人的运动范围 时间复杂度:O(???) 空间复杂度:O(mn) """ class Solution: def movingCount(self, threshold, rows, cols): if threshold <0 and rows <= 0 and cols <= 0: return 0 visited = [[0]*cols for _ in range(rows)] count = self.movingCountCore(threshold, rows, cols, 0, 0, visited) re...
#!/usr/bin/env python if __name__ == "__main__": print(__file__[0:-3]) elif __name__ == __file__[0:-3]: print("__name__ isn't __main__") else: print("Hmm, something's fishy!" )
ships = { "destroyer":[[[0,0], [0,1]], [[0,0],[1,0]]], "submarine":[[[0,0], [0,1], [0,2]], [[0,0],[1,0], [2,0]]], "cruiser": [[[0,0], [0,1], [0,2]], [[0,0],[1,0], [2,0]]], "carrier": [[[0,0], [0,1], [0,2], [0,3], [0,4]], [[0,0],[1,0], [2,0], [3,0], [4,0]]] } shipSymbols = {"destroyer":1, "submarine":...
# what the heck is a class ? ## the class groups similar features together ## the init function in the class are the costructors class Enemy: life = 3 def __init__(self): print("Enemy created") def attack(self): print('ouch') self.life -= 1 def checklife(self): if ...
""" Provides a collection of molior exceptions. """ class MoliorError(Exception): """Base exception for all molior specific errors.""" pass class MaintainerParseError(MoliorError): """ Exception which is raised if the maintainer could not be parsed. """ pass
sentence = "What is the Airspeed Velocity of an Unladen Swallow?" list_words = sentence.split() result = {word: len(word) for word in list_words} print(result)
NUM_PAGES = 25 LIMIT = 500 FREQ = 0.1 STOP_LIST_FILE = "StopList.txt"
# by Kami Bigdely # Extract class class Actor: def __init__(self, first_name, last_name, birth_year, movies, email): self.first_name = first_name self.last_name = last_name self.birth_year = birth_year self.movies = movies self.email = Email(email) def send_email(self):...
# # PySNMP MIB module MSERIES-ALARM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MSERIES-ALARM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:05:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
""" 题目:1008. 先序遍历构造二叉树 返回与给定先序遍历 preorder 相匹配的二叉搜索树(binary search tree)的根结点。 (回想一下,二叉搜索树是二叉树的一种,其每个节点都满足以下规则,对于 node.left 的任何后代,值总 < node.val,而 node.right 的任何后代,值总 > node.val。此外,先序遍历首先显示节点的值,然后遍历 node.left,接着遍历 node.right。) 示例: 输入:[8,5,1,7,10,12] 输出:[8,5,10,1,7,null,12] 图:https://assets.leetcode-cn.com/aliyun-lc-upl...
class Solution: def reverse(self, x): """ :type x: int :rtype: int """ cmp(x, 0)
## allow us to use key value pairs ## create a program that will convert digit to num ## inside dic need {} monthConversions = { "Jan": "January", "Feb": "February", "Mar": "March", "Apr": "April", "May" : "May", "Jun" : "June", "Jul": "July", "Aug" : "August", "Sep" : "...
# 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...
directions = { "E": [0, 1], "S": [-1, 0], "W": [0, -1], "N": [1, 0], } cardinal = { 0: "E", 1: "S", 2: "W", 3: "N", } def travel(input): cur_x = 0 cur_y = 0 facing = 0 for instruction in input: action = instruction[0] value = int(instruction[1:]) ...
#1 Manual way def keep_evens (nums): new_list = [] for num in nums: if num % 2 == 0: new_list.append(num) return new_list print(keep_evens([3, 4, 6, 7, 0, 1])) #2 def keep_evens(nums): new_seq = filter(lambda num: num %2 ==0, nums) #Instead of transforming an input like in map fun...
class Membresias(): """Contiene las funciones de membresía como métodos estáticos. """ @staticmethod def triangular(x, a, b, c): """Fusifica 'x' en una función triangular. """ if x > a and x <= b: return (x - a) / (b - a) elif x > b and x < c: retu...
"""Utilities for use with the manifest structure returned by GetManifest """ __author__ = "Chris Stradtman" __license__ = "MIT" __version__ = "1.0" def getManifestEtag(manifest): """ returns Etag hash for manifest""" return manifest["Etag"] def getManifestType(manifest): """ returns manifest type for m...
class Commands: def __init__(self, player_id): self.player_id = player_id def attack(self, direction): data = { 'command': 'attack', 'character_id': str(self.player_id), 'direction': direction } return data def collect(self): dat...
# coding: utf-8 # @author octopoulo <polluxyz@gmail.com> # @version 2020-11-12 """ Init """ __all__ = [ '__main__', 'antifraud', 'commoner', ]
class Room: def __init__( self, id, name, description, n_to=None, s_to=None, e_to=None, w_to=None ): self.id = id self.name = name self.description = description self.n_to = n_to self.s_to = s_to self.e_to = e_to self.w_to = w_to # def __repr_...
class Solution(object): def intersect(self, nums1, nums2): if len(nums1) > len(nums2): nums1, nums2 = nums2, nums1 c = collections.Counter(nums1) res = [] for i in nums2: if c[i] > 0: res += i, c[i] -= 1 ...
# Bite 5 https://codechalleng.es/bites/5/ NAMES = [ "arnold schwarzenegger", "alec baldwin", "bob belderbos", "julian sequeira", "sandra bullock", "keanu reeves", "julbob pybites", "bob belderbos", "julian sequeira", "al pacino", "brad pitt", "matt damon", "brad pitt...
#!/usr/bin/python # -*- coding: UTF-8 -*- """ practice by python for lessone 02 需求:汉诺塔操作路径 把高度为n的汉诺塔从起始位置挪到终点位置,计算出操作步骤 """ n = 3 # 高度 pillars = range(3) # 柱子编号,0是起点,2是终点 disks = range(n) # 盘子编号,从小到大,0最小 def move_tower(n): move_tower(n - 1) move_tower() # 如何抽象化?
# Released under the MIT License. See LICENSE for details. # # This file was automatically generated from "monkey_face.ma" # pylint: disable=all points = {} # noinspection PyDictCreation boxes = {} boxes['area_of_interest_bounds'] = (-1.657177611, 4.132574186, -1.580485661) + (0.0, ...
# Copyright 2016-2017 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
# PySNMP SMI module. Autogenerated from smidump -f python SNMP-VIEW-BASED-ACM-MIB # by libsmi2pysnmp-0.1.3 at Tue Apr 3 16:57:42 2012, # Python version sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0) # Imports ( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", ...
class Solution(object): def partition(self, s): """ :type s: str :rtype: List[List[str]] """ return [[s[:i]]+rest for i in xrange(1,len(s)+1) if s[:i]==s[:i][::-1] for rest in self.partition(s[i:])] or [[]]
W = 8 N = 4 wi = [3, 3, 5, 6] ci = [3, 5, 10, 14] d = [[0] * (W + 1) for i in range(N + 1)] for i in range(1, N + 1): for w in range(1, W + 1): if wi[i-1] > w: d[i][w] = d[i-1][w] else: d[i][w] = max(d[i-1][w], d[i-1][w-wi[i-1]]+ci[i-1]) print('\n'.join([' '.join(map(str, d...
def foo(i): print(i) for k in [1,2,3,4,5]: foo(k)
class Solution: def minOperations(self, n: int) -> int: if n % 2 == 1: n_2 = n // 2 return n_2 ** 2 + n_2 else: n_2 = n // 2 return n_2 ** 2
class FrameRole(object): def __init__(self, source, description): assert(isinstance(source, str)) assert(isinstance(description, str)) self.__source = source self.__description = description @property def Source(self): return self.__source @property def Des...
def f(x): if x == 0: return 0 return x + f(x - 1) print(f(3)) # Output is 6
def M(): i=0 while i<6: j=0 while j<5: if (j==0 or j==4) or (i<3 and (i-j==0 or i+j==4)): print("*",end=" ") else: print(end=" ") j+=1 i+=1 print()
'''v = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0 ]] c = 0 print(type(v)) for i in range(0, 3): for j in range(0, 4): v[i][j] = int(input('numero:')) for i in range(0, 3): for j in range(0, 4): print(f'[{v[i][j]}]', end= '') if v[i][j] > 10: c = c + 1 print() print(c)''' d...
# !/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/2/1 0001 22:21 # @Author : Gpp # @File : httper.py DEBUG = True # 这个参数是固定的,'mysql'表示数据库类型,‘cymysql’表示mysqle的驱动,需要pipenv 手动安装 SQLALCHEMY_DATABASE_URI = 'mysql+cymysql://root:asd1234@111.33.152.130:10659/fisher' SECRET_KEY = '\x88D\x91'
class Vaca: cola = True da_leche = False camina = False def __init__(self, nombre, color, cola): self._nombre = nombre self.color = color self.cola = cola def info(self): print("#"*30) print("Nombre :", self._nombre) print("Color:", self.color) ...
#This program says Hello and asks for my name print('Hello World') print('What\'s your name?')#ask for their name myName=input() print('Nice to meet you,'+ myName) print('your length name is : '+str(len(myName))) print('Your age?')#ask for their age myAge=input() print('You will be '+str(int(myAge)+1)+' in a...
STATS = [ { "num_node_expansions": 8573, "plan_length": 112, "search_time": 9.18, "total_time": 9.18 }, { "num_node_expansions": 9432, "plan_length": 109, "search_time": 10.41, "total_time": 10.41 }, { "num_node_expansions": 117...
#https://practice.geeksforgeeks.org/problems/subarray-with-0-sum-1587115621/1 #Complete this function def subArrayExists(arr,n): ##Your code here #Return true or false sum=0 store =set() for i in range(n): sum+=arr[i] if sum==0 or sum in store: return 1 store.add...
def someAction_Decorator(func): def wrapper(*args, **kwargs): func(*args, **kwargs) print("something else") return wrapper class someAction_ClassDecorator(object): def __init__(self, func): self.func = func def __call__(self, *args, **kwargs): self.func(self, *args, *...
# # PySNMP MIB module HIRSCHMANN-MMP4-ROUTING-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HIRSCHMANN-MMP4-ROUTING-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:18:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python versio...
def feuer_frei(concentration, barrels): fuel_hours = barrels * concentration if fuel_hours < 100: return '{} Stunden mehr Benzin ben\xf6tigt.'.format(100 - fuel_hours) elif fuel_hours == 100: return 'Perfekt!' return fuel_hours - 100
# Part 1 a_list = [1, 2, 3, 4, 5] a = a_list[1] b = a_list[3] print(a) print(b) # Part 2 a_string = "FIT2085" print(a_string[a]) print(a_string[b]) # Part 3 print("a = not True: " + str(not True)) print("b = 2 + 2 > 4: " + str(2 + 2 > 4)) print("c = not '0' == 0: " + str(not '0' == 0)) # Reassigning variables wit...
n1 = float(input('Primeiro segmento: ')) n2 = float(input('Segundo segmento: ')) n3 = float(input('Terceiro segmento: ')) if n1 < n1 + n3 and n2 < n1 +n3 and n3 < n1 + n2: print('Os segmentos podem formar um triangulo.') if n1 == n2 == n3 == n1 : print('EQUILATERO') elif n1 != n2 != n3 != n1: ...
# dataset_paths = { # 'celeba_train': '', # 'celeba_test': '', # 'celeba_train_sketch': '', # 'celeba_test_sketch': '', # 'celeba_train_segmentation': '', # 'celeba_test_segmentation': '', # 'ffhq': '', # } dataset_paths = { 'trump_train': '/media/ubuntu/Data1/data/Trump/trump-high-res-photos_aligne...
e = [int(x) for x in str(input()).split()] q = e[0] e = [int(x) for x in str(input()).split()] for i in range(q): n = int(input()) if n in e: print(0) else: print(1) e.append(n)
""" 2 - The underscore is used to ignore a given value. You can just assign the values to underscore. """ x, _ , z = (1,2,3) print(x, z) a, *_ , b = (1,2,3,4,5) print(a,b) for _ in range(10): print('hello world')
# # PySNMP MIB module ISPGRPEXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ISPGRPEXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:57:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
class Solution: @staticmethod def naive(nums): s = set() for i in nums: if i in s: return True s.add(i) return False
foo = input("Team: ") for c in foo: print("Give me a " + c.upper() + "!" ) print("What does that spell? " + foo.upper() + "!") foo = input("What animal would you like? ") bar = input("How many? ") if foo.isupper() == True: print("Woah! No need to shout, you'll scare the animals!") elif...
def main(request, response): response.headers.set("Cache-Control", "no-store") response.headers.set("Access-Control-Allow-Origin", request.headers.get("origin")) response.headers.set("Access-Control-Allow-Credentials", "true") uid = request.GET.first("uid", None) if request.method == "OPTIONS": ...
#.q1 Multiply following matrices #Using for loops and print the result. a =[[1,2,3], [4,5,6], [7,8,9]] b=[[111,22,33], [44,55,56], [47,86,19]] mul=[[0,0,0], [0,0,0], [0,0,0]] for i in range(3): for j in range (3): for k in range (3): mul[i][j]+=a[i][k]*b[k][j] for l in mu...
# -*- coding: utf-8 -*- """ Editor: Zhao Xinlu School: BUPT Date: 2018-04-11 算法思想:普通二叉树层结点连接 """ # Definition for binary tree with next pointer. class TreeLinkNode: def __init__(self, x): self.val = x self.left = None self.right = None self.next = None class Solution: # @param r...
# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making BK-BASE 蓝鲸基础平台 available. Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. BK-BASE 蓝鲸基础平台 is licensed under the MIT License. License for BK-BASE 蓝鲸基础平台: ------------------------------------------...
class RetryException(Exception): """可以重新尝试的异常""" pass class MaybeChanged(Exception): pass class FrequentAccess(Exception): """部分网站会识别爬虫,在一段时间内禁止访问""" pass class ConnectFailed(Exception): """网络连接失败,需要中断程序""" pass class NoWebData(Exception): """无数据异常""" pass class FutureDate(...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 数値の読み込み x,y = [int(i) for i in input().split()] res = 0 if abs(y) > abs(x): # |x| < |y| if x < 0: res = res + 1 if y < 0: res = res + 1 res = res + (abs(y)-abs(x)) else : # x > y if x > 0: res = res + 1 if y > 0: ...
# 2020.08.07 # Problem Statement: # https://leetcode.com/problems/search-insert-position/ class Solution: def searchInsert(self, nums: List[int], target: int) -> int: # check empty list if len(nums) == 0: return 0 # check out of range, early return if target < nums[0]: return 0 ...
#encoding:utf-8 subreddit = 'formula1' # This is for your public telegram channel. t_channel = '@r_formula1' def send_post(submission, r2t): return r2t.send_simple(submission)
""" Função len ve a qyantidade de caracteres e retorna inteiro """ nome = input('Qua é o seu nome?') print(f'{len(nome)}')
""" Levantando os próprios erros com Raise raise -> Lança exceções OBS: O raise não é uma função, é uma palavra reservada, assim como def ou qualquer outra em Pyhton Para simplificar, pense no raise como sendo útil para que possamos criar as nossas prórpias exceções e mensagens de erro. A forma geral de utilização ...
# https://leetcode.com/problems/dungeon-game/ class Solution(object): def calculateMinimumHP(self, dungeon): """ The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initial...
# Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file> # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> # Created By: anze@reciprocitylabs.com # Maintained By: anze@reciprocitylabs.com scope = "Admin" description = """ gGRC System Administrator with super-user pr...
def fatorial(n): f = 1 for c in range(n, 0, -1): f *= c return print(f'{f}') x = int(input('Fatorial do número: ')) fatorial(x)
seg = int(input('Insira votos para Segunda: ')) ter = int(input('Insira votos para Terça: ')) qua = int(input('Insira votos para Quarta: ')) qui = int(input('Insira votos para Quinta: ')) sex = int(input('Insira votos para Sexta: ')) if seg > ter and seg > qua and seg > qui and seg > sex: print('O dia escolhido pa...
# take a number as an input from user and print a multiplication table of that number def multiplication_table(): value = int(input('please type a number: ')) for num in range(1, 11): print(f'{value} * {num} = {value * num}' ) multiplication_table()
STATE_FILENAME = ".state.json" CACHE_DIR_REL = ".cache" ARCHIVE_SUBDIR_REL = "archives" SNAPSHOT_SUBDIR_REL = "snapshots"
class JSError(Exception): def __init__(self,ErrorInfo): super(JSError,self).__init__() self.errorinfo = ErrorInfo def __str__(self): return self.errorinfo
arr = ["eat", "tea", "tan", "ate", "nat", "bat"] def is_anna(str1, str2): chars = [0] * 26 if len(str1) != len(str2): return False for s1, s2 in zip(str1, str2): is1 = ord(s1) is2 = ord(s2) chars[97 - is1] = chars[97 - is1] + 1 chars[97 - is2] = chars[97 - is2] - 1 ...
def fix_teen(n): if (n >= 13 and n <= 14) or (n >= 17 and n <= 19): return 0 def no_teen_sum(a, b, c): abc = [a, b, c] count = 0 for i in abc: if fix_teen(i) != 0: count += i return count
''' Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 1...
if True : print(True) else : print(False) if not False : print(True) else : print(False)
""" quiz materials for feature scaling clustering """ ### FYI, the most straightforward implementation might ### throw a divide-by-zero error, if the min and max ### values are the same ### but think about this for a second--that means that every ### data point has the same value for that feature! ### why would you...
def findSum(numbers, queries): k = [] sum = 0 for i in range(len(queries)): for j in range(len(queries[i])): k.append(queries[i][j]) for l in range(k[0] + 1, k[1]): if numbers[l] != 0: sum = sum + numbers[l] else: sum += k[2] print(numbers...
n=int(input()) for i in range(0,n): for j in range(0,n-i): print(' ',end='') for k in range(0,n-i): print('*',end='') print() for i in range(1,n): for j in range(-1,i): print(' ',end='') for k in range(-1,i): print('*',end='') print()
''' * Conversão de tipos de dados (casting) * Repositório: Lógica de Programação e Algoritmos em Python * GitHub: @michelelozada ''' # 1. Convertendo para int a = int(5) b = int(5.7) c = int("5") print(a,type(a)) # Retorna: 5 <class 'int'> print(b,type(b)) # 5 <class 'int'> print(c,type(c)) # 5 <class 'int'...
""" Welcome to My Module I am description of the module """ print ("My Name is Module") def hello_method(): '''The hello method greets you''' pass def string_reverse(str1): ''' Returns the reversed String. Parameters: str1 (str):The string which is to be reversed. Returns: ...
## Simple cache class OwnCache: __cache = {} __save_interval = 10 ## In seconds def __init__(self,save_to_disk=0): self.save = save_to_disk def set(self,key,data): self.__cache[key] = data def get (self,key): data = None if key in self.__cache: data =...
""" --- title: Retrieval-Enhanced Transformer (Retro) summary: > This is a PyTorch implementation/tutorial of the paper Improving language models by retrieving from trillions of tokens. It builds a key-value database of chunks of text and retrieves and uses them when making predictions. --- # Retrieval-Enhance...
"""A command line tool to view detailed information about a character.""" __name__ = "charinfo" __title__ = __name__ __license__ = "MIT" __version__ = "0.2.0" __author__ = "Arian Mollik Wasi" __github__ = "https://github.com/wasi-master/charinfo"
def main(): my_workers = workers_data() print(my_workers.add("A", 4)) print(my_workers.add("A", 5)) print(my_workers.add("B", 3)) print(my_workers.add("C", 3)) print(my_workers.get("A")) print(my_workers) class workers_data(): jobList = {} def __init__(self): pass de...
n = int(input()) numbers = [] for i in range(n): numbers.append(int(input())) max_number = max(numbers) numbers.remove(max_number) if sum(numbers) == max_number: print(f"Yes\nSum = {max_number}") else: print(f"No\nDiff = {abs(max_number - sum(numbers))}")
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the...
# # Define directories # data_dir = "/Users/hn/Documents/01_research_data/Ag_check_point/remote_sensing/01_NDVI_TS/Grant/" # # Define some parameters # file_names = ["Grant_2018_TS.csv"] # # Read Data # file_N = file_names[0] grant_2018 = pd.read_csv(data_dir + file_N) # # clean # grant_2018 = initial_clean(grant_20...
with open('a.csv', 'r', encoding = 'UTF8') as a: l = [] for linha in a: l.append(linha.replace('\n', '').split(',')) print(l)
#!/usr/bin/env python # Bisection search algorithm for finding square root using high and low # values x = float(input('Enter a number: ')) epsilon = 0.01 num_guesses, low = 0,0 high = max(1, x) ans = (high + low)/2 while abs(ans**2 - x) >= epsilon: print('low =', low, 'high =', high, 'ans =', ans) num_guesses ...
''' In a string check how many deletions are needed so that there are only alternating As and Bs ''' def alternatingChars(s): deletions = 0 for i in range(len(s) - 1): j = i + 1 if s[i] == s[j]: deletions += 1 return deletions print(alternatingChars('AAABBB'))
# kubectl explain deployment --recursive dict_data = {} space_count = 3 def addString(key): dict_data[key] = " " def addObject(key): dict_data[key] = " " with open("temp.txt", "r") as f: lines = f.readlines() for i in lines: if i[space_count + 1] == " ": addObject(i.split()[0...
q = int(input("")) s1 = int(input("")) s2 = int(input("")) s3 = int(input("")) s1 = s1 - ((s1 // 35) * 35) s2 = s2 - ((s2 // 100) * 100) s3 = s3 - ((s3 // 10) * 10) a = 0 while q > 0: s1 += 1 if s1 == 35: s1 = 0 q += 30 q -= 1 if q == 0: a += 1 break ...
#!/usr/bin/env python """ Gurunudi Language codes for different languages """ ABKHAZIAN ="abk" AFAR ="aar" AFRIKAANS ="afr" AHOM ="aho" ALBANIAN ="sqi" ARABIC ="ara" ARMENIAN ="hye" AZERBAIJANI ="aze" BALINESE ="ban" BAMUM ="bax" BASQUE ="eus" BASSA ="bsq" BATAK ="btk" BELARUSIAN ="bel" BENGALI ="ben" BOSNIAN ="bos"...
"""Number Checker This script takes user input and converts it to an integer, float or error. """ def number_checker(input): """Finds type of input (in, float, other). Args: input : a string of alphanumeric characters Returns: input : the string converted to an int, float or e...
class ResponseCodeError(Exception): """ Called when the Skyblock API returns an unexpected response code. """ pass class UnexpectedUpdateError(Exception): """ Called when the Skyblock API updates during a cache. """ pass
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode """ if ...
input = """ :- a, c. a | b. a | a. fact1. :- fact1, not c. """ output = """ :- a, c. a | b. a | a. fact1. :- fact1, not c. """
class ResponseType: CH_STATUS = "CH_STATUS" CH_FAILED = "CH_FAILED" LIVETV_READY = "LIVETV_READY" MISSING_TELEPORT_NAME = "MISSING_TELEPORT_NAME" INVALID_KEY = "INVALID_KEY" class ChannelStatusReason: LOCAL = "LOCAL" REMOTE = "REMOTE" RECORDING = "RECORDING" class ChannelSetFailureRe...
def site_info(request): """ An example of using context processor """ return { 'owner': 'Кромм Владимир', }