content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# EG8-13 Average Sales
# test sales data
sales=[50,54,29,33,22,100,45,54,89,75]
def average_sales():
'''
Print out the average sales value
'''
total=0
for sales_value in sales:
total = total+sales_value
average_sales=total/len(sales)
print('Average sales are:', average_sales)
aver... | sales = [50, 54, 29, 33, 22, 100, 45, 54, 89, 75]
def average_sales():
"""
Print out the average sales value
"""
total = 0
for sales_value in sales:
total = total + sales_value
average_sales = total / len(sales)
print('Average sales are:', average_sales)
average_sales() |
TRACK_WORDS = ["coronavirus"]
TABLE_NAME = "coronavirus"
TABLE_ATTRIBUTES = "id_str VARCHAR(255), created_at DATETIME, text VARCHAR(255), \
polarity INT, subjectivity INT, user_location VARCHAR(255), \
user_description VARCHAR(255), longitude DOUBLE, latitude DOUBLE, \
retweet_count ... | track_words = ['coronavirus']
table_name = 'coronavirus'
table_attributes = 'id_str VARCHAR(255), created_at DATETIME, text VARCHAR(255), polarity INT, subjectivity INT, user_location VARCHAR(255), user_description VARCHAR(255), longitude DOUBLE, latitude DOUBLE, retweet_count INT, f... |
'''
1. Write a Python program to find the first triangle number to have over n(given) divisors.
From Wikipedia: A triangular number is a number that is the sum of all of the natural numbers up to a certain number. For example, 10 is a triangular number because 1 + 2 + 3 + 4 = 10. The first 25 triangular numbers are: 1... | """
1. Write a Python program to find the first triangle number to have over n(given) divisors.
From Wikipedia: A triangular number is a number that is the sum of all of the natural numbers up to a certain number. For example, 10 is a triangular number because 1 + 2 + 3 + 4 = 10. The first 25 triangular numbers are: 1... |
def predict(lr, sample):
return lr.predict(sample.reshape(1, -1))
def predict2(lr, sample):
return lr.predict([sample])
| def predict(lr, sample):
return lr.predict(sample.reshape(1, -1))
def predict2(lr, sample):
return lr.predict([sample]) |
class Solution:
def getMoneyAmount(self, n: int) -> int:
# dp[i][j] means minimum amount of money [i , j]
# dp[i][j] = min(n + max(dp[i][n-1] , dp[n+1][j]))
dp = [[-1 for _ in range(n+1)] for _ in range(n+1)]
def cal_range(i,j):
# basic situation
if i >= len(... | class Solution:
def get_money_amount(self, n: int) -> int:
dp = [[-1 for _ in range(n + 1)] for _ in range(n + 1)]
def cal_range(i, j):
if i >= len(dp) or j >= len(dp) or i <= 0 or (j <= 0):
return 0
if i >= j:
dp[i][j] = 0
if dp[... |
class Question:
def __init__(self, q_text, q_answer):
self._text = q_text
self._answer = q_answer
@property
def text(self):
return self._text
@text.setter
def text(self, d):
self._text = d
@property
def answer(self):
return self._answer
| class Question:
def __init__(self, q_text, q_answer):
self._text = q_text
self._answer = q_answer
@property
def text(self):
return self._text
@text.setter
def text(self, d):
self._text = d
@property
def answer(self):
return self._answer |
# Given a string, find the first uppercase character.
# Solve using both an iterative and recursive solution.
input_str_1 = "lucidProgramming"
input_str_2 = "LucidProgramming"
input_str_3 = "lucidprogramming"
def find_uppercase_iterative(input_str):
for i in range(len(input_str)):
if input_str[i].isupper... | input_str_1 = 'lucidProgramming'
input_str_2 = 'LucidProgramming'
input_str_3 = 'lucidprogramming'
def find_uppercase_iterative(input_str):
for i in range(len(input_str)):
if input_str[i].isupper():
return input_str[i]
return 'No uppercase character found'
def find_uppercase_recursive(inpu... |
def phi1(n):
'''
sqrt(n)
'''
res=n
i=2
while(i*i<=n):
if n%i==0:
res=res//i
res=res*(i-1)
while(n%i==0):
n=n//i
i+=1
if n>1:
res=res//n
res=res*(n-1)
return res
'''
log(log(n))
'''
def phi2(maxn)... | def phi1(n):
"""
sqrt(n)
"""
res = n
i = 2
while i * i <= n:
if n % i == 0:
res = res // i
res = res * (i - 1)
while n % i == 0:
n = n // i
i += 1
if n > 1:
res = res // n
res = res * (n - 1)
return res
... |
def say_(func):
func()
def hi():
print("Hello")
# Estoy pasando hi como argumento de say_
say_(hi)
| def say_(func):
func()
def hi():
print('Hello')
say_(hi) |
N, A, B = map(int, input().split())
print(min(A, B), end=" ")
if N - A <= B:
print(B - N + A)
else:
print(0)
| (n, a, b) = map(int, input().split())
print(min(A, B), end=' ')
if N - A <= B:
print(B - N + A)
else:
print(0) |
class Solution:
def countStudents(self, students: List[int], sandwiches: List[int]) -> int:
hashStudent = {0:0, 1:0}
for student in students:
hashStudent[student] += 1
for sandwich in sandwiches:
if hashStudent[sandwich] == 0:
break
... | class Solution:
def count_students(self, students: List[int], sandwiches: List[int]) -> int:
hash_student = {0: 0, 1: 0}
for student in students:
hashStudent[student] += 1
for sandwich in sandwiches:
if hashStudent[sandwich] == 0:
break
el... |
def main():
a = 1.0
b = 397.0
print(a/b)
return(0)
main() | def main():
a = 1.0
b = 397.0
print(a / b)
return 0
main() |
class Solution:
def nextGreaterElement(self, n: int) -> int:
num = list(str(n))
i = len(num) - 2
while i >= 0:
if num[i] < num[i + 1]:
break
i -= 1
if i == -1:
return -1
j = len(num) - 1
while num[j] <= nu... | class Solution:
def next_greater_element(self, n: int) -> int:
num = list(str(n))
i = len(num) - 2
while i >= 0:
if num[i] < num[i + 1]:
break
i -= 1
if i == -1:
return -1
j = len(num) - 1
while num[j] <= num[i]:
... |
def cake(candles,debris):
res = 0
for i,v in enumerate(debris):
if i%2:
res+=ord(v)-97
else:
res+=ord(v)
if res>0.7*candles and candles:
return "Fire!"
else:
return 'That was close!' | def cake(candles, debris):
res = 0
for (i, v) in enumerate(debris):
if i % 2:
res += ord(v) - 97
else:
res += ord(v)
if res > 0.7 * candles and candles:
return 'Fire!'
else:
return 'That was close!' |
class ColorTheme:
def __init__(self, name: str, display_name: str, version: str):
self.name = name
self.display_name = display_name
self.version = version
| class Colortheme:
def __init__(self, name: str, display_name: str, version: str):
self.name = name
self.display_name = display_name
self.version = version |
class ProjectStatus:
def __init__(self, name):
self.name = name
self.icon = None
self.status = None
def add_icon(self, icon):
self.icon = icon
def set_status(self, status):
self.status = status
class ProjectStatusDictionary(object):
def __init__(self):
... | class Projectstatus:
def __init__(self, name):
self.name = name
self.icon = None
self.status = None
def add_icon(self, icon):
self.icon = icon
def set_status(self, status):
self.status = status
class Projectstatusdictionary(object):
def __init__(self):
... |
class Vitals:
LEARNING_RATE = 0.1
MOMENTUM_RATE = 0.8
FIRST_LAYER = 5 * 7
SECOND_LAYER = 14
OUTPUT_LAYER = 3 | class Vitals:
learning_rate = 0.1
momentum_rate = 0.8
first_layer = 5 * 7
second_layer = 14
output_layer = 3 |
print('C L A S S I C S O L U T I O N')
range_of_numbers = []
div_by_2 = []
div_by_3 = []
other_numbers = []
for i in range(1,11):
range_of_numbers.append(i)
if i%2 == 0:
div_by_2.append(i)
elif i%3 == 0:
div_by_3.append(i)
else:
other_numbers.append(i)
print('The range of numbe... | print('C L A S S I C S O L U T I O N')
range_of_numbers = []
div_by_2 = []
div_by_3 = []
other_numbers = []
for i in range(1, 11):
range_of_numbers.append(i)
if i % 2 == 0:
div_by_2.append(i)
elif i % 3 == 0:
div_by_3.append(i)
else:
other_numbers.append(i)
print('The range of ... |
# limitation :pattern count of each char to be max 1
text = "912873129"
pat = "123"
window_found = False
prev_min = 0
prev_max = 0
prev_pos = -1
lookup_tab = dict()
# detect first window formation when all characters are found
# change window whenever new character was the previous minimum
# if new window smaller t... | text = '912873129'
pat = '123'
window_found = False
prev_min = 0
prev_max = 0
prev_pos = -1
lookup_tab = dict()
for (pos, c) in enumerate(text):
if c in pat:
prev_pos = lookup_tab.get(c, -1)
lookup_tab[c] = pos
if window_found == True:
cur_max = pos
if prev_pos == cur... |
class ResponseKeys(object):
POST = 'post'
POSTS = 'posts'
POST_SAVED = 'The post was saved successfully'
POST_UPDATED = 'The post was updated successfully'
POST_DELETED = 'The post was deleted successfully'
POST_NOT_FOUND = 'The post could not be found'
| class Responsekeys(object):
post = 'post'
posts = 'posts'
post_saved = 'The post was saved successfully'
post_updated = 'The post was updated successfully'
post_deleted = 'The post was deleted successfully'
post_not_found = 'The post could not be found' |
# This problem was recently asked by Google:
# Given a singly-linked list, reverse the list. This can be done iteratively or recursively. Can you get both solutions?
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# Function to print the list
def printList... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
def print_list(self):
node = self
output = ''
while node != None:
output += str(node.val)
output += ' '
node = node.next
print(output)
def rever... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def LF_flux(FL, FR, lmax, lmin, UR, UL, dt, dx):
ctilde = dx / dt
return 0.5 * (FL + FR) - 0.5 * ctilde * (UR - UL)
| def lf_flux(FL, FR, lmax, lmin, UR, UL, dt, dx):
ctilde = dx / dt
return 0.5 * (FL + FR) - 0.5 * ctilde * (UR - UL) |
def get_circles(image):
img = image.copy()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 2, 100)
if circles is not None:
circles = np.round(circles[0, :]).astype("int")
for x, y, r in circles:
cv2.circle(img, (x, y), r, ... | def get_circles(image):
img = image.copy()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 2, 100)
if circles is not None:
circles = np.round(circles[0, :]).astype('int')
for (x, y, r) in circles:
cv2.circle(img, (x, y), r, (2... |
x, y, w, h = map(int,input().split())
if x >= w-x:
a = w-x
else:
a = x
if y >= h-y:
b = h-y
else:
b = y
if a >= b:
print(b)
else:
print(a)
| (x, y, w, h) = map(int, input().split())
if x >= w - x:
a = w - x
else:
a = x
if y >= h - y:
b = h - y
else:
b = y
if a >= b:
print(b)
else:
print(a) |
#3-1 Names
names = ["Jason", "Bob", "James", "Brian", "Marie"]
print(names[0])
print(names[1])
print(names[2])
print(names[3])
print(names[4])
#3-2 Greetings
message = " you are a friend"
print(names[0] + message)
print(names[1] + message)
print(names[2] + message)
print(names[3] + message)
print(names[4] + message)
... | names = ['Jason', 'Bob', 'James', 'Brian', 'Marie']
print(names[0])
print(names[1])
print(names[2])
print(names[3])
print(names[4])
message = ' you are a friend'
print(names[0] + message)
print(names[1] + message)
print(names[2] + message)
print(names[3] + message)
print(names[4] + message)
cars = ['BMW', 'BatMobile', ... |
# import pytest
def test_with_authenticated_client(client, django_user_model):
username = "admin"
password = "123456"
django_user_model.objects.create_user(username=username, password=password)
# Use this:
# client.login(username=username, password=password)
response = client.get('/')
asse... | def test_with_authenticated_client(client, django_user_model):
username = 'admin'
password = '123456'
django_user_model.objects.create_user(username=username, password=password)
response = client.get('/')
assert response.status_code == 302
response = client.get(response.url)
assert response.... |
def setup():
global s, x_count, y_count, tiles, covers
s = 50
x_count = width//s
y_count = height//s
size(800, 600)
tiles = []
covers = []
for x in range(x_count):
tiles.append([])
covers.append([])
for y in range(y_count):
tiles[x].append("... | def setup():
global s, x_count, y_count, tiles, covers
s = 50
x_count = width // s
y_count = height // s
size(800, 600)
tiles = []
covers = []
for x in range(x_count):
tiles.append([])
covers.append([])
for y in range(y_count):
tiles[x].append('bomb' i... |
#forma de somar comprar de carrinho virtual
carrinho = []
carrinho.append(('Produto 1', 30))
carrinho.append(('Produto 2', '20'))
carrinho.append(('Produto 3', 50))
#no python essa baixo nao eh muito boa
# total = []
# for produto in carrinho:
# total.append(produto[1])
# print(sum(total))
total = sum([float(y)... | carrinho = []
carrinho.append(('Produto 1', 30))
carrinho.append(('Produto 2', '20'))
carrinho.append(('Produto 3', 50))
total = sum([float(y) for (x, y) in carrinho])
print(total) |
# -*- coding: utf-8 -*-
{
"name": "Import Settings",
"vesion": "10.0.1.0.0",
"summary": "Allows to save import settings to don't specify columns to fields mapping each time.",
"category": "Extra Tools",
"images": ["images/icon.png"],
"author": "IT-Projects LLC, Dinar Gabbasov",
"website": "h... | {'name': 'Import Settings', 'vesion': '10.0.1.0.0', 'summary': "Allows to save import settings to don't specify columns to fields mapping each time.", 'category': 'Extra Tools', 'images': ['images/icon.png'], 'author': 'IT-Projects LLC, Dinar Gabbasov', 'website': 'https://www.twitter.com/gabbasov_dinar', 'license': 'O... |
room_cost = {
'room for one person': {'cost': 18, 'discount': (0, 0, 0)},
'apartment': {'cost': 25, 'discount': (0.3, 0.35, 0.5)},
'president apartment': {'cost': 35, 'discount': (0.1, 0.15, 0.2)}
}
def discount_index(days_: int) -> int:
if days_ < 10:
return 0
elif 10 <= days_ <= 15:
... | room_cost = {'room for one person': {'cost': 18, 'discount': (0, 0, 0)}, 'apartment': {'cost': 25, 'discount': (0.3, 0.35, 0.5)}, 'president apartment': {'cost': 35, 'discount': (0.1, 0.15, 0.2)}}
def discount_index(days_: int) -> int:
if days_ < 10:
return 0
elif 10 <= days_ <= 15:
return 1
... |
for left in range(7):
for right in range(left,7):
print("[" + str(left) + "|" + str(right) + "]", end=" ")
print
| for left in range(7):
for right in range(left, 7):
print('[' + str(left) + '|' + str(right) + ']', end=' ')
print |
number = int(input())
bonus_points = 0
if number <= 100:
bonus_points += 5
elif number > 1000:
bonus_points += number * 0.10
else:
bonus_points += number * 0.20
if number % 2 == 0:
bonus_points += 1
if number % 10 == 5:
bonus_points += 2
print(bonus_points)
print(bonus_points + number) | number = int(input())
bonus_points = 0
if number <= 100:
bonus_points += 5
elif number > 1000:
bonus_points += number * 0.1
else:
bonus_points += number * 0.2
if number % 2 == 0:
bonus_points += 1
if number % 10 == 5:
bonus_points += 2
print(bonus_points)
print(bonus_points + number) |
def if_hexagon_enabled(a):
return select({
"//micro:hexagon_enabled": a,
"//conditions:default": [],
})
def if_not_hexagon_enabled(a):
return select({
"//micro:hexagon_enabled": [],
"//conditions:default": a,
})
def new_local_repository_env_impl(repository_ctx):
ech... | def if_hexagon_enabled(a):
return select({'//micro:hexagon_enabled': a, '//conditions:default': []})
def if_not_hexagon_enabled(a):
return select({'//micro:hexagon_enabled': [], '//conditions:default': a})
def new_local_repository_env_impl(repository_ctx):
echo_cmd = 'echo ' + repository_ctx.attr.path
... |
DATABASE = '/tmp/tmc2.db'
DEBUG = False
# By default we only listen on localhost. Set this to '0.0.0.0' to accept
# requests from any interface
HOST = '127.0.0.1'
PORT = 5000
# How many quotes per page
PAGE_SIZE = 10
# How should dates be formatted. The format is defined in
# http://arrow.readthedocs.io/en/latest/in... | database = '/tmp/tmc2.db'
debug = False
host = '127.0.0.1'
port = 5000
page_size = 10
date_formats = {'en_US': 'MMMM D, YYYY', 'fr_FR': 'D MMMM YYYY'}
locale = 'en_US' |
# -*- coding: utf-8 -*-
'''
File name: code\lychrel_numbers\sol_55.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #55 :: Lychrel numbers
#
# For more information see:
# https://projecteuler.net/problem=55
# Problem Statement
'''
If we ... | """
File name: code\\lychrel_numbers\\sol_55.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
"""
'\nIf we take 47, reverse and add, 47 + 74 = 121, which is palindromic.\nNot all numbers produce palindromes so quickly. For example,\n349 + 943 = 1292,\n1292 + 2921 = 4213\n4213 + 312... |
n,v = map(int,input().split())
mx = -1
for i in range(n):
l,w,h = map(int,input().split())
vo = l*w*h
#print(vo)
if vo>mx: mx = vo
print(mx - v) | (n, v) = map(int, input().split())
mx = -1
for i in range(n):
(l, w, h) = map(int, input().split())
vo = l * w * h
if vo > mx:
mx = vo
print(mx - v) |
#
# PySNMP MIB module TIARA-IP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIARA-IP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:09:01 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,... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection, constraints_union) ... |
#
# PySNMP MIB module HP-ICF-CHAIN (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-CHAIN
# Produced by pysmi-0.3.4 at Wed May 1 13:33:33 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,... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint, constraints_union) ... |
'''
Missing number in an array
Given an array of size N-1 such that,
it can only contain distinct integers in the range of 1 to N.
Find the missing element.
Example:
Input:
N = 5
A[] = {1,2,3,5}
Output: 4
Input:
N = 10
A[] = {1,2,3,4,5,6,7,8,10}
Output: 9
'''
# Approach-1
'''
We know that sum of N natu... | """
Missing number in an array
Given an array of size N-1 such that,
it can only contain distinct integers in the range of 1 to N.
Find the missing element.
Example:
Input:
N = 5
A[] = {1,2,3,5}
Output: 4
Input:
N = 10
A[] = {1,2,3,4,5,6,7,8,10}
Output: 9
"""
' \nWe know that sum of N natural number is ... |
#
# PySNMP MIB module CADANT-HW-MEAS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CADANT-HW-MEAS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:45:55 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_union, constraints_intersection, single_value_constraint) ... |
YT_API_SERVICE_NAME = 'youtube'
DEVELOPER_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
MAX_RESULTS = 50
YT_API_VERSION = 'v3'
LINK = 'https://www.youtube.com/watch?v='
| yt_api_service_name = 'youtube'
developer_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
max_results = 50
yt_api_version = 'v3'
link = 'https://www.youtube.com/watch?v=' |
out_data = b"\x1c\x91\x73\x94\xba\xfb\x3c\x30" + \
b"\x3c\x30\xac\x26\x62\x09\x74\x65" + \
b"\x73\x74\x31\x2e\x74\x78\x74\x5e" + \
b"\xc5\xf7\x32\x4c\x69\x76\x65\x20" + \
b"\x66\x72\x65\x65\x20\x6f\x72\x20" + \
b"\x64\x69\x65\x20\x68\x61\x72\x64" + \
... | out_data = b'\x1c\x91s\x94\xba\xfb<0' + b'<0\xac&b\tte' + b'st1.txt^' + b'\xc5\xf72Live ' + b'free or ' + b'die hard' + b'\r\n\xd3\x14|.\x86\x89' + b'zBX\xed\x06S\x9f\x15' + b'\xcc\xca~{7(_<' |
class A():
@staticmethod
def staticMethod():
print("STATIC method fired!")
print("Nothing is bound to me")
print("~"*30)
@classmethod
def classMethod(cls):
print("CLASS method fired!")
print(str(cls)+" is bound to me")
print("~"*30)
# normal method
def normalMethod(self):
print... | class A:
@staticmethod
def static_method():
print('STATIC method fired!')
print('Nothing is bound to me')
print('~' * 30)
@classmethod
def class_method(cls):
print('CLASS method fired!')
print(str(cls) + ' is bound to me')
print('~' * 30)
def normal... |
class Solution:
def removeDuplicates(self, S: str) -> str:
def process(S):
lst = []
for key, g in itertools.groupby(S):
n = len(list(g))
if n % 2:
lst.append(key)
return lst
S_lst = list(S)
while True:
... | class Solution:
def remove_duplicates(self, S: str) -> str:
def process(S):
lst = []
for (key, g) in itertools.groupby(S):
n = len(list(g))
if n % 2:
lst.append(key)
return lst
s_lst = list(S)
while Tru... |
class User:
'''
class that generates new instance of user
'''
user_list = []
def __init__ (self, user_name, password):
self.user_name = user_name
self.password = password
def save_user(self):
User.user_list.append(self)
def delete_user(self):
'''
... | class User:
"""
class that generates new instance of user
"""
user_list = []
def __init__(self, user_name, password):
self.user_name = user_name
self.password = password
def save_user(self):
User.user_list.append(self)
def delete_user(self):
"""
del... |
print("Example 05: [The else Statement] \n"
" Print a message once the condition is false")
i = 1
while i < 6:
print(i)
i += 1
else:
print("The condition is false")
| print('Example 05: [The else Statement] \n Print a message once the condition is false')
i = 1
while i < 6:
print(i)
i += 1
else:
print('The condition is false') |
def isPalindrome(s):
temp = [c for c in s]
temp.reverse()
return ''.join(temp) == s
def twodigit():
return reversed(range(100, 999))
q = reversed(sorted([a * b for a in twodigit() for b in twodigit()]))
found = False
for s in q:
if isPalindrome(str(s)):
print(s)
found = True
break... | def is_palindrome(s):
temp = [c for c in s]
temp.reverse()
return ''.join(temp) == s
def twodigit():
return reversed(range(100, 999))
q = reversed(sorted([a * b for a in twodigit() for b in twodigit()]))
found = False
for s in q:
if is_palindrome(str(s)):
print(s)
found = True
... |
def mutations(inputs):
item_a = set(inputs[0].lower())
item_b = set(inputs[1].lower())
return item_b.intersection(item_a) == item_b
print(mutations(["hello", "Hello"]))
print(mutations(["hello", "hey"]))
print(mutations(["Alien", "line"])) | def mutations(inputs):
item_a = set(inputs[0].lower())
item_b = set(inputs[1].lower())
return item_b.intersection(item_a) == item_b
print(mutations(['hello', 'Hello']))
print(mutations(['hello', 'hey']))
print(mutations(['Alien', 'line'])) |
while True:
try:
n = int(input("Enter N: "))
except ValueError:
print("Enter correct number!")
else:
if n <= 100:
print("Error: N must be greater than 100!")
else:
for i in range(11, n + 1):
s = i
i = (i-1) + i*i
... | while True:
try:
n = int(input('Enter N: '))
except ValueError:
print('Enter correct number!')
else:
if n <= 100:
print('Error: N must be greater than 100!')
else:
for i in range(11, n + 1):
s = i
i = i - 1 + i * i
... |
# PySNMP SMI module. Autogenerated from smidump -f python RUCKUS-SCG-TTG-MIB
# by libsmi2pysnmp-0.1.3
# Python version sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)
# pylint:disable=C0302
mibBuilder = mibBuilder # pylint:disable=undefined-variable,used-before-assignment
# Imports
(Int... | mib_builder = mibBuilder
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, single_value_constraint, value_range_constraint... |
class Slot:
def __init__(name, _type=None, item=None):
self.name = name,
if _type is not None:
self.type = _type
else:
self.type = name
self.item = item,
def equip(self):
pass
def unequip(self):
pass
def show(sel... | class Slot:
def __init__(name, _type=None, item=None):
self.name = (name,)
if _type is not None:
self.type = _type
else:
self.type = name
self.item = (item,)
def equip(self):
pass
def unequip(self):
pass
def show(self):
... |
def test_modulemap(snapshot):
snapshot.assert_match([1, 2, 4])
def test_runlist():
assert 1 == 1 | def test_modulemap(snapshot):
snapshot.assert_match([1, 2, 4])
def test_runlist():
assert 1 == 1 |
# Charlie Conneely
# Dictionary parser file
def parse(f):
file = open(f, "r")
words = file.read().split()
file.close()
return words
if __name__ == "__main__":
print("please run runner.py instead")
| def parse(f):
file = open(f, 'r')
words = file.read().split()
file.close()
return words
if __name__ == '__main__':
print('please run runner.py instead') |
def fibonacci(n):
if n == 0:
return (0, 1)
else:
a, b = fibonacci(n // 2)
c = a * (b * 2 - a)
d = a * a + b * b
if n % 2 == 0:
return (c, d)
else:
return (d, c + d)
x = 0
y = 0
num = 1
while len(str(x)) < 1000:
x, y = fib... | def fibonacci(n):
if n == 0:
return (0, 1)
else:
(a, b) = fibonacci(n // 2)
c = a * (b * 2 - a)
d = a * a + b * b
if n % 2 == 0:
return (c, d)
else:
return (d, c + d)
x = 0
y = 0
num = 1
while len(str(x)) < 1000:
(x, y) = fibonacci(num)... |
def add(x, y):
return x + y
print(add(5, 7))
# -- Written as a lambda --
add = lambda x, y: x + y
print(add(5, 7))
# Four parts
# lambda
# parameters
# :
# return value
# Lambdas are meant to be short functions, often used without giving them a name.
# For example, in conjunction with built-in function map
# ... | def add(x, y):
return x + y
print(add(5, 7))
add = lambda x, y: x + y
print(add(5, 7))
def double(x):
return x * 2
sequence = [1, 3, 5, 9]
doubled = [double(x) for x in sequence]
doubled = map(double, sequence)
print(list(doubled))
sequence = [1, 3, 5, 9]
doubled = map(lambda x: x * 2, sequence)
print(list(dou... |
def test_3_5_15(n):
if (n % 15 == 0) and n != 0 :
return 'FizzBuzz'
elif n % 3 ==0 and n != 0:
return 'Fizz'
elif n % 5 == 0 and n != 0:
return 'Buzz'
else:
return n
def coundown():
for x in range (0,101):
print(test_3_5_15(x))
coundown() | def test_3_5_15(n):
if n % 15 == 0 and n != 0:
return 'FizzBuzz'
elif n % 3 == 0 and n != 0:
return 'Fizz'
elif n % 5 == 0 and n != 0:
return 'Buzz'
else:
return n
def coundown():
for x in range(0, 101):
print(test_3_5_15(x))
coundown() |
def average(data):
if isinstance(data[0], int):
return sum(data) / len(data)
else:
raw_data = list(map(lambda r: r.value, data))
return sum(raw_data) / len(raw_data)
def minimum(data, index=0):
if index == 0:
data_slice = data
else:
data_slice = data[index:]
return min(data_slice)
def maximum(data, i... | def average(data):
if isinstance(data[0], int):
return sum(data) / len(data)
else:
raw_data = list(map(lambda r: r.value, data))
return sum(raw_data) / len(raw_data)
def minimum(data, index=0):
if index == 0:
data_slice = data
else:
data_slice = data[index:]
... |
EXCHANGE_MAX_NAME_LENGTH = 100
EXCHANGE_MAX_DESCRIPTION_LENGTH = 1000
FOLDER_FORBIDDEN_CHARS = {'/', '\\', ':', '*', '"', '<', '>', '?', '|'}
FOLDER_MAX_NAME_LENGTH = 60
def validate_folder(folder):
if 'name' not in folder:
raise Exception('No name')
for c in VALIDATE_FOLDER_FORBIDDEN_CHARS:
... | exchange_max_name_length = 100
exchange_max_description_length = 1000
folder_forbidden_chars = {'/', '\\', ':', '*', '"', '<', '>', '?', '|'}
folder_max_name_length = 60
def validate_folder(folder):
if 'name' not in folder:
raise exception('No name')
for c in VALIDATE_FOLDER_FORBIDDEN_CHARS:
if... |
class OperationStaResult(object):
def __init__(self):
self.total = None
self.wait = None
self.processing = None
self.success = None
self.fail = None
self.stop = None
self.timeout = None
def getTotal(self):
return self.total
def setTotal(self... | class Operationstaresult(object):
def __init__(self):
self.total = None
self.wait = None
self.processing = None
self.success = None
self.fail = None
self.stop = None
self.timeout = None
def get_total(self):
return self.total
def set_total(se... |
# Medium
# https://leetcode.com/problems/next-greater-element-ii/
# TC: O(N)
# SC: O(N)
class Solution:
def nextGreaterElements(self, nums: List[int]) -> List[int]:
nums = nums + nums
stack = []
out = [-1 for _ in nums]
for index, num in enumerate(nums):
while len(stack) ... | class Solution:
def next_greater_elements(self, nums: List[int]) -> List[int]:
nums = nums + nums
stack = []
out = [-1 for _ in nums]
for (index, num) in enumerate(nums):
while len(stack) and num > nums[stack[-1]]:
out[stack.pop()] = num
stack... |
days = ["Mon", "Thu", "Wed", "Thur", "Fri"] # list(mutable sequence)
print(days)
days.append("Sat")
days.reverse()
print(days)
| days = ['Mon', 'Thu', 'Wed', 'Thur', 'Fri']
print(days)
days.append('Sat')
days.reverse()
print(days) |
class StreamPredictorConsumer(object):
def __init__(self, name, algorithm=None, **kw):
self.algorithm = algorithm
self.name = name
self.run_count = 0
self.runs = []
async def handle(self, payload):
self.run_count += 1
try:
results, err = await self.a... | class Streampredictorconsumer(object):
def __init__(self, name, algorithm=None, **kw):
self.algorithm = algorithm
self.name = name
self.run_count = 0
self.runs = []
async def handle(self, payload):
self.run_count += 1
try:
(results, err) = await self... |
group_template_tag_prefix = 'DRKNS_GROUP_TEMPLATE_' # BEGIN / END
unit_template_tag_prefix = 'DRKNS_UNIT_TEMPLATE_' # BEGIN / END
groups_tag = 'DRKNS_GROUPS'
group_units_tag = 'DRKNS_GROUP_UNITS'
group_name_tag = 'DRKNS_GROUP_NAME'
unit_name_tag = 'DRKNS_UNIT_NAME'
dependency_groups_names_tag = 'DRKNS_DEPENDENCY_G... | group_template_tag_prefix = 'DRKNS_GROUP_TEMPLATE_'
unit_template_tag_prefix = 'DRKNS_UNIT_TEMPLATE_'
groups_tag = 'DRKNS_GROUPS'
group_units_tag = 'DRKNS_GROUP_UNITS'
group_name_tag = 'DRKNS_GROUP_NAME'
unit_name_tag = 'DRKNS_UNIT_NAME'
dependency_groups_names_tag = 'DRKNS_DEPENDENCY_GROUPS_NAMES'
all_group_names_tag ... |
#!/usr/bin/env python3
def main():
for i in range(1,11):
for j in range(1,11):
if(j==10):
print(i*j)
else:
print(i*j, end=" ")
if __name__ == "__main__":
main()
| def main():
for i in range(1, 11):
for j in range(1, 11):
if j == 10:
print(i * j)
else:
print(i * j, end=' ')
if __name__ == '__main__':
main() |
def require(*types):
'''
Return a decorator function that requires specified types.
types -- tuple each element of which is a type or class or a tuple of
several types or classes.
Example to require a string then a numeric argument
@require(str, (int, long, float))
will do the tric... | def require(*types):
"""
Return a decorator function that requires specified types.
types -- tuple each element of which is a type or class or a tuple of
several types or classes.
Example to require a string then a numeric argument
@require(str, (int, long, float))
will do the tric... |
def try_if(l):
ret = 0
for x in l:
if x == 1:
ret += 2
elif x == 0:
ret += 4
else:
ret -= 2
return ret
try_if([0, 1, 0, 1, 2, 3])
| def try_if(l):
ret = 0
for x in l:
if x == 1:
ret += 2
elif x == 0:
ret += 4
else:
ret -= 2
return ret
try_if([0, 1, 0, 1, 2, 3]) |
namespace = '/map'
routes = {
'getAllObjectDest': '/',
}
| namespace = '/map'
routes = {'getAllObjectDest': '/'} |
# Validar uma string
def valida_str(texto, min, max):
tam = len(texto)
if tam < min or tam > max:
return False
else:
return True
# Programa Principal
texto = input('Digite um string (3-15 caracteres): ')
while valida_str(texto, 3, 15):
texto = input('Digite uma string (3-15 caracteres)... | def valida_str(texto, min, max):
tam = len(texto)
if tam < min or tam > max:
return False
else:
return True
texto = input('Digite um string (3-15 caracteres): ')
while valida_str(texto, 3, 15):
texto = input('Digite uma string (3-15 caracteres): ')
print(texto) |
#
# PySNMP MIB module HH3C-STACK-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-STACK-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:29:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) ... |
l1=[1,2,3,4,5,6,7,8,9,10]
l2=list(map(lambda n:n*n,l1))
print('l2:',l2)
l3=list((map(lambda n,m:n*m,l1,l2)))#map function can take more than one sequence argument
print('l3:',l3)
#if the length of the sequence is not equal then function will perform till same length
l3.pop()
print('popped l3:',l3)
l4=list(map(lambda n,... | l1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
l2 = list(map(lambda n: n * n, l1))
print('l2:', l2)
l3 = list(map(lambda n, m: n * m, l1, l2))
print('l3:', l3)
l3.pop()
print('popped l3:', l3)
l4 = list(map(lambda n, m, o: n + m + o, l1, l2, l3))
print('l4:', l4) |
{
'targets': [
{
'target_name': 'gpiobcm2835nodejs',
'sources': [
'src/gpiobcm2835nodejs.cc'
],
"cflags" : [ "-lrt -lbcm2835" ],
'conditions': [
['OS=="linux"', {
'cflags!': [
'-lrt -lbcm2835',
],
... | {'targets': [{'target_name': 'gpiobcm2835nodejs', 'sources': ['src/gpiobcm2835nodejs.cc'], 'cflags': ['-lrt -lbcm2835'], 'conditions': [['OS=="linux"', {'cflags!': ['-lrt -lbcm2835']}]], 'include_dirs': ['src/gpio_functions'], 'libraries': ['-lbcm2835']}]} |
class SpekulatioError(Exception):
pass
class FrontmatterError(SpekulatioError):
pass
| class Spekulatioerror(Exception):
pass
class Frontmattererror(SpekulatioError):
pass |
class Sql:
make_itemdb = '''
CREATE TABLE IF NOT EXISTS ITEMDB (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
NAME TEXT,
PRICE REAL,
REGDATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
'''
insert_itemdb = '''
INSERT INTO ITEMDB (NAME, PRICE) VALUES ... | class Sql:
make_itemdb = '\n CREATE TABLE IF NOT EXISTS ITEMDB (\n ID INTEGER PRIMARY KEY AUTOINCREMENT,\n NAME TEXT,\n PRICE REAL,\n REGDATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )\n '
insert_itemdb = '\n INSERT INTO ITEMDB (NAME, PRICE) VALUE... |
def getbounds(img):
return tuple([min((si[i] for si in img)) for i in range(2)]), \
tuple([max((si[i] for si in img)) for i in range(2)])
def enhance(img, setval, algo):
bounds = getbounds(img)
offsets = ((1, 1), (0, 1), (-1, 1), (1, 0), (0, 0), (-1, 0), (1, -1), (0, -1), (-1, -1))
overhang... | def getbounds(img):
return (tuple([min((si[i] for si in img)) for i in range(2)]), tuple([max((si[i] for si in img)) for i in range(2)]))
def enhance(img, setval, algo):
bounds = getbounds(img)
offsets = ((1, 1), (0, 1), (-1, 1), (1, 0), (0, 0), (-1, 0), (1, -1), (0, -1), (-1, -1))
overhang = 2
n_i... |
class TrieNode:
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word = False
class Solution:
def findWords(self, board: List[List[str]], words: List[str]) -> List[str]:
root = TrieNode()
for word in words:
cur = root
for ch i... | class Trienode:
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word = False
class Solution:
def find_words(self, board: List[List[str]], words: List[str]) -> List[str]:
root = trie_node()
for word in words:
cur = root
for ... |
def rotate(matrix):
#code here
for i in range(len(matrix)):
listt = list(reversed(matrix[i]))
for j in range(len(matrix[i])):
matrix[i][j] = listt[j]
# print(matrix)
for i in range(len(matrix)):
for j in range(i, len(matrix[i])):
matrix[i][j], matrix... | def rotate(matrix):
for i in range(len(matrix)):
listt = list(reversed(matrix[i]))
for j in range(len(matrix[i])):
matrix[i][j] = listt[j]
for i in range(len(matrix)):
for j in range(i, len(matrix[i])):
(matrix[i][j], matrix[j][i]) = (matrix[j][i], matrix[i][j])
i... |
# Like list we can have set and dict comprehensions.
# Set comprehensions.
# The below set is not ordered.
square_set = {num * num for num in range(11)}
print(square_set)
# Dict Comprehension
dict_square = {num: num * num for num in range(11)}
print(dict_square)
# Use f"string to create a set and dict
f_string_squar... | square_set = {num * num for num in range(11)}
print(square_set)
dict_square = {num: num * num for num in range(11)}
print(dict_square)
f_string_square_set = {f'The square of {num} is {num * num}' for num in range(5)}
for x in f_string_square_set:
print(x)
f_string_square_dict = {num: f'the square is {num * num}' fo... |
#ANSI Foreground colors
black = u"\u001b[30m"
red = u"\u001b[31m"
green = u"\u001b[32m"
yellow = u"\u001b[33m"
blue = u"\u001b[34m"
magneta = u"\u001b[35m"
magenta = magneta
cyan = u"\u001b[36m"
white = u"\u001b[37m"
#ANSI Background colors
blackB = u"\u001b[40m"
redB = u"\u001b[41m"
greenB = u"\u001b[42m"
yellowB = u"... | black = u'\x1b[30m'
red = u'\x1b[31m'
green = u'\x1b[32m'
yellow = u'\x1b[33m'
blue = u'\x1b[34m'
magneta = u'\x1b[35m'
magenta = magneta
cyan = u'\x1b[36m'
white = u'\x1b[37m'
black_b = u'\x1b[40m'
red_b = u'\x1b[41m'
green_b = u'\x1b[42m'
yellow_b = u'\x1b[43m'
blue_b = u'\x1b[44m'
magneta_b = u'\x1b[45m'
magenta_b =... |
athlete_1 = int(input())
athlete_2 = int(input())
athlete_3 = int(input())
podium = []
if (athlete_1 < athlete_2 and athlete_1 < athlete_3):
podium.append(1)
if(athlete_2 < athlete_3):
podium.append(2)
podium.append(3)
else:
podium.append(3)
podium.append(2)
elif (athlete... | athlete_1 = int(input())
athlete_2 = int(input())
athlete_3 = int(input())
podium = []
if athlete_1 < athlete_2 and athlete_1 < athlete_3:
podium.append(1)
if athlete_2 < athlete_3:
podium.append(2)
podium.append(3)
else:
podium.append(3)
podium.append(2)
elif athlete_2 < ath... |
Number = int(input("\nPlease Enter the Range Number: "))
First_Value = 0
Second_Value = 1
for Num in range(0, Number):
if (Num <= 1):
Next = Num
else:
Next = First_Value + Second_Value
First_Value = Second_Value
Second_Value = Next
print(Next) | number = int(input('\nPlease Enter the Range Number: '))
first__value = 0
second__value = 1
for num in range(0, Number):
if Num <= 1:
next = Num
else:
next = First_Value + Second_Value
first__value = Second_Value
second__value = Next
print(Next) |
def Spell_0_10(n):
refTuple = ("zero","one","two","three","four","five",
"six","seven","eight","nine","ten")
return refTuple[n]
print(1, " is spelt as ", Spell_0_10(1))
for i in range(11):
print("{} is spelt as {}".format(i,Spell_0_10(i)))
for i in range (-9,0,1):
print("{} i... | def spell_0_10(n):
ref_tuple = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten')
return refTuple[n]
print(1, ' is spelt as ', spell_0_10(1))
for i in range(11):
print('{} is spelt as {}'.format(i, spell_0_10(i)))
for i in range(-9, 0, 1):
print('{} is spelt as {}'.f... |
#Plugin to handle dialogues for men and women
#Written by Owain for Runefate
#31/01/18
#I want to give every spawned NPC a use, and not do what most servers have with useless non functioning NPCs.
#Even small things such as NPC dialogues can help make Runefate more rounded and enjoyable.
npc_ids = [3078, 3079]
dialo... | npc_ids = [3078, 3079]
dialogue_ids = [7502, 7504, 7506, 7508]
def first_click_npc_3078(player):
player.getDH().sendDialogues(7500)
def chat_7500(player):
player.getDH().sendPlayerChat('Hi there.', 591)
dialogue = random.choice(dialogue_ids)
player.nextDialogue = dialogue
def chat_7502(player):
p... |
class ReferenceDummy():
def __init__(self, *args):
return
def _to_dict(self, *args):
return "dummy"
| class Referencedummy:
def __init__(self, *args):
return
def _to_dict(self, *args):
return 'dummy' |
# #1
# def make_negative( number ):
# return number if number < 0 else - number
# #2
def make_negative( number ):
return -abs(number) | def make_negative(number):
return -abs(number) |
# This class parses a gtfs text file
class Reader:
def __init__(self, file):
self.fields = []
self.fp = open(file, "r")
self.fields.extend(self.fp.readline().rstrip().split(","))
def get_line(self):
data = {}
line = self.fp.readline().rstrip().split(",")
for e... | class Reader:
def __init__(self, file):
self.fields = []
self.fp = open(file, 'r')
self.fields.extend(self.fp.readline().rstrip().split(','))
def get_line(self):
data = {}
line = self.fp.readline().rstrip().split(',')
for (el, field) in zip(line, self.fields):
... |
# Cajones es una aplicacion que calcula el listado de partes
# de una cajonera
# unidad de medida en mm
# constantes
hol_lado = 13
# variables
h = 900
a = 600
prof_c = 400
h_c = 120
a_c = 200
hol_sup = 20
hol_inf = 10
hol_int = 40
hol_lateral = 2
esp_lado = 18
esp_sup = 18
esp_inf = 18
esp... | hol_lado = 13
h = 900
a = 600
prof_c = 400
h_c = 120
a_c = 200
hol_sup = 20
hol_inf = 10
hol_int = 40
hol_lateral = 2
esp_lado = 18
esp_sup = 18
esp_inf = 18
esp_c = 15
cubre_der_total = True
cubre_iz_total = True
def calcular_lado_cajon(prof_c, esp_c):
lado_cajon = prof_c - 2 * esp_c
return lado_cajon
def ca... |
def middle(t):
'''Write a function called middle that takes a list and returns a new list that contains
all but the first and last elements'''
return t[1: -1]
if __name__ == '__main__':
t = [1, 2, 30, 400, 5000]
print(t)
print(middle(t))
| def middle(t):
"""Write a function called middle that takes a list and returns a new list that contains
all but the first and last elements"""
return t[1:-1]
if __name__ == '__main__':
t = [1, 2, 30, 400, 5000]
print(t)
print(middle(t)) |
print("Size of list");
list1 = [1,23,5,2,42,526,52];
print(list1);
print(len(list1));
| print('Size of list')
list1 = [1, 23, 5, 2, 42, 526, 52]
print(list1)
print(len(list1)) |
FANARTTV_PROJECTKEY = ''
TADB_PROJECTKEY = ''
TMDB_PROJECTKEY = ''
THETVDB_PROJECTKEY = ''
| fanarttv_projectkey = ''
tadb_projectkey = ''
tmdb_projectkey = ''
thetvdb_projectkey = '' |
# Regards, Takeda Shingen (Sengoku Era) Questline | Near Momiji Hills 1 (811000001)
# Author: Tiger
TAKEDA = 9000427
if "1" in sm.getQRValue(58901): # Regards, Takeda Shingen
sm.setSpeakerID(TAKEDA)
sm.flipDialogue()
sm.sendNext("Good, you're here! I was about to pick another fight")
sm.flipDialogue... | takeda = 9000427
if '1' in sm.getQRValue(58901):
sm.setSpeakerID(TAKEDA)
sm.flipDialogue()
sm.sendNext("Good, you're here! I was about to pick another fight")
sm.flipDialogue()
sm.sendSay("We have a problem, and it's not a lack of conditioner. I'll tell ya that!")
sm.flipDialogue()
sm.sendSa... |
array = [3,5,-4,8,11,-1,6]
targetSum = 10
def twoNumberSum(array, targetSum):
#for loop to iterate the array
for i in range(len(array) - 1):
firstNum = array[i]
for j in range(i + 1, len(array)):
secondNum = array[j]
if firstNum + secondNum == targetSum:
r... | array = [3, 5, -4, 8, 11, -1, 6]
target_sum = 10
def two_number_sum(array, targetSum):
for i in range(len(array) - 1):
first_num = array[i]
for j in range(i + 1, len(array)):
second_num = array[j]
if firstNum + secondNum == targetSum:
return [firstNum, second... |
#!/usr/bin/env python
major_version = 0
minor_version = 0
patch_version = 10
def format_version():
return "{0}.{1}.{2}".format(major_version, minor_version, patch_version)
| major_version = 0
minor_version = 0
patch_version = 10
def format_version():
return '{0}.{1}.{2}'.format(major_version, minor_version, patch_version) |
# BIP39 Wordlist Validator - A tool to validate BIP39 wordlists in Latin
# languages.
# bip39validator/data_structs.py: Program data structures.
# Copyright 2020 Ali Sherief
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Softw... | class Wordandlinearray:
def __init__(self, args):
self.word_list = args[0]
self.line_numbers = args[1]
class Levdist:
def __init__(self, **kwargs):
self.dist = kwargs['dist']
self.line_numbers = kwargs['line_numbers']
self.words = kwargs['words']
class Levdistarray:
... |
#!/bin/python3
FAVORITE_NUMBER = 1362
GRID = [[0 for j in range(50)] for i in range(50)]
TARGET = (31, 39)
def check_wall(coordinates):
x, y = coordinates
if x < 0 or y < 0 or x >= 50 or y >= 50:
return False
elif GRID[x][y] != 0:
return False
current = x * x + 3 * x + 2 * x * y + ... | favorite_number = 1362
grid = [[0 for j in range(50)] for i in range(50)]
target = (31, 39)
def check_wall(coordinates):
(x, y) = coordinates
if x < 0 or y < 0 or x >= 50 or (y >= 50):
return False
elif GRID[x][y] != 0:
return False
current = x * x + 3 * x + 2 * x * y + y + y * y
cu... |
_title = 'KleenExtractor'
_description = 'Clean extract system to export folder content and sub content.'
_version = '0.1.2'
_author = 'Edenskull'
_license = 'MIT'
| _title = 'KleenExtractor'
_description = 'Clean extract system to export folder content and sub content.'
_version = '0.1.2'
_author = 'Edenskull'
_license = 'MIT' |
q = int(input())
for _ in range(q):
n = int(input())
m = []
for _ in range(n*2):
m.append(list(map(int, input().split(' '))))
# Sorcery here...
bigMax = 0
for i in range(n):
for j in range(n):
try:
bigMax += max(m[i][j], m[i][2*... | q = int(input())
for _ in range(q):
n = int(input())
m = []
for _ in range(n * 2):
m.append(list(map(int, input().split(' '))))
big_max = 0
for i in range(n):
for j in range(n):
try:
big_max += max(m[i][j], m[i][2 * n - 1 - j], m[2 * n - 1 - i][j], m[2 * n... |
secret = 'BEEF0123456789a'
skipped_sequential_false_positive = '0123456789a'
print('second line')
var = 'third line'
| secret = 'BEEF0123456789a'
skipped_sequential_false_positive = '0123456789a'
print('second line')
var = 'third line' |
#http://www.pythonchallenge.com/pc/def/ocr.html
s = ""
with open("3.html") as f:
for line in f.readlines():
s += line
for el in s:
if el >= 'a' and el <= 'z':
print(el),
| s = ''
with open('3.html') as f:
for line in f.readlines():
s += line
for el in s:
if el >= 'a' and el <= 'z':
(print(el),) |
# feel free to change these settings
APP_NAME = 'Deep Vision' # any string: The application title (desktop and web).
ABOUT_TITLE = "Deep Vision" # any string: The about box title (desktop and web).
ABOUT_MESSAGE = "Created By : FastAI Student" # any string: The about box contents (desktop and web).
APP_TYPE = 'deskt... | app_name = 'Deep Vision'
about_title = 'Deep Vision'
about_message = 'Created By : FastAI Student'
app_type = 'desktop'
show_media = True
save_media = False
save_media_path = None
save_media_file = None
show_logs = False
camera_id = 0
images_types = ['*.jpg', '*.jpeg', '*.jpe', '*.png', '*.bmp']
videos_types = ['*.mp4'... |
ch=input(('Enter any alphabet or digit '))
if ch in 'aeiouAEIOU':
print(ch,'is a vowel.')
elif ch in '0123456789':
print(ch,'is a digit.')
else:
print(ch,'is a consonant.')
| ch = input('Enter any alphabet or digit ')
if ch in 'aeiouAEIOU':
print(ch, 'is a vowel.')
elif ch in '0123456789':
print(ch, 'is a digit.')
else:
print(ch, 'is a consonant.') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.