content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
dataset_type = 'CocoDataset' classes = ('beading', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog') data_root = 'data/' img_norm_cfg = dict( mean=[123.6...
dataset_type = 'CocoDataset' classes = ('beading', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog') data_root = 'data/' img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57....
# -*- coding: utf-8 -*- class BasicAnalyzer(object): """Basic analyzer class""" name = "BasicAnalyzer" def __init__(self, actions, identifier=None): """ Basic analyzer which is extended to create other analyzer subclasses :param actions: A single action or a list of actions to be ...
class Basicanalyzer(object): """Basic analyzer class""" name = 'BasicAnalyzer' def __init__(self, actions, identifier=None): """ Basic analyzer which is extended to create other analyzer subclasses :param actions: A single action or a list of actions to be executed on every paste ...
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def get_ratio(a, b): g = gcd(a, b) return '{}/{}'.format(a // g, b // g) _ = int(input()) rings = [int(x) for x in input().split()] first = rings[0] for ring in rings[1:]: print(get_ratio(first, ring))
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def get_ratio(a, b): g = gcd(a, b) return '{}/{}'.format(a // g, b // g) _ = int(input()) rings = [int(x) for x in input().split()] first = rings[0] for ring in rings[1:]: print(get_ratio(first, ring))
# encoding: utf-8 # module System.IO.Compression calls itself Compression # from System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 # by generator 1.145 """ NamespaceTracker represent a CLS namespace. """ # no imports # no functions # classes class CompressionLevel(Enum, IComparable...
""" NamespaceTracker represent a CLS namespace. """ class Compressionlevel(Enum, IComparable, IFormattable, IConvertible): """ enum CompressionLevel, values: Fastest (1), NoCompression (2), Optimal (0) """ def __eq__(self, *args): """ x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y """...
version = "0.8.5" appDBVersion = 0.70 videoRoot = "/var/www/" # Build Channel Restream Subprocess Dictionary restreamSubprocesses = {} # Build Edge Restream Subprocess Dictionary activeEdgeNodes = [] edgeRestreamSubprocesses = {} apiLocation = "http://127.0.0.1"
version = '0.8.5' app_db_version = 0.7 video_root = '/var/www/' restream_subprocesses = {} active_edge_nodes = [] edge_restream_subprocesses = {} api_location = 'http://127.0.0.1'
# -*- coding: utf-8 -*- """MLOne_GithubDemo_.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/github/AIEdX/MLOne-Basic/blob/master/Lesson/Lesson3/Demo/MLOne_GithubDemo_.ipynb """ #@title Copyright 2020 AIEDX. Double-click here for license information. #...
"""MLOne_GithubDemo_.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/github/AIEdX/MLOne-Basic/blob/master/Lesson/Lesson3/Demo/MLOne_GithubDemo_.ipynb """ '# <font color=\'Orange\' size="33" type="Arial Black">ML-</font><font color=\'blue\' font-backgro...
# numbers = [2,3,1,5] # min_number = min(numbers) # max_number = max(numbers) x = 2 y = 5 min_number = min(x,y) max_number = max(x,y) print(min_number) print(max_number)
x = 2 y = 5 min_number = min(x, y) max_number = max(x, y) print(min_number) print(max_number)
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def glut(): http_archive( name="glut" , build_file="//bazel/deps/glut:build.BUILD" , sha256="e1d4e2d38aad559c32985...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def glut(): http_archive(name='glut', build_file='//bazel/deps/glut:build.BUILD', sha256='e1d4e2d38aad559c329859a0dc45c8fc8ff3ec5a1001587d5ca3d7a2b57f9a38', strip_prefix='glut-8cd96cb440f1f2fac3a154227937be39d06efa53', urls=['https://github.com/U...
d = {'k1': 1, 'k2': 2, 'k3': 3} d['k10'] = d['k1'] del d['k1'] print(d) # {'k2': 2, 'k3': 3, 'k10': 1} d = {'k1': 1, 'k2': 2, 'k3': 3} print(d.pop('k1')) # 1 print(d) # {'k2': 2, 'k3': 3} d = {'k1': 1, 'k2': 2, 'k3': 3} d['k10'] = d.pop('k1') print(d) # {'k2': 2, 'k3': 3, 'k10': 1} d = {'k1': 1, 'k2': 2, 'k3':...
d = {'k1': 1, 'k2': 2, 'k3': 3} d['k10'] = d['k1'] del d['k1'] print(d) d = {'k1': 1, 'k2': 2, 'k3': 3} print(d.pop('k1')) print(d) d = {'k1': 1, 'k2': 2, 'k3': 3} d['k10'] = d.pop('k1') print(d) d = {'k1': 1, 'k2': 2, 'k3': 3} print(d.pop('k10', None)) print(d) def change_dict_key(d, old_key, new_key, default_value=N...
class Tap(): def __init__(self, client): self.client = client def sync(self, query, query_language='ADQL'): return self.client.post('/tap/sync', { 'QUERY': query, 'LANG': query_language }, json=False)
class Tap: def __init__(self, client): self.client = client def sync(self, query, query_language='ADQL'): return self.client.post('/tap/sync', {'QUERY': query, 'LANG': query_language}, json=False)
#abc = 'with three people' #stuff = abc.split() #print(stuff) #print(len(stuff)) #for w in stuff: # print(w) line = 'first;second;third' thing = line.split() print(thing) print(len(thing)) thing = line.split(';') print(thing) print(len(thing))
line = 'first;second;third' thing = line.split() print(thing) print(len(thing)) thing = line.split(';') print(thing) print(len(thing))
def rgb(r, g, b): if r < 0: r = 0 elif r > 255: r = 255 if g < 0: g = 0 elif g > 255: g = 255 if b < 0: b = 0 elif b > 255: b = 255 return ''.join(f'{i:02X}' for i in [r, g, b])
def rgb(r, g, b): if r < 0: r = 0 elif r > 255: r = 255 if g < 0: g = 0 elif g > 255: g = 255 if b < 0: b = 0 elif b > 255: b = 255 return ''.join((f'{i:02X}' for i in [r, g, b]))
"""Submodule of direct_downloader, provides formatting helper methods.""" def sizeof_fmt(num): """Make an amount of bytes humanreadable with the correct unit. Args: num (int): amount of bytes Returns str: formated amount of bytes with unit """ for unit in ['', 'Ki', 'Mi']: ...
"""Submodule of direct_downloader, provides formatting helper methods.""" def sizeof_fmt(num): """Make an amount of bytes humanreadable with the correct unit. Args: num (int): amount of bytes Returns str: formated amount of bytes with unit """ for unit in ['', 'Ki', 'Mi']: ...
# Christina Andrea Putri - Universitas Kristen Duta Wacana # Anda ingin menginput data diri Anda dan keluarga Anda untuk kepentingan sensus penduduk. Setelah itu untuk memastikan data sudah lengkap, Anda ingin melihat kembali # data yang Anda input. # Input : pilihan menu, jml data, data-data yang diperlukan # Pr...
print('=Data Sensus Penduduk=') print('Menu : \n 1. Masukkan data \n 2. Cek Data \n 3. Keluar') inp = 0 handle = open('data.txt', 'w+') handle.close() try: while inp != 3: inp = int(input('Masukkan menu pilihan Anda:')) if inp == 1: inp_sum = int(input('Jumlah data yang ingin dimasukkan:...
class Solution: def subtractProductAndSum(self, n: int) -> int: ans1, ans2 = 1, 0 while n: tmp = n % 10 n //= 10 ans1 *= tmp ans2 += tmp return ans1 - ans2
class Solution: def subtract_product_and_sum(self, n: int) -> int: (ans1, ans2) = (1, 0) while n: tmp = n % 10 n //= 10 ans1 *= tmp ans2 += tmp return ans1 - ans2
def Results(counter,elapsed,Netloc,Path): #Output of the final result of the program. print( f'\n\n\033[38;5;201mNumber of links found: \033[38;5;226m{counter}\033[0m', f'\n\n\033[38;5;201mTime (seconds):\033[38;5;226m %.4f \033[0m' % (elapsed), f'\n\n\033[38;5;201mLink URL Root: \033[38;5;226m\033[4m{Netloc}\...
def results(counter, elapsed, Netloc, Path): print(f'\n\n\x1b[38;5;201mNumber of links found: \x1b[38;5;226m{counter}\x1b[0m', f'\n\n\x1b[38;5;201mTime (seconds):\x1b[38;5;226m %.4f \x1b[0m' % elapsed, f'\n\n\x1b[38;5;201mLink URL Root: \x1b[38;5;226m\x1b[4m{Netloc}\x1b[0m', f'\n\n\x1b[38;5;201mPath file site-map: ...
class MinMax(object): def __init__(self,min=None,max=None): self.min = min self.max = max def __str__(self): return "Min: {:d} Max: {:d}".format(self.min,self.max) def __repr__(self): return "<Min: {:d} Max: {:d}>".format(self.min,self.max) def update(self,val): if self.min is None: ...
class Minmax(object): def __init__(self, min=None, max=None): self.min = min self.max = max def __str__(self): return 'Min: {:d} Max: {:d}'.format(self.min, self.max) def __repr__(self): return '<Min: {:d} Max: {:d}>'.format(self.min, self.max) def update(self, val): ...
"""This module contains all the Facebook specific selectors and text. Whenever Facebook modifies their code, this will need to be updated to accomodate the changes. #webscraperlife CSS Selectors have better performance than XPath and should be used in all circumstances UNLESS you cannot select it properly in CSS. For ...
"""This module contains all the Facebook specific selectors and text. Whenever Facebook modifies their code, this will need to be updated to accomodate the changes. #webscraperlife CSS Selectors have better performance than XPath and should be used in all circumstances UNLESS you cannot select it properly in CSS. For ...
class bird(object): feather=True class chicken(bird): fly=False def __init__(self,age): self.age=age def getAdult(self): if self.age>1.0: return True else: return False adult= property(getAdult) #property is built-in summer=chicken(2) print(summer.a...
class Bird(object): feather = True class Chicken(bird): fly = False def __init__(self, age): self.age = age def get_adult(self): if self.age > 1.0: return True else: return False adult = property(getAdult) summer = chicken(2) print(summer.age) print...
""" Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. Two binary trees are considered leaf-similar if their leaf value sequence is the same. Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar. Input: ...
""" Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. Two binary trees are considered leaf-similar if their leaf value sequence is the same. Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar. Input: ...
# -*- coding: utf-8 -*- """ Created on Fri Feb 22 18:52:23 2019 @author: lenovo """ # done for union-find 20190222 19:11 class UNION_FIND: def __init__(self): self.p = {} def make_set(self, nums): for i in nums: self.p[i] = [i,0] def find_set(self, x): if x...
""" Created on Fri Feb 22 18:52:23 2019 @author: lenovo """ class Union_Find: def __init__(self): self.p = {} def make_set(self, nums): for i in nums: self.p[i] = [i, 0] def find_set(self, x): if x != self.p[x][0]: self.p[x][0] = self.find_set(self.p[x][0...
class GlobalCommands(object): # so commands can call other commands def __init__(self): self.commands = {} def register(self, cmd, force_name=None): name = force_name or cmd.callback.__name__ if name in self.commands: raise Exception() self.commands[name] = cmd ...
class Globalcommands(object): def __init__(self): self.commands = {} def register(self, cmd, force_name=None): name = force_name or cmd.callback.__name__ if name in self.commands: raise exception() self.commands[name] = cmd def invoke(self, ctx, cmd, missing_ok...
get_authors = '''{authors{id name}}''' bad_get_authors = '''{authors{id name}}}''' get_authors_siblings = ''' query Siblings($lastName: String!) { authors(filter: { lastName: $lastName }) { name lastName } } ''' get_last_author = ''' { authors(orderBy:{desc:ID} limit:1){ name ...
get_authors = '{authors{id name}}' bad_get_authors = '{authors{id name}}}' get_authors_siblings = '\n query Siblings($lastName: String!) {\n authors(filter: { lastName: $lastName }) {\n name\n lastName\n }\n }\n' get_last_author = '\n {\n authors(orderBy:{desc:ID} limit:1){\n name\n last...
""" Module: 'gsm' on esp32_LoBo MCU: (sysname='esp32_LoBo', nodename='esp32_LoBo', release='3.2.24', version='ESP32_LoBo_v3.2.24 on 2018-09-06', machine='ESP32 board with ESP32') Stubber: 1.0.0 """ SMS_ALL = 0 SMS_READ = 2 SMS_UNREAD = 1 SORT_ASC = 1 SORT_DESC = 2 SORT_NONE = 0 def atcmd(): pass def checkSMS(): ...
""" Module: 'gsm' on esp32_LoBo MCU: (sysname='esp32_LoBo', nodename='esp32_LoBo', release='3.2.24', version='ESP32_LoBo_v3.2.24 on 2018-09-06', machine='ESP32 board with ESP32') Stubber: 1.0.0 """ sms_all = 0 sms_read = 2 sms_unread = 1 sort_asc = 1 sort_desc = 2 sort_none = 0 def atcmd(): pass def check_sms(): ...
# 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 dfs(self, cur): if cur: if self.smallest is None: self.smallest = cur.val ...
class Solution(object): def dfs(self, cur): if cur: if self.smallest is None: self.smallest = cur.val elif self.smallest > cur.val: (self.smallest, self.secondSmallest) = (cur.val, self.smallest) elif self.smallest < cur.val: ...
n = input() k = input() count = 0 for i in n: if k==i: count+=1 print(count)
n = input() k = input() count = 0 for i in n: if k == i: count += 1 print(count)
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: n = len(s) h = {} ans = i = 0 for j in range(n): if s[j] in h: i = max(i, h[s[j]]) ans = max(ans, j - i + 1) h[s[j]] = j + 1 return ans
class Solution: def length_of_longest_substring(self, s: str) -> int: n = len(s) h = {} ans = i = 0 for j in range(n): if s[j] in h: i = max(i, h[s[j]]) ans = max(ans, j - i + 1) h[s[j]] = j + 1 return ans
class Stats(object): """ Object for building query params for a global email statistics request """ def __init__( self, start_date=None): """Create a Stats object :param start_date: Date of when stats should begin in YYYY-MM-DD format, defaults to None :type start_da...
class Stats(object): """ Object for building query params for a global email statistics request """ def __init__(self, start_date=None): """Create a Stats object :param start_date: Date of when stats should begin in YYYY-MM-DD format, defaults to None :type start_date: string, ...
class GenyratorError(Exception): pass
class Genyratorerror(Exception): pass
COLUMNS = [ 'tipo_registro', 'nro_pv', 'nro_rv', 'nro_banco', 'nro_agencia', 'nro_conta_corrente', 'dt_rv', 'qtde_cvnsu', 'vl_bruto', 'vl_gorjeta', 'vl_rejeitado', 'vl_desconto', 'vl_liquido', 'dt_credito_primeira_parcela', 'bandeira' ]
columns = ['tipo_registro', 'nro_pv', 'nro_rv', 'nro_banco', 'nro_agencia', 'nro_conta_corrente', 'dt_rv', 'qtde_cvnsu', 'vl_bruto', 'vl_gorjeta', 'vl_rejeitado', 'vl_desconto', 'vl_liquido', 'dt_credito_primeira_parcela', 'bandeira']
#!/usr/bin/python3 def print_sorted_dictionary(a_dictionary): "prints a dictionary by ordered keys" for i in sorted(a_dictionary.keys()): print("{}: {}".format(i, a_dictionary[i]))
def print_sorted_dictionary(a_dictionary): """prints a dictionary by ordered keys""" for i in sorted(a_dictionary.keys()): print('{}: {}'.format(i, a_dictionary[i]))
""" fosscord.types ~~~~~~~~~~~~~~ Typings for the Fosscord API :copyright: (c) 2015-present Rapptz :license: MIT, see LICENSE for more details. """
""" fosscord.types ~~~~~~~~~~~~~~ Typings for the Fosscord API :copyright: (c) 2015-present Rapptz :license: MIT, see LICENSE for more details. """
def error(e: Exception): print("error") print(e)
def error(e: Exception): print('error') print(e)
# -*- coding: utf-8 -*- """ Created on Wed Dec 23 13:05:33 2020 @author: William """ def collatz_len(n): len = 0 while n != 1: if n % 2 == 0: n = n/2 len +=1 else: n = 3*n+1 len +=1 return len end = 1000000 longest_leng...
""" Created on Wed Dec 23 13:05:33 2020 @author: William """ def collatz_len(n): len = 0 while n != 1: if n % 2 == 0: n = n / 2 len += 1 else: n = 3 * n + 1 len += 1 return len end = 1000000 longest_length = 0 num = 0 for i in range(1, end + ...
class Solution: def fullJustify(self, words: [str], maxWidth: int) -> [str]: res = [] cur = [] cnt = 0 for w in words: if cnt + len(w) + len(cur) > maxWidth: for i in range(maxWidth - cnt): cur[i % (len(cur) - 1 or 1)] += ' ' ...
class Solution: def full_justify(self, words: [str], maxWidth: int) -> [str]: res = [] cur = [] cnt = 0 for w in words: if cnt + len(w) + len(cur) > maxWidth: for i in range(maxWidth - cnt): cur[i % (len(cur) - 1 or 1)] += ' ' ...
# O(n) time complexity # O(n) space complexity def reverse1(a): i = 0 j = len(a) b = a[:] while j > 0: #b.append(a[j - 1]) -> not efficient b[i] = a[j - 1] i += 1 j -= 1 return b # O(n) time complexity # O(1) space complexity def reverse2(a...
def reverse1(a): i = 0 j = len(a) b = a[:] while j > 0: b[i] = a[j - 1] i += 1 j -= 1 return b def reverse2(a): temp = None i = 0 j = len(a) half_len = int(j / 2) for _ in range(half_len): temp = a[i] a[i] = a[j - 1] a[j - 1] = tem...
# This program reads all of the values in # the sales.txt file. def main(): # Open the sales.txt file for reading. sales_file = open('sales.txt', 'r') # Read the first line from the file, but # don't convert to a number yet. We still # need to test for an empty string. line = sales_file.readli...
def main(): sales_file = open('sales.txt', 'r') line = sales_file.readline() while line != '': amount = float(line) print(format(amount, '.2f')) line = sales_file.readline() sales_file.close() main()
def get_db_uri(dbinfo): ENGINE = dbinfo.get("ENGINE") or 'mysql' DRIVER = dbinfo.get("DRIVER") or "pymysql" USER = dbinfo.get("USER") or "root" PASSWORD = dbinfo.get("PASSWORD") or "root" HOST = dbinfo.get("HOST") or "localhost" PORT = dbinfo.get("PORT") or "3306" NAME = dbinfo.get("NAME") ...
def get_db_uri(dbinfo): engine = dbinfo.get('ENGINE') or 'mysql' driver = dbinfo.get('DRIVER') or 'pymysql' user = dbinfo.get('USER') or 'root' password = dbinfo.get('PASSWORD') or 'root' host = dbinfo.get('HOST') or 'localhost' port = dbinfo.get('PORT') or '3306' name = dbinfo.get('NAME') o...
class Solution: def findReplaceString(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str: sl = list(S) for i, source, target in sorted(zip(indexes, sources, targets), reverse=True): if S[i: i + len(source)] == source: sl[i: i + len(source)] =...
class Solution: def find_replace_string(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str: sl = list(S) for (i, source, target) in sorted(zip(indexes, sources, targets), reverse=True): if S[i:i + len(source)] == source: sl[i:i + len(source)...
"""This module contains all custom exceptions in the `cloudpathlib` library. All exceptions subclass the [`CloudPathException` base exception][cloudpathlib.exceptions.CloudPathException] to facilitate catching any exception from this library. """ class CloudPathException(Exception): """Base exception for all clou...
"""This module contains all custom exceptions in the `cloudpathlib` library. All exceptions subclass the [`CloudPathException` base exception][cloudpathlib.exceptions.CloudPathException] to facilitate catching any exception from this library. """ class Cloudpathexception(Exception): """Base exception for all cloud...
"""Defines the version number and details of testing_actions.""" __all__ = ( '__version__', '__author__', '__authoremail__', '__license__', '__sourceurl__', '__description__' ) __version__ = "1.0.0" __author__ = "Joseph T. Iosue" __authoremail__ = "joe.iosue@yahoo.com" __license__ = "MIT License" __sourceurl...
"""Defines the version number and details of testing_actions.""" __all__ = ('__version__', '__author__', '__authoremail__', '__license__', '__sourceurl__', '__description__') __version__ = '1.0.0' __author__ = 'Joseph T. Iosue' __authoremail__ = 'joe.iosue@yahoo.com' __license__ = 'MIT License' __sourceurl__ = 'https:/...
def sanitize_version(raw_version): if raw_version[0] == 'v': return raw_version[1:] elif raw_version.startswith('release/'): return raw_version[8:] return raw_version
def sanitize_version(raw_version): if raw_version[0] == 'v': return raw_version[1:] elif raw_version.startswith('release/'): return raw_version[8:] return raw_version
class Solution(object): def lastSubstring(self, s): """ :type s: str :rtype: str This was quite difficult to understand, but basically I keep track of two substrings - i, j where i is the first substring - 'k' is the substring length of both i and j, used to reduce co...
class Solution(object): def last_substring(self, s): """ :type s: str :rtype: str This was quite difficult to understand, but basically I keep track of two substrings - i, j where i is the first substring - 'k' is the substring length of both i and j, used to reduce ...
NORTH, EAST, SOUTH, WEST = 1, 2, 3, 4 _directional_advances = {NORTH: (0, 1), EAST: (1, 0), SOUTH: (0, -1), WEST: (-1, 0)} _possible_moves = {'L': 'turn_left', 'R': 'turn_right', 'A': 'advance'} def tuple_add(a, b): return tuple([item1 +...
(north, east, south, west) = (1, 2, 3, 4) _directional_advances = {NORTH: (0, 1), EAST: (1, 0), SOUTH: (0, -1), WEST: (-1, 0)} _possible_moves = {'L': 'turn_left', 'R': 'turn_right', 'A': 'advance'} def tuple_add(a, b): return tuple([item1 + item2 for (item1, item2) in zip(a, b)]) class Robot: def __init__(s...
#!/usr/bin/python3 def get_remote_module_template(enable_moving_cpu_tensors_to_cuda: bool): return _TEMPLATE_PREFIX + ( _REMOTE_FORWARD_TEMPLATE_ENABLE_MOVING_CPU_TENSORS_TO_CUDA if enable_moving_cpu_tensors_to_cuda else _REMOTE_FORWARD_TEMPLATE ) _TEMPLATE_PREFIX = """from typing im...
def get_remote_module_template(enable_moving_cpu_tensors_to_cuda: bool): return _TEMPLATE_PREFIX + (_REMOTE_FORWARD_TEMPLATE_ENABLE_MOVING_CPU_TENSORS_TO_CUDA if enable_moving_cpu_tensors_to_cuda else _REMOTE_FORWARD_TEMPLATE) _template_prefix = 'from typing import *\n\nimport torch\nimport torch.distributed.rpc as...
p = int(input()) x = int(input()) y = int(input()) full_price = x + y / 100 full_price *= (1 + p / 100) full_price = round(full_price, 4) print(int(full_price), int(full_price * 100 % 100))
p = int(input()) x = int(input()) y = int(input()) full_price = x + y / 100 full_price *= 1 + p / 100 full_price = round(full_price, 4) print(int(full_price), int(full_price * 100 % 100))
''' The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
""" The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { 'name': 'Twitter Roller', 'category': 'Website', 'summary': 'Twitter scroller snippet in website', 'version': '1.0', 'description': """ This module adds a Twitter roller building block to the websit...
{'name': 'Twitter Roller', 'category': 'Website', 'summary': 'Twitter scroller snippet in website', 'version': '1.0', 'description': '\nThis module adds a Twitter roller building block to the website builder, so that you can display Twitter feeds on any page of your website.\n ', 'depends': ['website'], 'data': ['se...
def onPointcloud(name): polyData = pointcloudMap.take(name) if polyData: obj = vis.updatePolyData(polyData, name, colorByName='intensity', parent='ROS') if not obj.getChildFrame(): vis.addChildFrame(obj) pointcloudMap.connect('objectAssigned(const QString&)', onPointcloud)
def on_pointcloud(name): poly_data = pointcloudMap.take(name) if polyData: obj = vis.updatePolyData(polyData, name, colorByName='intensity', parent='ROS') if not obj.getChildFrame(): vis.addChildFrame(obj) pointcloudMap.connect('objectAssigned(const QString&)', onPointcloud)
#!/usr/bin/env python HMDSyntaxDefault = { # primitive 'STRING': r"[A-Za-z?'_]+", 'NUMBER': r'[\d]+', 'SPACE': r'[ ]+', # rule binding 'RULE_BEGIN': r'[(]', 'RULE_END': r'[)]', # match: positive 'MATCH_NEXT': r'[+]', 'MATCH_BEFORE': r'[-]', 'MATCH_ALWAYS': r'[@]', # ...
hmd_syntax_default = {'STRING': "[A-Za-z?'_]+", 'NUMBER': '[\\d]+', 'SPACE': '[ ]+', 'RULE_BEGIN': '[(]', 'RULE_END': '[)]', 'MATCH_NEXT': '[+]', 'MATCH_BEFORE': '[-]', 'MATCH_ALWAYS': '[@]', 'MATCH_NOT': '[!]', 'GRAMMAR_HAT': '[\\^]', 'GRAMMAR_WILD': '[%]', 'GRAMMAR_OR': '[|]', 'VARIABLE_IDENTIFIER': '[$]', 'VARIABLE_...
__version__ = "1.0.0" __name__ = "Test Mod" __modid__ = "Test_Mod" __main__ = "testmod.py"
__version__ = '1.0.0' __name__ = 'Test Mod' __modid__ = 'Test_Mod' __main__ = 'testmod.py'
""" Given an array where elements are sorted in ascending order, convert it to a height balanced BST. URL: https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ """ # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = Non...
""" Given an array where elements are sorted in ascending order, convert it to a height balanced BST. URL: https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ """ class Treenode(object): def __init__(self, x): self.val = x self.left = None self.right = None class S...
""" Remove empty tags. >>> from GDLC.GDLC import * >>> dml = '''\ ... <html> ... <head> ... <title>TITLE</title> ... </head> ... <body>LOOSE TEXT ... <div></div> ... <p></p> ... <div>MORE TEXT</div> ... <div><b></b></div> ... <p><i></i></p> # COMMENT ... </body> ... </html>''' >>> soup = BeautifulSoup(dml,...
""" Remove empty tags. >>> from GDLC.GDLC import * >>> dml = '''... <html> ... <head> ... <title>TITLE</title> ... </head> ... <body>LOOSE TEXT ... <div></div> ... <p></p> ... <div>MORE TEXT</div> ... <div><b></b></div> ... <p><i></i></p> # COMMENT ... </body> ... </html>''' >>> soup = BeautifulSoup(dml, f...
API_URL = "https://www.metaweather.com/api/" API_METHODS = { "Location Search": "location/search/", "Location Day": "location/{woeid}/{date}/", } RAIN_STATES = [ "Heavy Rain", "Light Rain", "Showers", ]
api_url = 'https://www.metaweather.com/api/' api_methods = {'Location Search': 'location/search/', 'Location Day': 'location/{woeid}/{date}/'} rain_states = ['Heavy Rain', 'Light Rain', 'Showers']
# How to convert a list to a string in python? # https://youtu.be/24ZIhX30NPo def lst_to_str_with_loops(lst): output = '' for item in lst: output += str(item) # output += ' ' + str(item) return repr(output) def lst_to_str_with_join(lst): return repr(','.join(lst)) def lst_to_str_with_...
def lst_to_str_with_loops(lst): output = '' for item in lst: output += str(item) return repr(output) def lst_to_str_with_join(lst): return repr(','.join(lst)) def lst_to_str_with_lst_comprehension(lst): return repr(''.join([str(item) for item in lst])) def lst_to_str_with_map(lst): re...
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-03-24 Last_modify: 2016-03-24 ****************************************** ''' ''' Given a range [m, n] where 0 <= m <= n <= ...
""" ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-03-24 Last_modify: 2016-03-24 ****************************************** """ '\nGiven a range [m, n] where 0 <= m <= n <= 2147483647,\nreturn the bitwise AND of all numbe...
class DataParserF8(object): def __init__(self, ch): self.ch = ch ###################################### @property def roomT(self): return self.ch.get_value()[1] ###################################### @property def waterT(self): return self.ch.get_value()[2] ################...
class Dataparserf8(object): def __init__(self, ch): self.ch = ch @property def room_t(self): return self.ch.get_value()[1] @property def water_t(self): return self.ch.get_value()[2] @property def electro_meter_t1(self): return self.ch.get_value()[4] @...
class FilterModule(object): def filters(self): return { 'normalize_sasl_protocol': self.normalize_sasl_protocol, 'kafka_protocol_normalized': self.kafka_protocol_normalized, 'kafka_protocol': self.kafka_protocol, 'kafka_protocol_defaults': self.kafka_protocol_...
class Filtermodule(object): def filters(self): return {'normalize_sasl_protocol': self.normalize_sasl_protocol, 'kafka_protocol_normalized': self.kafka_protocol_normalized, 'kafka_protocol': self.kafka_protocol, 'kafka_protocol_defaults': self.kafka_protocol_defaults, 'get_sasl_mechanisms': self.get_sasl_m...
# https://leetcode.com/problems/concatenation-of-array/submissions/ class Solution: def getConcatenation(self, nums: List[int]) -> List[int]: return 2*nums
class Solution: def get_concatenation(self, nums: List[int]) -> List[int]: return 2 * nums
# An implementation that uses a storage array as the backing # for the min heap. In order to emulate a binary tree structure, # we have the following rules: # 1. We can calculate a parent node's left child with the # formula `index * 2 + 1`. # 2. We can calculate a parent node's right child with the # formula `i...
class Heap: def __init__(self): self.storage = [] def insert(self, value): self.storage.append(value) self._bubbleUp(len(self.storage) - 1) def delete(self): if len(self.storage) == 0: return if len(self.storage) == 1: return self.storage.po...
# 698. Partition to K Equal Sum Subsets # ttungl@gmail.com # Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all equal. # Example 1: # Input: nums = [4, 3, 2, 3, 5, 2, 1], k = 4 # Output: True # Explanation: It's possible...
class Solution(object): def can_partition_k_subsets(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ def can_partition(nums, visited, index, k, curSum, curElem, target): if k == 1: return True if curSum ...
# This is a sample quisk_conf.py configuration file for Microsoft Windows. # For Windows, your default config file name is "My Documents/quisk_conf.py", # but you can use a different config file by using -c or --config. Quisk creates # an initial default config file if there is none. To control Quisk, edit # "My Doc...
sample_rate = 48000 name_of_sound_capt = 'Primary' name_of_sound_play = 'Primary' latency_millisecs = 150 default_screen = 'Graph'
''' Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Exampl...
""" Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Exampl...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ============================================================================= # # ============================================================================= __author__ = 'Chet Coenen' __copyright__ = 'Copyright 2020' __credits__ = ['Chet Coenen'] __license__ = '/LICE...
__author__ = 'Chet Coenen' __copyright__ = 'Copyright 2020' __credits__ = ['Chet Coenen'] __license__ = '/LICENSE' __version__ = '1.0' __maintainer__ = 'Chet Coenen' __email__ = 'chet.m.coenen@icloud.com' __socials__ = '@Denimbeard' __status__ = 'Complete' __description__ = 'Insert Sort Algorithm' __date__ = '30 Novemb...
"""Dashboard mappings """ DASHBOARD_MAPPINGS = { "multivector_search": "/sdk/search", "cluster_centroids_closest": "/sdk/cluster/centroids/closest", "cluster_centroids_furthest": "/sdk/cluster/centroids/furthest", "cluster_aggregation": "/sdk/cluster/aggregation", }
"""Dashboard mappings """ dashboard_mappings = {'multivector_search': '/sdk/search', 'cluster_centroids_closest': '/sdk/cluster/centroids/closest', 'cluster_centroids_furthest': '/sdk/cluster/centroids/furthest', 'cluster_aggregation': '/sdk/cluster/aggregation'}
class Solution: def smallestCommonElement(self, mat: List[List[int]]) -> int: x={} for i in range(len(mat)): for j in range(len(mat[0])): if mat[i][j] not in x: x[mat[i][j]]=1 else: x[mat[i][j]]+=1 if...
class Solution: def smallest_common_element(self, mat: List[List[int]]) -> int: x = {} for i in range(len(mat)): for j in range(len(mat[0])): if mat[i][j] not in x: x[mat[i][j]] = 1 else: x[mat[i][j]] += 1 ...
def is_isogram(string) -> bool: """ Determine if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. Examples of isograms: lumberjacks bac...
def is_isogram(string) -> bool: """ Determine if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. Examples of isograms: lumberjacks bac...
def Writerecord(sroll,sname,sperc,sremark): with open ('StudentRecord.dat','ab') as Myfile: srecord={"SROLL":sroll,"SNAME":sname,"SPERC":sperc, "SREMARKS":sremark} pickle.dump(srecord,Myfile) def Readrecord(): with open ('StudentRecord.dat','rb') as Myfile: ...
def writerecord(sroll, sname, sperc, sremark): with open('StudentRecord.dat', 'ab') as myfile: srecord = {'SROLL': sroll, 'SNAME': sname, 'SPERC': sperc, 'SREMARKS': sremark} pickle.dump(srecord, Myfile) def readrecord(): with open('StudentRecord.dat', 'rb') as myfile: print('\n-------D...
if enable_http_handler: zaruba_module_name_http_controller(app, mb, rpc) if enable_event_handler: zaruba_module_name_event_controller(mb) if enable_rpc_handler: zaruba_module_name_rpc_controller(rpc)
if enable_http_handler: zaruba_module_name_http_controller(app, mb, rpc) if enable_event_handler: zaruba_module_name_event_controller(mb) if enable_rpc_handler: zaruba_module_name_rpc_controller(rpc)
""" OpenCV Android SDK configuration file """ def getFlags(armeabi=False, x86=False): # NOTE: can be disabled if VideoRecorder is not needed. Also note that # FFMpeg, which is LGPL-licensed (with some GPL-licensed codecs) is not # included with these settings and consequently only the OpenCV built-in #...
""" OpenCV Android SDK configuration file """ def get_flags(armeabi=False, x86=False): videorecording = 'ON' flags = dict(BUILD_opencv_dnn='OFF', BUILD_opencv_photo='OFF', BUILD_opencv_ml='OFF', BUILD_opencv_stitching='OFF', BUILD_opencv_objdetect='OFF', BUILD_opencv_highgui='OFF', BUILD_opencv_videoio=videore...
''' Decorator function for appending class docstrings ''' def adddocs(original): def wrapper(target): target.__doc__ += '\n\n' + original.__doc__ return target return wrapper
""" Decorator function for appending class docstrings """ def adddocs(original): def wrapper(target): target.__doc__ += '\n\n' + original.__doc__ return target return wrapper
"""695. Max Area of Island""" class Solution(object): def maxAreaOfIsland(self, grid): """ :type grid: List[List[int]] :rtype: int """ ### Practice: def dfs(i, j): if i < 0 or j < 0 or i >= m or j >= n or grid[i][j] == 0: return 0 ...
"""695. Max Area of Island""" class Solution(object): def max_area_of_island(self, grid): """ :type grid: List[List[int]] :rtype: int """ def dfs(i, j): if i < 0 or j < 0 or i >= m or (j >= n) or (grid[i][j] == 0): return 0 grid[i][j...
class Student: def __init__(self, name, year): self.name = name self.year = year self.grades = [] def add_grade(self, grade): if type(grade) is Grade: self.grades.append(grade) class Grade: minimum_passing = 65 def __init__(self, score): self.score = score roger = Stu...
class Student: def __init__(self, name, year): self.name = name self.year = year self.grades = [] def add_grade(self, grade): if type(grade) is Grade: self.grades.append(grade) class Grade: minimum_passing = 65 def __init__(self, score): self.score...
# Read: http://jinja.pocoo.org/docs/dev/api/#custom-filters def first_upper(s): if s: return s[0].upper() + s[1:] def first_lower(s): if s: return s[0].lower() + s[1:] filters = { 'first_upper': first_upper, 'first_lower': first_lower }
def first_upper(s): if s: return s[0].upper() + s[1:] def first_lower(s): if s: return s[0].lower() + s[1:] filters = {'first_upper': first_upper, 'first_lower': first_lower}
class HealthCheckError(Exception): """ Base exception class for anything healthcheck related """ class InvalidKeyError(HealthCheckError): """ Thrown if we look up a healthcheck that doesnt exist """ class ConfigurationError(HealthCheckError): """ Thrown if we have a configuration th...
class Healthcheckerror(Exception): """ Base exception class for anything healthcheck related """ class Invalidkeyerror(HealthCheckError): """ Thrown if we look up a healthcheck that doesnt exist """ class Configurationerror(HealthCheckError): """ Thrown if we have a configuration that'...
""" LC 392 Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a s...
""" LC 392 Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a s...
class RangeModule: def __init__(self): self.lefts = [] self.rights = [] def crossedRange(self, left: int, right: int) -> []: pos = [] for i in range(len(self.lefts)): if not (left >= self.rights[i] or right <= self.lefts[i]): pos.append(i) re...
class Rangemodule: def __init__(self): self.lefts = [] self.rights = [] def crossed_range(self, left: int, right: int) -> []: pos = [] for i in range(len(self.lefts)): if not (left >= self.rights[i] or right <= self.lefts[i]): pos.append(i) r...
PROJECTNAME = 'Perham example' TARGET = 0 NPATHS = 200 DURATION = 10*365.25 NREALIZATIONS = 200 BASE = 0.0 C_DIST = (12.0, 65.0, 120.0) P_DIST = (0.20, 0.25) T_DIST = (10, 20, 30) BUFFER = 100 SPACING = 4 UMBRA = 8 SMOOTH = 2 CONFINED = True TOL = 1 MAXSTEP = 10 WELLS = [ (302338, 5162551, 0.2, 1372), (302...
projectname = 'Perham example' target = 0 npaths = 200 duration = 10 * 365.25 nrealizations = 200 base = 0.0 c_dist = (12.0, 65.0, 120.0) p_dist = (0.2, 0.25) t_dist = (10, 20, 30) buffer = 100 spacing = 4 umbra = 8 smooth = 2 confined = True tol = 1 maxstep = 10 wells = [(302338, 5162551, 0.2, 1372), (302320, 5162497,...
''' Created on 2017/09/25 @author: lionheart '''
""" Created on 2017/09/25 @author: lionheart """
class Seat: def __init__(self, id, flight_id, team_member_id, seat_number): self.id = id self.startpoint = startpoint self.flight_id = flight_id self.team_member_id = team_member_id self.seat_number = seat_number def to_dict(self): retur...
class Seat: def __init__(self, id, flight_id, team_member_id, seat_number): self.id = id self.startpoint = startpoint self.flight_id = flight_id self.team_member_id = team_member_id self.seat_number = seat_number def to_dict(self): return {'id': self.id, 'flight...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Todo: * For module TODOs * You have to also use ``sphinx.ext.todo`` extension """ module_level_variable1 = 12345 """int: Module level variable documented inline.""" def module_level_function(param1: int, param2: str, *args, **kwargs) -> bool: """Example...
""" Todo: * For module TODOs * You have to also use ``sphinx.ext.todo`` extension """ module_level_variable1 = 12345 'int: Module level variable documented inline.' def module_level_function(param1: int, param2: str, *args, **kwargs) -> bool: """Example function with PEP 484 type annotations. Args: ...
# pylint: disable=unused-argument class Top: def __add__(self, other): return self def __and__(self, other): return self def __sub__(self, other): return self def __rsub__(self, other): return self def __radd__(self, other): return self def __ror__(...
class Top: def __add__(self, other): return self def __and__(self, other): return self def __sub__(self, other): return self def __rsub__(self, other): return self def __radd__(self, other): return self def __ror__(self, other): return self ...
def count_consonants(): list123=['a','e','i','o','u'] dstring=input(" enter the string ") index=0 for i in dstring: if i in list123: index+=0 else: index+=1 return index print(count_consonants())
def count_consonants(): list123 = ['a', 'e', 'i', 'o', 'u'] dstring = input(' enter the string ') index = 0 for i in dstring: if i in list123: index += 0 else: index += 1 return index print(count_consonants())
num_tests = int(raw_input()) for test_index in range(num_tests): (num_nodes, num_edges) = map(int, raw_input().split()) for edge_index in range(num_edges): (from_node, to_node, weight) = map(int, raw_input().split()) print(num_nodes + num_edges)
num_tests = int(raw_input()) for test_index in range(num_tests): (num_nodes, num_edges) = map(int, raw_input().split()) for edge_index in range(num_edges): (from_node, to_node, weight) = map(int, raw_input().split()) print(num_nodes + num_edges)
# 45. Jump Game II class Solution: def jump(self, nums) -> int: n = len(nums) if n == 1: return 0 ans = 1 r, next_r = nums[0], 0 for i, j in enumerate(nums[:-1]): next_r = max(next_r, i+j) if i == r: ans += 1 r ...
class Solution: def jump(self, nums) -> int: n = len(nums) if n == 1: return 0 ans = 1 (r, next_r) = (nums[0], 0) for (i, j) in enumerate(nums[:-1]): next_r = max(next_r, i + j) if i == r: ans += 1 r = next_...
CREATE_TABLE_SQL = "CREATE TABLE {name} ({fields});" CONDITIONAL_OPRATORS = { '=' : '=', '&' : 'AND', '!=': '!=', '|' : 'OR', 'in': 'IN', 'not in': 'NOT IN', 'like': 'LIKE' } class CelertixSql: ''' POSTGRESQL SCHEMA AND INFORMATION RELATED QURIES ''' @classmethod ...
create_table_sql = 'CREATE TABLE {name} ({fields});' conditional_oprators = {'=': '=', '&': 'AND', '!=': '!=', '|': 'OR', 'in': 'IN', 'not in': 'NOT IN', 'like': 'LIKE'} class Celertixsql: """ POSTGRESQL SCHEMA AND INFORMATION RELATED QURIES """ @classmethod def get_all_tables(cls): r...
class Leaf: def __init__(self, di): self.di = di self.lzt = [] self.hits = 0 def add(self, trail): self.hits += 1 if len(trail) < 1: return for x in self.lzt: if (x.di == trail[0]): x.add(trail[1:]) ...
class Leaf: def __init__(self, di): self.di = di self.lzt = [] self.hits = 0 def add(self, trail): self.hits += 1 if len(trail) < 1: return for x in self.lzt: if x.di == trail[0]: x.add(trail[1:]) return ...
{ 'variables': { 'target_arch%': '<!(node preinstall.js --print-arch)>' }, 'targets': [ { 'target_name': 'libsodium-prebuilt', 'include_dirs' : [ "<!(node -e \"require('nan')\")", 'libsodium.build/include' ], 'sources': [ 'binding.cc', ], 'xcode_...
{'variables': {'target_arch%': '<!(node preinstall.js --print-arch)>'}, 'targets': [{'target_name': 'libsodium-prebuilt', 'include_dirs': ['<!(node -e "require(\'nan\')")', 'libsodium.build/include'], 'sources': ['binding.cc'], 'xcode_settings': {'OTHER_CFLAGS': ['-g', '-O3']}, 'cflags': ['-g', '-O3'], 'libraries': ['<...
def shift_dummies(df, col, shift): shift_cols = [] shift_sign = "+" if shift < 0: shift_sign = "-" for t in range(shift): col_name = f"{col} t{shift_sign}{abs(t)}" df[col_name] = df[col].shift(t) shift_cols.append(col_name) if shift_sign == "+": prefix =...
def shift_dummies(df, col, shift): shift_cols = [] shift_sign = '+' if shift < 0: shift_sign = '-' for t in range(shift): col_name = f'{col} t{shift_sign}{abs(t)}' df[col_name] = df[col].shift(t) shift_cols.append(col_name) if shift_sign == '+': prefix = 'post...
TEXT = """abba com mother bill mother com abba dog abba mother com""" def secuenced_words(txt): """ Function identifies the three words most often repeated as a group, regardless of the words order in the group """ word_list = txt.split() collector = dict() for idx in ra...
text = 'abba com mother bill mother com \nabba dog abba mother com' def secuenced_words(txt): """ Function identifies the three words most often repeated as a group, regardless of the words order in the group """ word_list = txt.split() collector = dict() for idx in range(...
## 1. The Spark DataFrame: An Introduction ## f = open('census_2010.json') for i in range(0,4): print(f.readline()) ## 3. Schema ## sqlCtx = SQLContext(sc) df = sqlCtx.read.json("census_2010.json") df.printSchema() ## 4. Pandas vs Spark DataFrames ## df.show(5) ## 5. Row Objects ## first_five = df.head(5) f...
f = open('census_2010.json') for i in range(0, 4): print(f.readline()) sql_ctx = sql_context(sc) df = sqlCtx.read.json('census_2010.json') df.printSchema() df.show(5) first_five = df.head(5) for r in first_five: print(r.age) df[['age']].show() df[['age', 'males', 'females']].show() five_plus = df[df['age'] > 5]...
# -*- coding: utf-8 -*- """ Created on Wed May 19 11:47:55 2021 @author: Vladimir """ noise_signal = [2.7696641934421677, 4.769664193442168, 3.7696641934421677, 3.7696641934421677, 5.769664193442168, 6.769664193442168, 3.7696641934421677, 0.7696641934421677, -0.23033580655783226, -0.23033580655783226, -1.230335806557...
""" Created on Wed May 19 11:47:55 2021 @author: Vladimir """ noise_signal = [2.7696641934421677, 4.769664193442168, 3.7696641934421677, 3.7696641934421677, 5.769664193442168, 6.769664193442168, 3.7696641934421677, 0.7696641934421677, -0.23033580655783226, -0.23033580655783226, -1.2303358065578323, -2.2303358065578323...
# A list of dictionary... person1 = {'first_name':'alex','last_name':'brucle','age': 25,'city':'newyork'} person2 = {'first_name':'shreya','last_name':'rani','age': 25,'city':'puna'} person3 = {'first_name':'vidya','last_name':'vox','age': 28,'city':'kerla'} person = [person1,person2,person3] #storing dictionary i...
person1 = {'first_name': 'alex', 'last_name': 'brucle', 'age': 25, 'city': 'newyork'} person2 = {'first_name': 'shreya', 'last_name': 'rani', 'age': 25, 'city': 'puna'} person3 = {'first_name': 'vidya', 'last_name': 'vox', 'age': 28, 'city': 'kerla'} person = [person1, person2, person3] for info in person: print(in...
""" Helper classes for creating frontend metadata """ class ContactPersonDesc(object): """ Description class for a contact person """ def __init__(self): self.contact_type = None self._email_address = [] self.given_name = None self.sur_name = None def add_email_ad...
""" Helper classes for creating frontend metadata """ class Contactpersondesc(object): """ Description class for a contact person """ def __init__(self): self.contact_type = None self._email_address = [] self.given_name = None self.sur_name = None def add_email_add...
class Solution: def canMakeArithmeticProgression(self, arr: List[int]) -> bool: arr.sort() i = 0 while i < len(arr)-1: if i == 0: diff = arr[i] - arr[i+1] else: if arr[i] - arr[i+1] != diff: return False ...
class Solution: def can_make_arithmetic_progression(self, arr: List[int]) -> bool: arr.sort() i = 0 while i < len(arr) - 1: if i == 0: diff = arr[i] - arr[i + 1] elif arr[i] - arr[i + 1] != diff: return False else: ...
print("####################################################") print("#FILENAME:\t\ta2p1.py\t\t\t #") print("#ASSIGNMENT:\t\tHomework Assignment 2 Pt. 1#") print("#COURSE/SECTION:\tCIS 3389.251\t\t #") print("#DUE DATE:\t\tMonday, 30.March 2020\t #") print("####################################################\n") ...
print('####################################################') print('#FILENAME:\t\ta2p1.py\t\t\t #') print('#ASSIGNMENT:\t\tHomework Assignment 2 Pt. 1#') print('#COURSE/SECTION:\tCIS 3389.251\t\t #') print('#DUE DATE:\t\tMonday, 30.March 2020\t #') print('####################################################\n') ...
program_title = "Smelted: Rezz-a-tron 4000" HOST = "localhost" PORT = 5250 current_unit = "U0"
program_title = 'Smelted: Rezz-a-tron 4000' host = 'localhost' port = 5250 current_unit = 'U0'
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) lista = [a, b, c, d, e] pares = [num for num in lista if num % 2 == 0] impares = [num for num in lista if num % 2 != 0] positivos = [num for num in lista if num > 0] negativos = [num for num in lista if num < 0] print(f"{len(pares)}...
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) lista = [a, b, c, d, e] pares = [num for num in lista if num % 2 == 0] impares = [num for num in lista if num % 2 != 0] positivos = [num for num in lista if num > 0] negativos = [num for num in lista if num < 0] print(f'{len(pares)} va...
def fizzbuzz(): for i in range (1, 100): if (i % 3 == 0 and i % 5 == 0): print("fizzbuzz") elif i % 3 == 0: print("fizz") elif i % 5 == 0: print("buzz") else: print(i) def prime(): n = int(input("enter any number.")) for i in range(2, n + 1): counter = 0 for j in range(2, i): if i % j ==...
def fizzbuzz(): for i in range(1, 100): if i % 3 == 0 and i % 5 == 0: print('fizzbuzz') elif i % 3 == 0: print('fizz') elif i % 5 == 0: print('buzz') else: print(i) def prime(): n = int(input('enter any number.')) for i in rang...
# The isBadVersion API is already defined for you. # @param version, an integer # @return an integer def isBadVersion(version): return True class Solution: def firstBadVersion(self, n): """ :type n: int :rtype: int """ start = 1 end = n while start < end...
def is_bad_version(version): return True class Solution: def first_bad_version(self, n): """ :type n: int :rtype: int """ start = 1 end = n while start < end: mid = start + (end - start) // 2 if is_bad_version(mid): ...