content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Program verificare nr prim/compus
num = int(input("Enter number: "))
# nr prime sunt mai mari decat 1
if num > 1:
# verificare
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"... | num = int(input('Enter number: '))
if num > 1:
for i in range(2, num):
if num % i == 0:
print(num, 'is not a prime number')
print(i, 'times', num // i, 'is', num)
break
else:
print(num, 'is a prime number')
else:
print(num, 'is not a prime number') |
expected_output = {
"vrf": {
"default": {
"address_family": {
"ipv4": {
"routes": {
"10.121.65.0/24": {
"active": True,
"candidate_default": False,
"dat... | expected_output = {'vrf': {'default': {'address_family': {'ipv4': {'routes': {'10.121.65.0/24': {'active': True, 'candidate_default': False, 'date': '7w0d', 'metric': 20, 'next_hop': {'next_hop_list': {1: {'index': 1, 'next_hop': '10.121.64.35', 'outgoing_interface_name': 'inside'}, 2: {'index': 2, 'next_hop': '10.121.... |
#n=int(input('Diga o valor'))
#print('O quadrado {}'.format(n**2))
#print('O Antecessor {} Sucessor {}'.format(n+1,n-1))
dist=int(input('Diga o valor Distancia'))
comb=int(input('Diga o valor Combustivel'))
print('O consumo Medio {}'.format(dist/comb))
| dist = int(input('Diga o valor Distancia'))
comb = int(input('Diga o valor Combustivel'))
print('O consumo Medio {}'.format(dist / comb)) |
def ali_sta_seznama_enaka(sez1, sez2):
slo1 = {}
slo2 = {}
for i in sez1:
slo1[i] = slo1.get(i, 0) + 1
for i in sez2:
slo2[i] = slo2.get(i, 0) + 1
if slo1 == slo2:
return True
else:
return False
def permutacijsko_stevilo():
x = 1
while True:
sez1 ... | def ali_sta_seznama_enaka(sez1, sez2):
slo1 = {}
slo2 = {}
for i in sez1:
slo1[i] = slo1.get(i, 0) + 1
for i in sez2:
slo2[i] = slo2.get(i, 0) + 1
if slo1 == slo2:
return True
else:
return False
def permutacijsko_stevilo():
x = 1
while True:
sez1 ... |
def solution(s: str) -> bool:
stack = []
left = 0
right = 0
for c in s:
if not stack:
if c == ")":
return False
stack.append(c)
left += 1
continue
if c == ")":
if stack[-1] == "(":
stack.pop()
... | def solution(s: str) -> bool:
stack = []
left = 0
right = 0
for c in s:
if not stack:
if c == ')':
return False
stack.append(c)
left += 1
continue
if c == ')':
if stack[-1] == '(':
stack.pop()
... |
self.description = "Quick check for using XferCommand"
# this setting forces us to download packages
self.cachepkgs = False
#wget doesn't support file:// urls. curl does
self.option['XferCommand'] = ['/usr/bin/curl %u -o %o']
numpkgs = 10
pkgnames = []
for i in range(numpkgs):
name = "pkg_%s" % i
pkgnames.ap... | self.description = 'Quick check for using XferCommand'
self.cachepkgs = False
self.option['XferCommand'] = ['/usr/bin/curl %u -o %o']
numpkgs = 10
pkgnames = []
for i in range(numpkgs):
name = 'pkg_%s' % i
pkgnames.append(name)
p = pmpkg(name)
p.files = ['usr/bin/foo-%s' % i]
self.addpkg2db('sync', ... |
class Solution:
def search(self, nums: List[int], target: int) -> bool:
start_idx = 0
for i in range(len(nums)-1):
if nums[i] > nums[i + 1]:
start_idx = i + 1
break
originList = nums[start_idx:] + nums[:start_idx]
... | class Solution:
def search(self, nums: List[int], target: int) -> bool:
start_idx = 0
for i in range(len(nums) - 1):
if nums[i] > nums[i + 1]:
start_idx = i + 1
break
origin_list = nums[start_idx:] + nums[:start_idx]
if target < originList... |
VERSION = (0, 6)
__version__ = '.'.join(map(str, VERSION))
__author__ = 'Ministry of Justice'
__email__ = 'dev@digital.justice.gov.uk'
default_app_config = 'govuk_forms.apps.FormsAppConfig'
| version = (0, 6)
__version__ = '.'.join(map(str, VERSION))
__author__ = 'Ministry of Justice'
__email__ = 'dev@digital.justice.gov.uk'
default_app_config = 'govuk_forms.apps.FormsAppConfig' |
# -*- coding: utf-8 -*-
VERSION = (1, 0, 0, 'beta')
__version__ = ".".join(map(str, VERSION[0:3])) + "".join(VERSION[3:])
__author__ = 'Kuba Janoszek'
| version = (1, 0, 0, 'beta')
__version__ = '.'.join(map(str, VERSION[0:3])) + ''.join(VERSION[3:])
__author__ = 'Kuba Janoszek' |
# Make an algorithm that reads an employee's salary and shows his new salary, with a 15% increase
n1 = float(input('Enter the employee`s salary: US$ '))
n2 = n1 * 1.15
print('The new salary, with 15% increase, is US${:.2f}'.format(n2))
| n1 = float(input('Enter the employee`s salary: US$ '))
n2 = n1 * 1.15
print('The new salary, with 15% increase, is US${:.2f}'.format(n2)) |
def get_string_count_to_by(to, by):
if by < 1:
raise ValueError("'by' must be > 0")
if to < 1:
raise ValueError("'to' must be > 0")
if to <= by:
return str(to)
return get_string_count_to_by(to - by, by) + ", " + str(to)
def count_to_by(to, by):
print(get_string_count_to_by(t... | def get_string_count_to_by(to, by):
if by < 1:
raise value_error("'by' must be > 0")
if to < 1:
raise value_error("'to' must be > 0")
if to <= by:
return str(to)
return get_string_count_to_by(to - by, by) + ', ' + str(to)
def count_to_by(to, by):
print(get_string_count_to_by... |
def sol():
N, M = map(int, input().split(" "))
data = sorted(list(map(int, input().split(" "))))
visited = [False] * (N + 1)
save = set()
dfs(N, M, data, visited, save, 0, "")
def dfs(N, M, data, visited, save, cnt, line):
if cnt == M:
if line not in save:
save.add(line)
... | def sol():
(n, m) = map(int, input().split(' '))
data = sorted(list(map(int, input().split(' '))))
visited = [False] * (N + 1)
save = set()
dfs(N, M, data, visited, save, 0, '')
def dfs(N, M, data, visited, save, cnt, line):
if cnt == M:
if line not in save:
save.add(line)
... |
def generate_instance_name(name):
out = name[0].lower()
for char in name[1:]:
if char.isupper():
out += "_%s" % char.lower()
else:
out += char
return out
def generate_human_name(name):
out = name[0]
for char in name[1:]:
if char.isupper():
... | def generate_instance_name(name):
out = name[0].lower()
for char in name[1:]:
if char.isupper():
out += '_%s' % char.lower()
else:
out += char
return out
def generate_human_name(name):
out = name[0]
for char in name[1:]:
if char.isupper():
... |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
_base_ = [
'../_base_/models/upernet_convnext.py', '../_base_/datasets/ade20k.py',
'../_base_/default_runtime.py... | _base_ = ['../_base_/models/upernet_convnext.py', '../_base_/datasets/ade20k.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py']
crop_size = (512, 512)
model = dict(backbone=dict(type='ConvNeXt', in_chans=3, depths=[3, 3, 9, 3], dims=[96, 192, 384, 768], drop_path_rate=0.4, layer_scale_init_val... |
'''
Kompresi Benny
Menyederhanakan sebuah kata dengan membuat beberapa
karakter yang sama dan berurutan hanya akan menjadi
satu karakter saja.
'''
def kompresi(a_str):
'''
Mengompres a_str sehingga tidak ada
karakter yang sama yang bersebelahan.
Contoh: kompresi('aabbbbaaacddeae')
... | """
Kompresi Benny
Menyederhanakan sebuah kata dengan membuat beberapa
karakter yang sama dan berurutan hanya akan menjadi
satu karakter saja.
"""
def kompresi(a_str):
"""
Mengompres a_str sehingga tidak ada
karakter yang sama yang bersebelahan.
Contoh: kompresi('aabbbbaaacddeae')
akan me... |
__all__ = ['CommandError', 'CommandLineError']
class CommandError(Exception):
pass
class CommandLineError(Exception):
pass
class SubcommandError(Exception):
pass
class MaincommandError(Exception):
pass
class CommandCollectionError(Exception):
pass
| __all__ = ['CommandError', 'CommandLineError']
class Commanderror(Exception):
pass
class Commandlineerror(Exception):
pass
class Subcommanderror(Exception):
pass
class Maincommanderror(Exception):
pass
class Commandcollectionerror(Exception):
pass |
# Copyright (c) 2021, Carlos Millett
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the Simplified BSD License. See the LICENSE file for details.
'''
Renamer renames your TV files into a nice new format.
The new filename includes the TV show name, season and episode num... | """
Renamer renames your TV files into a nice new format.
The new filename includes the TV show name, season and episode numbers and
the episode title.
"""
__version__ = '0.3.2'
__author__ = 'Carlos Millett <carlos4735@gmail.com>' |
s = open('input.txt','r').read()
s = [k for k in s.split("\n")]
ans = 0
p = ""
q = 0
for line in s:
if line == "":
x = [0]*26
for i in p:
j = ord(i) - 97
if 0 <= j < 26:
x[j] += 1
ans += len([k for k in x if k == q])
p = ""
q = 0
... | s = open('input.txt', 'r').read()
s = [k for k in s.split('\n')]
ans = 0
p = ''
q = 0
for line in s:
if line == '':
x = [0] * 26
for i in p:
j = ord(i) - 97
if 0 <= j < 26:
x[j] += 1
ans += len([k for k in x if k == q])
p = ''
q = 0
... |
# Python - 3.6.0
def presses(phrase):
keypads = ['1', 'ABC2', 'DEF3', 'GHI4', 'JKL5', 'MNO6', 'PQRS7', 'TUV8', 'WXYZ9', '*', ' 0', '#']
times, i = 0, 0
for p in phrase.upper():
for keypad in keypads:
i = keypad.find(p)
if i >= 0:
break
times += i + 1
... | def presses(phrase):
keypads = ['1', 'ABC2', 'DEF3', 'GHI4', 'JKL5', 'MNO6', 'PQRS7', 'TUV8', 'WXYZ9', '*', ' 0', '#']
(times, i) = (0, 0)
for p in phrase.upper():
for keypad in keypads:
i = keypad.find(p)
if i >= 0:
break
times += i + 1
return tim... |
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DEPS = [
'flavor',
'recipe_engine/properties',
'recipe_engine/raw_io',
'run',
'vars',
]
def test_exceptions(api):
try:
api.flavor.copy_dir... | deps = ['flavor', 'recipe_engine/properties', 'recipe_engine/raw_io', 'run', 'vars']
def test_exceptions(api):
try:
api.flavor.copy_directory_contents_to_device('src', 'dst')
except ValueError:
pass
try:
api.flavor.copy_directory_contents_to_host('src', 'dst')
except ValueError:... |
pass_marks = 70
if pass_marks == 70:
print('pass')
its_raining = True # you can change this to False
if its_raining:
print("It's raining!")
its_raining = True # you can change this to False
its_not_raining = not its_raining # False if its_raining, True otherwise
if its... | pass_marks = 70
if pass_marks == 70:
print('pass')
its_raining = True
if its_raining:
print("It's raining!")
its_raining = True
its_not_raining = not its_raining
if its_raining:
print("It's raining!")
if its_not_raining:
print("It's not raining.")
if its_raining:
print("It's raining!")
else:
pri... |
a = 28
b = 1.5
c = "Hello!"
d = True
e = None
| a = 28
b = 1.5
c = 'Hello!'
d = True
e = None |
#1) Indexing lists and tuples
list_values = [1, 2, 3]
set_values = (10, 20, 30)
print(list_values[0])
print(set_values[0])
#2) Changing values: lists vs tuples
list_values = [1, 2, 3]
set_values = (10, 20, 30)
list_values[0] = 100
print(list_values)
set_values[0] = 100
#3) Tuple vs List Expanding
list_values = ... | list_values = [1, 2, 3]
set_values = (10, 20, 30)
print(list_values[0])
print(set_values[0])
list_values = [1, 2, 3]
set_values = (10, 20, 30)
list_values[0] = 100
print(list_values)
set_values[0] = 100
list_values = [1, 2, 3]
set_values = (1, 2, 3)
print(id(list_values))
print(id(set_values))
print()
list_values += [4... |
dic_cal = {}
def cal(a, b):
if (a, b) in dic_cal:
return dic_cal[(a, b)]
return cal(a - 1, b) + cal(a, b - 1)
if __name__ == '__main__':
for j in range(0, 1):
for k in range(0, 21):
dic_cal[(j, k)] = 1
for j in range(0, 21):
for k in range(0, 1):
dic_c... | dic_cal = {}
def cal(a, b):
if (a, b) in dic_cal:
return dic_cal[a, b]
return cal(a - 1, b) + cal(a, b - 1)
if __name__ == '__main__':
for j in range(0, 1):
for k in range(0, 21):
dic_cal[j, k] = 1
for j in range(0, 21):
for k in range(0, 1):
dic_cal[j, k... |
# shorthand for tabulation
def get_tabs(num):
ret = ""
for _ in range(num):
ret += "\t"
return ret
| def get_tabs(num):
ret = ''
for _ in range(num):
ret += '\t'
return ret |
n = int(input())
chars_of_each_string = [[char for char in input()] for _ in range(n)]
chars = []
for characters in chars_of_each_string:
chars += list(set(characters))
chars_used_in_all = []
for char in set(chars):
if chars.count(char) == n:
chars_used_in_all.append(char)
if not chars_us... | n = int(input())
chars_of_each_string = [[char for char in input()] for _ in range(n)]
chars = []
for characters in chars_of_each_string:
chars += list(set(characters))
chars_used_in_all = []
for char in set(chars):
if chars.count(char) == n:
chars_used_in_all.append(char)
if not chars_used_in_all:
... |
'''
Description: exercise: finding the area
Version: 1.0.0.20210113
Author: Arvin Zhao
Date: 2021-01-13 12:20:06
Last Editors: Arvin Zhao
LastEditTime: 2021-01-13 12:48:56
'''
def display_square_area() -> None:
'''
Calculate and display the area of a square.
'''
while True:
try:
si... | """
Description: exercise: finding the area
Version: 1.0.0.20210113
Author: Arvin Zhao
Date: 2021-01-13 12:20:06
Last Editors: Arvin Zhao
LastEditTime: 2021-01-13 12:48:56
"""
def display_square_area() -> None:
"""
Calculate and display the area of a square.
"""
while True:
try:
sid... |
class MultiheadAttention(Module):
__parameters__ = ["in_proj_weight", "in_proj_bias", ]
__buffers__ = []
in_proj_weight : Tensor
in_proj_bias : Tensor
training : bool
out_proj : __torch__.torch.nn.modules.linear.___torch_mangle_9395._LinearWithBias
def forward(self: __torch__.torch.nn.modules.activation._... | class Multiheadattention(Module):
__parameters__ = ['in_proj_weight', 'in_proj_bias']
__buffers__ = []
in_proj_weight: Tensor
in_proj_bias: Tensor
training: bool
out_proj: __torch__.torch.nn.modules.linear.___torch_mangle_9395._LinearWithBias
def forward(self: __torch__.torch.nn.modules.act... |
#
# PySNMP MIB module Nortel-MsCarrier-MscPassport-DataCollectionMIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-DataCollectionMIB
# Produced by pysmi-0.3.4 at Wed May 1 14:29:37 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 ... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ... |
# Algocia is placed on a great dessert and consists of cities and oases connected by roads. There is
# exactly one road leading from each gate to one oasis (but any given oasis can have any number of roads
# leading to them, oases can also be interconnected by roads). Algocian law requires that if someone
# enters a ci... | def check_and_bishop(graph, oasis):
changed_graph = []
for i in range(len(graph)):
if i not in oasis:
changed_graph.append([graph[i][0], graph[i][1], 0])
else:
for j in range(len(graph[i])):
if graph[i][j] in oasis:
if [graph[i][j], i, ... |
'''
You are given a circular array nums of positive and negative integers.
If a number k at an index is positive, then move forward k steps.
Conversely, if it's negative (-k), move backward k steps.
Since the array is circular, you may assume that the last element's next element is the first element, and the first elem... | """
You are given a circular array nums of positive and negative integers.
If a number k at an index is positive, then move forward k steps.
Conversely, if it's negative (-k), move backward k steps.
Since the array is circular, you may assume that the last element's next element is the first element, and the first elem... |
class PartyAnimal:
x = 0
name = ""
def __init__(self, nameCons):
self.name = nameCons
print("name: ", self.name)
def party(self):
self.x = self.x + 1
print(self.name," - party count: ", self.x)
class FootballFan(PartyAnimal):
points = 0
def touchdown(self):... | class Partyanimal:
x = 0
name = ''
def __init__(self, nameCons):
self.name = nameCons
print('name: ', self.name)
def party(self):
self.x = self.x + 1
print(self.name, ' - party count: ', self.x)
class Footballfan(PartyAnimal):
points = 0
def touchdown(self):
... |
__author__ = 'Nathen'
input_str = input('Paste input nums: ')
k, m, n = map(lambda num: float(num), input_str.split(' '))
population = k + m + n
# odds when dominant first
pK = k / population
# odds when heterozygous first
pMK = (m / population) * (k / (population - 1.0))
pMM = (m / population) * ((m - 1.0) / (pop... | __author__ = 'Nathen'
input_str = input('Paste input nums: ')
(k, m, n) = map(lambda num: float(num), input_str.split(' '))
population = k + m + n
p_k = k / population
p_mk = m / population * (k / (population - 1.0))
p_mm = m / population * ((m - 1.0) / (population - 1.0)) * 0.75
p_mn = m / population * (n / (populatio... |
with open("tinder_api/utils/token.txt", "r") as f:
tinder_token = f.read()
# it is best for you to write in the token to save yourself the file I/O
# especially if you have python byte code off
#tinder_token = ""
headers = {
'app_version': '6.9.4',
'platform': 'ios',
'content-type': 'application/json'... | with open('tinder_api/utils/token.txt', 'r') as f:
tinder_token = f.read()
headers = {'app_version': '6.9.4', 'platform': 'ios', 'content-type': 'application/json', 'User-agent': 'Tinder/7.5.3 (iPohone; iOS 10.3.2; Scale/2.00)', 'X-Auth-Token': 'enter_auth_token'}
host = 'https://api.gotinder.com'
if __name__ == '_... |
with open('day9.txt') as f:
data = f.read().splitlines()[0].split(' ')
nPlayers = int(data[0])
nMarbles = int(data[6])
# Players
playerScores = [0] * nPlayers
currentPlayer = -1
# Marbles
right = [None] * nMarbles
left = [None] * nMarbles
# Initialise
current = 0
total = 1
right[current] = current
left[... | with open('day9.txt') as f:
data = f.read().splitlines()[0].split(' ')
n_players = int(data[0])
n_marbles = int(data[6])
player_scores = [0] * nPlayers
current_player = -1
right = [None] * nMarbles
left = [None] * nMarbles
current = 0
total = 1
right[current] = current
left[current] = current
for i in range... |
LUCYFER_SETTINGS = {
"SAVED_SEARCHES_ENABLE": False,
"SAVED_SEARCHES_KEY": None,
}
| lucyfer_settings = {'SAVED_SEARCHES_ENABLE': False, 'SAVED_SEARCHES_KEY': None} |
r = 'S'
while r == "S":
n = int(input('Digite um numero: '))
r = str(input('Quer continuar [S/N]: ')).upper()
print('Acabou') | r = 'S'
while r == 'S':
n = int(input('Digite um numero: '))
r = str(input('Quer continuar [S/N]: ')).upper()
print('Acabou') |
def reverse(number):
stack = []
result = ""
for num in str(number):
stack.append(num)
for i in range(len(stack)):
result += stack.pop()
print(result)
return int(result)
reverse(3479)
| def reverse(number):
stack = []
result = ''
for num in str(number):
stack.append(num)
for i in range(len(stack)):
result += stack.pop()
print(result)
return int(result)
reverse(3479) |
T_Call = 0
T_Squat = 1
T_Shank = 2
T_Jump = 3
T_Slap = 4
T_EyeContact = 5
function_name_dict = {
T_Call: "call",
T_Squat: "squat",
T_Shank: "shank",
T_Jump: "jump",
T_Slap: "slap",
T_EyeContact: "eye_contact"
}
RESPECT_MAX = 255 | t__call = 0
t__squat = 1
t__shank = 2
t__jump = 3
t__slap = 4
t__eye_contact = 5
function_name_dict = {T_Call: 'call', T_Squat: 'squat', T_Shank: 'shank', T_Jump: 'jump', T_Slap: 'slap', T_EyeContact: 'eye_contact'}
respect_max = 255 |
def power_of_two(x):
if x == 1:
return True
if x < 1:
return False
return power_of_two(x / 2)
| def power_of_two(x):
if x == 1:
return True
if x < 1:
return False
return power_of_two(x / 2) |
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
def search(lo, hi):
if nums[lo] == target == nums[hi]:
return [lo, hi]
if nums[lo] <= target <= nums[hi]:
mid = (lo + hi) // 2
l, r = search(lo, mid), sea... | class Solution:
def search_range(self, nums: List[int], target: int) -> List[int]:
def search(lo, hi):
if nums[lo] == target == nums[hi]:
return [lo, hi]
if nums[lo] <= target <= nums[hi]:
mid = (lo + hi) // 2
(l, r) = (search(lo, mid... |
#15 Distance units
# Askng for distance in feet.
x = float(input("Enter the distance in feet = "))
inches = x * 12
yards = x * 0.33333
miles = x * 0.000189
print("Inches = ",inches," Yards = ",yards," Miles = ",miles)
| x = float(input('Enter the distance in feet = '))
inches = x * 12
yards = x * 0.33333
miles = x * 0.000189
print('Inches = ', inches, ' Yards = ', yards, ' Miles = ', miles) |
load("@berty_go//:config.bzl", "berty_go_config")
load("@co_znly_rules_gomobile//:repositories.bzl", "gomobile_repositories")
load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies")
def berty_bridge_conf... | load('@berty_go//:config.bzl', 'berty_go_config')
load('@co_znly_rules_gomobile//:repositories.bzl', 'gomobile_repositories')
load('@build_bazel_apple_support//lib:repositories.bzl', 'apple_support_dependencies')
load('@build_bazel_rules_swift//swift:repositories.bzl', 'swift_rules_dependencies')
def berty_bridge_conf... |
n = 95
for i in range(1,1000):
a = n ^ i
print(bin(a),a)
print(i,bin(n),n)
print() | n = 95
for i in range(1, 1000):
a = n ^ i
print(bin(a), a)
print(i, bin(n), n)
print() |
'''
Description : Use Of Basic Input / Output
Function Date : 07 Feb 2021
Function Author : Prasad Dangare
Input : Str
Output : --
'''
print("Enter One Number") # to display on screen
no = input() # to accept the standard input device ie keyword
print ("Your Number Is :... | """
Description : Use Of Basic Input / Output
Function Date : 07 Feb 2021
Function Author : Prasad Dangare
Input : Str
Output : --
"""
print('Enter One Number')
no = input()
print('Your Number Is : ', no)
print('Data Type Of Give Number Is : ', type(no)) |
# Global Reach
# Demonstrates global variables
def read_global():
print("From inside the local scope of read_global(), value is:", value)
def shadow_global():
value = -10
print("From inside the local scope of shadow_global(), value is:", value)
def change_global():
global value
value = -10
... | def read_global():
print('From inside the local scope of read_global(), value is:', value)
def shadow_global():
value = -10
print('From inside the local scope of shadow_global(), value is:', value)
def change_global():
global value
value = -10
print('From inside the local scope of change_globa... |
a = int(input("Enter: "))
reserve = a
temp = 0
rev=0
while a>0:
temp = a%10
a = a//10
rev = rev*10 + temp
if reserve == rev:
print("Palindrome")
else:
print("not") | a = int(input('Enter: '))
reserve = a
temp = 0
rev = 0
while a > 0:
temp = a % 10
a = a // 10
rev = rev * 10 + temp
if reserve == rev:
print('Palindrome')
else:
print('not') |
class Track(object):
id = 0
header_line = 1
filename = ""
key_color = "#FF4D55"
name = ""
description = ""
track_image_url = "http://lorempixel.com/400/200"
location = ""
gid = ""
order = -1
def __init__(self, id, name, header_line, key_color, location, gid, order):
... | class Track(object):
id = 0
header_line = 1
filename = ''
key_color = '#FF4D55'
name = ''
description = ''
track_image_url = 'http://lorempixel.com/400/200'
location = ''
gid = ''
order = -1
def __init__(self, id, name, header_line, key_color, location, gid, order):
... |
#!/usr/bin/env python3
if __name__ == '__main__':
students_list = []
while True:
command = input("Add, list, exit: ").lower()
if command == 'exit':
break
elif command == 'add':
last_name = input('Your last name^ ')
class_name = input('... | if __name__ == '__main__':
students_list = []
while True:
command = input('Add, list, exit: ').lower()
if command == 'exit':
break
elif command == 'add':
last_name = input('Your last name^ ')
class_name = input('Class ')
grades = []
... |
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
# pretrained='checkpoints/metanet-b4/det_fmtb4_v1.pth.tar',
backbone=dict(
type='Central_Model',
backbone_name='MTB4',
task_names=('gv_patch', 'gv_global'),
main_task_name... | norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(type='EncoderDecoder', backbone=dict(type='Central_Model', backbone_name='MTB4', task_names=('gv_patch', 'gv_global'), main_task_name='gv_global', trans_type='crossconvhrnetlayer', task_name_to_backbone={'gv_global': {'repeats': [2, 3, 6, 6, 6, 12], 'expan... |
# OpenWeatherMap API Key
weather_api_key = "2e751db150eed8a2a8ae9dc91e31a091"
# Google API Key
g_key = "AIzaSyBqrWs9x-quXSBQkAVuz-x7PP3t64gJj7E"
| weather_api_key = '2e751db150eed8a2a8ae9dc91e31a091'
g_key = 'AIzaSyBqrWs9x-quXSBQkAVuz-x7PP3t64gJj7E' |
def main():
s = input()
weathers = ['Sunny', 'Cloudy', 'Rainy']
length = weathers.__len__()
index = weathers.index(s) + 1
if index >= length:
index = 0
print(weathers[index])
if __name__ == "__main__":
main()
| def main():
s = input()
weathers = ['Sunny', 'Cloudy', 'Rainy']
length = weathers.__len__()
index = weathers.index(s) + 1
if index >= length:
index = 0
print(weathers[index])
if __name__ == '__main__':
main() |
# Find height of a given binary tree
class Node():
def __init__(self, value):
self.left = None
self.right = None
self.value = value
class Tree():
def height(self, node: Node):
if node is None or (node.left is None and node.right is None):
return 0
else:... | class Node:
def __init__(self, value):
self.left = None
self.right = None
self.value = value
class Tree:
def height(self, node: Node):
if node is None or (node.left is None and node.right is None):
return 0
else:
left_sub_tree_height = self.heig... |
#!/usr/local/bin/python3
message = str(input("Message: "))
secret = ""
for character in reversed(message):
secret = secret + str(chr(ord(character)+1))
print(secret) | message = str(input('Message: '))
secret = ''
for character in reversed(message):
secret = secret + str(chr(ord(character) + 1))
print(secret) |
class Solution:
def majorityElement(self, nums: List[int]) -> int:
counter = {}
for num in nums:
if num not in counter:
counter[num] = 1
else:
counter[num] += 1
for key, value in counter.items():
if value > ... | class Solution:
def majority_element(self, nums: List[int]) -> int:
counter = {}
for num in nums:
if num not in counter:
counter[num] = 1
else:
counter[num] += 1
for (key, value) in counter.items():
if value > len(nums) / 2... |
oo000 = 0
for ii in range ( 11 ) :
oo000 += ii
if 51 - 51: IiI1i11I
print ( oo000 )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
| oo000 = 0
for ii in range(11):
oo000 += ii
if 51 - 51:
IiI1i11I
print(oo000) |
APP_PORT = 7991
LOGFILE_PATH = "/var/log/application/db_replication.log"
MASTER_MYSQL = {
'host': '127.0.0.1',
'port': 3306,
'user': 'root',
'password': 'password'
}
| app_port = 7991
logfile_path = '/var/log/application/db_replication.log'
master_mysql = {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'password': 'password'} |
#############################################################################
#Replace with the persons name that you were texting
leftName = "Bob"
#Replace with your name
rightName = "John"
#############################################################################
| left_name = 'Bob'
right_name = 'John' |
BASE_DIR=""
DATA_DIR="/mnt/nfs/work1/akshay/akshay/projects/oracle_cb/data/"
REMOTE_PATH_TO_PYTHON="/mnt/nfs/work1/akshay/akshay/anaconda3/python3"
REMOTE_BASE_DIR="/mnt/nfs/work1/akshay/akshay/projects/oracle_cb/"
| base_dir = ''
data_dir = '/mnt/nfs/work1/akshay/akshay/projects/oracle_cb/data/'
remote_path_to_python = '/mnt/nfs/work1/akshay/akshay/anaconda3/python3'
remote_base_dir = '/mnt/nfs/work1/akshay/akshay/projects/oracle_cb/' |
def prime(num):
flag=False
for a in range(2,num-1): #basically prime no are divisible by itself and by 1 only so set input value -1 so i takes previous num
if num%a==0:
flag=True
if flag==False:
print("prime")
else:
print("not prime")
num=int(input("enter... | def prime(num):
flag = False
for a in range(2, num - 1):
if num % a == 0:
flag = True
if flag == False:
print('prime')
else:
print('not prime')
num = int(input('enter the no'))
prime(num) |
#!/usr/bin/env python
###############################################################################
# Copyright 2017 The Apollo Authors. All Rights Reserved.
# Modifications Copyright (c) 2018 LG Electronics, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not ... | class Advehicle:
def __init__(self):
self._chassis_pb = None
self._localization_pb = None
self.front_edge_to_center = 3.89
self.back_edge_to_center = 1.043
self.left_edge_to_center = 1.055
self.right_edge_to_center = 1.055
self.speed_mps = None
self.x... |
HTTP_STATUS_CODES = {
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
"206": "Partial Content",
"207": "Multi-Status",
... | http_status_codes = {'100': 'Continue', '101': 'Switching Protocols', '102': 'Processing', '200': 'OK', '201': 'Created', '202': 'Accepted', '203': 'Non-Authoritative Information', '204': 'No Content', '205': 'Reset Content', '206': 'Partial Content', '207': 'Multi-Status', '208': 'Already Reported', '226': 'IM Used', ... |
# Write your code here
N = int(input())
arr = list(map(int, input().split()))
def give_soln(n):
return ((2**n) - (1 + (n) + (n*(n-1)/2)))
my_dict = dict()
for i in arr:
if i in my_dict:
my_dict[i] += 1
else:
my_dict[i] = 1
count = 0
for side in my_dict:
if my_dict[side... | n = int(input())
arr = list(map(int, input().split()))
def give_soln(n):
return 2 ** n - (1 + n + n * (n - 1) / 2)
my_dict = dict()
for i in arr:
if i in my_dict:
my_dict[i] += 1
else:
my_dict[i] = 1
count = 0
for side in my_dict:
if my_dict[side] >= 3:
count += give_soln(my_dic... |
model = dict(
type='GroupFree3DNet',
backbone=dict(
type='PointNet2SASSG',
in_channels=3,
num_points=(2048, 1024, 512, 256),
radius=(0.2, 0.4, 0.8, 1.2),
num_samples=(64, 32, 16, 16),
sa_channels=((64, 64, 128), (128, 128, 256), (128, 128, 256),
... | model = dict(type='GroupFree3DNet', backbone=dict(type='PointNet2SASSG', in_channels=3, num_points=(2048, 1024, 512, 256), radius=(0.2, 0.4, 0.8, 1.2), num_samples=(64, 32, 16, 16), sa_channels=((64, 64, 128), (128, 128, 256), (128, 128, 256), (128, 128, 256)), fp_channels=((256, 256), (256, 288)), norm_cfg=dict(type='... |
#!/usr/bin/env python
__all__ = ['adaptor', 'get_by_cai','util']
__author__ = "Rob Knight"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Rob Knight", "Stephanie Wilson", "Michael Eaton"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Rob Knight"
__email__ = "rob@spot.colorado.e... | __all__ = ['adaptor', 'get_by_cai', 'util']
__author__ = 'Rob Knight'
__copyright__ = 'Copyright 2007-2012, The Cogent Project'
__credits__ = ['Rob Knight', 'Stephanie Wilson', 'Michael Eaton']
__license__ = 'GPL'
__version__ = '1.5.3'
__maintainer__ = 'Rob Knight'
__email__ = 'rob@spot.colorado.edu'
__status__ = 'Prod... |
# -*- coding: utf-8 -*-
class FieldError(Exception):
pass
class FieldDoesNotExist(Exception):
pass
class ReadOnlyError(AttributeError):
pass
| class Fielderror(Exception):
pass
class Fielddoesnotexist(Exception):
pass
class Readonlyerror(AttributeError):
pass |
# Created by MechAviv
# Quest ID :: 34931
# Not coded yet
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendNext("#face1#Good work! I'm getting the signal again. W... | sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendNext("#face1#Good work! I'm getting the signal again. We need to move quickly. Follow me.")
sm.setSpeakerID(300150... |
__all__ = ["InvalidCredentialsException"]
class InvalidCredentialsException(Exception):
pass
class NoHostsConnectedToException(Exception):
pass
| __all__ = ['InvalidCredentialsException']
class Invalidcredentialsexception(Exception):
pass
class Nohostsconnectedtoexception(Exception):
pass |
# More details on this kata
# https://www.codewars.com/kata/51c8e37cee245da6b40000bd
def solution(string,markers):
if len(string) == 0:
return ''
t, tt, test, l, j, ret= [], [], [], [], [], ''
s = string.split('\n')
for _s in s:
for m in markers:
if _s.find(m) != -1:
... | def solution(string, markers):
if len(string) == 0:
return ''
(t, tt, test, l, j, ret) = ([], [], [], [], [], '')
s = string.split('\n')
for _s in s:
for m in markers:
if _s.find(m) != -1:
t.append(_s.find(m))
test.append(t)
t = []
for a in... |
def get_global_config():
result = {
'outcome' : 'success',
'data' : {
'credentials_file' : r'./config/config.ini',
}
}
return result | def get_global_config():
result = {'outcome': 'success', 'data': {'credentials_file': './config/config.ini'}}
return result |
# Url to manually retrieve authorization code
AUTH_URL = "https://auth.tdameritrade.com/auth"
# API endpoint for token and authorization code authentication
OAUTH_URL = "https://api.tdameritrade.com/v1/oauth2/token"
# Quote endpoints
GET_QUOTES_URL = "https://api.tdameritrade.com/v1/marketdata/quotes"
GET_QUOTE_URL =... | auth_url = 'https://auth.tdameritrade.com/auth'
oauth_url = 'https://api.tdameritrade.com/v1/oauth2/token'
get_quotes_url = 'https://api.tdameritrade.com/v1/marketdata/quotes'
get_quote_url = 'https://api.tdameritrade.com/v1/marketdata/'
get_price_history_url = 'https://api.tdameritrade.com/v1/marketdata/' |
def start():
print('\nThis is my Rock Paper Scissors Game!\n\n')
Player_one = "Kaly"
Player_two = "Erik"
def choices(Player_one_choice, Player_two_choice):
if Player_one_choice == 'rock' and Player_two_choice == 'paper':
return('Paper cover Rock! ' + Player_two + ' Wins !')
... | def start():
print('\nThis is my Rock Paper Scissors Game!\n\n')
player_one = 'Kaly'
player_two = 'Erik'
def choices(Player_one_choice, Player_two_choice):
if Player_one_choice == 'rock' and Player_two_choice == 'paper':
return 'Paper cover Rock! ' + Player_two + ' Wins !'
e... |
def parameters():
epsilon = 0.0001 # regularization
K = 3 # number of desired clusters
n_iter = 5 # number of iterations
skin_n_iter = 5
skin_epsilon = 0.0001
skin_K = 3
theta = 2.0 # threshold for skin detection
return epsilon, K, n_iter, skin_n_iter, skin_epsilon, skin_K, theta
| def parameters():
epsilon = 0.0001
k = 3
n_iter = 5
skin_n_iter = 5
skin_epsilon = 0.0001
skin_k = 3
theta = 2.0
return (epsilon, K, n_iter, skin_n_iter, skin_epsilon, skin_K, theta) |
def perm(text1, text2):
return sum(ord(c) for c in text1) == sum(ord(c) for c in text2)
# test
one = 'abc'
two = 'bcaa'
print(perm(one, two))
| def perm(text1, text2):
return sum((ord(c) for c in text1)) == sum((ord(c) for c in text2))
one = 'abc'
two = 'bcaa'
print(perm(one, two)) |
class Problem:
def __init__(self, n, m):
self.n = n
self.m = m
self.answer = [0 for _ in range(m)]
self.used = [False for _ in range(n)]
def printAnswer(self):
for number in self.answer:
print(number,end=' ')
print()
def makeAnswer(self, index):
... | class Problem:
def __init__(self, n, m):
self.n = n
self.m = m
self.answer = [0 for _ in range(m)]
self.used = [False for _ in range(n)]
def print_answer(self):
for number in self.answer:
print(number, end=' ')
print()
def make_answer(self, inde... |
class Node:
def __init__(self, data):
self.right = self.left = None
self.data = data
class Solution:
def insert(self, root, data):
if root is None:
return Node(data)
else:
if data <= root.data:
cur = self.insert(root.left, data)
... | class Node:
def __init__(self, data):
self.right = self.left = None
self.data = data
class Solution:
def insert(self, root, data):
if root is None:
return node(data)
elif data <= root.data:
cur = self.insert(root.left, data)
root.left = cur
... |
def define_suit(card):
if card.endswith("C"): return "clubs"
if card.endswith("D"): return "diamonds"
if card.endswith("H"): return "hearts"
if card.endswith("S"): return "spades" | def define_suit(card):
if card.endswith('C'):
return 'clubs'
if card.endswith('D'):
return 'diamonds'
if card.endswith('H'):
return 'hearts'
if card.endswith('S'):
return 'spades' |
_base_ = [
'../_base_/models/retinanet_r50_fpn.py',
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
backbone=dict(
type='ResNetEMOD',
ar=dict(ratio=1. / 4.),
stage_with_ar=(True, True, True, True)
),... | _base_ = ['../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
model = dict(backbone=dict(type='ResNetEMOD', ar=dict(ratio=1.0 / 4.0), stage_with_ar=(True, True, True, True)), bbox_head=dict(num_classes=11))
dataset_type =... |
class ValorantApi(Exception):
pass
class InvalidOrMissingParameter(ValorantApi): # 400
pass
class NotFound(ValorantApi): # 404
pass
class AttributeExistsError(ValorantApi):
pass
| class Valorantapi(Exception):
pass
class Invalidormissingparameter(ValorantApi):
pass
class Notfound(ValorantApi):
pass
class Attributeexistserror(ValorantApi):
pass |
class MobilePhone:
def __init__(self, memory):
self.memory = memory
class Camera:
def take_picture(self):
print("Say cheese!")
class CameraPhone(MobilePhone, Camera):
pass
iphone = CameraPhone('16GB')
print(iphone.memory)
iphone.take_picture() | class Mobilephone:
def __init__(self, memory):
self.memory = memory
class Camera:
def take_picture(self):
print('Say cheese!')
class Cameraphone(MobilePhone, Camera):
pass
iphone = camera_phone('16GB')
print(iphone.memory)
iphone.take_picture() |
# ===============================================================
# =======================AST=HIERARCHY===========================
# ===============================================================
ERROR = 0
INTEGER = 1
class Node:
def __init__(self):
self.static_type = ""
class ProgramNode(Node):
de... | error = 0
integer = 1
class Node:
def __init__(self):
self.static_type = ''
class Programnode(Node):
def __init__(self, class_list):
Node.__init__(self)
self.class_list = class_list
class Classnode(Node):
def __init__(self, name, parent, feature_list):
Node.__init__(sel... |
# for i in range(17):
# print("{0:>2} in hex is {0:>02x}".format(i))
# #
# x = 0x20
# y = 0x0a
# #
# print(x)
# print(y)
# print(x * y)
# #
# print(0b101010)
# When converting a decimal number to binary, you look for the highest power
# of 2 smaller than the number and put a 1 in that column. You then take the
# r... | powers = []
for power in range(15, -1, -1):
powers.append(2 ** power)
print(powers)
x = int(input('Please enter a number: '))
printing = False
for power in powers:
bit = x // power
if bit != 0 or power == 1:
printing = True
if printing:
print(bit, end='')
x %= power |
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __repr__(self):
return str(self.val)
# Brute Force; Time: O(n^2); Space: O(n)
def next_larger_nodes(head):
res = []
slow = head
while slow:
fast = slow.next
while fa... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __repr__(self):
return str(self.val)
def next_larger_nodes(head):
res = []
slow = head
while slow:
fast = slow.next
while fast:
if fast.val > slow.val:
... |
{
"targets": [
{
"target_name": "crc",
"sources": [ "./src/crc_module.c", "./src/crc.c" ]
},
]
} | {'targets': [{'target_name': 'crc', 'sources': ['./src/crc_module.c', './src/crc.c']}]} |
class Node:
def __init__(self, val, next=None):
self.val = val
self.next = next
input_list = [0, 1, 2, 3, 4]
root = None
for val in input_list:
root = Node(val, root)
cur = root
while cur:
print(cur.val)
cur = cur.next
print('Stack after pop: ')
root = root.next
cur = root
while cu... | class Node:
def __init__(self, val, next=None):
self.val = val
self.next = next
input_list = [0, 1, 2, 3, 4]
root = None
for val in input_list:
root = node(val, root)
cur = root
while cur:
print(cur.val)
cur = cur.next
print('Stack after pop: ')
root = root.next
cur = root
while cur:
... |
class ExportObjStatus:
SUCCESS = 'success'
ERROR = 'error'
IN_PROGRESS = 'in_progress'
CHOICES = [
(SUCCESS, 'Success'),
(ERROR, 'Error'),
(IN_PROGRESS, 'In progress'),
]
| class Exportobjstatus:
success = 'success'
error = 'error'
in_progress = 'in_progress'
choices = [(SUCCESS, 'Success'), (ERROR, 'Error'), (IN_PROGRESS, 'In progress')] |
def capitalize(string):
# We can't use title() here, consider the case: "123name" -> "123Name", which isn't correct.
for substring in string.split():
string = string.replace(substring, substring.capitalize())
return string | def capitalize(string):
for substring in string.split():
string = string.replace(substring, substring.capitalize())
return string |
# https://leetcode.com/problems/find-leaves-of-binary-tree/
class Solution:
def findLeaves(self, root: Optional[TreeNode]) -> List[List[int]]:
result = []
while root.left or root.right:
result.append(self.popLeaves(root, root, []))
result.append([root.val])
... | class Solution:
def find_leaves(self, root: Optional[TreeNode]) -> List[List[int]]:
result = []
while root.left or root.right:
result.append(self.popLeaves(root, root, []))
result.append([root.val])
return result
def pop_leaves(self, root: Optional[TreeNode], parent... |
class Monster:
def __init__(self, name, color):
self.name = name
self.color = color
def attack(self):
print('I am attacking...')
class Fogthing(Monster):
def attack(self):
print('I am killing...')
def make_sound(self):
print('Grrrrrrrrrr\n')
fogthing = Fogth... | class Monster:
def __init__(self, name, color):
self.name = name
self.color = color
def attack(self):
print('I am attacking...')
class Fogthing(Monster):
def attack(self):
print('I am killing...')
def make_sound(self):
print('Grrrrrrrrrr\n')
fogthing = fogthi... |
# https://codeforces.com/problemset/problem/1367/A
t = int(input())
for i in range(t):
s = input()
ss = [s[0]]
for i in range(0, len(s)-1, 2):
ss.append((s[i], s[i+1])[1])
print(''.join(ss)) | t = int(input())
for i in range(t):
s = input()
ss = [s[0]]
for i in range(0, len(s) - 1, 2):
ss.append((s[i], s[i + 1])[1])
print(''.join(ss)) |
# coding : utf-8
'''
Copyright 2019 Agnese Salutari.
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 wr... | """
Copyright 2019 Agnese Salutari.
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 di... |
ora_start=int(input("Ora="))
minut_start=int(input("Minute="))
durata_ore=int(input("Cate ore dureaza drumul="))
durata_minute=int(input("Cate minute dureaza drumul"))
ora_fin = ora_start+durata_ore
minute_fin = minut_start+durata_minute
if minute_fin>60:
minute_fin%=60
ora_fin+=1
print(ora_fin,minute_fin)
| ora_start = int(input('Ora='))
minut_start = int(input('Minute='))
durata_ore = int(input('Cate ore dureaza drumul='))
durata_minute = int(input('Cate minute dureaza drumul'))
ora_fin = ora_start + durata_ore
minute_fin = minut_start + durata_minute
if minute_fin > 60:
minute_fin %= 60
ora_fin += 1
print(ora_fi... |
def digitDifferenceSort(a):
def dg(n):
s = list(map(int, str(n)))
return max(s) - min(s)
ans = [(a[i], i) for i in range(len(a))]
A = sorted(ans, key = lambda x: (dg(x[0]), -x[1]))
return [c[0] for c in A]
| def digit_difference_sort(a):
def dg(n):
s = list(map(int, str(n)))
return max(s) - min(s)
ans = [(a[i], i) for i in range(len(a))]
a = sorted(ans, key=lambda x: (dg(x[0]), -x[1]))
return [c[0] for c in A] |
# Topology with a single loop
# A --- B --- C
# | |
# D --- E
topo = { 'A' : ['B', 'D'],
'B' : ['A', 'C', 'E'],
'C' : ['B'],
'D' : ['A', 'E'],
'E' : ['B', 'D'] }
| topo = {'A': ['B', 'D'], 'B': ['A', 'C', 'E'], 'C': ['B'], 'D': ['A', 'E'], 'E': ['B', 'D']} |
#
# PySNMP MIB module IB-SMA-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IB-SMA-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:39:05 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection) ... |
def phone_number(num):
string = [(str(x)) for x in num]
string = ''.join(string)
return f'({string[:3]}) {string[3:6]}-{string[6:]}'
print(phone_number([1,2,3,4,5,6,7,8,9,0]))
| def phone_number(num):
string = [str(x) for x in num]
string = ''.join(string)
return f'({string[:3]}) {string[3:6]}-{string[6:]}'
print(phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])) |
freeze_as_mpy('$(MPY_DIR)/tools', 'upip.py')
freeze_as_mpy('$(MPY_DIR)/tools', 'upip_utarfile.py', opt=3)
freeze('$(MPY_DIR)/lib/lv_bindings/driver/linux', 'evdev.py')
freeze('$(MPY_DIR)/lib/lv_bindings/lib', 'lv_colors.py')
freeze('$(MPY_DIR)/lib/lv_bindings/lib', 'async_utils.py')
freeze('$(MPY_DIR)/lib/lv_bindings/l... | freeze_as_mpy('$(MPY_DIR)/tools', 'upip.py')
freeze_as_mpy('$(MPY_DIR)/tools', 'upip_utarfile.py', opt=3)
freeze('$(MPY_DIR)/lib/lv_bindings/driver/linux', 'evdev.py')
freeze('$(MPY_DIR)/lib/lv_bindings/lib', 'lv_colors.py')
freeze('$(MPY_DIR)/lib/lv_bindings/lib', 'async_utils.py')
freeze('$(MPY_DIR)/lib/lv_bindings/l... |
NAME='fastrouter'
CFLAGS = []
LDFLAGS = []
LIBS = []
REQUIRES = ['corerouter']
GCC_LIST = ['fastrouter']
| name = 'fastrouter'
cflags = []
ldflags = []
libs = []
requires = ['corerouter']
gcc_list = ['fastrouter'] |
# implicit conversion
num_int=123
num_float=1.23
result=num_int+num_float
print('datatype of num_int is',type(num_int))
print('datatype of num_float is',type(num_float))
print('datatype of result is',type(result))
# it automatically converts int to float to avoid data loss | num_int = 123
num_float = 1.23
result = num_int + num_float
print('datatype of num_int is', type(num_int))
print('datatype of num_float is', type(num_float))
print('datatype of result is', type(result)) |
class Body(object):
def __init__(self, mass, position, velocity, name = None):
if (name != None):
self.name = name
self.mass = mass
self.position = position
self.velocity = velocity
| class Body(object):
def __init__(self, mass, position, velocity, name=None):
if name != None:
self.name = name
self.mass = mass
self.position = position
self.velocity = velocity |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.