content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
dp=[[0]*5 for i in range(101)]
dp[0][0]=1
dp[1][0]=1
dp[2][0]=1
dp[2][1]=1
dp[2][2]=1
dp[2][3]=1
dp[2][4]=1
for i in range(3,101):
dp[i][0]=sum(dp[i-1])
dp[i][4]=sum(dp[i-2])
j=i-2
while j>=0:
dp[i][1]+=sum(dp[j])
j-=2
j=i-2
while j>=0:
dp[i][2]+=sum(dp[j])
dp[i][3]+=sum(dp[j])
j-=1
for... | dp = [[0] * 5 for i in range(101)]
dp[0][0] = 1
dp[1][0] = 1
dp[2][0] = 1
dp[2][1] = 1
dp[2][2] = 1
dp[2][3] = 1
dp[2][4] = 1
for i in range(3, 101):
dp[i][0] = sum(dp[i - 1])
dp[i][4] = sum(dp[i - 2])
j = i - 2
while j >= 0:
dp[i][1] += sum(dp[j])
j -= 2
j = i - 2
while j >= 0:
... |
# leapyear
y=input("enter any year")
if y%4==0:
print("{} is:leap year".format(y))
else:
print("{} is not a leap year".format(y))
| y = input('enter any year')
if y % 4 == 0:
print('{} is:leap year'.format(y))
else:
print('{} is not a leap year'.format(y)) |
t = int(input())
for i in range(t):
n, m = list(map(int, input().split()))
if(n%m == 0):
print("YES")
else:
print("NO")
| t = int(input())
for i in range(t):
(n, m) = list(map(int, input().split()))
if n % m == 0:
print('YES')
else:
print('NO') |
a, b, c = (int(input()) for i in range(3))
if a <= b <= c:
print("True")
else:
print("False")
| (a, b, c) = (int(input()) for i in range(3))
if a <= b <= c:
print('True')
else:
print('False') |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( arr , n , x ) :
for i in range ( n ) :
if arr [ i ] > arr [ i + 1 ] :
break
l = ( i + 1... | def f_gold(arr, n, x):
for i in range(n):
if arr[i] > arr[i + 1]:
break
l = (i + 1) % n
r = i
cnt = 0
while l != r:
if arr[l] + arr[r] == x:
cnt += 1
if l == (r - 1 + n) % n:
return cnt
l = (l + 1) % n
r = (r... |
class Queue:
def __init__(self) -> None:
self._queue = []
def insert(self, val: int) -> None:
self._queue.append(val)
def pop(self) -> None:
self._queue.pop(0)
def __str__(self):
return "{}".format(self._queue)
def __len__(self):
... | class Queue:
def __init__(self) -> None:
self._queue = []
def insert(self, val: int) -> None:
self._queue.append(val)
def pop(self) -> None:
self._queue.pop(0)
def __str__(self):
return '{}'.format(self._queue)
def __len__(self):
return len(self._queue)
i... |
class PreRequisites:
def __init__(self, course_list=None):
self.course_list = course_list
| class Prerequisites:
def __init__(self, course_list=None):
self.course_list = course_list |
#!/usr/local/bin/python3
def soma_1(x, y):
return x + y
def soma_2(x, y, z):
return x + y + z
def soma(*numeros):
return sum(numeros)
if __name__ == '__main__':
print(soma_1(10, 10))
print(soma_2(10, 10, 10))
# packing
print(soma(10, 10, 10, 10))
# unpacking
list_nums = [10, ... | def soma_1(x, y):
return x + y
def soma_2(x, y, z):
return x + y + z
def soma(*numeros):
return sum(numeros)
if __name__ == '__main__':
print(soma_1(10, 10))
print(soma_2(10, 10, 10))
print(soma(10, 10, 10, 10))
list_nums = [10, 20]
print(soma_1(*list_nums))
tuple_nums = (10, 20)
... |
class CPU:
VECTOR_RESET = 0xFFFC # Reset Vector address.
def __init__(self, system):
self._system = system
self._debug_log = open("debug.log", "w")
def reset(self):
# Program Counter 16-bit, default to value located at the reset vector address.
self._pc = self._syste... | class Cpu:
vector_reset = 65532
def __init__(self, system):
self._system = system
self._debug_log = open('debug.log', 'w')
def reset(self):
self._pc = self._system.mmu.read_word(self.VECTOR_RESET)
self._sp = 253
self._a = 0
self._x = 0
self._y = 0
... |
def greet_customer(grocery_store, special_item):
print("Welcome to "+ grocery_store + ".")
print("Our special is " + special_item + ".")
print("Have fun shopping!")
greet_customer("Stu's Staples", "papayas")
def mult_x_add_y(number, x, y):
print("Total: ", number * x + y)
mult_x_add_y(5, 2, 3)
mult_x_add_y... | def greet_customer(grocery_store, special_item):
print('Welcome to ' + grocery_store + '.')
print('Our special is ' + special_item + '.')
print('Have fun shopping!')
greet_customer("Stu's Staples", 'papayas')
def mult_x_add_y(number, x, y):
print('Total: ', number * x + y)
mult_x_add_y(5, 2, 3)
mult_x_... |
class TransitionId(object):
ClearReadout=0
Reset =1
Configure =2
Unconfigure =3
BeginRun =4
EndRun =5
BeginStep =6
EndStep =7
Enable =8
Disable =9
SlowUpdate =10
Unused_11 =11
L1Accept =12
NumberOf =13
| class Transitionid(object):
clear_readout = 0
reset = 1
configure = 2
unconfigure = 3
begin_run = 4
end_run = 5
begin_step = 6
end_step = 7
enable = 8
disable = 9
slow_update = 10
unused_11 = 11
l1_accept = 12
number_of = 13 |
MIN_MATCH = 4
STRING = 0x0
BYTE_ARR = 0x01
NUMERIC_INT = 0x02
NUMERIC_FLOAT = 0x03
NUMERIC_LONG = 0x04
NUMERIC_DOUBLE = 0x05
SECOND = 1000
HOUR = 60 * 60 * SECOND
DAY = 24 * HOUR
SECOND_ENCODING = 0x40
HOUR_ENCODING = 0x80
DAY_ENCODING = 0xC0
BLOCK_SIZE = 128
INDEX_OPTION_NONE = 0
INDEX_OPTION_DOCS = 1
INDEX_OPTION_... | min_match = 4
string = 0
byte_arr = 1
numeric_int = 2
numeric_float = 3
numeric_long = 4
numeric_double = 5
second = 1000
hour = 60 * 60 * SECOND
day = 24 * HOUR
second_encoding = 64
hour_encoding = 128
day_encoding = 192
block_size = 128
index_option_none = 0
index_option_docs = 1
index_option_docs_freqs = 2
index_opt... |
#encoding:utf-8
subreddit = 'ProsePorn'
t_channel = '@r_proseporn'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| subreddit = 'ProsePorn'
t_channel = '@r_proseporn'
def send_post(submission, r2t):
return r2t.send_simple(submission) |
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2021 Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free... | layer = 123
objects = {85337187: 'pyrogram.raw.types.ResPQ', 2211011308: 'pyrogram.raw.types.PQInnerData', 2851430293: 'pyrogram.raw.types.PQInnerDataDc', 1013613780: 'pyrogram.raw.types.PQInnerDataTemp', 1459478408: 'pyrogram.raw.types.PQInnerDataTempDc', 1973679973: 'pyrogram.raw.types.BindAuthKeyInner', 2043348061: ... |
hour_exam = int(input())
min_exam = int(input())
hour_arrival = int(input())
min_arrival = int(input())
status = 0
exam_time = (hour_exam * 60) + min_exam
arrival_time = (hour_arrival * 60) + min_arrival
difference = arrival_time - exam_time
if difference > 0:
status = "Late"
elif difference < -30:
status =... | hour_exam = int(input())
min_exam = int(input())
hour_arrival = int(input())
min_arrival = int(input())
status = 0
exam_time = hour_exam * 60 + min_exam
arrival_time = hour_arrival * 60 + min_arrival
difference = arrival_time - exam_time
if difference > 0:
status = 'Late'
elif difference < -30:
status = 'Early'... |
def foo():
'''
>>> from mod import good as bad
'''
pass
| def foo():
"""
>>> from mod import good as bad
"""
pass |
#
# PySNMP MIB module CISCO-ETHERNET-FABRIC-EXTENDER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ETHERNET-FABRIC-EXTENDER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:57:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint) ... |
JAZZMIN_SETTINGS = {
# title of the window
'site_title': 'DIT Admin',
# Title on the brand, and the login screen (19 chars max)
'site_header': 'DIT',
# square logo to use for your site, must be present in static files, used for favicon and brand on top left
'site_logo': 'data_log_sheet/img/log... | jazzmin_settings = {'site_title': 'DIT Admin', 'site_header': 'DIT', 'site_logo': 'data_log_sheet/img/logo.png', 'welcome_sign': 'Welcome to DIT Data Log Sheet', 'copyright': 'antonnifo', 'search_model': 'data_log_sheet.DataLogSheet', 'user_avatar': None, 'topmenu_links': [{'name': 'Home', 'url': 'admin:index', 'permis... |
numbers = [4, 400, 5000]
print("Max Value Element: ", max(numbers))
animals = ["dogs", "crocodiles", "turtles"]
print(max(animals))
animals.append(["zebras"]) #adds the the list with one element "zebras" to the existing list as one object.
print(animals)
animals.extend("zebras") #iterates through the string one... | numbers = [4, 400, 5000]
print('Max Value Element: ', max(numbers))
animals = ['dogs', 'crocodiles', 'turtles']
print(max(animals))
animals.append(['zebras'])
print(animals)
animals.extend('zebras')
print(animals)
animals.append(['zebras, lions, tigers'])
print(animals)
animals.extend(['zebras, lions, tigers'])
print(a... |
def get_subarray_sum_1(s_array): #O(n**2)
'''
Return max subarray and max subarray sum
'''
#initialise variables
max_sum = 0
max_sub_array = []
#get all items in array and go through them
for item in range(len(s_array)):
#get all possible sub arrays while maintaining their max... | def get_subarray_sum_1(s_array):
"""
Return max subarray and max subarray sum
"""
max_sum = 0
max_sub_array = []
for item in range(len(s_array)):
index1 = item
index2 = item
while index2 < len(s_array):
index2 += 1
if sum(s_array[index1:index2 + 1]... |
#sort function
def Binary_Insertion_Sort(lst):
for i in range(1, len(lst)):
x = lst[i] # here x is a temporary variable
pos = BinarySearch(lst, x, 0, i) + 1
for j in range(i, pos, -1):
lst[j] = lst[j - 1]
lst[pos] = x
#binary search func... | def binary__insertion__sort(lst):
for i in range(1, len(lst)):
x = lst[i]
pos = binary_search(lst, x, 0, i) + 1
for j in range(i, pos, -1):
lst[j] = lst[j - 1]
lst[pos] = x
def binary_search(array, value, low, high):
if high - low <= 1:
if value < array[low]:... |
prog = ['H', 'Q', '9']
code = list(i for i in input())
run = False
for i in code:
if i in prog:
run = True
break
if run:
print('YES')
else:
print('NO') | prog = ['H', 'Q', '9']
code = list((i for i in input()))
run = False
for i in code:
if i in prog:
run = True
break
if run:
print('YES')
else:
print('NO') |
def th_selector(over_area, altitude):
if altitude <= 10:
th_x = over_area // 2 # 40
th_y = over_area // 4 # 20
return th_x, th_y
elif altitude <=20:
th_x = over_area // 8
th_y = over_area // 20
return th_x, th_y
else:
th_x = over_area // 20
th_... | def th_selector(over_area, altitude):
if altitude <= 10:
th_x = over_area // 2
th_y = over_area // 4
return (th_x, th_y)
elif altitude <= 20:
th_x = over_area // 8
th_y = over_area // 20
return (th_x, th_y)
else:
th_x = over_area // 20
th_y = o... |
MAX_SIZE = 2000001
isprime = [True] * MAX_SIZE
prime = []
SPF = [None] * (MAX_SIZE)
def sieve(N):
isprime[0] = isprime[1] = False
for i in range(2, N):
if isprime[i] == True:
prime.append(i)
SPF[i] = i
j = 0
while j < len(prime) and i * prime[j] < N and prime[j]... | max_size = 2000001
isprime = [True] * MAX_SIZE
prime = []
spf = [None] * MAX_SIZE
def sieve(N):
isprime[0] = isprime[1] = False
for i in range(2, N):
if isprime[i] == True:
prime.append(i)
SPF[i] = i
j = 0
while j < len(prime) and i * prime[j] < N and (prime[j] <... |
# # 01 solution
line_nums = input().split()
remove = int(input())
line_nums_list = [int(x) for x in line_nums]
for i in range(remove):
line_nums_list.remove(min(line_nums_list))
line_nums = ", ".join([str(x) for x in line_nums_list])
print(line_nums)
# # INPUT 1
# 10 9 8 7 6 5
# 3
# # INPUT 2
# 1 10 2 9 3 8
# 2
# #... | line_nums = input().split()
remove = int(input())
line_nums_list = [int(x) for x in line_nums]
for i in range(remove):
line_nums_list.remove(min(line_nums_list))
line_nums = ', '.join([str(x) for x in line_nums_list])
print(line_nums) |
'''
Routines for generating dynamic files.
'''
def file_with_dyn_area(
file_path, content,
first_guard='<!-- guard line: beginning -->',
second_guard='<!-- guard line: end -->'):
'''
The function reads a file, locates the guards, replaces the content.
'''
full_content = ''
g... | """
Routines for generating dynamic files.
"""
def file_with_dyn_area(file_path, content, first_guard='<!-- guard line: beginning -->', second_guard='<!-- guard line: end -->'):
"""
The function reads a file, locates the guards, replaces the content.
"""
full_content = ''
guard_count = 0
with o... |
# @arnaud drop this file?
# ----------------------------------------------------------------------
#
# Misc constants
#
UA_MAXOP = 6
# ----------------------------------------------------------------------
# instruc_t related constants
#
# instruc_t.feature
#
CF_STOP = 0x00001 # Instruction doesn't pass execution... | ua_maxop = 6
cf_stop = 1
cf_call = 2
cf_chg1 = 4
cf_chg2 = 8
cf_chg3 = 16
cf_chg4 = 32
cf_chg5 = 64
cf_chg6 = 128
cf_use1 = 256
cf_use2 = 512
cf_use3 = 1024
cf_use4 = 2048
cf_use5 = 4096
cf_use6 = 8192
cf_jump = 16384
cf_shft = 32768
cf_hll = 65536
o_void = 0
o_reg = 1
o_mem = 2
o_phrase = 3
o_displ = 4
o_imm = 5
o_far... |
n = int(input())
if n == 1:
print(101)
exit()
a = sum(map(int, input().split()))
ans = 0
for i in range(101):
if (a + i) % n == 0:
ans += 1
print(ans) | n = int(input())
if n == 1:
print(101)
exit()
a = sum(map(int, input().split()))
ans = 0
for i in range(101):
if (a + i) % n == 0:
ans += 1
print(ans) |
class QuerioFileError(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, args, kwargs)
| class Queriofileerror(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, args, kwargs) |
def countWords(file):
wordsCount = 0
with open(file, "r") as f:
for line in f:
words = line.split()
wordsCount += len(words)
print (wordsCount)
| def count_words(file):
words_count = 0
with open(file, 'r') as f:
for line in f:
words = line.split()
words_count += len(words)
print(wordsCount) |
class SqlInsertError(Exception):
def __init__(self, object, table: str) -> None:
self.object = object
self.table = table
super().__init__(f'Could not insert {object.__repr__()} in {table}.')
class SqlSelectError(Exception):
def __init__(self, table: str, function: str, data=None) -> No... | class Sqlinserterror(Exception):
def __init__(self, object, table: str) -> None:
self.object = object
self.table = table
super().__init__(f'Could not insert {object.__repr__()} in {table}.')
class Sqlselecterror(Exception):
def __init__(self, table: str, function: str, data=None) -> N... |
# -*- coding: utf-8 -*-
MONGO_CONFIG = {
'host': '47.93.9.48',
'port': 27017,
'user': 'root',
'pwd': 'Yunxi20191231'
}
chrome_driver_path = '/usr/local/bin/chromedriver'
sogou_wechat_url = 'https://weixin.sogou.com' | mongo_config = {'host': '47.93.9.48', 'port': 27017, 'user': 'root', 'pwd': 'Yunxi20191231'}
chrome_driver_path = '/usr/local/bin/chromedriver'
sogou_wechat_url = 'https://weixin.sogou.com' |
# coding: utf-8
# Distributed under the terms of the MIT License.
class AppModel(object):
def __init__(self):
pass
def __run__(self):
pass
| class Appmodel(object):
def __init__(self):
pass
def __run__(self):
pass |
def find_first_invalid(numbers):
for k in range(25, len(numbers)):
if not any(
numbers[i] + numbers[j] == numbers[k]
for i in range(k - 25, k)
for j in range(i + 1, k)
):
return numbers[k]
with open("input.txt", 'r', encoding="utf-8") as file:
in... | def find_first_invalid(numbers):
for k in range(25, len(numbers)):
if not any((numbers[i] + numbers[j] == numbers[k] for i in range(k - 25, k) for j in range(i + 1, k))):
return numbers[k]
with open('input.txt', 'r', encoding='utf-8') as file:
inp = list(map(int, file))
print(find_first_inva... |
class Solution:
def addStrings(self, num1: str, num2: str) -> str:
res = ''
add_on = 0
i, j = len(num1) - 1, len(num2) - 1
while i != -1 or j != -1:
if i != -1 and j != -1:
digit_sum = int(num1[i]) + int(num2[j]) + add_on
i -= 1
... | class Solution:
def add_strings(self, num1: str, num2: str) -> str:
res = ''
add_on = 0
(i, j) = (len(num1) - 1, len(num2) - 1)
while i != -1 or j != -1:
if i != -1 and j != -1:
digit_sum = int(num1[i]) + int(num2[j]) + add_on
i -= 1
... |
class Matrix(object):
def __init__(self, matrix_string):
self.matrix = []
rows = matrix_string.splitlines()
for row in rows:
self.matrix.append([int(num) for num in row.split()])
def row(self, index):
return self.matrix[index - 1]
def column(self, index):
... | class Matrix(object):
def __init__(self, matrix_string):
self.matrix = []
rows = matrix_string.splitlines()
for row in rows:
self.matrix.append([int(num) for num in row.split()])
def row(self, index):
return self.matrix[index - 1]
def column(self, index):
... |
def mesclaListas(lista1, lista2):
lista1.sort()
lista2.sort()
listaMesclada = []
i = 0
for i in lista2:
if lista1[0] < i:
listaMesclada.append(lista1.pop(0))
for i in lista1:
if lista2[0] < i:
listaMesclada.append(lista2.pop(0))
print(lista1, lista2)... | def mescla_listas(lista1, lista2):
lista1.sort()
lista2.sort()
lista_mesclada = []
i = 0
for i in lista2:
if lista1[0] < i:
listaMesclada.append(lista1.pop(0))
for i in lista1:
if lista2[0] < i:
listaMesclada.append(lista2.pop(0))
print(lista1, lista2)... |
def multBy3(x):
return x*3
def add5(y):
return y+5
def applyfunc(f, g, p):
return f(p), g(p)
print(applyfunc(multBy3, add5, 3))
def returnArgsAsList(das, *lis):
print(lis)
print(das)
returnArgsAsList(2, 1,2,3,5,6,'byn') | def mult_by3(x):
return x * 3
def add5(y):
return y + 5
def applyfunc(f, g, p):
return (f(p), g(p))
print(applyfunc(multBy3, add5, 3))
def return_args_as_list(das, *lis):
print(lis)
print(das)
return_args_as_list(2, 1, 2, 3, 5, 6, 'byn') |
class Field:
def __init__(self, name, encoder, decoder):
assert name and isinstance(name, str)
assert encoder and callable(encoder)
assert decoder and callable(decoder)
self.name = name
self.encoder = encoder
self.decoder = decoder
| class Field:
def __init__(self, name, encoder, decoder):
assert name and isinstance(name, str)
assert encoder and callable(encoder)
assert decoder and callable(decoder)
self.name = name
self.encoder = encoder
self.decoder = decoder |
def valid(triangle):
big = max(triangle)
return big < sum(triangle) - big
def part1(triangles):
return sum(map(valid, triangles))
def group(n, it):
return zip(*[iter(it)]*n)
def transpose(it):
return zip(*it)
def part2(triangles):
triangles = group(3, triangles)
triangles = (t for gr... | def valid(triangle):
big = max(triangle)
return big < sum(triangle) - big
def part1(triangles):
return sum(map(valid, triangles))
def group(n, it):
return zip(*[iter(it)] * n)
def transpose(it):
return zip(*it)
def part2(triangles):
triangles = group(3, triangles)
triangles = (t for grou... |
#
# This one does a little more then required and handles all types of brackets
#
def balancedParens(s):
stack, opens, closes = [], ['(', '[', '{'], [')', ']', '}']
for c in s:
if c in opens:
stack.append(c)
elif c in closes:
try:
if opens.index(stack.pop()) != closes.index(c):
... | def balanced_parens(s):
(stack, opens, closes) = ([], ['(', '[', '{'], [')', ']', '}'])
for c in s:
if c in opens:
stack.append(c)
elif c in closes:
try:
if opens.index(stack.pop()) != closes.index(c):
return False
except (V... |
def f():
print('hello')
print('calling f')
f()
| def f():
print('hello')
print('calling f')
f() |
n, y = map(int, input().split())
y /= 1000
res10, res5, res1 = -1, -1, -1
for a in range(n + 1):
if res1 != -1:
break
for b in range(n - a + 1):
c = n - a - b
total = 10000 * a + 5000 * b + 1000 * c
if total == y:
res10, res5, res1 = a, b, c
if res1... | (n, y) = map(int, input().split())
y /= 1000
(res10, res5, res1) = (-1, -1, -1)
for a in range(n + 1):
if res1 != -1:
break
for b in range(n - a + 1):
c = n - a - b
total = 10000 * a + 5000 * b + 1000 * c
if total == y:
(res10, res5, res1) = (a, b, c)
if res1 ... |
class Finder:
_finders = {}
@classmethod
def register(cls, finder_class):
cls._finders[finder_class.name] = finder_class
@classmethod
def factory(cls, finder_name, deployment, **args):
for name, finder in cls._finders.items():
if name == finder_name:
re... | class Finder:
_finders = {}
@classmethod
def register(cls, finder_class):
cls._finders[finder_class.name] = finder_class
@classmethod
def factory(cls, finder_name, deployment, **args):
for (name, finder) in cls._finders.items():
if name == finder_name:
r... |
message = 'Hello World!'
message2 = 'Hello World! \n'
number = 32/35
display = message + repr(number)
display2 = message + str(number)
display3 = message2 + repr(number)
print(display)
print(display2)
print(display3)
print(repr(display3))
| message = 'Hello World!'
message2 = 'Hello World! \n'
number = 32 / 35
display = message + repr(number)
display2 = message + str(number)
display3 = message2 + repr(number)
print(display)
print(display2)
print(display3)
print(repr(display3)) |
class Agent(object):
def __init__(self):
pass
def act(self, obs):
pass
def train(self, replay_buffer, logger, step):
pass
| class Agent(object):
def __init__(self):
pass
def act(self, obs):
pass
def train(self, replay_buffer, logger, step):
pass |
print('Welcome to tip calculator')
bill = float(input('Enter Your total bill : $'))
per_tip = int(input("Enter percentage of tip would you like to give (10,12 or 15): "))
num = int(input("No.of friends that would split the bill : "))
final_bill = round((bill + bill*0.01*per_tip)/num,2)
print(f"Each person should pay ... | print('Welcome to tip calculator')
bill = float(input('Enter Your total bill : $'))
per_tip = int(input('Enter percentage of tip would you like to give (10,12 or 15): '))
num = int(input('No.of friends that would split the bill : '))
final_bill = round((bill + bill * 0.01 * per_tip) / num, 2)
print(f'Each person shoul... |
class RequiredFieldsError(Exception):
def __init__(self, message, is_get=True, abnormal=False, title=None,
error_fields=None):
super(RequiredFieldsError, self).__init__()
self.message = message
self.is_get = is_get
self.abnormal = abnormal
self.title = title... | class Requiredfieldserror(Exception):
def __init__(self, message, is_get=True, abnormal=False, title=None, error_fields=None):
super(RequiredFieldsError, self).__init__()
self.message = message
self.is_get = is_get
self.abnormal = abnormal
self.title = title
self.err... |
_perms_self_read_only = [
{
"principal": "SELF",
"action": "READ_ONLY"
}
]
_perms_self_read_write = [
{
"principal": "SELF",
"action": "READ_WRITE"
}
]
_perms_self_hide = [
{
"principal": "SELF",
"action": "HIDE"
}
]
# a dump of an okta... | _perms_self_read_only = [{'principal': 'SELF', 'action': 'READ_ONLY'}]
_perms_self_read_write = [{'principal': 'SELF', 'action': 'READ_WRITE'}]
_perms_self_hide = [{'principal': 'SELF', 'action': 'HIDE'}]
okta_user_schema = {'id': 'https://paracelsus.okta.com/meta/schemas/user/default', '$schema': 'http://json-schema.o... |
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
for _ in range(m):
op, x = map(int, input().split())
if op == 2:
l = 2**(x - 1)
r = min(n + 1, 2**x)
print(' '.join(map(str, a[l:r])))
elif op == 1:
t = []
t.append(a[x]... | (n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
for _ in range(m):
(op, x) = map(int, input().split())
if op == 2:
l = 2 ** (x - 1)
r = min(n + 1, 2 ** x)
print(' '.join(map(str, a[l:r])))
elif op == 1:
t = []
t.append(a[x])
... |
class BaseException(Exception):
default_message = None
def __init__(self, *args, **kwargs):
if not (args or kwargs):
args = (self.default_message,)
super().__init__(*args, **kwargs)
class NotEnoughBallotClaimTickets(BaseException):
default_message = 'You do not have enough cl... | class Baseexception(Exception):
default_message = None
def __init__(self, *args, **kwargs):
if not (args or kwargs):
args = (self.default_message,)
super().__init__(*args, **kwargs)
class Notenoughballotclaimtickets(BaseException):
default_message = 'You do not have enough clai... |
class APIException(Exception):
pass
class ADBException(Exception):
pass
| class Apiexception(Exception):
pass
class Adbexception(Exception):
pass |
MAJOR = 0
MINOR = 1
PATCH = 6
__version__ = '%d.%d.%d' % (MAJOR, MINOR, PATCH)
| major = 0
minor = 1
patch = 6
__version__ = '%d.%d.%d' % (MAJOR, MINOR, PATCH) |
#
# PySNMP MIB module TRAPEZE-NETWORKS-AP-IF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TRAPEZE-NETWORKS-AP-IF-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:19:44 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint) ... |
def convex_hull_from_points(raw_v):
hull = ConvexHull(raw_v)
hull_eq = hull.equations
# H representation
v = raw_v[hull.vertices,:]
num_vertices = len(v)
g = np.hstack((np.ones((num_vertices,1)), v)) # zeros for vertex
mat = cdd.Matrix(g, number_type='fraction')
mat.rep_type = cdd.Re... | def convex_hull_from_points(raw_v):
hull = convex_hull(raw_v)
hull_eq = hull.equations
v = raw_v[hull.vertices, :]
num_vertices = len(v)
g = np.hstack((np.ones((num_vertices, 1)), v))
mat = cdd.Matrix(g, number_type='fraction')
mat.rep_type = cdd.RepType.GENERATOR
poly = cdd.Polyhedron(m... |
def valid_word(seq, word):
check=set(seq)
def helper(count, index):
if index>=len(word):
return True if count>=1 else False
return any(helper(count+1, i) for i in range(index+1, len(word)+1) if word[index:i] in seq)
return helper(0, 0) | def valid_word(seq, word):
check = set(seq)
def helper(count, index):
if index >= len(word):
return True if count >= 1 else False
return any((helper(count + 1, i) for i in range(index + 1, len(word) + 1) if word[index:i] in seq))
return helper(0, 0) |
class AbstractToken:
name = 'token'
def __init__(self, lexemes, form):
self.lexemes = lexemes
self.form = form
self.source = self.get_source(lexemes)
self.string = lexemes[0].string
self.string_index = lexemes[0].string_index
self.string_begin_index = lexemes... | class Abstracttoken:
name = 'token'
def __init__(self, lexemes, form):
self.lexemes = lexemes
self.form = form
self.source = self.get_source(lexemes)
self.string = lexemes[0].string
self.string_index = lexemes[0].string_index
self.string_begin_index = lexemes[0].... |
numbers = input().split()
for x in range(len(numbers)):
numbers[x] = int(numbers[x])
for a in range(0, len(numbers)-2):
for b in range(a+1, len(numbers)-1):
for c in range(b+1, len(numbers)):
A = numbers[a]
B = numbers[b]
C = numbers[c]
if... | numbers = input().split()
for x in range(len(numbers)):
numbers[x] = int(numbers[x])
for a in range(0, len(numbers) - 2):
for b in range(a + 1, len(numbers) - 1):
for c in range(b + 1, len(numbers)):
a = numbers[a]
b = numbers[b]
c = numbers[c]
if A + B in... |
def calculate_triangles(max_p: int) -> int:
max_value = -1
max_p_val = -1
for p in range(12, max_p + 1, 2):
current_value = sum((p*p - 2*a*p) % (2*p - 2*a) == 0
for a in range(2, p // 3))
if current_value > max_value:
max_value = current_value
... | def calculate_triangles(max_p: int) -> int:
max_value = -1
max_p_val = -1
for p in range(12, max_p + 1, 2):
current_value = sum(((p * p - 2 * a * p) % (2 * p - 2 * a) == 0 for a in range(2, p // 3)))
if current_value > max_value:
max_value = current_value
max_p_val = ... |
def partition(li, start, end):
pivot = li[start]
left = start + 1
right = end
done = False
while not done:
while left <= right and li[left] <= pivot:
left += 1
while right >= left and li[right] >= pivot:
right -= 1
if right < left:
done = ... | def partition(li, start, end):
pivot = li[start]
left = start + 1
right = end
done = False
while not done:
while left <= right and li[left] <= pivot:
left += 1
while right >= left and li[right] >= pivot:
right -= 1
if right < left:
done = T... |
number = int(input())
previous = 1
current = 1
for i in range(number - 2):
next = previous + current
previous = current
current = next
print(current) | number = int(input())
previous = 1
current = 1
for i in range(number - 2):
next = previous + current
previous = current
current = next
print(current) |
class Node(object):
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def _isValidBSTHelper(self, n, low, high):
if not n:
return True
val = n.val
if ((val > low and val < high)... | class Node(object):
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def _is_valid_bst_helper(self, n, low, high):
if not n:
return True
val = n.val
if (val > low and val < hi... |
#For these problems, DON'T COMMENT OUT FUNCTION DEFINITIONS! You will need to use them.
#######################################################################################
# 13.1
# Make a function which prints out a random string. Then call it.
###################################################################... | def print2():
x = 20
y = 5
print(x + y)
print2()
print(x)
x = 10
def print3():
x = 7
y = 5
print(x, y)
print3()
print(x) |
DEFAULT_KAFKA_PORT = 9092
#: Compression flag value denoting ``gzip`` was used
GZIP = 1
#: Compression flag value denoting ``snappy`` was used
SNAPPY = 2
#: This set denotes the compression schemes currently supported by Kiel
SUPPORTED_COMPRESSION = (None, GZIP, SNAPPY)
CLIENT_ID = "kiel"
#: The "api version" value ... | default_kafka_port = 9092
gzip = 1
snappy = 2
supported_compression = (None, GZIP, SNAPPY)
client_id = 'kiel'
api_version = 0
api_keys = {'produce': 0, 'fetch': 1, 'offset': 2, 'metadata': 3, 'offset_commit': 8, 'offset_fetch': 9, 'group_coordinator': 10, 'join_group': 11, 'heartbeat': 12, 'leave_group': 13, 'sync_grou... |
css = [
'about.css',
'button.css',
'frame.css',
'faq.css',
'index.css',
'map.css',
'ramanujan.css',
'rocket.css',
'shelf.css',
'snackbar.css',
'timeline.css',
'typewriter.css',
'mobile.css',
'info.css'
]
concat = ''
for i in css:
with open(f'css/{i}') as f:
... | css = ['about.css', 'button.css', 'frame.css', 'faq.css', 'index.css', 'map.css', 'ramanujan.css', 'rocket.css', 'shelf.css', 'snackbar.css', 'timeline.css', 'typewriter.css', 'mobile.css', 'info.css']
concat = ''
for i in css:
with open(f'css/{i}') as f:
concat += f.read()
concat += '\n\n'
f = open... |
CONTROLLERS = {}
def controller(code):
def register_controller(func):
CONTROLLERS[code] = func
return func
return register_controller
def get_controller_func(controller):
if controller in CONTROLLERS:
return CONTROLLERS[controller]
raise ValueError('Invalid request')
| controllers = {}
def controller(code):
def register_controller(func):
CONTROLLERS[code] = func
return func
return register_controller
def get_controller_func(controller):
if controller in CONTROLLERS:
return CONTROLLERS[controller]
raise value_error('Invalid request') |
course = ' Python for Beginners '
print(len(course)) # Genereal perpous function
print(course.upper())
print(course)
print(course.lower())
print(course.title())
print(course.lstrip())
print(course.rstrip())
# Returns the index of the first occurrence of the character.
print(course.find('P'))
print(course.find('B'... | course = ' Python for Beginners '
print(len(course))
print(course.upper())
print(course)
print(course.lower())
print(course.title())
print(course.lstrip())
print(course.rstrip())
print(course.find('P'))
print(course.find('B'))
print(course.find('o'))
print(course.find('O'))
print(course.find('Beginners'))
print(cou... |
print("Hello World!")
x = "Hello World"
print(x)
y = 42
print(y) | print('Hello World!')
x = 'Hello World'
print(x)
y = 42
print(y) |
class DefineRegion(object):
def __init__(self):
self.x = self.y = 10.0
self.depth = 1.0
self.subvolume_edge = 1.0
self.cytosol_depth = 10.0
self.num_chambers = (self.x / self.subvolume_edge) * (self.y / self.subvolume_edge) * (
self.depth / self.subvolume_... | class Defineregion(object):
def __init__(self):
self.x = self.y = 10.0
self.depth = 1.0
self.subvolume_edge = 1.0
self.cytosol_depth = 10.0
self.num_chambers = self.x / self.subvolume_edge * (self.y / self.subvolume_edge) * (self.depth / self.subvolume_edge)
self.num... |
#!/usr/bin/env python3
'''module that deals with functions'''
def commandpush(devicecmd): #devicecmd=list
''' push commands to devices '''
for coffeetime in devicecmd.keys():
print("Handshaking......connecting with " + coffeetime)
for mycmds in devicecmd[coffeetime]:
print("Attempti... | """module that deals with functions"""
def commandpush(devicecmd):
""" push commands to devices """
for coffeetime in devicecmd.keys():
print('Handshaking......connecting with ' + coffeetime)
for mycmds in devicecmd[coffeetime]:
print('Attempting to sending command --> ' + mycmds)
... |
for v in range(0, 3):
print(v)
for i, v in enumerate(range(10, 13)):
print(i, v)
for key, value in {'A': 0, 'B': 1}.items():
print(key, value)
| for v in range(0, 3):
print(v)
for (i, v) in enumerate(range(10, 13)):
print(i, v)
for (key, value) in {'A': 0, 'B': 1}.items():
print(key, value) |
n=22351
l=[]
s=str(n)
for ch in s:
l= l + [int(ch)]
highest=sorted (l,reverse=True)
s=""
for ch in highest:
s=s+ str(ch)
highest=int(s)
n=9
for i in range(n +1,highest+1):
print(i)
| n = 22351
l = []
s = str(n)
for ch in s:
l = l + [int(ch)]
highest = sorted(l, reverse=True)
s = ''
for ch in highest:
s = s + str(ch)
highest = int(s)
n = 9
for i in range(n + 1, highest + 1):
print(i) |
class Solution(object):
def intersection(self, nums1, nums2):
if len(nums1) > len(nums2):
return self.intersection(nums2, nums1)
lookup = set()
for i in nums1:
lookup.add(i)
res = []
for i in nums2:
if i in lookup:
res += ... | class Solution(object):
def intersection(self, nums1, nums2):
if len(nums1) > len(nums2):
return self.intersection(nums2, nums1)
lookup = set()
for i in nums1:
lookup.add(i)
res = []
for i in nums2:
if i in lookup:
res += (... |
def add(a, b):
return a + b
def multiply(a, b):
return a * b
assert add(10, 10) == 100, "confused addition"
assert multiply(10, 10) == 20, "confused multiplication"
| def add(a, b):
return a + b
def multiply(a, b):
return a * b
assert add(10, 10) == 100, 'confused addition'
assert multiply(10, 10) == 20, 'confused multiplication' |
def linear_search(a, key):
length = len(a)
idx = 0
while idx < length:
if a[idx] == key:
return idx
idx += 1
return -1
a = [1, 3, 5, 10, 13]
key = 5
print(linear_search(a, key))
| def linear_search(a, key):
length = len(a)
idx = 0
while idx < length:
if a[idx] == key:
return idx
idx += 1
return -1
a = [1, 3, 5, 10, 13]
key = 5
print(linear_search(a, key)) |
class Bar():
pass
def t1():
raise Bar()
def t2():
return Bar()
| class Bar:
pass
def t1():
raise bar()
def t2():
return bar() |
f = open("pb2.txt")
n = int(f.readline())
P = []
for i in range(n):
x, y = f.readline().split()
P.append((float(x), float(y))) # citirea punctelor poligonului
print("n=", n, " P=", P)
# pentru x-monotonie, de exemplu, vreau sa iau cel mai din stanga punct si sa parcurg punctele pentru ca sunt... | f = open('pb2.txt')
n = int(f.readline())
p = []
for i in range(n):
(x, y) = f.readline().split()
P.append((float(x), float(y)))
print('n=', n, ' P=', P)
minim = P[0][0]
indexmin = -1
for i in range(len(P)):
if P[i][0] < minim:
minim = P[i][0]
indexmin = i
(monotonie, elem_precedent, ok... |
def histogram(s):
'''
Maps values of sequence to its frequency / occurrence.
s: sequence
'''
d = {}
for c in s:
d[c] = d.get(c, 0) + 1
return d
def invert_dict(d):
'''
Inverts a dictionary(d).
Returns dictionary with values of d as keys and keys of d ... | def histogram(s):
"""
Maps values of sequence to its frequency / occurrence.
s: sequence
"""
d = {}
for c in s:
d[c] = d.get(c, 0) + 1
return d
def invert_dict(d):
"""
Inverts a dictionary(d).
Returns dictionary with values of d as keys and keys of d as values.... |
#
# PySNMP MIB module OMNI-gx2EDFA-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OMNI-gx2EDFA-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:24:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, value_size_constraint, constraints_union) ... |
class CQueue:
def __init__(self):
self.q = []
def appendTail(self, value: int) -> None:
self.q.append(value)
def deleteHead(self) -> int:
return self.q.pop(0) if self.q else -1
# Your CQueue object will be instantiated and called as such:
# obj = CQueue()
# obj.appendTail(value)... | class Cqueue:
def __init__(self):
self.q = []
def append_tail(self, value: int) -> None:
self.q.append(value)
def delete_head(self) -> int:
return self.q.pop(0) if self.q else -1 |
# -*- coding: utf-8 -*-
__author__ = "venkat"
__author_email__ = "venkatram0273@gmail.com"
def block_indentation():
if 10 > 10:
print("if statement indented")
elif 10 > 5:
print("elif statement indented")
else:
print("else default statement indented")
for i in range(10):
... | __author__ = 'venkat'
__author_email__ = 'venkatram0273@gmail.com'
def block_indentation():
if 10 > 10:
print('if statement indented')
elif 10 > 5:
print('elif statement indented')
else:
print('else default statement indented')
for i in range(10):
print(i)
print(... |
# read numbers
numbers = []
with open("nums.txt", "r") as f:
lines = f.readlines()
numbers = [int(i) for i in lines]
print(numbers)
# part 1 soln
for x,el in enumerate(numbers):
for i in range(x+1, len(numbers)):
if el + numbers[i] == 2020:
print("YAY: {} {}".format(el, num... | numbers = []
with open('nums.txt', 'r') as f:
lines = f.readlines()
numbers = [int(i) for i in lines]
print(numbers)
for (x, el) in enumerate(numbers):
for i in range(x + 1, len(numbers)):
if el + numbers[i] == 2020:
print('YAY: {} {}'.format(el, numbers[i]))
for (x, el) in enumerate(num... |
# -*- coding: UTF-8 -*-
def read_file(filepath):
with open(filepath,'rb') as file:
# yield (file.readlines())
for i in file:
yield i
a = read_file(r'D:\pythontest/test\python_100/2/base.txt')
print(next(a))
| def read_file(filepath):
with open(filepath, 'rb') as file:
for i in file:
yield i
a = read_file('D:\\pythontest/test\\python_100/2/base.txt')
print(next(a)) |
class Solution:
def destCity(self, paths: List[List[str]]) -> str:
start = (list(map(lambda x: x[0], paths)))
for path in paths:
if path[1] not in start: return path[1]
# dic = {}
# for i in range(len(paths)):
# dic[paths[i][0]] = paths[i][1]... | class Solution:
def dest_city(self, paths: List[List[str]]) -> str:
start = list(map(lambda x: x[0], paths))
for path in paths:
if path[1] not in start:
return path[1] |
class Solution:
def rotatedDigits(self, n: int) -> int:
goodnums = set([2,5,6,9])
badnums = set([3,4,7])
ans = 0
for i in range(1,n+1):
good = False
num = i
while num:
remains = num % 10
if remains in good... | class Solution:
def rotated_digits(self, n: int) -> int:
goodnums = set([2, 5, 6, 9])
badnums = set([3, 4, 7])
ans = 0
for i in range(1, n + 1):
good = False
num = i
while num:
remains = num % 10
if remains in goodn... |
def d(n):
return n + sum(list(map(int, list(str(n)))))
nums = [x for x in range(1, 10001)]
for i in range(1, 10001):
if d(i) in nums:
nums.remove(d(i))
for num in nums:
print(num) | def d(n):
return n + sum(list(map(int, list(str(n)))))
nums = [x for x in range(1, 10001)]
for i in range(1, 10001):
if d(i) in nums:
nums.remove(d(i))
for num in nums:
print(num) |
class Node:
def __init__(self, data) -> None:
self.data = data
self.next = None
self.traversed = False
class LinkedList:
def __init__(self) -> None:
self.head = self.rear = None
def check_loop(node):
temp = node.head
if temp == None:
print("Empty!!")
... | class Node:
def __init__(self, data) -> None:
self.data = data
self.next = None
self.traversed = False
class Linkedlist:
def __init__(self) -> None:
self.head = self.rear = None
def check_loop(node):
temp = node.head
if temp == None:
print('Empty!!')
r... |
def is_horiz_or_vert(line):
return line[0]["x"] == line[1]["x"] or line[0]["y"] == line[1]["y"]
def parse(input_line):
return [
{"x": int(x), "y": int(y)}
for x, y in [s.strip().split(",") for s in input_line.split("->")]
]
def do_it(input_lines, diagonals=False):
lines = [
l... | def is_horiz_or_vert(line):
return line[0]['x'] == line[1]['x'] or line[0]['y'] == line[1]['y']
def parse(input_line):
return [{'x': int(x), 'y': int(y)} for (x, y) in [s.strip().split(',') for s in input_line.split('->')]]
def do_it(input_lines, diagonals=False):
lines = [line for line in [parse(input_li... |
windowWight=650
windowHeight=650
ellipseSize=200
def setup():
size(windowWight,windowHeight)
smooth()
background(255)
fill(50,80)
stroke(100)
strokeWeight(3)
noLoop()
def draw():
ellipse(windowWight/2, windowHeight/2 - ellipseSize/2, ellipseSize, ellipseSize)
ellipse(wi... | window_wight = 650
window_height = 650
ellipse_size = 200
def setup():
size(windowWight, windowHeight)
smooth()
background(255)
fill(50, 80)
stroke(100)
stroke_weight(3)
no_loop()
def draw():
ellipse(windowWight / 2, windowHeight / 2 - ellipseSize / 2, ellipseSize, ellipseSize)
ell... |
# list(map(int, input().split()))
# int(input())
def main(N, A):
ans = 0
for n in range(1, N+1, 2):
if A[n-1] % 2 == 1:
ans += 1
print(ans)
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
main(N, A)
| def main(N, A):
ans = 0
for n in range(1, N + 1, 2):
if A[n - 1] % 2 == 1:
ans += 1
print(ans)
if __name__ == '__main__':
n = int(input())
a = list(map(int, input().split()))
main(N, A) |
budget = 150.0
pi_string = '03.14159260'
age_string = '21'
# convert string to number
pi_float = float(pi_string)
age_int = int(age_string)
# convert and print to string
print('The budget is: $' + str(budget))
print('pi_string: ' + pi_string)
print('pi_float: ' + str(pi_float))
print('age_int: ' + str(age_int)) | budget = 150.0
pi_string = '03.14159260'
age_string = '21'
pi_float = float(pi_string)
age_int = int(age_string)
print('The budget is: $' + str(budget))
print('pi_string: ' + pi_string)
print('pi_float: ' + str(pi_float))
print('age_int: ' + str(age_int)) |
ficha=list()
while True:
nome=str(input('Nome: '))
nota1=float(input('Nota 1: '))
nota2=float(input('Nota 2: '))
media= (nota1+nota2)/2
ficha.append([nome, [nota1,nota2],media])
resp=str(input('Quer continuar? [S/N]: ')).strip().upper()
if resp in 'N':
break
print('-='*30)
| ficha = list()
while True:
nome = str(input('Nome: '))
nota1 = float(input('Nota 1: '))
nota2 = float(input('Nota 2: '))
media = (nota1 + nota2) / 2
ficha.append([nome, [nota1, nota2], media])
resp = str(input('Quer continuar? [S/N]: ')).strip().upper()
if resp in 'N':
break
print('-... |
#exercice 1
#calories calculator. create 2 functions main, calories.
#It should calculate the amount of calories from
#the grams of carbs, fat and protein.
#calories from fat = fat gram x 9
#calories from carbs = carbs gram x 4
#calories from protein = protein gram x 4
#example:
#if item has 1 gram of fat, 2 grams o... | def main():
fat = int(input('Please enter a number of grams of fat:\n'))
carbs = int(input('Please enter a number of grams of carbs:\n'))
protein = int(input('Please enter a number of grams of protein:\n'))
calories(fat, carbs, protein)
def calories(fat, carbs, protein):
total = fat * 9 + carbs * 4... |
# 7-3. Multiples of Ten: Ask the user for a number, and then report whether the number is a multiple of 10 or not.
number = input("Tell me a number man :v : ")
number = int(number)
if number % 10 == 0:
print(str(number) + " is a multiple of 10.")
else:
print(str(number) + " is not a multiple of 10.") | number = input('Tell me a number man :v : ')
number = int(number)
if number % 10 == 0:
print(str(number) + ' is a multiple of 10.')
else:
print(str(number) + ' is not a multiple of 10.') |
# pylint: skip-file
# pylint: disable=too-many-instance-attributes
class GcloudConfig(GcloudCLI):
''' Class to wrap the gcloud config command'''
# pylint allows 5
# pylint: disable=too-many-arguments
def __init__(self,
project=None,
region=None):
''' Construct... | class Gcloudconfig(GcloudCLI):
""" Class to wrap the gcloud config command"""
def __init__(self, project=None, region=None):
""" Constructor for gcloud resource """
super(GcloudConfig, self).__init__()
self._working_param = {}
if project:
self._working_param['name'] ... |
class TouchData:
x_distance = None
y_distance = None
x_offset = None
y_offset = None
relative_distance = None
is_external = None
in_range = None
def __init__(self, joystick, touch):
self.joystick = joystick
self.touch = touch
self._calculate()
def _calculate... | class Touchdata:
x_distance = None
y_distance = None
x_offset = None
y_offset = None
relative_distance = None
is_external = None
in_range = None
def __init__(self, joystick, touch):
self.joystick = joystick
self.touch = touch
self._calculate()
def _calculate... |
def testing_system(right_answer, Iras_answer):
if right_answer == Iras_answer:
print("YES")
else:
print("NO")
testing_system(int(input()), int(input())) | def testing_system(right_answer, Iras_answer):
if right_answer == Iras_answer:
print('YES')
else:
print('NO')
testing_system(int(input()), int(input())) |
#!/usr/bin/env python3
'''
lib/subl
sublime-ycmd sublime utility module.
'''
| """
lib/subl
sublime-ycmd sublime utility module.
""" |
class StyleGenerator:
def __init__(self):
self.sidebar_style = {}
self.content_style = {}
def getSidebarStyle(self):
return self.sidebar_style
def getContentStyle(self):
return self.content_style
def setSidebarStyle(self, position="fixed", top=0, left=0, bottom=0, width="0rem", padding="0rem 0rem", back... | class Stylegenerator:
def __init__(self):
self.sidebar_style = {}
self.content_style = {}
def get_sidebar_style(self):
return self.sidebar_style
def get_content_style(self):
return self.content_style
def set_sidebar_style(self, position='fixed', top=0, left=0, bottom=... |
# implementation of linked list using python 3
# Node class
class Node:
#function to initialize the node object
def __init__(self, data):
self.data = data #assign data
self.next = None #initialize next as null
#Linked list class
class LinkedList:
#function to initialize the linked
#... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def printing_list(self):
temp = self.head
while temp:
print(temp.data)
temp = temp.next
if __name__ == '__main__'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.