content stringlengths 7 1.05M |
|---|
class basedriver (object):
def __init__(self, ctx, model):
self._ctx = ctx
self._model = model
def check_update(self, current):
if current is None:
return True
if current.version is None:
return True
if current.version != self._model.version:
... |
def get(key):
return None
def set(key, value):
pass
|
"""
[2017-09-29] Challenge #333 [Hard] Build a Web API-driven Data Site
https://www.reddit.com/r/dailyprogrammer/comments/739j8c/20170929_challenge_333_hard_build_a_web_apidriven/
# Description
A common theme in present-day programming are web APIs. We've had a previous challenge where you had to _consume_ an
API, to... |
# Problem Statement: https://leetcode.com/problems/longest-increasing-subsequence/
class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
arr = nums
if not arr:
return 0
lens = [1 for num in arr]
seqs = [None for num in arr]
for i, num in enumerate(arr):... |
print('load # extractor diagram V1 essential')
# Essential version for the final summary automation in the main notebook.
#It contains only the winning prefilter and feature extraction from the development process.
class extdia_v1_essential(extractor_diagram):
def ini_diagram(self): # custom
... |
class Solution(object):
def kidsWithCandies(self, candies, extraCandies):
"""
:type candies: List[int]
:type extraCandies: int
:rtype: List[bool]
"""
max_candies = max(candies)
# out_l = []
# for i in candies:
# if(i + extraCandies >= max_c... |
n = int(input())
sticks = list(map(int, input().split()))
uniq = sorted(set(sticks))
for i in uniq:
print(len([x for x in sticks if x >= i])) |
x = 1
y = 10
if(x == 1):
print("x equals 1")
if(y != 1):
print("y doesn't equal 1")
if(x < y):
print("x is less than y")
elif(x > y):
print("x is greater than y")
else:
print("x equals y")
if (x == 1 and y == 10):
print("Both values true")
if(x < 10):
if (y > 5):
print("x is less th... |
class BackgroundClip(
Property,
):
BorderBox = "border-box"
PaddingBox = "padding-box"
ContentBox = "content-box"
|
'''
config file
'''
n_one_hot_slot = 6 # 0 - user_id, 1 - movie_id, 2 - gender, 3 - age, 4 - occ, 5 - release year
n_mul_hot_slot = 2 # 6 - title (mul-hot), 7 - genres (mul-hot)
max_len_per_slot = 5 # max num of fts in one mul-hot slot
num_csv_col_warm = 17
num_csv_col_w_ngb = 17 + 160 # num of cols in the csv file (... |
first_num_elements, second_num_elements2 = [int(num) for num in input().split()]
first_set = {input() for _ in range(first_num_elements)}
second_set = {input() for _ in range(second_num_elements2)}
print(*first_set.intersection(second_set), sep='\n')
# 4 3
# 1
# 3
# 5
# 7
# 3
# 4
# 5 |
def decode_index(index: int) -> str:
return {0: "ham", 1: "spam"}[index]
def probability_to_index(prediction: list) -> int:
return 0 if prediction[0] > prediction[1] else 1
|
a = []
impar = []
par = []
while True:
n1 = int(input("Digite um valor: "))
a.append(n1)
if n1 % 2 == 0:
par.append(n1)
elif n1 % 2 != 0:
impar.append(n1)
s = str(input("Deseja continuar? [S/N]"))
if s in 'Nn':
break
print(f"Lista geral {a}")
print(f"Lista dos pares {par}... |
# Рекурсивные функции
print(' Рекурсивные функции ')
print('factorial методом пекурсивной функции')
def fact(num):
if num == 0:
return 1
else:
return num * fact(num - 1)
print(fact(10))
print()
# То же самое, но В ЦИКЛЕ
print(' То же самое, но ... |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def findTilt(self, root):
def travel(node, tiles):
if node is None:
return 0
... |
class Triangle:
def __init__(self,a,b,c):
self.a=a
self.b=b
self.c=c
def is_valid(self):
if (self.a+self.b>self.c) and (self.a+self.c>self.b) and (self.b+self.c>self.a):
return 'Valid'
else:
return 'Invalid'
def Side_Classification(sel... |
def main(app_config=None, q1=0, q2=2):
some_var = {'key': 'value'}
if q1 > 9:
return {
"dict_return": 1,
}
return some_var
if __name__ == "__main__":
main()
|
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Copyright (c) 2002-2018 "Neo Technology,"
# Network Engine for Objects in Lund AB [http://neotechnology.com]
#
# This file is part of Neo4j.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Li... |
#Implemnting queue ADT using singly linked list
class LinkedQueue:
"""FIFO queue implementation using a singly linked list for storage"""
class Empty(Exception):
"""Error attempting to access an element from an empty container"""
pass
class _Node:
"""Lightweight, nonpublic class... |
# -*- coding: utf-8 -*-
"""
Created on Fri May 29 10:48:30 2020
@author: Tim
"""
n = 1000
count = 0
for i in range(n):
for j in range(n):
for k in range(n):
if i < j and j < k:
count += 1
print(count) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
def isSymmetric(self, root: TreeNode) -> bool:
"""
function to determine if the provided TreeNode is the root
of a symmetric binary tree
"""
... |
# Python3 program to find the numbers
# of non negative integral solutions
# return number of non negative
# integral solutions
def countSolutions(n, val,indent):
print(indent+"countSolutions(",n,val,")")
# initialize total = 0
total = 0
# Base Case if n = 1 and val >= 0
# then it shoul... |
# -*- coding: utf-8 -*-
DATABASE_MAPPING = {
'database_list': {
'resource': 'database/',
'docs': '',
'methods': ['GET'],
},
'database_get': {
'resource': 'database/{id}/',
'docs': '',
'methods': ['GET'],
},
'database_create': {
'resource': 'da... |
def is_abundant(number):
mysum = 1 # Can always divide by 1, so start looking at divisor 2
for divisor in range(2, int(round(number / 2 + 1))):
if number % divisor == 0:
mysum += divisor
if mysum > number:
return True
else:
return False
|
# Copyright European Organization for Nuclear Research (CERN)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - Muhammad Aditya Hilmy... |
class OAuthError(Exception):
"""Base class for OAuth errors"""
pass
class OAuthStateMismatchError(OAuthError):
pass
class OAuthCannotDisconnectError(OAuthError):
pass
class OAuthUserAlreadyExistsError(OAuthError):
pass
|
def ispow2(n):
'''
True if n is a power of 2, False otherwise
>>> ispow2(5)
False
>>> ispow2(4)
True
'''
return (n & (n-1)) == 0
def nextpow2(n):
'''
Given n, return the nearest power of two that is >= n
>>> nextpow2(1)
1
>>> nextpow2(2)
2
>>> nextpow2(5)
... |
# Complete the fibonacciModified function below.
def fibonacciModified(t1, t2, n):
term = 3
while term <= n:
actual_number = t1 + t2**2
t1 = t2
t2 = actual_number
term += 1
return actual_number
|
a=1;
b=2;
c=a+b;
print("hello world")
121213 |
name = input()
age = int(input())
while name != 'Anton':
print(name)
name = input()
age = input()
print(f'I am Anton') |
class Task(object):
def __init__(self, name, description="", task_id=None):
self.id = task_id
self.name = name
self.description = description
def serialize(self):
return {
"id": self.id,
"name": self.name,
"description": self.d... |
# -*- coding: utf-8 -*-
_available_examples = ["ex_001_Molecule_Hamiltonian.py",
"ex_002_Molecule_Aggregate.py",
"ex_003_CorrFcnSpectDens.py",
"ex_004_SpectDensDatabase.py",
"ex_005_UnitsManagementHamiltonian.py",
... |
def recursive_multiply(x, y):
if (x < y):
return recursive_multiply(y, x)
elif (y != 0):
return (x + recursive_multiply(x, y-1))
else:
return 0
x = int(input("Enter x"))
y = int(input("Enter y"))
print(recursive_multiply(x, y)) |
DEFAULT_STACK_SIZE = 8
class PcStack(object):
def __init__(self, programCounter, size: int=DEFAULT_STACK_SIZE):
self._programCounter = programCounter
self._size = size
self._stack = [0]*size
self._stackPointer = 0
@property
def programCounter(self):
return self._p... |
# -*- coding: utf-8 -*-
"""
File Name: kthLargest.py
Author : jynnezhang
Date: 2020/4/30 10:02 上午
Description:
二叉搜索树的第k大节点
https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/
"""
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
... |
# -*- coding: utf-8 -*-
user_schema = {
'username': {
'type': 'string',
'minlength': 1,
'maxlength': 64,
'required': True,
'unique': True
},
'email': {
'type': 'string',
'regex': '^\S+@\S+.\S+',
'required': True,
'unique': True
},
... |
'''
https://www.geeksforgeeks.org/find-count-number-given-string-present-2d-character-array/
Given a 2-Dimensional character array and a string, we need to find the given string in 2-dimensional character array such that individual characters can be present left to right, right to left, top to down or down to top.
Exa... |
#
# PHASE: jvm flags
#
# DOCUMENT THIS
#
def phase_jvm_flags(ctx, p):
if ctx.attr.tests_from:
archives = _get_test_archive_jars(ctx, ctx.attr.tests_from)
else:
archives = p.compile.merged_provider.runtime_output_jars
serialized_archives = _serialize_archives_short_path(archives)
test_su... |
METADATA = 'metadata'
CONTENT = 'content'
FILENAME = 'filename'
PARAM_CREATION_DATE = '_audit_creation_date'
PARAM_R1 = '_diffrn_reflns_av_R_equivalents'
PARAM_SIGMI_NETI = '_diffrn_reflns_av_sigmaI/netI'
PARAM_COMPLETENESS = '_reflns_odcompleteness_completeness'
PARAM_SPACEGROUP = '_space_group_name_H-M_alt'
PARAM_SP... |
class cves():
cve_url = "https://services.nvd.nist.gov/rest/json/cves/1.0?pubStartDate=2021-09-01T00:00:00:000+UTC-00:00&resultsPerPage=100&keyword="
keywords = ["RHCS", "RHEL", "Thales", "nShield", "Certificate+Authority&isExactMatch=true", "NSS", "tomcat", "TLS"]
|
class SingleMethods:
def __init__(self,
finished_reports_dictionary,
single_reports_dictionary,
sample_data,
latex_header_and_sample_list_dictionary,
loq_dictionary
):
self.finished_reports_dictionary = fi... |
#!/usr/local/bin/python3
class Object(object):
def __init__(self, id):
self.id = id
self.children = []
root = Object("COM")
objects = {"COM": root}
def get_object(id):
if id not in objects:
objects[id] = Object(id)
return objects[id]
with open("input.txt") as f:
for line in f... |
begin_unit
comment|'# Copyright (c) 2013 Intel, Inc.'
nl|'\n'
comment|'# Copyright (c) 2012 OpenStack Foundation'
nl|'\n'
comment|'# All Rights Reserved.'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'# not use this file except in ... |
#!/usr/bin/env python
"""
https://leetcode.com/problems/plus-one/description/
Created on 2018-11-14
@author: 'Jiezhi.G@gmail.com'
Reference:
"""
class Solution:
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
l = len(digits) - 1
while... |
key = {'f':'l', 'd': 'l','j':'r', 'k':'r'}
words = {}
for _ in range(int(input())):
n = int(input())
for _ in range(n):
s = input()
if words.get(s): words[s] += 1
else : words[s] = 1
# print(words)
final_ans = 0
for i in words:
c_word_ans = 0.2
pre = key[i[0]]
for j in i[1::]:
if(key[j] == pre):c_wo... |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
class PotentialEdgeColumnPair:
def __init__(self, source, destination, score):
self._source = source
self._destination = destination
self._score = score
def source(self):
return self._source
def dest... |
class ModelOutput:
# Class that defines model output structure
def __init__(self, arg_type, arg_size, is_spacial):
self.arg_type = arg_type
self.arg_size = arg_size
self.is_spacial = is_spacial
|
class DateGetter:
'''Parse a date using the datetime format string defined in
the current jxn's config.
'''
def _get_date(self, label_text):
fmt = self.get_config_value('datetime_format')
text = self.get_field_text(label_text)
if text is not None:
dt = datetime.strpti... |
# Crie um programa que leia vários números inteiros pelo teclado.
# o programa só vai parar quando o usuário digitar o valor 999.
# no final mostre quantos números foram digitados e a soma entre eles, desconsiderando o flag
'''Somar todos os valores digitados, exceto o 999'''
n = soma = c = 0
while n != 999:
soma... |
n = int(input())
alph = ["A",'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','Q','X','Y','Z']
boxes = []
for x in range(n):
box = []
length = int(input())
for y in range(length):
box.append([])
for i in range(length):
box[y].append("... |
PROCESS_CREATE = 0
PROCESS_EDIT = 1
PROCESS_VIEW = 2
PROCESS_DELETE = 3
PROCESS_EDIT_DELETE = 4 # Edit with delete button
PROCESS_VIEW_EDIT = 5 # View with edit button
PERMISSION_DISABLE = 2
PERMISSION_ON = 1
PERMISSION_OFF = 0
PERMISSION_AUTHENTICATED = 3
PERMISSION_STAFF = 4
PERMISSION_METHOD = 5
class P... |
# Copyright (c) 2020 Greg Dubicki
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# See the License for the specific language governing permissions and
# limitations under the License.
#
# MIT License
#
# Copyright (c) 2018 Shane ... |
def solution(clothes):
answer = {}
for i in clothes:
if i[1] in answer: answer[i[1]]+=1
else: answer[i[1]] = 1
cnt = 1
for i in answer.values():
cnt *= (i+1)
return cnt - 1 |
# Request Link and Long Polling Use
TELEGRAM_TOKEN = ''
WEBHOOK_URL = ''
TELEGRAM_BASE = f'https://api.telegram.org/bot{TELEGRAM_TOKEN}'
TELEGRAM_WEBHOOK_URL = TELEGRAM_BASE + f'/setWebhook?url={WEBHOOK_URL}/hook'
FUGLE_API_TOKEN = ''
# Other Chatbot Token
EXAMPLE_TOKEN = ''
# WEBHOOK_URL = ''
|
# Speed Fine Problem
# input
limit = int(input('Enter the speed limit: '))
speed = int(input('Enter the recorded speed of the car: '))
# processing & output
if speed <= limit:
print('Congratulations, you are within the speed limit!')
else:
difference = speed - limit
if difference > 30:
print('You ... |
# coding=utf-8
"""
Data Integration
"""
__author__ = 'Seray Beser'
__copyright__ = 'Copyright 2018 Seray Beser'
__license__ = 'Apache License 2.0'
__version__ = '0.0.1'
__email__ = 'seraybeserr@gmail.com'
__status__ = 'Development'
class DataIntegration(object):
"""
Data Integration
"""
def __init__... |
#
# PySNMP MIB module DEVICE (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DEVICE
# Produced by pysmi-0.3.4 at Mon Apr 29 18:26:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
... |
#Desenvolva um programa que leia o comprimento de 3 retas
#e diga ao usuário se elas podem ou não formar um triângulo.
r1 = float(input('Primeiro segmento: '))
r2 = float(input('Segundo segmento: '))
r3 = float(input('Terceiro segmento: '))
if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r1 + r2:
print('Essas medidas fo... |
# Question
# 17. Write a menu driven program to find the area of circle, square, rectangle & triangle.
# Code
types = ["circle", "square", "rectangle", "triangle"]
print("-"*15) # 15 is length of Area Calculator. not intentional though it was a random rumber
print("Area Calculator")
print("-"*15)
print()
print("Plea... |
"""."""
# import time
# import logging
class SCPI(object):
"""SCPI helper functions."""
@property
def SCPI_OPT(self):
return self.query(':SYSTem:OPTions?').strip('"').split(',')
@property
def SystemErrorQueue(self):
"""Get System Error Queue.
:returns: List of e... |
#######################
# Login configuration #
#######################
weblab_db_username = 'weblab'
weblab_db_password = 'weblab'
########################################
# User Processing Server configuration #
########################################
core_session_type = 'Memory'
core_coordinator_db_username = '... |
# DomirScire
def get_final_line(filename):
final_line = ''
for current_line in open(filename):
final_line = current_line
return final_line
if __name__ == "__main__":
print(get_final_line('./'))
|
class MockArgs(object):
"""Mock for command line args."""
def __init__(self, **kwargs):
self.doctype = kwargs.get('doctype')
self.output = kwargs.get('output')
self.path = kwargs.get('path')
class NameOptions(object):
"""Mock of configurable names."""
def __init__(self):
... |
# Indo de um número para outro na ordem decrescente.
num = int(input('Digite um número: '))
for c in range(0, num + 1):
print(c)
print('FIM') |
class Solution(object):
def sortColors(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
if not nums:
return None
redcount=0
whilecount=0
bluecount=0
for num in nu... |
class Solution:
def makeString(self, s: str) -> str:
result = []
for c in s:
if c != '#':
result.append(c)
elif len(result) > 0:
result.pop()
return str(result)
def backspaceCompare(self, s: str, t: str) -> bool:
return sel... |
# Get frequencies of attributes
def get_frequencies(plant_dict):
frequencies = {} # First keep count of how many times an attribute appears
count = 0 # Keep track of the number of plants
for plant in plant_dict:
plant_attributes = set() # Don't count duplicate attributes (such as a flower having... |
squares = []
for value in range(1,11):
squares.append(value **2)
print(squares)
digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
print(min(digits))
print(max(digits))
print(sum(digits))
squares = [value**2 for value in range(1,11)]
print(squares)
odd_numbers = list(range(1,20,1))
print(odd_numbers)
cars = ['audi', 'bmw... |
# Stub only, D support was broken with Python2.6 and unnecessary to Nuitka
def generate(env):
return
def exists(env):
return False
|
class Base:
def __init__(self, x=0):
self.x = x
class Slave(Base):
def __init__(self, x):
super(Slave, self).__init__()
self.x = x
s1 = Slave(x=2)
print(s1.x) |
def strStr(haystack: str, needle: str) -> int:
i = 0
j = 0
len1 = len(haystack)
len2 = len(needle)
while i < len1 and j < len2:
if haystack[i] == needle[j]:
i += 1
j += 1
else:
i = i - (j - 1)
j = 0
if j == len2:
return i-j
else:
return -1
print(strStr("abcdeabc", "bcd")) |
#!/usr/bin/env python3
# coding:utf-8
def getCommonDivisor(m, d):
while d:
m, d = d, m%d
return m
def calc(m, d):
if d == 0:
return "X -- ZeroDivisionError"
elif m == 0:
return '0'
elif m == d:
return '1'
com_div = getCommonDivisor(m, d)
return str(m//com... |
'''
Program to count number of trees in a forest.
Approach:
The idea is to apply Depth First Search on every node.
If every connected node is visited from one source then increment count by one.
If some nodes yet not visited again perform DFS traversal.
Return the count.
Example:
Input : edges[] = {0, 1}, {0, ... |
def reverseInput(word):
# str[start:stop:step]
return word[::-1]
def reverseInput2(word):
new_word = ""
for char in word:
new_word = char + new_word
return new_word
if __name__ == "__main__":
word = input("Enter the word: ")
print(reverseInput(word))
print(reverseInput2(word)... |
'''
In a N x N grid representing a field of cherries, each cell is one of three possible integers.
0 means the cell is empty, so you can pass through;
1 means the cell contains a cherry, that you can pick up and pass through;
-1 means the cell contains a thorn that blocks your way.
Your task is to collect maximu... |
EXAMPLE = '''\
|+1|-1|+2|-2|+3|-3|+sg|+pl|-sg|-pl|
1sg| X| | | X| | X| X| | | X|
1pl| X| | | X| | X| | X| X| |
2sg| | X| X| | | X| X| | | X|
2pl| | X| X| | | X| | X| X| |
3sg| | X| | X| X| | X| | | X|
3pl| | X| | X| X| | | X| X| |
'''
|
class Solution:
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
roman = 'MDCLXVI'
romandiv = [1000, 500, 100, 50, 10, 5, 1]
ans = ''
strnum = str(num)
i = 6 - (len(strnum) - 1) * 2
for c in strnum:
if c == ... |
def is_valid_row_col(next_r, next_c):
if 0 <= next_r < 8 and 0 <= next_c < 8:
return True
return False
matrix = []
queens = []
for _ in range(8):
data = input().split(" ")
matrix.append(data)
row_king = int
col_king = int
for row in range(8):
for column in range(8):
if matrix[ro... |
# O(n) time and O(log n) space
def max_path_sum(tree):
_, max_path_sum = max_path_sum_helper(tree)
return max_path_sum
def max_path_sum_helper(tree):
if not tree:
# Base case of not a node
return (0, 0)
# Depth first bottom up approach to calculate the max path sum
left_branch_sum,... |
"""
Mouse Press.
Saves one PDF of the contents of the display window
each time the mouse is pressed.
"""
add_library('pdf')
saveOneFrame = False
def setup():
size(600, 600)
frameRate(24)
def draw():
global saveOneFrame
if saveOneFrame:
beginRecord(PDF, "Line.pdf")
background(255)
... |
#!/usr/bin/env python
# encoding: utf-8
'''
@author: Jason Lee
@license: (C) Copyright @ Jason Lee
@contact: jiansenll@163.com
@file: jianzhi_offer_63_2.py
@time: 2019/4/24 15:13
@desc:
'''
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class... |
#
# PySNMP MIB module SW-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:36:37 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
... |
text = '''aaaaaa aaaaaa aaaa aaaa a aa aa a aa0
bbbbbb bbbbbb bbbbbbbbbb.ccc ccccc c0
dddd ddddd ddddd.eeeee eeeeeee.fffff0
fffff fff ffffff.ggg ggg gg g.eeefaa0.'''
lines = list(text.split('\n'))
words = list(text.split(' '))
sentenses = list(text.split('.'))
print(len(lines), lines, '\n')
print(len(words), words, '... |
class BinaryTree:
def __init__(self, rootValue):
self.value = rootValue
self.left = None
self.right = None
def addLeftChild(self, val):
newNode = BinaryTree(val)
self.left = newNode
def addRightChild(self, val):
newNode = BinaryTree(val)
self.right... |
#!/usr/bin/env python
"""Args, Kwargs"""
__author__ = "Petar Stoyanov"
def main(*args, **kwargs):
"""Docstring"""
for arg in args:
print(arg)
for (key, value) in kwargs.items():
print("{} - {}".format(key, value))
if __name__ == '__main__':
main(1, 2, 3, name='pesho', age=30)
|
#a = 3
#b = 4
#c = a ** b
#print (c)
#x = 5
#print(x)
#x = 5
#x += 3
#
#print(x)
#x = 5
#x -= 3
#
#print(x)
#x = 5
#x *= 3
#print(x)
#x = 5
#x /= 3
#print(x)
#x = 5
#x%=3
#print(x)
# comparisin opperraters
#x = 5
#y = 3
#
#print(x == y)
#
# returns False because 5 is not equal to 3
#x = 5
#y = 3
... |
fruit = ["apple", "banana", "peach"]
fruit
# outputs
# >>> ['apple', 'banana', 'peach']
|
#!/usr/bin/env python
#--- Day 6: Universal Orbit Map ---
#You've landed at the Universal Orbit Map facility on Mercury. Because navigation in space often involves transferring between orbits, the orbit maps here are useful for finding efficient routes between, for example, you and Santa. You download a map of the loc... |
"""
Classes which create external representations of core objects. This allows
the core objects to remain decoupled from the API and clients. These classes
act as an adapter between the data format api clients expect, and the internal
data of an object.
"""
|
def line(char='-', size=40):
print(char * size)
def title(text=''):
line()
print(f'{text.upper():^40}')
line()
def section(title='', paragraph='', size=40, char='-'):
"""
AINDA PRECISA TERMINAR ESSA MERDA
:param title:
:param paragraph:
:param size:
:param char:
:return:
... |
def print_name(prefix):
print("searchingname with" + prefix)
try:
while True:
name = (yield)
if prefix in name:
print(name)
except GeneratorExit as identifier:
print("Coroutine Exited")
corou = print_name("Dear")
corou.__next__()
corou.send("Atul")... |
n = int(input())
s = [1 if element == 'U' else -1 for element in input()]
counter = 0
status = 0
step = 0
while step < n:
if status == 0 and s[step] == -1:
status = 1
start_pt = step
step += 1
sum_val = -1
while step < n and status != 0:
sum_val += s[step]
if sum_val == 0:
counter += 1
... |
'''
Author: tusikalanse
Date: 2021-07-10 18:07:33
LastEditTime: 2021-07-10 18:10:07
LastEditors: tusikalanse
Description:
'''
cnt = 0
def gao(i: int) -> int:
for _ in range(50):
i = i + int(str(i)[::-1])
if str(i) == str(i)[::-1]:
return 0
return 1
for i in range(10000):
cnt ... |
# To demonstrate, we insert the number 8 to specify the available space for the value.
# Use "=" to place the plus/minus sign at the left most position:
txt = "The temperature is {:=8} degrees celsius."
print(txt.format(-5))
|
pais=('Alemania', 'Francia','Reino Unido','Italia','España', 'Países Bajos', 'Polonia', 'Bélgica', 'Suecia', 'Austria', 'Grecia','Rumania', 'República Checa', 'Portugal', 'Dinamarca', 'Hungría', 'Irlanda', 'Finlandia',
'Eslovaquia', 'Bulgaria' , 'Lituania', 'Eslovenia', 'Letonia', 'Luxemburgo', 'Estonia', '... |
# Given a sentence, reverse each word in the sentence while keeping the order the same!
# Code
def word_flipper(our_string):
"""
Flip the individual words in a sentence
Args:
our_string(string): String with words to flip
Returns:
string: String with words flipped
"""
split... |
"""
sort and two pointers (twosum2)
"""
class Solution(object):
def threeSum(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
result = []
nums.sort()
for i in range(len(nums)):
if i > 0 and nums[i] == nums[i-1]:
... |
'''
Flask config.
'''
display = {}
CREDS_PATH = "app/creds.txt"
TEMPLATES_AUTO_RELOAD = True |
# equation constants
# gas diffusivity
CONST_EQ_GAS_DIFFUSIVITY = {
"Chapman-Enskog": 1,
"Wilke-Lee": 2
}
# gas viscosity
CONST_EQ_GAS_VISCOSITY = {
"eq1": 1,
"eq2": 2
}
# sherwood number
CONST_EQ_Sh = {
"Frossling": 1,
"Rosner": 2,
"Garner-and-Keey": 3
}
# thermal conductivity
CONST_EQ_... |
#shape of rectangle:
def for_rectangle():
"""printing shape of'rectangle' using for loop"""
for row in range(5):
for col in range(11):
if row in(0,4) or col in(0,10):
print("*",end=" ")
else:
print(" ",end=" ")
print()
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.