content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
''' CTCI -> pg. 109, Trees and Graphs Given a directed graph, design an algo to find out whether there is a route between nodes ''' class Solution: def doesRouteExist(self, root, p, q): return True
""" CTCI -> pg. 109, Trees and Graphs Given a directed graph, design an algo to find out whether there is a route between nodes """ class Solution: def does_route_exist(self, root, p, q): return True
class Fruit: fruit_type="Orange" def __init__(self): self.name=input("enter the name:") self.season=input("enter the season:") self.price=input("enter the price:") def getDetails(self): print("enter the name:",self.name) print("enter the season:",self.season) ...
class Fruit: fruit_type = 'Orange' def __init__(self): self.name = input('enter the name:') self.season = input('enter the season:') self.price = input('enter the price:') def get_details(self): print('enter the name:', self.name) print('enter the season:', self.sea...
# Used for exporting to a central model to work from class Issue(): def __init__(self, data=None, src_type='*'): self.identifier = '' self.is_open = True self.assignees = [] self.description = '' self.column_id = '' self.board_id = '' self.milestone_id = '' ...
class Issue: def __init__(self, data=None, src_type='*'): self.identifier = '' self.is_open = True self.assignees = [] self.description = '' self.column_id = '' self.board_id = '' self.milestone_id = '' self.labels = [] self.name = '' ...
def sortnum(num): for i in range(0,len(num)): key = num[i] j=i-1 while j>=0 and key<num[j]: num[j+1]=num[j] j=j-1 num[j+1]=key print("Enter 5 numbers\n") num=[] for i in range(0,5): n=int(input("number: ")) num.append(n) sortnum(num) mi...
def sortnum(num): for i in range(0, len(num)): key = num[i] j = i - 1 while j >= 0 and key < num[j]: num[j + 1] = num[j] j = j - 1 num[j + 1] = key print('Enter 5 numbers\n') num = [] for i in range(0, 5): n = int(input('number: ')) num.append(n) sortn...
__author__ = 'demi' # Define a procedure is_palindrome, that takes as input a string, and returns a # Boolean indicating if the input string is a palindrome. # Base Case: '' => True # Recursive Case: if first and last characters don't match => False # if they do match, is the middle a palindrome? def is_palindrome(...
__author__ = 'demi' def is_palindrome(s): if s == '': return True return s[0] == s[-1] and is_palindrome(s[1:-1]) print(is_palindrome('')) print(is_palindrome('abab')) print(is_palindrome('abba'))
dial_codes = { 'All': [ ('611', 'Self-Service') ], 'Sprint-Prepaid': [ ('*3', '#611'), ('611', '#311'), ('#411', '#123'), ('411', '#123'), ('#611', '#123'), ('*611', '#123'), ('*411', '#123'), ('*2', '#123') ], 'Sprint-P...
dial_codes = {'All': [('611', 'Self-Service')], 'Sprint-Prepaid': [('*3', '#611'), ('611', '#311'), ('#411', '#123'), ('411', '#123'), ('#611', '#123'), ('*611', '#123'), ('*411', '#123'), ('*2', '#123')], 'Sprint-PCS': [('*2', '#611'), ('*3', '#311'), ('*4', '#123'), ('0', '#123')], 'Boost-Mobile': [('888667848', '#61...
#Animator is basically Skia's (much saner) version of Flash. #On top of Views it provides a declarative UI model which can be updated #based on events which trigger changes or scripts. { 'includes': [ 'common.gypi', ], 'targets': [ { 'target_name': 'animator', 'type': 'static_library', ...
{'includes': ['common.gypi'], 'targets': [{'target_name': 'animator', 'type': 'static_library', 'include_dirs': ['../deps/skia/include/config', '../deps/skia/include/core', '../deps/skia/include/effects', '../deps/skia/include/animator', '../deps/skia/include/views', '../deps/skia/include/xml', '../deps/skia/include/ut...
num = int(input("ENTER :")) flag=0 for i in range(2,num//2): if num%i==0: flag = 50 else: continue if flag!=50: print("prime") else: print("not prime")
num = int(input('ENTER :')) flag = 0 for i in range(2, num // 2): if num % i == 0: flag = 50 else: continue if flag != 50: print('prime') else: print('not prime')
''' Create a Binary Tree, and traverse through it's nodes (inorder, preorder, postorder) and print the tree accordingly ! ''' class Node: def __init__(self, data): self.left = None self.right = None self.data = data # Inserting a Node def insert(self, data): if self.d...
""" Create a Binary Tree, and traverse through it's nodes (inorder, preorder, postorder) and print the tree accordingly ! """ class Node: def __init__(self, data): self.left = None self.right = None self.data = data def insert(self, data): if self.data: if data < s...
# Test metrica config c = get_config() load_subconfig('etc/base_config.py') load_subconfig('etc/github_auth.py') c.MetricaIdsMixin.g_analitics_id="" c.MetricaIdsMixin.ya_metrica_id=""
c = get_config() load_subconfig('etc/base_config.py') load_subconfig('etc/github_auth.py') c.MetricaIdsMixin.g_analitics_id = '' c.MetricaIdsMixin.ya_metrica_id = ''
#!/usr/bin/env python3 # -*- coding: utf-8 -*- if __name__ == '__main__': student = { 1: 'anton', 2: 'varvara', 3: 'pavel', 4: 'anna', 5: 'igor', 6: 'liza', 7: 'dasha' } print(student) dict_items = student.items() new_student = dict(zip(studen...
if __name__ == '__main__': student = {1: 'anton', 2: 'varvara', 3: 'pavel', 4: 'anna', 5: 'igor', 6: 'liza', 7: 'dasha'} print(student) dict_items = student.items() new_student = dict(zip(student.values(), student.keys())) print(new_student)
''' (CTCI 1.1) Is Unique: Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? ''' ''' # sort the string, iterate through each char and check neighboring char def is_unique_chars(string): unique = True for i in range(len(string) - 1): # l...
""" (CTCI 1.1) Is Unique: Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? """ '\n# sort the string, iterate through each char and check neighboring char\ndef is_unique_chars(string):\n unique = True\n\n for i in range(len(string) - 1): ...
def surface_area(l, w, h): return 2*l*w + 2*w*h + 2*h*l + min([l*w, w*h, h*l]) def ribbon_length(l, w, h): return sum([*map(lambda x: x*2, sorted([l,w,h])[:-1])]) + l*w*h if __name__ == "__main__": with open('2015/input/day02.txt') as f: data = f.read().splitlines() print( sum( [*map( l...
def surface_area(l, w, h): return 2 * l * w + 2 * w * h + 2 * h * l + min([l * w, w * h, h * l]) def ribbon_length(l, w, h): return sum([*map(lambda x: x * 2, sorted([l, w, h])[:-1])]) + l * w * h if __name__ == '__main__': with open('2015/input/day02.txt') as f: data = f.read().splitlines() ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: mx = 0 def helper(root,mx): if root is None: ...
class Solution: def diameter_of_binary_tree(self, root: TreeNode) -> int: mx = 0 def helper(root, mx): if root is None: return (mx, 0) if root.left is None and root.right is None: return (mx, 1) else: (ml, l) = hel...
tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm \\ a \\ cat." fat_cat = ''' I'll do a list: \t* Cat fo\rod \t* Fishies \t* Catnip\n\t* Grass ''' print (tabby_cat) print (persian_cat) print (backslash_cat) print (fat_cat) while 10: for i in ["|","|","|","|","|"]: ...
tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm \\ a \\ cat." fat_cat = "\nI'll do a list:\n\t* Cat fo\rod\n\t* Fishies\n\t* Catnip\n\t* Grass\n" print(tabby_cat) print(persian_cat) print(backslash_cat) print(fat_cat) while 10: for i in ['|', '|', '|', '|', '|']: pr...
# declare step = 4 s = '\t' for i in range((step + 2) * 3): s = s + 'tmp' + str(i) + ', '; s = s[:-2] + ';' print('unsigned int', s); # initialize s = '' for k in range(step + 2): s += '\t\ttmp{} = src[RIDX(0, j + {}, dim)].red + src[RIDX(1, j + {}, dim)].red + src[RIDX(2, j + {}, dim)].red;'.format(k * 3 + 0,...
step = 4 s = '\t' for i in range((step + 2) * 3): s = s + 'tmp' + str(i) + ', ' s = s[:-2] + ';' print('unsigned int', s) s = '' for k in range(step + 2): s += '\t\ttmp{} = src[RIDX(0, j + {}, dim)].red + src[RIDX(1, j + {}, dim)].red + src[RIDX(2, j + {}, dim)].red;'.format(k * 3 + 0, k, k, k) + '\n' s += ...
#Solution by nnk94087 in python 2 i = int(input()) lis = list(map(int,input().strip().split())) m = max(lis) while max(lis) == m: lis.remove(max(lis)) print(max(lis))
i = int(input()) lis = list(map(int, input().strip().split())) m = max(lis) while max(lis) == m: lis.remove(max(lis)) print(max(lis))
#!/usr/bin/env python3 def main(): user_input = input("Please input an IPv4 IP address:") print("You told me the IPv4 Address is: " + user_input) main()
def main(): user_input = input('Please input an IPv4 IP address:') print('You told me the IPv4 Address is: ' + user_input) main()
#!/usr/bin/env python class Invoicer: def __init__(self, bitpay_provider, frontend, nfc_broadcast): self.bitpay_provider = bitpay_provider self.frontend = frontend self.nfc_broadcast = nfc_broadcast def new_invoice(self, price, currency): invoice = self.bitpay_provider.create_i...
class Invoicer: def __init__(self, bitpay_provider, frontend, nfc_broadcast): self.bitpay_provider = bitpay_provider self.frontend = frontend self.nfc_broadcast = nfc_broadcast def new_invoice(self, price, currency): invoice = self.bitpay_provider.create_invoice(price, currency...
class DownloadService: def check_download_url(self): pass def check_access_allowed(self): pass def check_network(self): pass def download_file(self): pass def save_file(_): pass # LBYL - Look before You Leap def some_method(): svr = DownloadService() ...
class Downloadservice: def check_download_url(self): pass def check_access_allowed(self): pass def check_network(self): pass def download_file(self): pass def save_file(_): pass def some_method(): svr = download_service() if not svr.check_access_allowed(...
p1 = input("input a number:\ Rock: 1\ Paper: 2\ Scissors: 3 ") p2 = input("input a number:\ Rock: 1\ Paper: 2\ Scissors: 3 ") # if both are the same, it's a draw if p1 == p2: print("Draw!") if p1 == "1": if p2 == "2": print("P2 wins!") elif p2 == "3": print("P1 ...
p1 = input('input a number: Rock: 1 Paper: 2 Scissors: 3 ') p2 = input('input a number: Rock: 1 Paper: 2 Scissors: 3 ') if p1 == p2: print('Draw!') if p1 == '1': if p2 == '2': print('P2 wins!') elif p2 == '3': print('P1 wins!') if p1 == '2': if p2 == '1': pr...
# 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") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def tuple(): http_archive( name = "tuple", build_file = "...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_file') def tuple(): http_archive(name='tuple', build_file='//bazel/deps/tuple:build.BUILD', sha256='42b2dbe0bc94085aeacf1c246bdcca6ce63ffe7388951e64eb0eaadf97e937cb', strip_prefix='tuple-...
class Solution: # # Reverse sort by unit per box + Greedy (Accepted), O(n log n) time, O(n) space, n is len(boxTypes) # def maximumUnits(self, boxTypes: List[List[int]], truckSize: int) -> int: # def unit_per_box(box): # return box[1] # boxTypes.sort(reverse=True, key=unit_per_box) ...
class Solution: def maximum_units(self, boxTypes: List[List[int]], truckSize: int) -> int: boxTypes.sort(key=lambda x: -x[1]) ans = 0 for (box, units) in boxTypes: if truckSize > box: truck_size -= box ans += box * units else: ...
MIN = 235741 MAX = 706948 def isCandidate(num): numAsString = str(num) numAsList = list(numAsString) nums = map(int, numAsList) i = 0 hasConsecutive = False while i < len(nums)-1: current = nums[i] next = nums[i+1] if (current > next): return ...
min = 235741 max = 706948 def is_candidate(num): num_as_string = str(num) num_as_list = list(numAsString) nums = map(int, numAsList) i = 0 has_consecutive = False while i < len(nums) - 1: current = nums[i] next = nums[i + 1] if current > next: return False ...
# # PySNMP MIB module CENTILLION-BRIDGEGROUP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CENTILLION-BRIDGEGROUP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:31:29 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ...
def get_ip_address_from_request(request): x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR") return ( x_forwarded_for.split(",")[0] if x_forwarded_for else request.META.get("REMOTE_ADDR") )
def get_ip_address_from_request(request): x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') return x_forwarded_for.split(',')[0] if x_forwarded_for else request.META.get('REMOTE_ADDR')
# 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...
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'openstackdocstheme'] wsme_protocols = ['restjson'] source_suffix = '.rst' master_doc = 'index' project = u'Watcher Dashboard' copyright = u'OpenStack Foundation' modindex_common_prefix = ['watcher.'] exclude_patterns = ['man/footer.rst', 'man/general-options.r...
ifXTable = u'.1.3.6.1.2.1.31.1.1.1' ifName = ifXTable + u'.1' ifInMulticastPkts = ifXTable + u'.2' ifHCInOctets = ifXTable + u'.6' ifHCInUcastPkts = ifXTable + u'.7' ifHCInMulticastPkts = ifXTable + u'.8' ifHCInBroadcastPkts = ifXTable + u'.9' ifHCOutOctets = ifXTable + u'.10' ifHCOutUcastPkts = ifXTable + u'.11' ifHCO...
if_x_table = u'.1.3.6.1.2.1.31.1.1.1' if_name = ifXTable + u'.1' if_in_multicast_pkts = ifXTable + u'.2' if_hc_in_octets = ifXTable + u'.6' if_hc_in_ucast_pkts = ifXTable + u'.7' if_hc_in_multicast_pkts = ifXTable + u'.8' if_hc_in_broadcast_pkts = ifXTable + u'.9' if_hc_out_octets = ifXTable + u'.10' if_hc_out_ucast_pk...
# Discord Config # Bot token, generated via discord developer portal: TOKEN = 'BOT TOKEN HERE' # Delay between reads in seconds READ_DELAY = 1 # Prefix to use for bot commands PREFIX = '!' # ESI Config ESI_BASE_URL = 'https://esi.evetech.net' ESI_DATASOURCE = 'tranquility' ESI_SWAGGER_JSON = '{}/_latest/swagger.json?d...
token = 'BOT TOKEN HERE' read_delay = 1 prefix = '!' esi_base_url = 'https://esi.evetech.net' esi_datasource = 'tranquility' esi_swagger_json = '{}/_latest/swagger.json?datasource={}'.format(ESI_BASE_URL, ESI_DATASOURCE) esi_user_agent = 'USER AGENT HERE'
word = input() consonant = "bcdfghjklmnpqrstvwxyz" closestVowel = "aaeeeiiiiooooouuuuuuu" newWord = "" for i in range(len(word)): j = consonant.find(word[i]) newWord += word[i] if j > -1: newWord += closestVowel[j] + consonant[min(j+1, 20)] print(newWord)
word = input() consonant = 'bcdfghjklmnpqrstvwxyz' closest_vowel = 'aaeeeiiiiooooouuuuuuu' new_word = '' for i in range(len(word)): j = consonant.find(word[i]) new_word += word[i] if j > -1: new_word += closestVowel[j] + consonant[min(j + 1, 20)] print(newWord)
def convert_seconds(seconds): hours = seconds // 3600 minutes = (seconds - hours * 3600) // 60 remaining_seconds = seconds - hours * 3600 - minutes *60 return hours, minutes, remaining_seconds cows = ["moo", "mouu", "mmmmmooo"] for cow in cows: print(cow) print(type(7)) print(type("s")) print(type(...
def convert_seconds(seconds): hours = seconds // 3600 minutes = (seconds - hours * 3600) // 60 remaining_seconds = seconds - hours * 3600 - minutes * 60 return (hours, minutes, remaining_seconds) cows = ['moo', 'mouu', 'mmmmmooo'] for cow in cows: print(cow) print(type(7)) print(type('s')) print(typ...
DEBUG = True TESTING = True SECRET_KEY = 'test' SQLALCHEMY_DATABASE_URI = 'sqlite://' SQLALCHEMY_TRACK_MODIFICATIONS = False
debug = True testing = True secret_key = 'test' sqlalchemy_database_uri = 'sqlite://' sqlalchemy_track_modifications = False
# Time - O(Nlog N + MLogM) def smallestDifference(arrayOne, arrayTwo): arrayOne.sort() arrayTwo.sort() indexOne, indexTwo = 0, 0 result = [] smallestDifference = float("inf") currentDifference = float("inf") while indexOne < len(arrayOne) and indexTwo < len(arrayTwo): first = arra...
def smallest_difference(arrayOne, arrayTwo): arrayOne.sort() arrayTwo.sort() (index_one, index_two) = (0, 0) result = [] smallest_difference = float('inf') current_difference = float('inf') while indexOne < len(arrayOne) and indexTwo < len(arrayTwo): first = arrayOne[indexOne] ...
# https://www.interviewbit.com/problems/largest-coprime-divisor/ # Largest Coprime Divisor # You are given two positive numbers A and B. You need to find the maximum valued integer X such that: # 1. X divides A i.e. A % X = 0 # 2. X and B are co-prime i.e. gcd(X, B) = 1 def gcd(x, y): while(y): x, y ...
def gcd(x, y): while y: (x, y) = (y, x % y) return x class Solution: def cp_fact(self, x, y): while gcd(x, y) != 1: x = x // gcd(x, y) return x
countx=range(1,1440) county=range(1,2560) y=1 for x in range(0,len(countx)): x+=1 print(x,y) #Run Shell in Tasker for y in range(0,len(county)): y+=1 print(x,y) #Run Shell in Tasker
countx = range(1, 1440) county = range(1, 2560) y = 1 for x in range(0, len(countx)): x += 1 print(x, y) for y in range(0, len(county)): y += 1 print(x, y)
# tirgul 6 # a good source to study dictionary: # https://www.programiz.com/python-programming/dictionary-comprehension # 1. zip function (named after physical zip, just like in jeans) s1 = [2, 3, 1] s2 = ['b', 'a', 'c'] zipRes = zip(s1, s2) print(type(zipRes)) result = list(zip(s1, s2)) print(result) pri...
s1 = [2, 3, 1] s2 = ['b', 'a', 'c'] zip_res = zip(s1, s2) print(type(zipRes)) result = list(zip(s1, s2)) print(result) print(type(zipRes)) print(zipRes) print('Meaning we should convert to list in order to properly view zip object')
class Player: def getdata(self): self.name=input("Enter your name: ") self.no_of_matches=int(input("Enter number of matches: ")) def display(self): print("Name of Player:",self.name) print("Number of Matches Played:",self.no_of_matches) class Bowler(Player): def getdata(self): super().getdata()...
class Player: def getdata(self): self.name = input('Enter your name: ') self.no_of_matches = int(input('Enter number of matches: ')) def display(self): print('Name of Player:', self.name) print('Number of Matches Played:', self.no_of_matches) class Bowler(Player): def get...
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeKLists(self, lists): q = [] for i in range(len(lists)): while lists[i]: q += lists[i], lists[i] ...
class Solution: def merge_k_lists(self, lists): q = [] for i in range(len(lists)): while lists[i]: q += (lists[i],) lists[i] = lists[i].next root = cur = list_node(0) for h in sorted(q, key=lambda x: x.val): cur.next = cur = h ...
class Parser(object): def __init__(self, bot): self.bot = bot
class Parser(object): def __init__(self, bot): self.bot = bot
def snv_cluster(bed_in_dir=0,bed_out_dir=0,cluster_distance=-1,cluster_size=-1): fi=open(bed_in_dir) fo=open(bed_out_dir,'w') tmp='chr0:0:AA' limitdistance=int(cluster_distance) limitnum=int(cluster_size) lst=[] for line in fi: seq=line.split('\t') tmpseq=tmp.split(':') if seq[0]==tmpseq[0] and int(seq[...
def snv_cluster(bed_in_dir=0, bed_out_dir=0, cluster_distance=-1, cluster_size=-1): fi = open(bed_in_dir) fo = open(bed_out_dir, 'w') tmp = 'chr0:0:AA' limitdistance = int(cluster_distance) limitnum = int(cluster_size) lst = [] for line in fi: seq = line.split('\t') tmpseq = ...
_base_ = [ '../_base_/datasets/sunrgbd-3d-10class.py', '../_base_/default_runtime.py', '../_base_/models/base_yolo.py' ] # use caffe img_norm img_norm_cfg = dict( mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) train_pipeline = [ dict(type='LoadImageFromFile', to_float32=True),...
_base_ = ['../_base_/datasets/sunrgbd-3d-10class.py', '../_base_/default_runtime.py', '../_base_/models/base_yolo.py'] img_norm_cfg = dict(mean=[103.53, 116.28, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) train_pipeline = [dict(type='LoadImageFromFile', to_float32=True), dict(type='LoadAnnotations', with_bbox=True), d...
class Life360: base_url = "https://www.life360.com/v3/" auth = "Bearer super_secret_token" class InfluxDB: host = "influx.example.com" port = 8086 username = "username" password = "password" database = "database" class Recorder: fields = [ {"name": "location/latitude", "attri...
class Life360: base_url = 'https://www.life360.com/v3/' auth = 'Bearer super_secret_token' class Influxdb: host = 'influx.example.com' port = 8086 username = 'username' password = 'password' database = 'database' class Recorder: fields = [{'name': 'location/latitude', 'attribute': 'lat...
c = get_config() # Our user list c.Authenticator.whitelist = [ 'instructor1', 'instructor2', 'student1', 'grader-course101', 'grader-course123' ] c.Authenticator.admin_users = { 'instructor1', 'instructor2' } # instructor1 and instructor2 have access to different shared servers: c.Jupyter...
c = get_config() c.Authenticator.whitelist = ['instructor1', 'instructor2', 'student1', 'grader-course101', 'grader-course123'] c.Authenticator.admin_users = {'instructor1', 'instructor2'} c.JupyterHub.load_groups = {'formgrade-course101': ['instructor1', 'grader-course101'], 'formgrade-course123': ['instructor2', 'gra...
def points(games): p = 0 for x in games: x1,y1 = int(x[0]),int(x[-1]) if x1>y1: p+=3 elif x1==y1: p+=1 else: pass return p print(points(["3:1", "2:2", "0:1"]))
def points(games): p = 0 for x in games: (x1, y1) = (int(x[0]), int(x[-1])) if x1 > y1: p += 3 elif x1 == y1: p += 1 else: pass return p print(points(['3:1', '2:2', '0:1']))
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: mx = 0 for customer in accounts: total = 0 for bank in customer: total += bank mx = total if total > mx else mx return mx
class Solution: def maximum_wealth(self, accounts: List[List[int]]) -> int: mx = 0 for customer in accounts: total = 0 for bank in customer: total += bank mx = total if total > mx else mx return mx
result = 0 for i in range (1, 1000): if (i % 3 == 0 or i % 5 == 0): result += i print(result)
result = 0 for i in range(1, 1000): if i % 3 == 0 or i % 5 == 0: result += i print(result)
''' Probem Task : This program will convert age to days Problem Link : https://edabit.com/challenge/xbZR26rHMNo32yz35 ''' def AgeToNumber(n): return n*365 if __name__ =="__main__": age = int(input()) while age < 0: print("You entered Invalid age!, Please enter again!") age = int(i...
""" Probem Task : This program will convert age to days Problem Link : https://edabit.com/challenge/xbZR26rHMNo32yz35 """ def age_to_number(n): return n * 365 if __name__ == '__main__': age = int(input()) while age < 0: print('You entered Invalid age!, Please enter again!') age = in...
# this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print(f"argl: {arg1}, arg2: {arg2}") #ok, that *args is actaully pointless, w{e can jus do this def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") #this just takes one argument def print_one(arg1...
def print_two(*args): (arg1, arg2) = args print(f'argl: {arg1}, arg2: {arg2}') def print_two_again(arg1, arg2): print(f'arg1: {arg1}, arg2: {arg2}') def print_one(arg1): print(f'arg1: {arg1}') def print_none(): print_two('sandeep', 'sharma') print_two_again('sandeep', 'sharma') print_one(...
def f(x): return x*x print("zhangsixuanzuihaokan")
def f(x): return x * x print('zhangsixuanzuihaokan')
class KVStore(dict): def __setitem__(self, key, value): try: self[key] except KeyError: super(KVStore, self).__setitem__(key, []) self[key].append(value)
class Kvstore(dict): def __setitem__(self, key, value): try: self[key] except KeyError: super(KVStore, self).__setitem__(key, []) self[key].append(value)
class Executor: def __init__(self, expression, cursor): self.expression = expression self.cursor = cursor def execute(self, cursor): sql, args = self.expression.to_sql() cursor.execute(sql, args) for row in cursor: yield row
class Executor: def __init__(self, expression, cursor): self.expression = expression self.cursor = cursor def execute(self, cursor): (sql, args) = self.expression.to_sql() cursor.execute(sql, args) for row in cursor: yield row
########################### ## COMMON COMMONNODENAME = None UTILS_MENUNAME = "UTILS" UTILSID = 1 UTILS_ISRADIAL = True UTILS_RADIALPOS = "N" COPYID = 10 COPY_MENUNAME = "copyNodes" PASTEID = 11 PASTE_MENUNAME = "pasteNodes" ########################### ## HERMITE HA_NODENAME = "jd_hermiteArrayCrv" HASOUTH = 100 HAS...
commonnodename = None utils_menuname = 'UTILS' utilsid = 1 utils_isradial = True utils_radialpos = 'N' copyid = 10 copy_menuname = 'copyNodes' pasteid = 11 paste_menuname = 'pasteNodes' ha_nodename = 'jd_hermiteArrayCrv' hasouth = 100 hasouth_menuname = 'Create OutputJoints' hasouth_isradial = True hasouth_radialpos = ...
fep_control_clinical = [[24, 45, 120, 1, -0.1, 0.0, -0.1, 17, 4, 100, 0.17, 0.012, 97, 0.12, 0.007, 96, 138, 70, 137, 55, 129, 77, 131, 50, 266, 249, 258, 294, 272, 292, 259, 250, 247, 9.80, 273, 248, 9.90, 275, 77, 77], [21, 49, 127, 1, 0.0, 0.0, 0.0, 16, 1, 66, 0.07, 0.000, 85, 0.08, 0.000, 68, 57, 76, 80, 52, 94...
fep_control_clinical = [[24, 45, 120, 1, -0.1, 0.0, -0.1, 17, 4, 100, 0.17, 0.012, 97, 0.12, 0.007, 96, 138, 70, 137, 55, 129, 77, 131, 50, 266, 249, 258, 294, 272, 292, 259, 250, 247, 9.8, 273, 248, 9.9, 275, 77, 77], [21, 49, 127, 1, 0.0, 0.0, 0.0, 16, 1, 66, 0.07, 0.0, 85, 0.08, 0.0, 68, 57, 76, 80, 52, 94, 98, 99, ...
#insert in mutation val def get_treshold(model, label, x_test, ok_model): pred = np.argmax(model.predict(x_test), axis = 1) correct = [] correct_lab = [] for i in range(len(label)): if label[i] == pred[i]: correct.append(x_test[i]) correct_lab.append(label[i]) corre...
def get_treshold(model, label, x_test, ok_model): pred = np.argmax(model.predict(x_test), axis=1) correct = [] correct_lab = [] for i in range(len(label)): if label[i] == pred[i]: correct.append(x_test[i]) correct_lab.append(label[i]) correct = np.array(correct) c...
#!/usr/bin/env python # -*- coding: utf-8 -*- class Const: METHOD_CREATE = 'Create' METHOD_DELETE = 'Delete' METHOD_LIST = 'List' METHOD_GET = 'Get' METHOD_UPDATE = 'Update'
class Const: method_create = 'Create' method_delete = 'Delete' method_list = 'List' method_get = 'Get' method_update = 'Update'
def bubble_sort(array): length = len(array) for i in range(length): for j in range(i + 1, length): if array[j] < array[i]: temp = array[j] array[j] = array[i] array[i] = temp numbers = [99, 44, 6, 2, 1, 5, 63, 87, 283, 4, 0] bubble_sort(numbe...
def bubble_sort(array): length = len(array) for i in range(length): for j in range(i + 1, length): if array[j] < array[i]: temp = array[j] array[j] = array[i] array[i] = temp numbers = [99, 44, 6, 2, 1, 5, 63, 87, 283, 4, 0] bubble_sort(numbers...
def commandToTuple(command): [direction, value] = command.split(' ') return [direction, int(value)] def directionValue(commands, direction): return sum(map(lambda command: command[1], filter(lambda command: command[0] == direction, commands))) inputFile = open('input.txt', 'r') commands = list(map(command...
def command_to_tuple(command): [direction, value] = command.split(' ') return [direction, int(value)] def direction_value(commands, direction): return sum(map(lambda command: command[1], filter(lambda command: command[0] == direction, commands))) input_file = open('input.txt', 'r') commands = list(map(comm...
class PostponedTaskException(Exception): pass
class Postponedtaskexception(Exception): pass
async def commands_servers(ctx,bot): print(f'Logged in as: {bot.user.name}\n') print(f'Server List ({len(bot.guilds)})\n') server_counter = 1 for guild in bot.guilds: print(f"{server_counter}. {guild.name}") server_counter += 1
async def commands_servers(ctx, bot): print(f'Logged in as: {bot.user.name}\n') print(f'Server List ({len(bot.guilds)})\n') server_counter = 1 for guild in bot.guilds: print(f'{server_counter}. {guild.name}') server_counter += 1
def isEven(number): #generate list of even numbers evenNumbers=[] for i in range((number)): evenNumbers.append(i*2) if number in evenNumbers: return True else: return False print(isEven(100))
def is_even(number): even_numbers = [] for i in range(number): evenNumbers.append(i * 2) if number in evenNumbers: return True else: return False print(is_even(100))
class Solution: def divide(self, dividend: int, divisor: int) -> int: # Constants. MAX_INT = 2147483647 # 2**31 - 1 MIN_INT = -2147483648 # -2**31 HALF_MIN_INT = -1073741824 # MIN_INT // 2 # Special case: overflow. if dividend == MIN_INT and divisor == -1: ...
class Solution: def divide(self, dividend: int, divisor: int) -> int: max_int = 2147483647 min_int = -2147483648 half_min_int = -1073741824 if dividend == MIN_INT and divisor == -1: return MAX_INT negative = False if divisor < 0 or dividend < 0: ...
#def fonksiyon(): # a=5 # print(a) #fonksiyon() #a=10 #def fonksiyon(): #a=5 #print(a) #fonksiyon() #print(a) a=5 def fonksiyon(): global a a=2 print(a) fonksiyon() print(a)
a = 5 def fonksiyon(): global a a = 2 print(a) fonksiyon() print(a)
# # Object-Oriented Python: Advanced Objects # Python Techdegree # # Created by Dulio Denis on 12/14/18. # Copyright (c) 2018 ddApps. All rights reserved. # ------------------------------------------------ # Challenge Task 1 of 2 # This class should look familiar! # I need to you add __mul__ to NumString so we c...
class Numstring: def __init__(self, value): self.value = str(value) def __str__(self): return self.value def __int__(self): return int(self.value) def __float__(self): return float(self.value) def __add__(self, other): if '.' in self.value: re...
def functio1n(): print("hello python") print(functio1n.__class__.__name__)
def functio1n(): print('hello python') print(functio1n.__class__.__name__)
''' Description : Use Of Forloop With Whileloop Function Date : 15 Feb 2021 Function Author : Prasad Dangare Input : Int Output : str ''' def displayf(value): print("output of for loop") icnt = 0 for icnt in range(0, value): print("Jay Ganesh") ...
""" Description : Use Of Forloop With Whileloop Function Date : 15 Feb 2021 Function Author : Prasad Dangare Input : Int Output : str """ def displayf(value): print('output of for loop') icnt = 0 for icnt in range(0, value): print('Jay Ganesh') def displayw(va...
''' Abstract Base Class for a Heap Object.''' class Heap(object): '''Generic heap class for inheritance''' def __init__(self): '''initialize heap specific data structures''' pass def insert(self, key): '''insert a new vertex into heap''' pass def extract_min(self): ...
""" Abstract Base Class for a Heap Object.""" class Heap(object): """Generic heap class for inheritance""" def __init__(self): """initialize heap specific data structures""" pass def insert(self, key): """insert a new vertex into heap""" pass def extract_min(self): ...
# zip(list1, list2): combine two list and make a touple vehicles = ['unicycle', 'motorcycle', 'plane', 'car', 'truck'] wheels = [1, 2, 3, 4, 18] touple = list(zip(vehicles, wheels)) #print(touple) for i,j in touple: print(i, j) # to split touple print(*touple)
vehicles = ['unicycle', 'motorcycle', 'plane', 'car', 'truck'] wheels = [1, 2, 3, 4, 18] touple = list(zip(vehicles, wheels)) for (i, j) in touple: print(i, j) print(*touple)
class FileSystemImage: def __init__(self, media, file_path): self.media = media self.file_path = file_path def __str__(self): return "saved_image(%s, %s)" % (self.media.id, self.file_path)
class Filesystemimage: def __init__(self, media, file_path): self.media = media self.file_path = file_path def __str__(self): return 'saved_image(%s, %s)' % (self.media.id, self.file_path)
# Given a list of integers S and a target number k, write a function that returns # a subset of S that adds up to k. If such a subset cannot be made, then return null. # Integers can appear more than once in the list. You may aske all numbers in the list are positive. # For example, given S = [12, 1, 61, 5, 9, 2] and...
def recfunc(S, index, k, subset, subsets): if k == 0: subsets.append(subset) return if index == 0: return recfunc(S, index - 1, k, subset, subsets) new_subset = [] + subset new_subset.append(S[index - 1]) recfunc(S, index - 1, k - S[index - 1], new_subset, subsets) if...
def EN_wentropy(y,whaten = 'shannon',p = ''): N = len(y) if whaten == 'shannon': out = wentropy(y,'shannon') / N elif whaten == 'logenergy': out = wentropy(y,'logenergy') / N elif whaten == 'threshold': if p == '': p = np.mean(y) out = wentropy(y,'thr...
def en_wentropy(y, whaten='shannon', p=''): n = len(y) if whaten == 'shannon': out = wentropy(y, 'shannon') / N elif whaten == 'logenergy': out = wentropy(y, 'logenergy') / N elif whaten == 'threshold': if p == '': p = np.mean(y) out = wentropy(y, 'threshold',...
# # PySNMP MIB module CISCO-PROXY-CONTROL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-PROXY-CONTROL-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:10:10 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint) ...
def sortByLength(t, order): result = () if(order == 'asc'): return sorted(t, key=len) elif(order == 'des'): for i in reversed(sorted(t, key=len)): result += (i,) return result else: return FALSE print(sortByLength(('iOS', 'iPhone', 'iPad'), 'asc')) print(sort...
def sort_by_length(t, order): result = () if order == 'asc': return sorted(t, key=len) elif order == 'des': for i in reversed(sorted(t, key=len)): result += (i,) return result else: return FALSE print(sort_by_length(('iOS', 'iPhone', 'iPad'), 'asc')) print(sor...
def func(): pass a = func a()
def func(): pass a = func a()
# not accurate def bybit_wrap_defs(): # https://github.com/ccxt/ccxt/blob/master/python/ccxt/bybit.py#L113 return [ { 'regex': 'Get', 'tags': ['get'], 'count': 1, }, { 'regex': 'Post', 'tags': ['post'], 'count': 1, ...
def bybit_wrap_defs(): return [{'regex': 'Get', 'tags': ['get'], 'count': 1}, {'regex': 'Post', 'tags': ['post'], 'count': 1}, {'regex': 'Post.*Order', 'tags': ['order'], 'count': 1}, {'regex': 'Post.*Order.*All', 'tags': ['order'], 'count': 10 - 1}, {'regex': 'Get.*Order', 'tags': ['get_order'], 'count': 1}, {'reg...
#!/usr/bin/env python3 class MinHeap(object): def __init__(self): self.items = [None] self.count = 0 def insert(self, item): self.items.append(item) self.count += 1 self._swim() def get_min(self): if self.count == 0: return None return s...
class Minheap(object): def __init__(self): self.items = [None] self.count = 0 def insert(self, item): self.items.append(item) self.count += 1 self._swim() def get_min(self): if self.count == 0: return None return self.items[1] def d...
def bin_count(x): return bin(x).count('1') def logic(n, m, y): print(2) print(n, 1) if n == 0: print(1) print(1) for i in range(m): print(-1.0, end=' ') print(-1.0) return for idx in range(n): for binary in range(m): if idx ...
def bin_count(x): return bin(x).count('1') def logic(n, m, y): print(2) print(n, 1) if n == 0: print(1) print(1) for i in range(m): print(-1.0, end=' ') print(-1.0) return for idx in range(n): for binary in range(m): if idx & 2...
class Node: def __init__(self, value=None): self.value = value self.next_node = None def set_next_node(self, next_node): self.next_node = next_node def get_next_node(self): return self.next_node class NodeList: def __init__(self, values=None): self.node_head =...
class Node: def __init__(self, value=None): self.value = value self.next_node = None def set_next_node(self, next_node): self.next_node = next_node def get_next_node(self): return self.next_node class Nodelist: def __init__(self, values=None): self.node_head ...
# Largest Palindrome product # # A palindromic number reads the same both ways. The largest palindrome made from the # product of two 2-digit numbers is 9009 = 91x99. # # Find the largest palindrome made from the product of two 3-digit numbers. if __name__ == "__main__": max_val = 0 for i in range(100,10...
if __name__ == '__main__': max_val = 0 for i in range(100, 1000, 1): for v in range(100, 1000, 1): value = i * v f_value = str(value) r_value = f_value[::-1] if f_value == r_value and value > max_val: max_val = value print(max_val)
class Solution: def searchRange(self, nums, target: int) : if target in nums: start = nums.index(target) nums.reverse() end = nums.index(target) end = (len(nums) - end -1) result = [start , end] return result return [-1, -1] ...
class Solution: def search_range(self, nums, target: int): if target in nums: start = nums.index(target) nums.reverse() end = nums.index(target) end = len(nums) - end - 1 result = [start, end] return result return [-1, -1] prin...
#!/usr/bin/env python3 #encoding=utf-8 #--------------------------------------- # Usage: python3 validate_descriptors2-5.py # Description: attribute descriptor #--------------------------------------- class CardHolder(object): # Need all "(object)" in 2.X only ''' We could detect this with a minor amount o...
class Cardholder(object): """ We could detect this with a minor amount of additional code to trigger the error more explicitly, but there's probably no point -- because this version stores data in the client instance, there's no meaning to its descriptors unless they're accompanied by a client inst...
class Person: def __init__(self, fid, iid, father_id, mother_id, sex, birthday, datapresent): self.fid = fid self.iid = iid self.father_id = father_id self.mother_id = mother_id self.sex = sex self.birthday = birthday self.datapresent = datapresent self.father = None self.mother =...
class Person: def __init__(self, fid, iid, father_id, mother_id, sex, birthday, datapresent): self.fid = fid self.iid = iid self.father_id = father_id self.mother_id = mother_id self.sex = sex self.birthday = birthday self.datapresent = datapresent se...
# noinspection PyUnusedLocal # friend_name = unicode string def hello(friend_name): if type(friend_name) is not str: raise TypeError("Input parameter is not of string type") message = str("Hello, " + friend_name + "!") if type(message) is not str: raise TypeError("Output message is not of ...
def hello(friend_name): if type(friend_name) is not str: raise type_error('Input parameter is not of string type') message = str('Hello, ' + friend_name + '!') if type(message) is not str: raise type_error('Output message is not of string type') return message
# Medium # https://leetcode.com/problems/design-a-stack-with-increment-operation/ # TC: PUSH O(1) ; POP O(1) ; Increment O(1) # SC: O(N) class CustomStack: def __init__(self, maxSize: int): self.stack = [] self.offset = [] self.size = maxSize def isEmpty(self): return len(self...
class Customstack: def __init__(self, maxSize: int): self.stack = [] self.offset = [] self.size = maxSize def is_empty(self): return len(self.stack) == 0 def is_full(self): return len(self.stack) >= self.size def push(self, x: int) -> None: if not self...
# coding=utf-8 # date: 2018/12/12, 10:35 # name: smz EPOCHS = 25 BATCH_SIZE = 100 LEARNING_RATE = 0.0001 DATA_DIR = "J:\TF-deep-learn\Mnist\data\Mnist_data" LOGS_DIR = "J:\TF-deep-learn\Mnist\logs" CHECKPOINTS_DIR = "J:\\TF-deep-learn\\Mnist\\checkpoints\\MnistSotfmax.ckpt"
epochs = 25 batch_size = 100 learning_rate = 0.0001 data_dir = 'J:\\TF-deep-learn\\Mnist\\data\\Mnist_data' logs_dir = 'J:\\TF-deep-learn\\Mnist\\logs' checkpoints_dir = 'J:\\TF-deep-learn\\Mnist\\checkpoints\\MnistSotfmax.ckpt'
DEFAULT_PACKAGE_TITLE = "default sticker package" DEFAULT_STICKERSET_NAME = "stickers_{}_by_{}" EMOTIONS = { "anger": u'\U0001f621', "contempt": u'\U0001f644', "disgust": u'\U0001f92e', "fear": u'\U0001f628', "happiness": u'\U0001f604', "neutral": u'\U0001f610', "sadness": u'\U0001f622', ...
default_package_title = 'default sticker package' default_stickerset_name = 'stickers_{}_by_{}' emotions = {'anger': u'๐Ÿ˜ก', 'contempt': u'๐Ÿ™„', 'disgust': u'๐Ÿคฎ', 'fear': u'๐Ÿ˜จ', 'happiness': u'๐Ÿ˜„', 'neutral': u'๐Ÿ˜', 'sadness': u'๐Ÿ˜ข', 'surprise': u'๐Ÿ˜ฎ', 'not_detected': u'๐Ÿ˜Ž'} admins = [213800653, 469143491, -335034630, 84...
h = 0.1 T = 10 x = 0.0 v = 1.0 steps = int(T/h) for i in range(steps): x += v * h t = i * h print(f"{t} {x}")
h = 0.1 t = 10 x = 0.0 v = 1.0 steps = int(T / h) for i in range(steps): x += v * h t = i * h print(f'{t} {x}')
n,s = map(int,input().split()) if 2*n<=s: ans = [2]*(n-1) ans.append(s - 2*n + 2) print("YES") print(*ans) print(1) else: print("NO")
(n, s) = map(int, input().split()) if 2 * n <= s: ans = [2] * (n - 1) ans.append(s - 2 * n + 2) print('YES') print(*ans) print(1) else: print('NO')
def main(): # input N = str(input()) # compute i, cnt, flag = 0, 0, True if N == '0': print('Yes') exit() while N[-(i+1)] == '0': cnt += 1 i += 1 if cnt == 0: for i in range(len(N)//2): if N[i] != N[-(i+1)]: flag = False ...
def main(): n = str(input()) (i, cnt, flag) = (0, 0, True) if N == '0': print('Yes') exit() while N[-(i + 1)] == '0': cnt += 1 i += 1 if cnt == 0: for i in range(len(N) // 2): if N[i] != N[-(i + 1)]: flag = False else: f...
{ 'targets': [ { 'target_name': 'bootstrap', 'type': 'none', 'actions': [ { 'action_name': 'bootstrap', 'inputs': [], 'outputs': [''], 'action': [ 'node', 'lib/bootstrap.js' ] } ] } ] }
{'targets': [{'target_name': 'bootstrap', 'type': 'none', 'actions': [{'action_name': 'bootstrap', 'inputs': [], 'outputs': [''], 'action': ['node', 'lib/bootstrap.js']}]}]}
def to_pygame(p): # Converts pymunk body position into pygame coordinate tuple return int(p.x), int(p.y) def poly_centroid(vertices): centroid = [0, 0] area = 0.0 for i in range(len(vertices)): x0, y0 = vertices[i] if i == len(vertices) - 1: x1, y1 = vertices[0] ...
def to_pygame(p): return (int(p.x), int(p.y)) def poly_centroid(vertices): centroid = [0, 0] area = 0.0 for i in range(len(vertices)): (x0, y0) = vertices[i] if i == len(vertices) - 1: (x1, y1) = vertices[0] else: (x1, y1) = vertices[i + 1] a = x0...
# Author: b1tank # Email: b1tank@outlook.com #================================= ''' 448_find-all-numbers-disappeared-in-an-array LeetCode Solution: - sort by using swap to find the right position for each element (similar to 41_first-missing-positive) explanation of O(n): - The whi...
""" 448_find-all-numbers-disappeared-in-an-array LeetCode Solution: - sort by using swap to find the right position for each element (similar to 41_first-missing-positive) explanation of O(n): - The while loop condition evaluates to true at-most 'n' times across all iterations of the outer fo...
def rna(dna): rna = '' # Your code goes here! return rna
def rna(dna): rna = '' return rna
class Optimizer(object): def setup(self, link): self.target = link self.t = 0 self.states = {} self.prepare() def prepare(self): for name, param in self.target.namedparams(): if name not in self.states: state = {} self.init_st...
class Optimizer(object): def setup(self, link): self.target = link self.t = 0 self.states = {} self.prepare() def prepare(self): for (name, param) in self.target.namedparams(): if name not in self.states: state = {} self.init_...
AGE_IMMUNITY = [0.02, 0.02, 0.04, 0.06] SEVERITY_GROWTH = [1, 1, 1, 1] IMMUNITY_GROWTH = [1, 1, 1, 1] IMMUNITY_DISEASE_EXP1 = [0.1, 0.1, 0.1, 0.1] IMMUNITY_DISEASE_EXP2 = [0.3, 0.3, 0.3, 0.3] AGE_ALL_IMMUNITY = [0.001, 0.001, 0.002, 0.003] RAND_IMMUNITY = [0.2, 0.2, 0.2, 0.2]
age_immunity = [0.02, 0.02, 0.04, 0.06] severity_growth = [1, 1, 1, 1] immunity_growth = [1, 1, 1, 1] immunity_disease_exp1 = [0.1, 0.1, 0.1, 0.1] immunity_disease_exp2 = [0.3, 0.3, 0.3, 0.3] age_all_immunity = [0.001, 0.001, 0.002, 0.003] rand_immunity = [0.2, 0.2, 0.2, 0.2]
mais18 = mmenos20 = homens = 0 while True: idade = int(input('Digite a idade')) sexo = str(input('Digite o genero [F/M]')).strip().upper()[0] while sexo not in 'mMfF': sexo = str(input('Digite o genero [F/M]')).strip().upper()[0] cas = str(input('Deseja cadastrar mais uma pessoa ?[S/N]')).strip(...
mais18 = mmenos20 = homens = 0 while True: idade = int(input('Digite a idade')) sexo = str(input('Digite o genero [F/M]')).strip().upper()[0] while sexo not in 'mMfF': sexo = str(input('Digite o genero [F/M]')).strip().upper()[0] cas = str(input('Deseja cadastrar mais uma pessoa ?[S/N]')).strip(...
class Node: def __init__(self, value=None): self.value = value self.left = None self.right = None class BST: def __init__(self): self.root = None def insert(self, value): newnode = Node(value) if self.root == None: self.root = newnode ...
class Node: def __init__(self, value=None): self.value = value self.left = None self.right = None class Bst: def __init__(self): self.root = None def insert(self, value): newnode = node(value) if self.root == None: self.root = newnode ...
# # PySNMP MIB module CISCO-FLOW-MONITOR-TC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FLOW-MONITOR-TC-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:58:51 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ...
def countSubStr(st, n) : res=0 for i in range(0, n) : if (st[i] == '1') : for j in range(i+1, n) : if (st[j] == '1') : res = res + 1 return res st = '01101' list(st) n= len(st) print(countSubStr(st, n), end=" ")
def count_sub_str(st, n): res = 0 for i in range(0, n): if st[i] == '1': for j in range(i + 1, n): if st[j] == '1': res = res + 1 return res st = '01101' list(st) n = len(st) print(count_sub_str(st, n), end=' ')
def trans(intensity): if 0<=intensity<510000: return chr(35) elif 510000<=intensity<1020000: return chr(111) elif 1020000<=intensity<1530000: return chr(43) elif 1530000<=intensity<2040000: return chr(45) else: return chr(46) n,m = map(int,input().split()) i...
def trans(intensity): if 0 <= intensity < 510000: return chr(35) elif 510000 <= intensity < 1020000: return chr(111) elif 1020000 <= intensity < 1530000: return chr(43) elif 1530000 <= intensity < 2040000: return chr(45) else: return chr(46) (n, m) = map(int, ...
def numberOfDaysInAYear(year): if (year%4==0) and (year%100!=0) or (year%400==0): print(str(year)+' 364') else: print(str(year)+' 365') for i in range (2010,2021): numberOfDaysInAYear(i)
def number_of_days_in_a_year(year): if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print(str(year) + ' 364') else: print(str(year) + ' 365') for i in range(2010, 2021): number_of_days_in_a_year(i)