content stringlengths 7 1.05M |
|---|
class PiecewiseError(Exception):
"""Base error class for framework."""
def __init__(self, message=""):
self._message = message
def __str__(self):
return self._message
class InternalError(PiecewiseError):
"""Error indicating internal bug or logical flaw, not meant to be raised
unde... |
# Python - 3.6.0
def tickets(people):
moneys = {k: 0 for k in [25, 50, 100]}
for cost in people:
if cost == 50:
if moneys[25] < 1:
return 'NO'
moneys[25] -= 1
elif cost == 100:
if moneys[50] >= 1:
if moneys[25] < 1:
... |
class Error(Exception):
"""Generic error class for invalid wordnet operations."""
# reset the module so the user sees the public name
__module__ = 'wn'
class Warning(Warning):
"""Generic warning class for dubious worndet operations."""
# reset the module so the user sees the public name
__m... |
def calculate_age(year_of_birth: int, current_year: int) -> str:
"""Year report depending on year of birth and current year."""
def year_str(y:int) -> str:
return "1 year" if y == 1 else str(y)+" years"
delta = current_year - year_of_birth
if delta == 0:
return "You were born this very y... |
LANGS = ["hi,my,fa,tk,vi,zh,ka,zh_yue,hy,ru", "hi,my,fa,vi,zh,tk,zh_yue,ru,bxr,cdo", "hi,my,fa,vi,tk,jv,zh_yue,id,zh,am", "is,en,se,et,fi,fr,kv,cs,de,eu", "et,lv,fi,en,se,cs,de,fr,is,hu", "cs,en,de,fr,lv,et,hu,fi,la,eu", "lv,et,cs,hu,de,el,fi,myv,mhr,tr", "hu,el,cs,de,lv,tr,la,et,xmf,myv", "el,hu,tr,la,cs,de,xmf,lv,hy,... |
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
left = 0
right = x
while left <= right:
middle = (left + right) / 2
sqrt = middle * middle
if x == sqrt:
return middle
... |
a = [-11, -2, -4, -10, -9, 4, -5, -18, -16, 5, -6, -19, 0, -7, 11, -17, 11, 9, -7, -11, 19, -16, -11, -4, 19,
-6, -6, -15, 1, 11, -1, -16, 12, 0, -15, -13, 11, -19, -15, -18, -20, 7, -8, 17, -4, 16, 6, -5, -3, -8, 17, -2, 2, 1, -2, 19, -6, 13, -7, -8, 9, -13, 4, -19, -4, 20, 20, -10, 9, 13, 18, 15, -15, -16, 20, 15, 1... |
BASE_STATS = {
1: {
"Monster": {"HP": 7, "Attack": 5, "Defence": 5, "Scaling": 0.05},
"Player": {"HP": 5, "Attack": 2, "Defence": 2},
},
30: {
"Monster": {"HP": 15, "Attack": 10, "Defence": 10, "Scaling": 0.1},
"Player": {"HP": 9, "Attack": 6, "Defence": 5},
},
60: {
... |
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
'''
T: O(m * n) and S: O(1)
'''
if not matrix: return
n = len(matrix)
i, j = 0, n - 1
while i < ... |
# Atharv Kolhar
# Python Bytes
"""
Questions:
1. Create a Set of even numbers up to 20.
2. Create another list of number multiple of 3 up to 30
3. Find Intersection, Union, and Difference between the above two sets
4. Declare an Empty set and add the first 4 prime numbers to it.
""" |
# Sum vs XOR
# https://www.hackerrank.com/challenges/sum-vs-xor/problem
def sumXor(n):
if n == 0:
return 1
return 1 << f'{n:b}'.count('0')
n = int(input().strip())
result = sumXor(n)
print (result) |
##################################################################
# Mocked returns for patched functions that access web resources #
##################################################################
GET_POLICE_STATION_API_MOCK = {
"displayFieldName": "NAME",
"fieldAliases": {
"OBJECTID": "OBJECTID",... |
#https://www.hackerrank.com/contests/w35/challenges/lucky-purchase/problem
books= {} ;
n= int(input()) ;
for a0 in range(n):
string = input().split() ;
books[string[0]] = string[1] ;
books = list(books.items()) ;
mini = books[0] ;
for pair in books:
if pair[1].count('7')+pair[1].count('4')!=len(pair[1]):... |
dados = {}
dados['Nome'] = input('Nome: ')
dados['Média'] = float(input(f'Média de {dados["Nome"]}: '))
print(f'O nome é igual a {dados["Nome"]}')
print(f'A média é igual a {dados["Média"]}')
if dados['Média'] >= 7:
print('APROVADO!!!!')
else:
print('REPROVADO!!!') |
n = int(input("_gram? - "))
s = input("words: ")
grams = []
for i in range(len(s)):
op = ""
for x in range(i, i + n):
if x >= len(s):
op = ""
break
op += s[x]
if op != "":
grams.append(op)
print(op)
grams.sort()
print(grams)
|
VERSION = '0.1.6b0'
ENV_LIST = ['clustering-v0', 'clustering-v1',
'clustering-v2', 'clustering-v3', 'classification-v0']
|
# Solution A
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
prev = None
cur = head
while cur:
tmp = cur.next
... |
a=[2, 3, 5, 7]
print(a)
a.reverse()
print(a)
|
'''
Universidade Federal de Pernambuco (UFPE) (http://www.ufpe.br)
Centro de Informática (CIn) (http://www.cin.ufpe.br)
Graduando em Sistemas de Informação
IF968 - Programação 1
Autor: Antônio Paulino de Lima Neto (apln2); Gustavo Pimentel Fernandes de Melo (gpfm)
Email: {apln2, gpfm}[at]cin[dot]ufpe[dot]br
Da... |
# Copyright (C) 2018 O.S. Systems Software LTDA.
"""
This is the updatehub agent package SDK for the Python language. With this
package it's possible to access information about a running updatehub agent,
such as current states, log information and also force a new version probe.
For more information please access htt... |
def binarySearch(arr, x, left, right):
if right <= left:
if right + 1 <= len(arr):
return right + 1
return -1
mid = (left + right) // 2
if x <= arr[mid]:
return binarySearch(arr, x, left, mid)
else:
return binarySearch(arr, x, mid + 1, right)
def read_input(... |
river = {
'nile': 'egypt',
'huang': 'china',
'mississippi':'USA'
}
for key, value in river.items():
print("The " + key + "runs through " + value +".")
for name in (river.keys()):
print(name)
for country in (river.values()):
print(country) |
# coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.
"""
This package provides the packages and modules to perform IO from various
input file formats and pymatgen objects.
"""
|
# (C) Datadog, Inc. 2022-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__version__ = '1.1.0'
|
def printList():
li=list()
for i in range(1,21):
li.append(i**2)
print(li)
printList() |
def count_substring(string, sub_string):
res = 0
len_sub = len(sub_string)
for i in range(len(string) - len_sub + 1):
if string[i:i + len_sub] == sub_string:
res += 1
i += 1
return res
|
class shell_colors(object):
"""
Short hand for shell colors
"""
magenta = "\033[95m"
cyan = "\033[94m"
green = "\033[92m"
warn = "\033[93m"
err = "\033[91m"
end = "\033[0m"
bold = "\033[1m"
undeline = "\033[4m" |
name = "hyperparameter"
"""
The hyperparameter module
"""
|
"""19_sum_of_squares_of_first_n_natural_numbers.py."""
print("---- Sum of Squares of first n Natural numbers ----")
print("TODO")
|
_base_="../base-ucmerced-config-simpleaug.py"
# this will merge with the parent
model=dict(pretrained='data/basetrain_chkpts/moco_v2_800ep.pth')
# epoch related
total_iters=5000
checkpoint_config = dict(interval=total_iters)
model = dict(
pretrained='data/basetrain_chkpts/moco_v2_800ep.pth',
backbone=dict(
n... |
def finferensi(berat, pinjam, harga):
linguistik = []
derajat = []
for bk, bv in berat.items():
for pk, pv in pinjam.items():
for hk, hv in harga.items():
# rule 1
if bk == 'ringan' and pk == 'sebentar' and hk == 'rendah':
lingui... |
# Booknames.py
class Booknames:
def usfmBookId(self, bookName):
books = {
'Genesis': 'GEN',
'Exodus': 'EXO',
'Leviticus': 'LEV',
'Numbers': 'NUM',
'Deuteronomy': 'DEU',
'Joshua': 'JOS',
'Judges': 'JDG',
'Ruth': 'RUT',
'1Samuel': '1SA',
'2Samuel': '2SA',
'1... |
class Blocktype(basestring):
"""
32-bit|64-bit
Possible values:
<ul>
<li> "32_bit" ,
<li> "64_bit"
</ul>
"""
@staticmethod
def get_api_name():
return "blocktype"
|
# pylint: disable=missing-function-docstring, missing-module-docstring/
a = 4
a += 5.0
|
# encoding: utf-8
class FastCGIError(Exception):
pass
# Values for type component of FCGI_Header
FCGI_BEGIN_REQUEST = 1
FCGI_ABORT_REQUEST = 2
FCGI_END_REQUEST = 3
FCGI_PARAMS = 4
FCGI_STDIN = 5
FCGI_STDOUT = 6
FCGI_STDERR = 7
FCGI_DATA = 8
FCGI_GET_VALUES = 9
F... |
match x:
case Class( ):
pass
case Class( foo=1 ):
pass
case Class( foo=1, bar=2 ):
pass
case Class( foo=1, bar=2, ):
pass
|
def deep_flatten(in_list):
out_list = []
for i in in_list:
if type(i) == str:
out_list.append(i)
elif hasattr(i,'__iter__'):
out_list.extend(deep_flatten(i))
else:
out_list.append(i)
return out_list
a = [(1,2),3,4,5,[4,4,5,6]]
a = [['cats', ['car... |
"""Arcs BUILD rules."""
load(
"//third_party/bazel_rules/rules_kotlin/kotlin/js:js_library.bzl",
_kt_js_library = "kt_js_library",
)
load(
"//third_party/java/arcs/build_defs/internal:kotlin.bzl",
_arcs_kt_android_library = "arcs_kt_android_library",
_arcs_kt_android_test_suite = "arcs_kt_android_t... |
"""
This file is just for exporting stuffs :)
"""
def my_decorator(f):
return f
@my_decorator
def exported_func(abc: str, b: str = ", World!") -> str:
"""This is the
docstring from
an exported function
:param abc: Describing cool parameter `abc`
"""
return abc + b
class ExportedClass:
... |
# Default constants
DF_ADSB = 17
LAT_REF = 44.807047 # TODO put reference values
LONG_REF = -0.605526
NZ=15
# Default variables
fe=20*10**6; Te=1/fe
Ds=1*10**6; Ts=1/Ds
Fse=int(round(Ts/Te))
Ns=112 # Number of points of the signal : 1000, 112
Nfft=512 # Number of points of FFT
# Default TEB parameters
SIG_NB_ERROR... |
# names of hurricanes
names = ['Cuba I', 'San Felipe II Okeechobee', 'Bahamas', 'Cuba II', 'CubaBrownsville', 'Tampico', 'Labor Day', 'New England', 'Carol', 'Janet', 'Carla', 'Hattie', 'Beulah', 'Camille', 'Edith', 'Anita', 'David', 'Allen', 'Gilbert', 'Hugo', 'Andrew', 'Mitch', 'Isabel', 'Ivan', 'Emily', 'Katrina', ... |
alien_0 = {'color': 'green', 'points': 5}
alien_1 = {'color': 'yellow', 'points': 10}
alien_2 = {'color': 'red', 'points': 15}
aliens = [alien_0, alien_1, alien_2]
for alien in aliens:
print(alien)
print('...')
aliens = []
for alien_number in range(30):
new_alien = {'color': 'green', 'points': 5, 'speed': '... |
# THE WINTER IS COMING! the old driver will be driving who was a man of the world!
# -*- coding: utf-8 -*- python 3.6.7, create time is 18-11-30 下午6:19 GMT+8
DEFAULT_LOG_FILENAME = '日志.log' # 日志文件名称
# 启用的爬虫类
SPIDERS = [
'spiders.baidu.BaiduSpider',
'spiders.douban.DoubanSpider'
]
# 启用的管道类
PIPELINES = [
... |
class Node:
def __init__(self, data):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.head = None
self.tail = None
def enqueue(self, value):
new_node = Node(value)
if self.is_empty():
self.head = new_node
self... |
n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro número: '))
if n1 > n2:
print('O PRIMEIRO número é o maior.')
elif n1 < n2:
print ('O SEGUNDO número é o maior.')
else:
print ('O dois números são IGUAIS.') |
#!/usr/bin/env python3
with open("day-1/data") as f:
expenses = f.readlines()
founditems = []
def accounting(i):
for j in expenses:
j = int(j.strip('\n'))
for x in expenses:
x = int(x.strip('\n'))
if i + j + x == 2020 and i * j * x not in founditems:
pri... |
class Command(object):
CONTINUE = 1
SKIP_REMAINING = 2
def __init__(self, args=None, explicit=False):
self.explicit = explicit
self._args = args or []
@property
def args(self):
return self._args
def add_argument(self, arg):
self._args.append(arg)
def cmdli... |
# -*- coding: utf-8 -*-
"""
Created on Mar 23 11:57 2017
@author: Denis Tome'
"""
__all__ = [
'VISIBLE_PART',
'MIN_NUM_JOINTS',
'CENTER_TR',
'SIGMA',
'STRIDE',
'SIGMA_CENTER',
'INPUT_SIZE',
'OUTPUT_SIZE',
'NUM_JOINTS',
'NUM_OUTPUT',
'H36M_NUM_JOINTS',
'JOINT_DRAW_SIZE',... |
class SGD:
"""
Implements vanilla SGD update
"""
def update(self, w, d_w, learning_rate):
"""
Performs SGD update
Arguments:
w, np array - weights
d_w, np array, same shape as w - gradient
learning_rate, float - learning rate
Returns:
up... |
Desc = cellDescClass("DFFNSRX4")
Desc.properties["cell_footprint"] = "dffnsr"
Desc.properties["area"] = "116.424000"
Desc.properties["cell_leakage_power"] = "3723.759540"
Desc.pinOrder = ['CKN', 'D', 'IQ', 'IQN', 'Q', 'QN', 'RN', 'SN', 'next']
Desc.add_arc("CKN","D","setup_falling")
Desc.add_arc("CKN","D","hold_falling... |
class AbstractProvider(object):
"""Delegate class to provide requirement interface for the resolver."""
def identify(self, requirement_or_candidate):
"""Given a requirement, return an identifier for it.
This is used to identify a requirement, e.g. whether two requirements
should... |
def _is_socket(path): # -S
if not path:
return False
if hasattr(path, '_mode'):
return stat.S_ISSOCK(path._mode)
if hasattr(path, 'fileno') and os.stat in os.supports_fd:
path = path.fileno()
elif hasattr(path, 'name'):
path = path.name
return stat.S... |
"""
This package contains both data models related to points of interest (POIs):
:class:`~cms.models.pois.poi.POI` and
:class:`~cms.models.pois.poi_translation.POITranslation`.
POIs can be used to store information which is relevant for one specific location, e.g. a place where local authorities
offer a public service.... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @author: yewennuan
# @Mail: ywnjohu@gmail.com
# @date: 2020/7/24 15:13
class ResponseCode(object):
# 特殊状态码 0-99
# 请求成功
SUCCESS = 0
# 请求失败
FAIL = 1
# 未知错误
UNKNOWN_ERROR = 4
# 服务器内部错误
INTERNAL_ERROR = 5
# 数据库错误
DATABASE_ERROR ... |
#!/usr/bin/env python3
# Write a program that prints the reverse-complement of a DNA sequence
# You must use a loop and conditional
dna = 'ACTGAAAAAAAAAAA'
anti = ""
for i in range(len(dna)):
if dna[i] == 'A': anti += 'T'
elif dna[i] == 'T': anti += 'A'
elif dna[i] == 'C': anti += 'G'
else: anti ... |
"""
Write a modified version of the Matrix class(that was defined in
one of the example problems in this section) with an __add__
operation as well as a __sub__ operation. It should add matrices,
assuming that they will be of the same length. Also, the unmodified
Matrix class code will be given.
"""
"""
This is the un... |
num1 = 10
num2 = int(input())
def add_sum():
sum = num1+num2
print(sum)
add_sum()
|
class ConsoleCommandFailed(Exception):
pass
class ConvergeFailed(Exception):
pass
|
class Overflow(
Enum,
CascadeProperty,
):
Visible = "visible" # initial
Hidden = "hidden"
Scroll = "scroll"
Auto = "auto"
|
def Y_S(a):
if a == 0:
return 0
else:
ys = (a//30) * 10 + 10
return ys
def M_S(b):
if b == 0:
return 0
else:
ms = (b//60) * 15 + 15
return ms
N=int(input())
ms_add = 0
ys_add = 0
arr = list(map(int,input().split()))
for i in arr:
Y = Y_S(i)
M = M_S... |
"""79. Word Search"""
class Solution(object):
def exist(self, board, word):
"""
:type board: List[List[str]]
:type word: str
:rtype: bool
"""
# R2:
if not word:
return True
if not board:
return False
m = len(board)
... |
"""
File: hailstone.py
Name:
-----------------------
This program should implement a console program that simulates
the execution of the Hailstone sequence, defined by Douglas
Hofstadter. Output format should match what is shown in the sample
run in the Assignment 2 Handout.
"""
def main():
"""
1. judge wheth... |
animals = ['bear', 'python3.8', 'peacock', 'kangaroo', 'whale', 'platypus']
print("The animal at 1: ", animals[1]) # Python3.8
print("The third animal: ", animals[2]) # Peacock
print("The first animal: ", animals[0]) # bear
print("The animal at 3: ", animals[3]) # kangaroo
print("The fifth (5th) animal: ", animals... |
#######################
# Dennis MUD #
# rename_item.py #
# Copyright 2018-2020 #
# Michael D. Reiley #
#######################
# **********
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal i... |
class User:
def __init__(self, reddit_id, username, karma, relevant_comments, relevant_posts):
self.reddit_id = reddit_id
self.username = username
self.karma = karma
self.score = 0
self.relevant_comments = relevant_comments
self.relevant_posts = relevant_posts
|
def get_longest_word(line: str) -> str:
# Здесь реализация вашего решения
# lines = line.split(' ')
return max(line.split(' '), key=len)
def read_input() -> str:
_ = input()
line = input().strip()
return line
def print_result(result: str) -> None:
print(result)
print(len(result))
prin... |
# Mathematics > Algebra > Little Gaurav and Sequence
# Help Gaurav in calculating last digit of a sequence.
#
# https://www.hackerrank.com/challenges/little-gaurav-and-sequence/problem
#
def S_brutforce(n):
s = 0
i = 0
while 2 ** i <= n:
for j in range(0, n + 1):
s += 2 ** (2 ** i + 2 ... |
"""The configuration class used for testing using no default values"""
class TestConfig(object): # pylint: disable=too-few-public-methods
"""The configuration class used for testing using no default values"""
AZURE_STORAGE_ACCOUNT = 'TestApplicationAccount'
AZURE_STORAGE_KEY = 'TestApplicationKey'
AZUR... |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 CERN.
#
# invenio-app-ils is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""ILS minters."""
def pid_minter(record_uuid, data, provider_cls):
"""Generic ILS PID minter."""
provid... |
"""Global values for current session"""
testdir = None
settings = {}
|
def solution(answers):
'''
input answers: []
return answer: []
'''
# 가장 많이 맞춘 사람만 , 그러나 동점일때에는 오름차순으로
answer = []
p1 = [1, 2, 3, 4, 5]
p2 = [2, 1, 2, 3, 2, 4, 2, 5]
p3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
counts = [0, 0, 0]
for i in range(len(answers)):
if p1[i % len(p1)]... |
# Solution to Mega Contest 1 Problem: Maximum Sum
for testcase in range(int(input())):
n, k = map(int, input().split())
array_a = list(map(int, input().split()))
array_b = list(map(int, input().split()))
if k>0:
array_a.sort()
array_b.sort()
# max_sum = sum(array_a[k:]+array_b[n... |
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
result = 0
for i in range(N):
if V[i] > C[i]:
result += V[i] - C[i]
print(result)
|
class Hair(object):
def __init__(self, radius):
self.radius = radius
self.phi = random(TAU)
self.slow = random(1.15, 1.2)
self.theta = asin(random(-self.radius, self.radius) / self.radius)
self.z = self.radius * sin(self.theta)
def render(self):
oFF = (noise(mill... |
def dfs(tickets, path, isUsed):
if len(tickets) + 1 == len(path):
print(path)
return path
currAirport = path[-1]
for i in range(len(tickets)):
if isUsed[i]:
continue
fromAirport, toAirport = tickets[i]
if fromAirport == currAirport:
... |
"""Created on Mon Mar 26 14:32:39 2018"""
"""@author: WeiJin"""
total_consumers_d = "Number of consumers in the defined economy"
total_goods_d = "Number of types of goods available in the defined economy"
total_factors_d = "Number of types of factors available in the defined economy"
C_list_d = "An array... |
with open("input.txt") as f:
numbers = list(map(int, f.readline().split()))
def parse_tree_metadata(tree):
num_nodes = tree[0]
num_metadata = tree[1]
leafs = tree[2:]
total = 0
for i in range(num_nodes):
leafs, sum_metadata = parse_tree_metadata(leafs)
total += sum_metadata
... |
class Dough:
def __init__(self, flour_type, baking_technique, weight):
self.__flour_type = flour_type
self.__baking_technique = baking_technique
self.__weight = weight
@property
def flour_type(self):
return self.__flour_type
@flour_type.setter
def flour_type(self, ... |
"""
Returns starting node of the cycle if cycle exists
"""
def has_cycle(head):
fast = slow = head
while fast and fast.next and fast.next.next:
slow, fast = slow.next, fast.next.next
if slow is fast:
slow = head
while slow is not fast:
slow, fast = slow.... |
a, b = 10, 5
print("Add: a+b = ", a+b)
print("Sub: a-b = ", a-b)
print("Mul: a*b = ", a*b)
print("Div: a/b = ", a/b)
print("Mod: a%b = ", a%b)
print("Exp: a**b = ", a**b)
print("Floored Div: a//b = ", a//b) |
'''
189. Rotate Array
Given an array, rotate the array to the right by k steps, where k is non-negative.
Example 1:
Input: [1,2,3,4,5,6,7] and k = 3
Output: [5,6,7,1,2,3,4]
Explanation:
rotate 1 steps to the right: [7,1,2,3,4,5,6]
rotate 2 steps to the right: [6,7,1,2,3,4,5]
rotate 3 steps to the right: [5,6,7,1,2,... |
"""
11170. 0의 개수
작성자: xCrypt0r
언어: Python 3
사용 메모리: 29,380 KB
소요 시간: 2,788 ms
해결 날짜: 2020년 9월 17일
"""
def main():
for _ in range(int(input())):
N, M = map(int, input().split())
count = 0
for i in range(N, M + 1):
count += str(i).count('0')
print(count)
if __name__ ==... |
# Definition for a undirected graph node
# class UndirectedGraphNode:
# def __init__(self, x):
# self.label = x
# self.neighbors = []
class Solution:
# @param node, a undirected graph node
# @return a undirected graph node
def cloneGraph(self, node):
graph = {}
visited =... |
"""
Base config file to provide global settings that should be overwritten with
environment specific values.
"""
# Flask
DEBUG = False
TESTING = False
CSRF_ENABLED = True
SECRET_KEY = ''
# SQL Alchemy
SQLALCHEMY_DATABASE_URI = ''
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
#Assignment 1
print("welcome to the Controlroom of Hyderabad ATC")
Altitude = 1500
if Altitude <= 1000:
print('youre safe to land')
elif Altitude <=5000:
print('Please Bring Down Altitude to 1000')
else :
print('it is Danger now to land, please Turn around')
#Assignment2
for num in range(0,200):
if num > 1:
... |
s="2 3 4 5 66 74 33 2 3"
s=s.split()
s = [int(x) for x in s]
s1=[]
for i in s:
if i not in s1:
s1.append(i)
s1 = sorted(s1)
print(s1)
for i in s1:
print(i,s.count(i))
|
print('This is the dummy Controller')
def dummy_example():
print('This is a function in the dummy Controller')
if __name__ == '__main__':
print('This is printed only from __main__')
dummy_example() |
# Linked list operations in Python
# Create a node
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
# Insert at the beginning
def insertAtBeginning(self, new_data):
new_node =... |
"""
Alias_Map.py
Created by amounra on 2012-12-30.
Copyright (c) 2010 __artisia__. All rights reserved.
This file allows the reassignment of the controls from their default arrangement. The order is from left to right;
Buttons are Note #'s and Faders/Rotaries are Controller #'s
"""
DISABLE_MASTER_VOLUME = False ... |
def add(x, y):
"""Adds x to y"""
# Some comment
return x + y
v = add(1, 7)
print(v)
|
# -*- coding: utf-8 -*-
class BaseCompressor(object):
def __init__(self, options):
self._options = options
def compress(self, value):
raise NotImplementedError
def decompress(self, value):
raise NotImplementedError
|
n = 10
a = []
s = [[0] * n for i in range(n)]
s2 = [[0] * n for i in range(n)]
for i in range(n):
a.append(list(map(int, input().split())))
s[0][0] = a[0][0]
s2[0][0] = a[0][0]
for j in range(1, n):
s[0][j] = s[0][j - 1] + a[0][j]
for i in range(1, n):
s[i][0] = s[i - 1][0] + a[i][0]
for i in range(n):... |
#FUNCTION TEXT
def AddCharA(char,lista,z):
x=0
for y in lista[0]:
if y=="|":
break
else:
x+=1
x+=1
if x==len(lista[0]):
lista[0]=lista[0][:len(lista[0])-1]+char+"|"
elif x==1:
lista[0]=char+lista[0][:]
else:
lista[0]=lista[0][:x-1]+char+lista[0][x-1:]
print(char)
print(lista)
z[0].configure(t... |
"ts_project rule"
load("@rules_nodejs//nodejs:providers.bzl", "DeclarationInfo", "declaration_info", "js_module_info")
load("@build_bazel_rules_nodejs//:providers.bzl", "ExternalNpmPackageInfo", "run_node")
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect")
load(":tslib.... |
""" Node is defined as
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
"""
def checkBST(root):
return(check_in_order(root,[-1]))
def check_in_order(root,prev):
result = True
if root.left is not None:
result &= ... |
_base_ = [
'../_base_/datasets/OxfordPet_bs64.py', '../_base_/default_runtime.py', '../_base_/models/resnet50.py',
]
# load model pretrained on imagenet
model = dict(
backbone=dict(
init_cfg=dict(
type='Pretrained',
checkpoint='https://download.openmmlab.com/mmclassifi... |
def quick_sort(arr,low,high):
if len(arr) > 1:
if low < high:
position = partition(arr,low,high)
quick_sort(arr,low,position -1)
quick_sort(arr,position +1,high)
return arr
return arr
def partition(arr,low,high):
position = low
for i in range(low,high... |
name = 'snape'
print(name+name+str(7))
age = 11
wizard_age_multiplier = 56
final_age = age * wizard_age_multiplier
print(f'You are {age} which means you are {final_age} in wizard years')
print('You are ' + str(age) + ' which means you are ' + str(final_age) + ' in wizard years') |
# Python program to find the factorial of a number
num = int(input("Enter a number: "))
factorial = 1
if num < 0:
print("factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1, num + 1):
factorial = factorial*i
print("The factor... |
def wrap_lines(lines, width=80, sep=' ', ellipsis="...", force_ellipsis=False, rjust_ellipsis=False):
""" Wraps given list of lines into a single line of specified width
while they can fit. Parts are separated with sep string.
If first line does not fit and part of it cannot be displayed,
or there are other lines t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.