content
stringlengths
7
1.05M
# Copyright 2021 Jake Arkinstall # # Work based on efforts copyrighted 2018 The Bazel 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...
def add(matA,matB): dimA = [] dimB = [] # find dimensions of arrA a = matA b = matB while type(a) == list: dimA.append(len(a)) a = a[0] # find dimensions of arrB while type(b) == list: dimB.append(len(b)) b = b[0] #is it possible to add them if dim...
# This file contains code that can be used later which cannot fit in right now. '''This is the function to run 'map'. This is paused so that PyCUDA can support dynamic parallelism. if stmt.count('map') > 0: self.kernel_final.append(kernel+"}") start = stmt.index('map') + 2 declar = self.device_py[self.devi...
""" Code implementing standard data types. Can depend on core and calc, and no other Sauronlab packages. """
class Solution(object): def calculateMinimumHP(self, dungeon): """ :type dungeon: List[List[int]] :rtype: int """ if not dungeon: return 0 N = len(dungeon) M = len(dungeon[0]) matrix = [] for i in range(N): row = [0] * M...
# Copyright 2017 Rice University # # 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 writin...
names = [] children = [] with open("day7.txt") as f: for line in f.readlines(): data = line.split('->') names.append(data[0].split(" ")[0]) if len(data) == 2: [x.strip() for x in data[1].split(',')] children.append([x.strip() for x in data[1].split(',')]) children = [...
# Implementation of EA def gcd(p, q): while q != 0: (p, q) = (q, p % q) return p # Implementation of the EEA def extgcd(r0, r1): u, v, s, t = 1, 0, 0, 1 # Swap arguments if r1 is smaller if r1 < r0: temp = r1 r1 = r0 r0 = temp # While Loop to cumpute params w...
year=int(input("Enter any year to check for leap year: ")) if year%4==0: if year%100==0: if year%400==0: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) else: print("{0} is a leap year".format(year)) else: print("{0}...
s = input().strip() while(s != '0'): tam = len(s) i = 1 anagrama = 1 while(i <= tam): anagrama = anagrama * i i = i + 1 print(anagrama) s = input().strip()
class Solution: """ @param numbers: An array of Integer @param target: target = numbers[index1] + numbers[index2] @return: [index1, index2] (index1 < index2) """ def twoSum(self, numbers, target): # write your code here #遍历一遍,边遍历变查询哈希表,如果余数不再哈希表里面,就把当前值假如哈希表。如果在,就直接返回。这个方法 ...
# # @lc app=leetcode.cn id=1587 lang=python3 # # [1587] parallel-courses-ii # None # @lc code=end
class Solution: def findComplement(self, num: int) -> int: num = bin(num)[2:] ans = '' for i in num: if i == "1": ans += '0' else: ans += '1' ans = int(ans, 2) return ans
# # PySNMP MIB module AT-PIM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-PIM-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:30:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:...
def create_phone_number(n): return (f'({n[0]}{n[1]}{n[2]}) {n[3]}{n[4]}{n[5]}-{n[6]}{n[7]}{n[8]}{n[9]}') # Best Practices def create_phone_number(n): print ("({}{}{}) {}{}{}-{}{}{}{}".format(*n))
class Class: def __init__(self, name): self.name = name self.fields = [] def __str__(self): lines = ['class %s:' % self.name] if not self.fields: lines.append(' pass') else: lines.append(' def __init__(self):') for f in self.fields: ...
n1 = int(input('Digite um valor :')) n2 = n1*2 n3 = n1*3 nrz = n1**(1/2) print('O valor digitado foi {},\n seu dobro é : {},\n seu triplo é: {} \ne sua raiz quadrada é {}'.format(n1,n2,n3,nrz)) 100
class LCS: def __init__(self,str1,str2): self.str1=str1 self.str2=str2 self.m=len(str1) self.n=len(str2) self.dp = [[0 for x in range(self.n + 1)] for x in range(self.m + 1)] def lcs_length(self): for i in range(self.m): for j in range(self...
# n = s = 0 # while n != 999: # FLAG (PONTO DE PARADA) # n = int(input('Digite um número: ')) # s += n # s -= 999 # GAMBIARRA PARA O FLAG NÃO ENTRAR NA SOMA!!! # print('A soma vale {}'.format(s)) n = s = 0 while True: n = int(input('Digite um número: ')) if n == 999: break s += n # prin...
print(''' Exercício 51 da aula 13 de Python Curso do Guanabara Day 22 Code Python - 21/05/2018 ''') primeira = int(input('Primeiro termo: ')) razao = int(input('Razão: ')) décima = primeira + (10 - 1) * razao print('Os primeiros 10 termos são:', end=' ') for n in range(primeira, décima + razao, razao): ...
# Copyright (c) 2014 Eventbrite, Inc. All rights reserved. # See "LICENSE" file for license. """These functions should be made available via cs2mako in the Mako context""" def include(clearsilver_name): """loads clearsilver file and returns a rendered mako file""" pass # need to put whatever ported clearsil...
################################################################################ ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public ## License as published by the Free Software Foundation; either ## version 2.1 of the License, or (at your op...
parties = [] class Political(): @staticmethod def exists(name): """ Checks if a party with the same name exists Returns a boolean """ for party in parties: if party["name"] == name: return True return False def create_political_...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 16 11:05:36 2021 @author: Olli Nevalainen (Finnish Meteorological Institute) """
# Copyright (c) 2019 The Bazel Utils Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. load("//:conditions.bzl", "if_windows") load("//:warnings.bzl", "default_warnings") #################################################################...
#!/usr/bin/python3 # -*- coding: utf-8 -*- def f(x): return(x**2-2*x-3) def hata(x1,x2): return((x1-x2)/x1) x1 = int(input("bir başlangıç değeri girin: ")) x3 = int(input("ikinci başlangıç değerini girin: ")) for i in range(5): x2 = x1 - (f(x1)*(x3-x1))/(f(x3)-f(x1)) print(x3, x1, x2, hata(x2,x1)) ...
fps = 60 game_duration = 120 # in sec window_width = 1550 window_height = 800
class Solution(object): def maxLength(self, arr): """ :type arr: List[str] :rtype: int """ if not arr: return 0 if len(arr) == 1: return len(arr[0]) result = [0] self.max_unique(arr, 0, "", result) return result[0] ...
def main(): ans = 1 for n in range(1, 501): ans += f(n) print(ans) def f(n): return 4 * (2 * n + 1)**2 - (12 * n) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- __all__ = [ "StorageBackend" ] class StorageBackend(object): """Base class for storage backends.""" async def store_stats(self, stats): raise NotImplementedError
""" discpy.types ~~~~~~~~~~~~~~ Typings for the Discord API :copyright: (c) 2021 The DiscPy Developers (c) 2015-2021 Rapptz :license: MIT, see LICENSE for more details. """
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 16 12:02:13 2019 Customized by Pedro Villarroel from Peter Norvig's spell.py Words list retrieved from FrequencyWords by Hermit Dave (@hermitdave on github) """ """ #es_WORDS = pd.read_csv('Documents/Machine_Learning/MeLi_Classifier/data/es_50k.txt...
def get_param_dict(self): """Get the parameters dict from ELUT Parameters ---------- self : ELUT an ELUT object Returns ---------- param_dict : dict a Dict object """ param_dict = {"R1": self.R1, "L1": self.L1, "T1_ref": self.T1_ref} return param_dict
class A(object): pass print(A.__sizeof__) # <ref>
#Write a Python program to print the following floating numbers upto 2 decimal places with a sign. x = 3.1415926 y = 12.9999 a = float(+x) b = float(-y) print(round(a,2)) print(round(b,2))
# A place for secret local/dev environment settings UNIFIED_DB = { 'ENGINE': 'django.db.backends.oracle', 'NAME': 'DB_NAME', 'USER': 'username', 'PASSWORD': 'password', } MONGODB_DATABASES = { 'default': { 'NAME': 'wtc-console', 'USER': 'root', 'PASSWORD': 'root', } }
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def pseudoPalindromicPaths (self, root: TreeNode) -> int: s = set() def dfs(root): ...
'''For 18 points, answer the following questions: "Recursion" is when a function solves a problem by calling itself. Recursive functions have at least 2 parts: 1. Base case - This is where the function is finished. 2. Recursive case (aka Induction case) - this is where the function calls itself and gets clo...
''' Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Solution: Copyright 2017 Dave Cuthbert License MIT ''' def find_multiples(factor, limit): list_of_factors = []...
# Time: O(n) # Space: O(1) class Solution(object): def insert(self, intervals, newInterval): """ :type intervals: List[List[int]] :type newInterval: List[int] :rtype: List[List[int]] """ result = [] i = 0 while i < len(intervals) and newInterval[0] >...
d1=['13CS10001','12CS30016','12CS30043','12CS30042','12CS30043','13CS10038','12CS30017','12CS30044','13CS10041','12CS30041','12CS30010', '13CS10020','12CS30025','12CS30027','12CS30032','13CS10035','12CS30003','12CS30044','12CS30016','13CS10038','13CS10021','12CS30028', '12CS30016','13CS10006','13CS10046','13CS10034','1...
# -*- coding: utf-8 -*- def includeme(config): config.add_route('index', '') config.include(admin_include, '/admin') config.include(post_include, '/post') config.add_route('firework', '/firework') config.add_route('baymax', '/baymax') def admin_include(config): config.add_route('login', '/log...
def ada_int(f, a, b, tol=1.0e-6, n=5, N=10): area = trapezoid(f, a, b, N) check = trapezoid(f, a, b, n) if abs(area - check) > tol: # bad accuracy, add more points to interval m = (b + a) / 2.0 area = ada_int(f, a, m) + ada_int(f, m, b) return area
# -*- coding:utf-8 -*- # @Script: array_partition_1.py # @Author: Pradip Patil # @Contact: @pradip__patil # @Created: 2019-03-20 23:06:35 # @Last Modified By: Pradip Patil # @Last Modified: 2019-03-21 21:07:13 # @Description: https://leetcode.com/problems/array-partition-i/ ''' Given an array of 2n integers, your task...
# Options class SimpleOpt(): def __init__(self): self.method = 'gvae' self.graph_type = 'ENZYMES' self.data_dir = './data/ENZYMES_20-50_res.graphs' self.emb_size = 8 self.encode_dim = 32 self.layer_num = 3 self.decode_dim = 32 self.dropout = 0.5 ...
set_name(0x8013570C, "PresOnlyTestRoutine__Fv", SN_NOWARN) set_name(0x80135734, "FeInitBuffer__Fv", SN_NOWARN) set_name(0x80135760, "FeAddEntry__Fii8TXT_JUSTUsP7FeTableP5CFont", SN_NOWARN) set_name(0x801357E4, "FeAddTable__FP11FeMenuTablei", SN_NOWARN) set_name(0x80135860, "FeAddNameTable__FPUci", SN_NOWARN) set_name(0...
APKG_COL = r''' INSERT INTO col VALUES( null, :creation_time, :modification_time, :modification_time, 11, 0, 0, 0, '{ "activeDecks": [ 1 ], "addToCur": true, "collapseTime": 1200, "curDeck": 1, "curModel": "' || :modificatio...
def sum_numbers(text: str) -> int: return sum([int(x) for x in text.split() if x.isnumeric()]) if __name__ == '__main__': print("Example:") print(sum_numbers('hi')) # These "asserts" are used for self-checking and not for an auto-testing assert sum_numbers('hi') == 0 assert sum_numbers('who i...
class snake: poison='venom' # shared by all instances def __init__(self, name): self.name=name # instance variable unique to each instance def change_name(self, new_name): self.name=new_name cobra= snake('cobra') print(cobra.name)
name = input("Enter Your Username: ") age = int(input("Enter Your Age: ")) print(type(age)) if type(age) == int: print("Name :" ,name) print("Age :", age) else: print("Enter a valid Username or Age")
# glob.py viewPortX = None viewPortY = None
''' Given an array of ints, return True if 6 appears as either the first or last element in the array. The array will be length 1 or more. ''' def first_last6(nums): return nums[0] == 6 or nums[-1] == 6
números = [] maior = 0 menor = 0 for c in range(0, 5): n = int(input('Digite um valor: ')) if c == 0: maior = menor = n números.append(n) print('Adicionado ao final da lista...') else: if n > maior: maior = n números.append(maior) print('Ad...
def insertion_sort(lst): for i in range(len(lst)): j = (i - 1) temp = lst[i] while j >= 0 and temp < lst[j]: lst[j+1] = lst[j] j = j-1 lst[j + 1] = temp return lst
# the public parameters are passed as they are known globally def attacker(prime, root, alicepublic, bobpublic): attacksecret1=int(input("Enter a secret number1 for attacker: ")) attacksecret2=int(input("Enter a secret number2 for attacker: ")) print('\n') print ("Attacker's public key -> C=root^...
REC1 = b"""cam a22002051 4500001001300000003000400013005001700017008004100034010001700075035001900092040001800111050001600129100003500145245017600180260004300356300001900399500002600418650002100444650004900465 00000002 DLC20040505165105.0800108s1899 ilu 000 0 eng  a 00000002  a(OCoLC)585314...
"""A bunch of click related tools / helpers / patterns that have a potential of reuse across clis. TODO: We would improve sharing by moving these to a separate re-usable repository instead of copying. """
''' your local settings. Note that if you install using setuptools, change this module first before running setup.py install. ''' oauthkey = '7dkss6x9fn5v' secret = 't5f28uhdmct7zhdr' country = 'US'
#!/usr/bin/env python3 # Conditional Statements def drink(money): if (money >= 2): return "You've got yourself a drink!" else: return "NO drink for you!" print(drink(3)) print(drink(1)) def alcohol(age, money): if (age >= 21) and (money >= 5): # if statement ret...
def getUniqueID(inArray): ''' Given an int array that contains many duplicates and a single unique ID, find it and return it. ''' pairDictionary = {} for quadID in inArray: # print(quadID) # print(pairDictionary) if quadID in pairDictionary: del pairDic...
# create a dictionary from two lists using zip() # More information using help('zip') and help('dict') # create two lists dict_keys = ['bananas', 'bread flour', 'cheese', 'milk'] dict_values = [2, 1, 4, 3] # iterate over lists using zip iterator_using_zip = zip(dict_keys, dict_values) # create the dictionary from th...
p = int(input()) q = int(input()) for i in range(1, 101): if i % p == q: print(i)
# PATH UPLOAD_FOLDER = './upload_file' GENERATE_PATH = './download_file' # DATABASE DATABASE = 'mysql' DATABASE_URL = 'localhost:3306' USERNAME = 'root' PASSWORD = 'root'
# TODO - bisect operations class SortedDictCore: def __init__(self, *a, **kw): self._items = [] self.dict = dict(*a,**kw) ## def __setitem__(self,k,v): self._items = [] self.dict[k]=v def __getitem__(self,k): return self.dict[k] def __delitem__(self,k): self._items = [] del self.dict[k] ##...
n = 2001 number = 1 while n < 2101: if number % 10 == 0: print("\n") number += 1 if n % 100 == 0: if n % 400 == 0: print(n, end=" ") n += 1 number += 1 continue else: n += 1 continue else: if n % ...
# Python - 3.6.0 def high_and_low(numbers): lst = [*map(int, numbers.split(' '))] return f'{max(lst)} {min(lst)}'
# Peça um número para o usuário e mostre se ele é positivo ou negativo numero = int(input("Digite um número")) print("positivo") if numero >=0 else print("Negativo")
#!/usr/bin/env python # -*- coding=utf-8 -*- s = set('huangxiang') print('s=', s) t = frozenset('huangxiang') print('t= ', t) print('type(s):', type(s)) print('type(t)', type(t)) print('len(s)=', len(s)) print('len(t)=', len(t)) """输出结果: s= {'i', 'g', 'x', 'a', 'h', 'u', 'n'} t= frozenset({'i', 'g', 'x', 'a', 'h...
online_store = { "keychain": 0.75, "tshirt": 8.50, "bottle": 10.00 } choicekey = int(input("How many keychains will you be purchasing? If not purchasing keychains, enter 0. ")) choicetshirt = int(input("How many t-shirts will you be purchasing? If not purchasing t-shirts, enter 0. ")) choicebottle = in...
# -*- coding: utf-8 -*- config = {} config['log_name'] = 'app_log.log' config['log_format'] = '%(asctime)s - %(levelname)s: %(message)s' config['log_date_format'] = '%Y-%m-%d %I:%M:%S' config['format'] = 'json' config['source_dir'] = 'data' config['output_dir'] = 'export' config['source_glob'] = 'monitoraggio_serviz_co...
_mods = [] def get(): return _mods def add(mod): _mods.append(mod)
n = int(input()) lst = [list(map(int, input().split())) for _ in range(n)] dp = [[0]*3 for _ in range(n)] for i in range(3): dp[0][i] = lst[0][i] for i in range(1, n): dp[i][0] = max(dp[i-1][1], dp[i-1][2])+lst[i][0] dp[i][1] = max(dp[i-1][0], dp[i-1][2])+lst[i][1] dp[i][2] = max(dp[i-1][0], dp[i-1][...
# cases where FunctionAchievement should not unlock # >> CASE def test(): pass # >> CASE def func(): pass func # >> CASE def func(): pass f = func f() # >> CASE func() # >> CASE func
""" Tools to validate schema of python objects """ class RoyalValidationError(Exception): pass class SchemaValidator(object): def __init__(self, **kwargs): self.schema = kwargs self.checks = [] def validate(self, obj): for key in self.schema: if key not in obj: raise RoyalValidationError("Expecte...
class Solution: def removeDuplicates(self, nums: List[int]) -> int: return len(nums) if len(nums) < 2 else self.calculate(nums) @staticmethod def calculate(nums): result = 0 for i in range(1, len(nums)): if nums[i] != nums[result]: result += 1 ...
# split()采用none为sep时,可以自动舍去末尾的空格 class Solution: def lengthOfLastWord(self, s: str) -> int: l = s.split() if len(l)==0: return 0 return len(l[-1]) # 语言无差别解法 class Solution1: def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ ...
''' 在一个字符串(1<=字符串长度<=10000,全部由大写字母组成)中找到第一个只出现一次的字符。 ''' # 存储在字典中 class Solution(object): def FirstcomeChar(self, s): if s==None or s=="": return " " strList=list(s) dic={} for i in strList: if i not in dic.keys(): dic[i]=0 dic[i]+=1 for i in strList: if dic[i]==1: return i retu...
# function with large number of arguments def fun(a, b, c, d, e, f, g): return a + b + c * d + e * f * g print(fun(1, 2, 3, 4, 5, 6, 7))
# Input: nums = [0,1,2,2,3,0,4,2], val = 2 # Output: 5, nums = [0,1,4,0,3] # Explanation: Your function should return length = 5, # with the first five elements of nums containing 0, 1, 3, 0, and 4. # Note that the order of those five elements can be arbitrary. # It doesn't matter what values are set beyond the returne...
print(43*'\033[1;31m=') print(8*'\033[1;33m-\033[m', '\033[1mG E R A D O R D E P A', 8*'\033[1;33m-') print(43*'\033[1;31m=\033[m') first = int(input('Primeiro termo: ')) razao = int(input('Razão: ')) term = first cont = 1 resp = 10 tot = 0 while resp != 0: tot += resp while cont <= tot: print(term, ...
"""Top-level package for py_tutis.""" __author__ = """Chidozie C. Okafor""" __email__ = "chidosiky2015@gmail.com" __version__ = "0.1.0"
# Copyright 2021 The Bazel Authors. 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/LICENSE-2.0 # # Unless required by applicable la...
class Solution: def firstMissingPositive(self, nums: List[int], res: int = 1) -> int: for num in sorted(nums): res += num == res return res
""" 1991 : 트리 순회 URL : https://www.acmicpc.net/problem/1991 Input : 7 A B C B D . C E F E . . F . G D . . G . . Output : ABDCEFG DBAECFG DBEGFCA """ tree = {} def preorder(root): traversal = [] traversal +...
# # PySNMP MIB module Wellfleet-AOT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-AOT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:32:37 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
# absoluteimports/__init__.py print("inside absoluteimports/__init__.py")
''' 5 - Remapping categories To better understand survey respondents from airlines, you want to find out if there is a relationship between certain responses and the day of the week and wait time at the gate. The airlines DataFrame contains the day and wait_min columns, which are categorical and numerical respectiv...
def read_file(): file_input = open("data/file_input_data.txt", 'r') file_data = file_input.readlines() file_input.close() return file_data if __name__ == "__main__": data = read_file() print(type(data)) print(data) for line in data: print(line)
def is_armstrong_number(number): digits = [int(i) for i in str(number)] d_len = len(digits) d_sum = 0 for digit in digits: d_sum += digit ** d_len return d_sum == number
# Preprocessing config SAMPLING_RATE = 22050 FFT_WINDOW_SIZE = 1024 HOP_LENGTH = 512 N_MELS = 80 F_MIN = 27.5 F_MAX = 8000 AUDIO_MAX_LENGTH = 90 # in seconds # Data augmentation config MAX_SHIFTING_PITCH = 0.3 MAX_STRETCHING = 0.3 MAX_LOUDNESS_DB = 10 BLOCK_MIXING_MIN = 0.2 BLOCK_MIXING_MAX = 0.5 # Model config ...
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def repo(): http_archive( name = "fmt", strip_prefix = "fmt-7.1.3", urls = ["https://github.com/fmtlib/fmt/releases/download/7.1.3/fmt-7.1.3.zip"], sha256 = "5d98c504d0205f912e22449ecdea776b78ce0bb096927334f80781e7...
"""Constants and variables common to the whole program @var VISUALIZE: whether to generate video @var PRECONDITIONER_CLASS: class or function that returns preconditioner object (1-parameter callable object) for CG, see L{SGSPreconditioner} for example @var PRECONDITIONER: preconditioner object (1-parameter callable o...
""" In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise return -1. Your runtime beats 80.31 % of python submissions. """ c...
# 1 - push # 2 - pop # 3 - print max element # 4 - print max element # last - print all elements n = int(input()) query = [] for _ in range(n): num = input().split() if num[0] == "1": query.append(int(num[1])) elif num[0] == "2": if query: query.pop() continue el...
# Constants for the image IMAGE_URL = str(input("Enter a valid image URL: ")) IMAGE_WIDTH = 280 IMAGE_HEIGHT = 200 blueUpFactor = int(input("How much more blue do you want this image | Enter a value between 1 and 255")) maxPixelValue = 255 image = Image(IMAGE_URL) image.set_position(70, 70) image.set_size(IMAGE_WIDTH,...
class Solution: def reverseOnlyLetters(self, S: str) -> str: alpha = set([chr(i) for i in list(range(ord('a'), ord('z')+1)) + list(range(ord('A'), ord('Z')+1))]) words, res = [], list(S) for char in res: if char in alpha: words.append(char) ...
# SPDX-FileCopyrightText: 2020 Splunk Inc. # # SPDX-License-Identifier: Apache-2.0 def normalize_to_unicode(value): """ string convert to unicode """ if hasattr(value, "decode") and not isinstance(value, str): return value.decode("utf-8") return value def normalize_to_str(value): """ ...
number = int(input()) while number < 1 or number > 100: print('Invalid number') number = int(input()) print(f'The number is: {number}')
class Configuration(object): config={} def __str__(self): return str(Configuration.config) @staticmethod def defaults(): Configuration.config['api_base_link'] = 'https://api.twitch.tv/kraken/' @staticmethod def load(file=None): if file: with open (file, ...
# By Taiwo Kareem <taiwo.kareem36@gmail.com> # Github <https://github.com/tushortz> # Last updated (08-February-2016) # Card class class Card: # Initialize necessary field variables def __init__(self, *code): # Accept two character arguments if len(code) == 2: rank = code[0] suit = code[1] # Can also ac...