content stringlengths 7 1.05M |
|---|
"""Contains the methods for reading and writing of files.
All modules and classes involved in the reading or writing of files are
included within this module. Default methods used for writing files (such as
images) do not need to have further definition here, but it is recommended to
obtain the path used for writing t... |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# Copyright 2014 Telefónica Investigación y Desarrollo, S.A.U
#
# This file is part of FI-WARE project.
#
# 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 th... |
ans = []
while True:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
ans.append(a + b)
for a in ans:
print(a)
|
# -*- coding: utf-8 -*-
major = 0
minor = 0
patch = 1
semantic = '{}.{}.{}'.format(major, minor, patch)
|
#Ermittle alle denkbaren Sequenzen mit den vier Basenpaaren AT, TA, CG, GC
paare="AT","TA","CG","GC"
for a in paare:
for b in paare:
for c in paare:
for d in paare:
print(a+b+c+d,end=" ")
|
# listas compostas
test = []
test.append('Igor')
test.append(20)
galera = []
galera.append(test[:])
test[0] = 'maria'
test[1] = 25
galera.append(test)
totmai = totmen = 0
print(galera)
print('-' * 30)
galera = [['joão', 19], ['Ana', 33], ['Joaquim', 15], ['Maria', 45]]
print(galera[3][0][0])
for p in galera:
print(... |
class QuotaExceptionExceeded(Exception):
pass
class QuotaMaxSimultaneousExceeded(QuotaExceptionExceeded):
pass
class QuotaCpuExceeded(QuotaExceptionExceeded):
pass
class QuotaMemoryExceeded(QuotaExceptionExceeded):
pass
class QuotaHddExceeded(QuotaExceptionExceeded):
pass
class ResourceAlr... |
largura = int(input('Indique a largura da parede em metros: '))
altura = int(input('Informe a altura dela: '))
area = (largura * altura)
tinta = area / 2
print(f'A quantidade de tinta necessária para pintar {area}m2,')
print(f'É igual a {tinta} litros de tinta.')
|
class QueryReader:
def __init__(self, delim="\t"):
self.delim = delim
def __call__(self, query_path, include_relevancy=False):
with open(query_path, "r") as fp:
for line in fp:
if include_relevancy == True:
line = line.st... |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Codec:
def __init__(self):
self.array = []
def serialize(self, root):
"""Encodes a tree to a single string.
... |
"""
Crie um programa que leia nome e duas notas de varios alunos e
guarde tudo em uma lista composta. No final, mostre um boletim
contendo a media de cada um e permita que o usuario possa mostrar
as notas de cada aluno individualmente.
"""
nomes = []
notas = []
temp = []
while True:
nomes.append(str(input('Nome: '... |
def gangs(divisors,k):
res=set()
for i in range(1, k+1):
res.add(helper(divisors, i))
return len(res)
def helper(divisors, n):
res=tuple()
for i in divisors:
if n%i==0:
res+=(i, )
return res |
"""Rules for importing a Go toolchain from Nixpkgs.
**NOTE: The following rules must be loaded from
`@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl` to avoid unnecessary
dependencies on rules_go for those who don't need go toolchain.
`io_bazel_rules_go` must be available for loading before loading of
`@io_tweag_ru... |
def word_break2(s, word_dict):
"""
:type s: str
:type goal: str
:rtype: bool
"""
dp = []
for i in range(0, len(s)):
# print(i, s[:i+1] , dp)
if s[:i+1] in word_dict:
dp.append(i+1)
else:
for j in dp:
if s[j:i+1] in word_dict:
... |
#!/usr/bin/env python3
# *****************************************
# PiFire Display Prototype Interface Library
# *****************************************
#
# Description: This library simulates a display.
#
# *****************************************
# *****************************************
# Imported Libraries
... |
#! /usr/bin/env python
# coding: utf
str_var = "Calculator"
print("Hello, ", str_var)
a = b = 2
print("a: ", a)
print("b: ", b)
print("a + b = ", a + b)
# Функция input() с аргументом-приглашением
a = int(input("Enter a: "))
print("a: ", a)
b = int(input("Enter b: "))
print("b: ", b)
print(1 <= a < 10 and 1 <= b < ... |
# 4-6. Odd Numbers
odd_numbers = list(range(1,21,2))
print(odd_numbers)
|
lista = []
cont = 0
while True:
n = int(input('Digite um valor: '))
lista.append(n)
res = str(input('Quer continuar? [S/N] ')).upper().strip()
cont += 1
if res == 'N':
break
lista.sort(reverse=True)
print('-=' * 50)
print(f'Você digitou {cont} elementos.')
print(f'Os valores em ordem decresc... |
def proCategorization(pros, preferences):
pref_dict = {}
for i in range(len(pros)):
name = pros[i]
prefs = preferences[i]
for j in range(len(prefs)):
p = prefs[j]
if p not in pref_dict:
pref_dict[p] = [name]
else:
pr... |
def app(): # pragma: no cover
return None
def returns_app(): # pragma: no cover
return app
|
def test_success():
assert True
def add_and_del(startnum, addnum, delnum):
return startnum + addnum - delnum
|
# dp + recursion (top to down)
# Runtime: 688 ms, faster than 26.38% of Python3 online submissions for Burst Balloons.
# Memory Usage: 13.6 MB, less than 55.82% of Python3 online submissions for Burst Balloons.
class Solution:
def maxCoins(self, nums: List[int]) -> int:
nums = [1] + nums + [1]
n = l... |
"""Constants for Skoda Connect library."""
BASE_SESSION = 'https://msg.volkswagen.de'
BASE_AUTH = 'https://identity.vwgroup.io'
BRAND = 'skoda'
COUNTRY = 'CZ'
# Headers used in communication
CLIENT_ID = '7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com'
XCLIENT_ID = '28cd30c6-dee7-4529-a0e6-b1e07ff90b79'
XAPP... |
class Solution(object):
def repeatedSubstringPattern(self, s):
for l in range(1, len(s)//2+1):
if len(s)%l == 0:
str_sub = s[:l]
n = len(s)//l
if str_sub * n == s:
return True
return False
print(Solution().repeatedSubs... |
# AutoRead Configuration File default
"""
AUTOREAD CONFIG File
Author: James Cooper
Contact: james@jcooper.tech
Description: Shared code for many parts of AutoRead.
This project was made for the Guildhall School of Music and Drama.
Developed with the Milton Court TAIT eChameleon Automation installation in ... |
# n = A.length
# time = O(n)
# space = O(n)
# done time = 30m
class Solution:
def prefixesDivBy5(self, A: List[int]) -> List[bool]:
num = 0
ret = []
for a in A:
num = (num << 1) + a
ret.append(num % 5 == 0)
return ret
|
# -*- coding: utf-8 -*-
"""
Wanini's Python Sample Project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wPyProj is a template of Python project.
:copyright: (c) 2021 by Ting-Hsu Chang.
:license: MIT, see LICENSE for more details.
"""
|
n1 = int(input('Digite um Valor:'))
n2 = int(input('Digite outro valor:'))
s = n1 + n2
print('A some entre {} e {} é {}'.format(n1, n2, s))
|
"""
We are given an array containing n distinct numbers taken from the range 0 to n.
Since the array has only n numbers out of the total n+1 numbers, find the missing number."""
def find_missing_number(nums):
i = 0
while i < len(nums):
j = nums[i]
if j < len(nums) and i != nums[i]:
... |
author_activate = '''
mutation {
upsertAuthor(name: "Paulinna", author: { active: true }) {
successful
messages {
field
message
}
result {
name
active
}
}
}
'''
author_set_active = '''
mutation SetActive($active: Boolean!){
upsertAuthor(na... |
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
m, n = len(word1), len(word2)
if m * n == 0:
return max(m, n)
dp = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(1, m + 1):
dp[i][0] = i
for i in range(1, n + 1):
... |
"""Factories for the redirect_plus app."""
# import factory
# from ..models import YourModel
|
'''
SNMP Device Defines
'''
BMCSTATUS = {
1: 'ok',
2: 'minor',
3: 'major',
4: 'critical',
5: 'absence',
6: 'unknown',
}
BMCPRESENCE = {
1: 'absence',
2: 'presence',
3: 'unknown',
}
BMCPCESTATUS = {
1: 'disable',
2: 'enable',
}
BMCPCFA = {
1: '... |
"""
@file
@brief Shortcut to *algorithms*.
"""
|
def getData():
dataset = pd.read_csv('FUTURES MINUTE.txt', header = None)
dataset.columns = ['Date','time',"1. open","2. high",'3. low','4. close','5. volume']
dataset['date'] = dataset['Date'] +" "+ dataset['time']
dataset.drop('Date', axis=1, inplace=True)
dataset.drop('time', axis=1, inplace... |
class DataOwnerPrediction:
def __init__(self, model_id, model_public_key, public_key, encrypted_prediction):
self.id = encrypted_prediction.id
self.model_id = model_id
self.model_public_key = model_public_key
self.public_key = public_key
self.encrypted_prediction = encrypted... |
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
Loki module for body_part
Input:
inputSTR str,
utterance str,
args str[],
resultDICT dict
Output:
resultDICT dict
"""
DEBUG_body_part = True
userDefinedDICT = {}
ChildLIST =["小孩","兒子... |
class SegmentEndsPath(list):
"""
a list containing {gfapy.SegmentEnd} elements, which defines a path
in the graph
"""
def reverse(self):
"""
Reverses the direction of the path in place
"""
self[:] = list(reversed(self))
def __reversed__(self):
"""
Iterator over the reverse-directio... |
n = input()
s = set(map(int, input().split()))
q=int(input())
for x in range(q):
t=input().split()
try:
if(t[0]=="pop"):
s.pop()
elif(t[0]=="remove"):
s.remove(int(t[1]))
else:
s.discard(int(t[1]))
except:
continue
print(sum(s))
|
def isIncreasingDigitsSequence(n):
s = str(n)
for i in range(len(s)-1):
if s[i] >= s[i+1]:
return False
return True
"""
Call an integer an increasing digits sequence if its digits considered from left to right form a strictly increasing sequence.
Given an integer, check if it is an inc... |
year = int(input())
if (year % 400 == 0):
print("Високосный")
elif (year % 4 == 0) and (year % 100 != 0):
print("Високосный")
else:
print("Обычный") |
load("//scala:scala.bzl", "scala_test")
def analyzer_tests_scala_2():
common_jvm_flags = [
"-Dplugin.jar.location=$(execpath //third_party/dependency_analyzer/src/main:dependency_analyzer)",
"-Dscala.library.location=$(rootpath @io_bazel_rules_scala_scala_library)",
"-Dscala.reflect.locatio... |
NER_LABEL_TO_ID = {
"O": 0,
"B-ORG": 1,
"I-ORG": 2,
"B-PER": 3,
"I-PER": 4,
"B-LOC": 5,
"I-LOC": 6,
}
ID_TO_NER_LABEL = {value: key for key, value in NER_LABEL_TO_ID.items()}
def clean_label(ner_label: str) -> str:
"""
Clean the ner label from whitespaces
:param ner_label: ta... |
# This __about__.py file for storing project metadata is inspired by
# - github.com/delph-in/pydelphin/blob/master/delphin/__about__.py
# referencing (apud)
# - github.com/pypa/warehouse/blob/master/warehouse/__about__.py
__name__ = "Delphin RDF"
__summary__ = "DELPH-IN formats in RDF"
__version__ = "1.0.4"
__aut... |
#### USEFUL FUNCTIONS FOR CLAUSES AND LITERALS ####
# Return true if the clause is unit, false otherwise.
def is_unit_clause(clause):
return len(clause) == 1
# Return true if the clause is empty, false otherwise.
def is_empty_clause(clause):
return len(clause) == 0
# Return true if the literal is positive, fal... |
if __name__ == "__main__":
s = input()
new_s = ""
for i in range(len(s)-1, -1, -1):
new_s += s[i]
print(new_s)
if s == new_s: print("haha got ya !")
else: print("NOpe")
|
n = int(input())
total = []
for i in range(n):
a = [int(item) for item in input().split()]
temp = 0
for j in range(a[0]):
temp +=a[j + 1]
temp -= (a[0] - 1)
total.append(temp)
a = []
for i in total:
print(i)
|
class main:
def __init__(self):
pass
def draw(self):
print("Welcome to Friend_Tracker_2.0")
print("-----------------------------")
print("Type in read if you want to read a profile,\nand write if you want to add something to the profile,\nor type in help if you need help. Type i... |
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Common helper functions.
This will represent the bread and butter of the application.
"""
def add_two_numbers(x_val: int, y_val: int) -> int:
"""Just adds two numbers together."""
return x_val + y_val
def return_string() -> str:
"""Return the string ... |
'''
The MIT License (MIT)
Copyright (c) 2016 WavyCloud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, p... |
"""
0489. Robot Room Cleaner
Given a robot cleaner in a room modeled as a grid.
Each cell in the grid can be empty or blocked.
The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees.
When it tries to move into a blocked cell, its bumper sensor detects the obsta... |
# microbit.py 15/01/2021 D.J.Whale
# Simulator for a micro:bit - will be replaced with BITIO
class Radio():
# RCNNABGRR+SS (12 chars)
# 0123456789AB
TESTDATA = (
"RC0000F99+00",
None,
None,
"RC0000F00+99",
"RC0000F99-99",
"RC0000S00+00",
"RC0000B99... |
# Exercício 12 lista 1
print("----------Calcula a quantidade de litros necessário para fazer um refresco--------")
qtdLitros = float(input("Digite a quantidade de litros necessária:"))
concentracaoAgua = float(input("Digite o percentual de concentração da água:"))
concentracaoSuco = float(input("Digite o percentual d... |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
=================================================
@Project :span-aste
@IDE :PyCharm
@Author :Mr. Wireless
@Date :2022/1/19 13:49
@Desc :
==================================================
"""
|
class Solution:
def pivotIndex(self, nums):
left = 0
right = 0
left_sum = 0
right_sum = sum(nums)
while right < len(nums):
right_sum -= nums[right]
right += 1
if right_sum == left_sum:
return left
else:
... |
A, B = map(int, input().split())
diff = abs(A - B)
ans = diff // 10
diff %= 10
ans = ans + [0, 1, 2, 3, 2, 1, 2, 3, 3, 2][diff]
print(ans)
|
# https://www.hackerrank.com/challenges/python-quest-1/problem
# Condition
# 1 <= int(input()) <= 9
# String is not allowed.
# More than 1 for-statement is not allowed.
# More than 2 lines are not allowed. (Do not leave a blank line also.)
""" Mathmatical Answer
for i in range(1, int(input())):
print(10**i //... |
class RobotException(Exception):
pass
class UnitGuardCollision(RobotException):
def __init__(self, other_robot):
self.other_robot = other_robot
class UnitMoveCollision(RobotException):
def __init__(self, other_robots):
self.other_robots = other_robots
class UnitBlockCollision(RobotExcepti... |
""" Asked by: Apple [Medium].
Gray code is a binary code where each successive value differ in only one bit, as well as when wrapping around.
Gray code is common in hardware so that we don't see temporary spurious values during transitions.
Given a number of bits n, generate a possible gray code for it.
For example... |
class Solution:
def findPairs(self, nums: List[int], k: int) -> int:
result, frequencyMap = 0, Counter(nums)
for i in frequencyMap:
if k == 0 and frequencyMap[i] > 1:
result += 1
elif k > 0 and i + k in frequencyMap:
result += 1
return ... |
class Scorer(object):
def __init__(self, cards):
self.cards = cards
def flush(self):
suits = [card.suit for card in self.cards]
if len(set(suits)) == 1:
return True
return False
def straight(self):
values = [card.value for card in self.cards]
val... |
#!/usr/bin/env python
# coding=utf-8
# author: damonchen
# date: 2018-02-07
# 给公司内部做培训,编写一个Hierarchical Timing Wheels的timer的实现
class Slot(list):
pass
class Wheel(object):
def __init__(self, size):
self.size = size # 0~59, or 0~23
self.pointer = 0 # wheel指针,达到wheel_buffer尾部后会重... |
class Solution(object):
def canJump(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
n = len(nums)
if n < 2:
return True
target_i = n - 1
for i in range(n - 2, -1, -1):
if nums[i] >= target_i - i:
target_i... |
class InvalidPhoneNumber(Exception):
def __init__(self, phone_number):
self.phone_number = phone_number
self.message = phone_number + ' is an invalid phone number'
super().__init__(self.message)
|
def list():
'''Returns a list of streams
'''
return 'TO BE IMPLEMENTED'
def add():
'''Set an stream
'''
return 'TO BE IMPLEMENTED'
def find_by_name(name):
'''Returns the named stream
Params:
name - The name of the stream
'''
return 'TO BE IMPLEMENTED'
def delete_by_name(name):
'''D... |
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 20 21:16:13 2019
@author: CLIENTE
"""
def fatorial(n):
if n == 1:
return 1
else:
return n*fatorial(n-1) |
# Count Substrings That Differ by One Character
class Solution:
def countSubstrings(self, s, t):
# brute force
slen = len(s)
tlen = len(t)
count = 0
for si in range(slen):
for ti in range(tlen):
index = 0
diffCount = 0
... |
#!/usr/bin/python3
"""
Given a non-negative integer N, find the largest number that is less than or
equal to N with monotone increasing digits.
(Recall that an integer has monotone increasing digits if and only if each pair
of adjacent digits x and y satisfy x <= y.)
Example 1:
Input: N = 10
Output: 9
Example 2:
Inpu... |
# Description
# 中文
# English
# Given a binary tree, find its maximum depth.
# The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
# Have you met this question in a real interview?
# Example
# Example 1:
# Input: tree = {}
# Output: 0
# Explanation: The... |
"""
* Assignment: Decorator Class Type Check
* Complexity: medium
* Lines of code: 15 lines
* Time: 21 min
English:
1. Refactor decorator `decorator` to decorator `TypeCheck`
2. Decorator checks types of all arguments (`*args` oraz `**kwargs`)
3. Decorator checks return type
4. In case when received ty... |
# Copyright 2020 Cognite AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... |
#! /usr/bin/env python
class Template:
"""invite templates"""
def __init__(self):
self.profile_templates = {
'th invite templates' : u"{{{{subst:Wikipedia:Teahouse/HostBot_Invitation|personal=The Teahouse is a friendly space where new editors can ask questions about contributing to Wikipedia and ge... |
def o_signo(a, b):
if a == 3:
if b <= 20:
return f'Peixes'
else:
return f'Aries'
elif a == 4:
if b <= 19:
return f'Aries'
else:
return f'Touro'
elif a == 5:
if b <= 20:
return f'Touro'
else:
... |
"""Tracks devices by sending a ICMP echo request (ping)."""
PING_TIMEOUT = 3
PING_ATTEMPTS_COUNT = 3
|
set_name(0x80122CDC, "PreGameOnlyTestRoutine__Fv", SN_NOWARN)
set_name(0x80124DA0, "DRLG_PlaceDoor__Fii", SN_NOWARN)
set_name(0x80125274, "DRLG_L1Shadows__Fv", SN_NOWARN)
set_name(0x8012568C, "DRLG_PlaceMiniSet__FPCUciiiiiii", SN_NOWARN)
set_name(0x80125AF8, "DRLG_L1Floor__Fv", SN_NOWARN)
set_name(0x80125BE4, "StoreBlo... |
# -*- coding: utf-8 -*-
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
ans = 0
flag = 1
if x < 0:
flag = -1
x = - x
while x != 0:
cur = x % 10
ans = ans * 10 + cur
... |
#
# PySNMP MIB module ALCATEL-IND1-AUTO-FABRIC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-AUTO-FABRIC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:01:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python vers... |
"""settings.py - Contains MAILGUN settings"""
MAILGUN_DOMAIN_NAME = "sandbox301369dd8c464b87b7874ba72a5e3039.mailgun.org"
MAILGUN_PRIVATE_API_KEY = "key-de714a26093d427c84abcb980d3f3f0a"
MAILGUN_PUBLIC_API_KEY = "pubkey-2b308844086ef26cee582ce10ac7303b"
MAILGUN_SANDBOX_SENDER = "Mailgun Sandbox <postmaster@sandbox3013... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Cambia el formato de fecha dd/mm/aaaa por aaaa-mm-dd
ejemplo:
entrada = 20/04/2021
salida = 2021-20-04
"""
def plugin_main(*args, **kwargs):
# print ('args : ',args)
# print ('kwargs: ',kwargs)
fecha = kwargs['fecha'][0]
fecha = '{}-{}-{}'.format(fecha... |
# Copyright (c) 2014, Charles Duyk
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the fo... |
AWS_DOCKER_HOST = "308535385114.dkr.ecr.us-east-1.amazonaws.com"
def gen_docker_image(container_type):
return (
"/".join([AWS_DOCKER_HOST, "pytorch", container_type]),
f"docker-{container_type}",
)
def gen_docker_image_requires(image_name):
return [f"docker-{image_name}"]
DOCKER_IMAGE_BA... |
#
# PySNMP MIB module DNOS-KEYING-PRIVATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DNOS-KEYING-PRIVATE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:36:48 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 ... |
#coding: utf-8
#------------------------------------------------------------
# Um programa que recebe um nome e retorna com boas vindas.
#------------------------------------------------------------
# Respondendo ao usuário - Exercício #002
#------------------------------------------------------------
nome = str(in... |
class QTimer:
def __init__(self, ticks_per_hour = 60, hours_per_day:int = 24):
self.ticks = 0
self.ticks_per_hour = ticks_per_hour
self.hours_per_day = hours_per_day
def tick(self, increment : int = 1):
self.ticks += increment
@property
def minutes(self):
retu... |
# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "No Default Account",
"version": "14.0.1.0.0",
"development_status": "Beta",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"maintainers": ["dreispt"],
... |
def swap_even_and_odd_bits(n):
'''Swaps the even and odd bits of an unsigned, 8-bits number.
>>> swap_even_and_odd_bits(0b10101010) == 0b01010101
True
>>> swap_even_and_odd_bits(0b11100010) == 0b11010001
True
'''
assert 0 <= n <= 0xFF, 'Not an 8-bit unsigned number'
return ((n & 0b10101... |
URLs = {
"ADULT_SAMPLE":[
"https://s3.amazonaws.com/fast-ai-sample/adult_sample.tgz",
968212,
"64eb9d7e23732de0b138f7372d15492f"
],
"AG_NEWS":[
"https://s3.amazonaws.com/fast-ai-nlp/ag_news_csv.tgz",
11784419,
"b86f328f4dbd072486591cb7a5644dcd"
],
"AMAZON_REVIEWS":[
... |
# Construir um programa que calcule e apresente em metros por segundo o valor da velocidade de um projétil que percorre uma distância em quilômetros a um espaço de tempo em minutos. Utilize a fórmula VELOCIDADE <- (DISTÂNCIA* 1000) /(TEMPO* 60).
dist = int(input('informe a distancia: '))
tmp = int(input('informe o te... |
n = 6
k = 3
keys = [i for i in range(int(n))]
values = [0] * n
a = dict(zip(keys, values))
result = []
def recur(s, n, was, result):
if len(s) == k:
result.append(s)
return
for i in range(0, n):
if was[i] == 0:
was[i] = 1
recur(s + str(i + 1), n, was, result)
... |
class Vertice:
def __init__(self, key, payload):
self.key = int(key)
self.right = None
self.left = None
self.pai = None
self.payload = payload
def __str__(self):
return str(self.key)+" "+str(self.payload)
class Tree:
def __init... |
"""Test utils for gourde."""
def setup(gourde, args=None):
"""Setup gourde for testing."""
args = args or []
parser = gourde.get_argparser()
# Make sure we don't use sys.argv.
args = parser.parse_args(args)
# Setup everything.
gourde.setup(args)
|
#
# PySNMP MIB module DeltaUPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DeltaUPS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:43:21 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,... |
with open('trenutek.txt',"r") as datoteka:
i = 1
dat2 = open('trenutek1.txt',"w")
for vrstica in datoteka:
dat2.write(str(i) +","+ vrstica)
i += 1
dat2.close()
|
x=[1,1]
for i in range(1000):
x=x+[x[-1]+x[-2]]
#iteration 1
#x=[1,1]+[1+1]
#x=[1,1]+[2]
#x=[1,1,2]
#iteration 2
#x=[1,1,2]+[1+2]
#x=[1,1,2]+[3]
#x=[1,1,2,3]
print(x)
print(x[-1]/x[-2]) |
class Tablet :
def __init__(self,tablet_proxy):
self._tablet = tablet_proxy
def set_background(self,color):
self._tablet.setBackgroundColor(color)
def set_image(self,url):
self._tablet.showImage(url)
def load_image(self,url):
return self._table.preLoadImage(url)
|
input = """
b(1).
a(X) :- b(X).
:- p(X).
"""
output = """
b(1).
a(X) :- b(X).
:- p(X).
"""
|
'''
lab 7
'''
#3.1
i = 0
while i <=5:
if i !=3:
print(i)
i = i+1
#3.2
i = 1
result = 1
while i <=5:
print()
i = i+1
print(result)
#3.3
i = 1
result = 0
while i <=5:
result = result +i
i = i+1
print(result)
#3.4
i = 3
result = 0
while i <=8:
... |
lpu = "LPU"
speciality = "SPECIALLITY"
token = "TOKEN"
chat_id = "CHAT_NAME" # if u re planing to send
|
"""
Super-Automation MySQL plugin-related exceptions.
Raising one of these in a test will cause the
test-state to be logged appropriately in the DB
for tests that use the Super-Automation MySQL plugin.
"""
class BlockedTest(Exception):
""" Raise this to mark a test as Blocked in the DB. """
pass
class SkipT... |
class Event:
""""""
PINGED = 'ping'
PONGED = 'pong'
CONNECTED = 'connected'
"""
Called when the Websocket client has successfully connected to the server.
:param user: The twitch user that connected to the server
.. code-block:: python3
@client.event(twitch.Event.CONNECTED)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.