content stringlengths 7 1.05M |
|---|
# Faça um algoritmo que leia o salário de um funcionário e mostre seu novo salário, com 15% de aumento
salr = float(input('Qual seu salário? '))
print(f'Parabéns, você ganhou um aumento! Seu novo salário é R${salr * 1.15:.2f}\n'
f'(O aumento dado foi de R${salr * 0.15:.2f})')
|
'''Crie um programa que mostre na tela todos os números pares
que estão no intervalo entre 1 e 50'''
#for c in range (0,51,2):
# print(c, end=' ')
#print('Finished, modaFuck')
#ou
for c in range (0,51):
if c%2==0:
print(c) |
# -*- coding: utf-8 -*-
#%% Basic
#self class ın içindeki metotlara parametrelere ulaşmak için kullanılır.self zorunlu yazılır.
class Matematik:
def __init__(self,sayi1,sayi2): # __init__(genelde def başında kullanılır)başlatma işlemlerini gerçekleştirir.
self.sayi1 = sayi1
self.sayi2 = sayi2
d... |
"""Types used in configuration module for Spark's performance tests."""
class OptionSet(object):
"""Represents an option and a set of values for it to sweep over."""
def __init__(self, name, vals, can_scale=False):
self.name = name
self.vals = vals
self.can_scale = can_scale
def sc... |
"""
Projeto: Número por extenso
"""
numbers = ('Zero', 'Um', 'Dois', 'Três', 'Quatro', 'Cinco', 'Seis', 'Sete', 'Oito', 'Nove', 'Dez', 'Onze', 'Doze', 'Treze', 'Catorze', 'Quinze', 'Dezeseis', 'Dezesete', 'Dezoito', 'Dezenove', 'Vinte')
while True:
numberUser = int(input('Digite um número entre 0 e 20: '))
i... |
'''input
5
3
10000
9000
48000
2
3
10000
9000
20000
'''
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem A
if __name__ == '__main__':
n = int(input())
k = int(input())
x = int(input())
y = int(input())
diff = n - k
if diff > 0:
print((k * x) + diff * y)
else:
... |
# 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):
# p.left = parent.right
# parent.right = p.right
# p.right = parent
# parent = p.left
# p = left
def ... |
def intInput(prompt,default):
try:
return int(input(prompt))
except:
return default
age = intInput("How old is your car? ",0)
print("Your car is",age,"years old")
|
class Employee:
raise_amount = 1.04
num_of_emps = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@company.com'
Employee.num_of_emps += 1
def fullname(self):
return "{} {}".for... |
def solve_part_1(sequence):
sequence = sequence.split("\t")
historic = [sequence[:]]
block_redistribution = 0
sequence_size = len(sequence)
for i in range(sequence_size):
sequence[i] = int(sequence[i])
while True:
maximum = -1
index = -1
for i in range(seque... |
# ProjectEuler+ > Project Euler #6: Sum square difference
# Difference between sum of squares and square of sums.
#
# https://www.hackerrank.com/contests/projecteuler/challenges/euler006
# challenge id: 2632
#
for _ in range(int(input())):
n = int(input())
# (Σ𝑖)² = 𝑛² * (𝑛+1)² * 1/4
# Σ(𝑖²) = 𝑛 * (�... |
# Instruction: Replace the character H with a J.
txt = "Hello World"
# Solution:
txt = txt.replace("H", "J")
print(txt)
# Read More Here: https://www.w3schools.com/python/python_strings.asp
|
#!/usr/bin/env python3
"""
A Befunge-93 interpreter written in Python.
Spec can be found at https://en.wikipedia.org/wiki/Befunge.
"""
class Pointer:
def __init__(self):
self.x = 0
self.y = 0
|
# q1
def select_second(L):
"""Return the second element of the given list. If the list has no second
element, return None.
"""
if len(L) < 2:
return None
return L[1]
# q2
def losing_team_captain(teams):
"""Given a list of teams, where each team is a list of names, return the 2nd player ... |
N, M = map(int, input().split())
P = []
for _ in range(N):
a, b = map(int, input().split())
P.append((a, b))
P2 = []
for _ in range(M):
a, b = map(int, input().split())
P2.append((a, b))
for i, (x, y) in enumerate(P):
dis = 1e10
ans = 1
for j, (x2, y2) in enumerate(P2):
new_dis = ab... |
"""The code template to supply to the front end. This is what the user will
be asked to complete and submit for grading.
Do not include any imports.
This is not a REPL environment so include explicit 'print' statements
for any outputs you want to be displayed back to the user.
Use triple single q... |
class NoTokenError(Exception):
def __init__(self, *a, **kw):
super().__init__(*a, **kw)
class GetContentError(Exception):
def __init__(self, *a, **kw):
super().__init__(*a, **kw)
|
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
n = len(nums)
res = [1] * (n)
fwd = [1] * (n)
bwd = [1] * (n)
fwd[0] = 1
bwd[n-1] = 1
for i in range(1,n):
fwd[i] = fwd[i-1] * nums[i-1]
for i in range(n-2,... |
1
1_0
-1
0x1
0xff
0xf_f
0o123
0o12_3
10j
1_0j
1-2j
|
name='tkitAutoTokenizerPosition'#修改包名字-
version='0.0.0.4'
description='Terry toolkit tkitAutoTokenizerPosition'
author='Terry Chan'
author_email='napoler2008@gmail.com'
url='https://lab.terrychan.org/tkit-AutoTokenizerPosition/'
copyright = '2021, Terry Chan'
language = 'zh_cn' |
"""
538. Convert BST to Greater Tree
Input: The root of a Binary Search Tree like this:
5
/ \
2 13
Output: The root of a Greater Tree like this:
18
/ \
20 13
"""
""""
5
/ \
2 13 r = ... |
"""A bcftools modules.
Author: Shujia Huang
Date: 2020-04-28 20:29:09
"""
def concat(config, input_vcfs, output_vcf):
tabix = config["tabix"]
bcftools = config["bcftools"]["bcftools"]
concat_options = "%s" % " ".join(config["bcftools"]["concat_options"]).replace("-O z", "") \
if "concat_options"... |
class Solution:
def maxSubArray(self, nums):
sm, mn, mx = 0, 0, -float("inf")
for num in nums:
sm += num
mx, mn = max(mx, sm - mn), min(mn, sm)
return mx |
# expr
# : AWAIT? atom trailer*
# | <assoc=right> expr op=POWER expr
# | op=(ADD | MINUS | NOT_OP) expr
# | expr op=(STAR | DIV | MOD | IDIV | AT) expr
# | expr op=(ADD | MINUS) expr
# | expr op=(LEFT_SHIFT | RIGHT_SHIFT) expr
# | expr op=AND_OP expr
# | expr op=XOR expr
# | expr op=... |
LOCS__ABCDE = list('abcde')
LOCS__A_TO_Z = list('abcdefghijklmnopqrstuvwxyz')
SRCS_TGTS__ONE_SHOT__ABCDE = [('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e')]
SRCS_TGTS__FORWARD_BACK__ABCDE = [
('a', 'b'), ('b', 'c'), ('c', 'd'),
('d', 'c'), ('c', 'b'),
('b', 'c'), ('c', 'd'), ('d', 'e')
]
|
# Exercício Python 50: Desenvolva um programa que leia seis números inteiros e mostre a soma apenas daqueles que forem pares. Se o valor digitado for ímpar, desconsidere-o.
lista = []
for i in range(1,7):
a=int(input('Digite um numero: '))
if a % 2 ==0:
lista.append(a)
print(sum(lista)) |
def interpret(data, soc):
'''takes foot movements and converts to chess moves'''
row = ''
column = ''
if len(data) != 2 and len(data) != 4:
print("ERROR: command len is " + str(len(data)))
soc.send(bytes("FF", encoding='utf8'))
return -1
column = data[0]
row = str(ord(d... |
print("hello")
print("selam")
def selamver():
print("selam millet")
print("bunu VS içinde klon yaptıktan sonra ekledim")
|
#!/usr/bin/env python3
# --- general ------------------------------------------------------------------
project = "Ethereum Classic Technical Reference"
author = "Christian Seberino"
copyright = "2018 " + author
version = "0.1"
release = version
master_doc = "index"
source_suffix = ".r... |
#
# PySNMP MIB module NSC-TCP-EXCEL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NSC-TCP-EXCEL-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:15:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... |
power = {'BUSES': {'Area': 1.33155,
'Bus/Area': 1.33155,
'Bus/Gate Leakage': 0.00662954,
'Bus/Peak Dynamic': 0.0,
'Bus/Runtime Dynamic': 0.0,
'Bus/Subthreshold Leakage': 0.0691322,
'Bus/Subthreshold Leakage with power gating': 0.0259246,
'Gate... |
withdraw,balance = map(float,input().split())
#withdraw,balance = [float(item) for item in read]
if (withdraw%5 != 0) :
print (balance)
elif (balance < withdraw +0.5) :
print (balance)
else :
print(balance-(withdraw+0.5)) |
"""
let's reset the array by it's min value start out from (0,0)
in another words, after reset
grid[i][j]'s value will be the min value start out from (0,0)
if we are at (i,j), we will be either from (i-1,j) or (i,j-1)
we call them s1 and s2, let's assume they are both in range
grid[i][j] will be grid[i][j]+min(s1, s2... |
s1=input()
s2=input()
s3=input()
print(s1+s2+s3)
print(s2+s3+s1)
print(s3+s1+s2)
print('%s%s%s'%(s1[:10], s2[:10], s3[:10]))
|
class Board:
def __init__(self, settings):
self.number_of_players = settings.number_of_players
self.number_to_pass = settings.number_to_pass
self.missions = settings.missions
self.spy_score = 0
self.antifa_score = 0
self.current_mission = 0
self.stall_counte... |
# Copyright 2018-present Open Networking Foundation
# SPDX-License-Identifier: Apache-2.0
# This Starlark rule imports the BF SDE shared libraries and headers. The
# SDE_INSTALL environment variable needs to be set, otherwise the Stratum
# rules for barefoot platforms cannot be built.
def _impl(repository_ctx):
i... |
MOCK_SALE = [{
"id": 1,
"title": "Demix Magus M",
"description": "Lightweight and flexible Demix Magus training sneakers. Special grooves on the sole, located in places of the anatomical fold of the foot, allow you to move naturally. Ultra-lightweight knitwear with a special weave provides air circulation a... |
#!/usr/bin/env python
#_*_coding:utf-8_*_
__all__ = [
'readCode',
'saveCluster',
'kmeans',
'hcluster',
'apc',
'meanshift',
'dbscan',
'tsne',
'pca'
] |
# tombstone
__author__ = "N. Laughton"
__copyright__ = "Copyright 2018, N. Laughton"
__credits__ = ["N. Laughton"]
__license__ = "MIT"
__version__ = "0.1.0dev"
__maintainer__ = "N. Laughton"
__status__ = "development"
|
lista= []
for x in range (5):
lista.append(input("Ingrese un numero"))
menor=lista[0]
posicion_x=0
for x in range(1,5):
if lista[x] < menor:
menor= lista[x]
posicion_x= x
print("El valor es: ", menor, " y la posicion es: ", posicion_x) |
# This file is intended to be used with the HDLMAKE tool for HDL generator. If
# you don't use it, please ignore
files = [
"ahb3lite_to_wb.v",
"wb_to_ahb3lite.v",
]
|
"""
Good morning! Here's your coding interview problem for today.
This problem was asked by Facebook.
There is an N by M matrix of zeroes. Given N and M, write a function to count the number of ways of starting at the top-left corner and getting to the bottom-right corner. You can only move right or down.
For exampl... |
"""
Ask the user for a number.
Depending on whether the number is even or odd, print out an
appropriate message to the user. Hint: how does an even / odd number
react differently when divided by 2?
Extras:
If the number is a multiple of 4, print out a different message.
Ask the user for two numbers: one number to ... |
class _NFA:
pass
class NFA(_NFA):
STATE_ID = -1
def __init__(self, final_states=None, name=""):
if final_states is None:
final_states = set()
NFA.STATE_ID += 1
self.id = NFA.STATE_ID
self.final_states = final_states
self.transitions = {}
self.... |
class NumArray:
def __init__(self, nums: List[int]):
self.NumArray = nums
self.sum_mat = [0]*(len(nums)+1)
for i in range(len(nums)):
self.sum_mat[i+1] = nums[i] + self.sum_mat[i]
def sumRange(self, left: int, right: int) -> int:
#Approach 1
... |
def primes(N):
f = []
i = 1
while N > 1:
i = i + 1
k = 1
check = True
while k < i - 1:
k = k + 1
check = check and (i % k != 0)
if check:
c = 0
while N >= 1 and N % i == 0:
c = c + 1
N = ... |
#program to delete all the repetitive character in a list
c=0;
lis=[1,2,3,4,5,1,2,3,4,5,1];
lis1=[];
k=0
for i in range(0,len(lis)):
for j in range(0,i+1):
if(lis[j]==lis[i]):
c=c+1;
if(c>1):
break;
if(c==1):
lis1.append(lis[i]);
k+=1;
c=0;
print(lis1);
|
test = { 'name': 'q1_12_0',
'points': 0,
'suites': [ { 'cases': [ {'code': '>>> pop_for_year(1972) == 3345978384\nTrue', 'hidden': False, 'locked': False},
{'code': '>>> pop_for_year(1989) == 4567880153\nTrue', 'hidden': False, 'locked': False},
... |
# This program calculates the area of rectangle
# input for length
length = float(input('Enter the length: '))
# input for breadth
breadth = float(input('Enter the breadth: '))
# calculate area
area = length * breadth
# calculate perimeter
perimeter = 2 * (length + breadth)
print(f"Area is {area} and perimeter is ... |
# 3.2: Stack Min
# Runtime: O(1) - Space: O(1)
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.minimum = None
class Stack:
def __init__(self):
self.top = None
self.minimum = None
def push(self, value):
new_top = Node(value)
... |
def test_configuration_session(eos_conn):
eos_conn.register_configuration_session(session_name="scrapli_test_session1")
result = eos_conn.send_configs(
configs=["interface ethernet 1", "show configuration sessions"],
privilege_level="scrapli_test_session1",
)
eos_conn.close()
# pop t... |
def print_left_triangle(b):
for i in range(1,b+1):
print ("*"*i)
print ("%"*i)
print_left_triangle(20)
|
# -*- coding: utf-8 -*-
"""
Spyder Editor
@auther: syenpark
Python Version: 3.6
"""
class WeightedEdge(Edge):
"""
make a gragh weighted
"""
def __init__(self, src, dest, weight):
self.src = src
self.dest = dest
self.weight = weight
def getWeight(self):
retur... |
def getModels(self):
if self._isFalse(self._root):
return list([])
if self._isTrue(self._root):
models = list([])
else:
models = self._getModels(self._root)
if self._varFullCount != len(self._varMap):
scope1 = self._nodes[self._root].scope
scope2 = self._vtreeMan.getScope(self._vtreeMan.getRoot())
mis... |
def Corpus_bello():
return 'Corpus'
def actionMan(s):
return 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFU'
|
# coding=utf-8
"""
@author: conan
@date: 2018/6/25
"""
if __name__ == '__main__':
empty_list = list()
print(empty_list)
str1 = 'I love you!'
print(str1)
fac = (1, 1, 2, 3, 5, 8, 13, 21, 34)
fac_list = list(fac)
print(fac_list)
print(len(empty_list))
print(len(st... |
"""
https://leetcode.com/problems/duplicate-zeros/
Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.
Note that elements beyond the length of the original array are not written.
Do the above modifications to the input array in place, do not ret... |
# encoding: utf8
owner = 'module2'
def show_owner():
print(owner)
|
# Constants for first year, last year, date of march, and special years
FIRST_YEAR = 1900
LAST_YEAR = 2099
DATE_OF_MARCH = 31
SPECIAL_YEARS = [1954, 1981, 2049, 2076]
# Prompt and return year
def get_year():
valid = False
# Enter year until valid year is entered
while not valid:
year = int(in... |
def parser(l, r):
if all(S[i].isdigit() for i in range(l, r + 1)):
return int(S[l:r + 1]) // 2 + 1
ret = []
cnt = 0
start = 0
for i in range(l, r + 1):
if S[i] == '[':
cnt += 1
if cnt == 1:
start = i
elif S[i] == ']':
if cnt... |
# Print out an error message when DIV by zero occurs
#
# %rdi := the line of the binary expression
#
error_div_by_zero_code = """__error_div_by_zero:
pushq %rbx
movq %rdi, %rbx
movq $1, %rax
movq $2, %rdi
movq $_div_error, %rsi
movq $47, %rdx
syscall
movq %rbx, %rdi
call __write_stderr
movq $1, %rax... |
matrix = [[int(input(f"Número de [{n}x{num}]: ")) for num in range(3)] for n in range(3)]
ind = len(matrix)
for line in matrix:
ind -= 1
for n, col in enumerate(line):
if n >= ind:
print(col, end=" ")
else:
print(" ", end=" ")
print("")
|
class Strip(object):
def plotSurf(self):
for cyc in self.cut_cycs:
self.df = None
print("file to analyse: ",self.file)
myResults = RTQuICData_feat(self.file, numCycles =cyc)
self.df = myResults.getData()
self.addSurflabels()
for param i... |
class Demo:
def __init__(self):
pass
def runDemo(self):
print("Hi , This is demo !") |
print('--------------简单函数--------------')
def im_a_function():
print("I'm a function")
im_a_function()
print('--------------带参数的函数--------------')
def function_with_param(n=1):
print(f'n={n}')
function_with_param(10)
print('--------------关键字参数--------------')
def function_with_keywords_arguments(a, ... |
n=int(input('Digite um número: '))
dobro=n*2
triplo=n*3
raiz=n**(1/2)
print('O dobro de {} é {}. \nO triplo de {} é {}. A raiz de {} é {}'.format(n, dobro, n, triplo, n, raiz))
|
# 40 ms ; faster than 97.67 %
"""
# Definition for a Node.
class Node:
def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None):
self.val = val
self.left = left
self.right = right
self.next = next
"""
class Solution:
def connect(self, roo... |
def median(l):
tmp = l
tmp.sort()
n = len(tmp)
m = n // 2
if n % 2:
return tmp[m]
else:
return (tmp[m] + tmp[m-1]) // 2
n = int(input())
x_ = []
y_ = []
for i in range(n):
x, y = [int(j) for j in input().split()]
x_.append(x)
y_.append(y... |
class libro():
def __init__(self,prestamo,devolucion,dame_info):
self.prestamo = prestamo
self.devolucion = devolucion
self.dame_info = dame_info
def get_prestamo(self):
return
def get_devolucion(self):
return
def get_dame_info(self):
return
|
class Solution:
def findClosestNumber(self, nums: List[int]) -> int:
nums.sort(key=lambda x: (abs(x), -x))
return nums[0]
|
# Create a program that has a tuple fully populated with a count in full, from zero to twenty.
# Your program should read a number on the keyboard (between 0 and 20) and show it in full.
full = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
'nine', 'ten', 'eleven', 'twelve', 'thirtee... |
class Node:
def __init__(self, data):
self.val = data
self.next = None
def __str__(self):
return str(self.val)
class LinkedList:
def __init__(self):
self.head = None
self._size = 0
def append(self, el):
if self.head:
pointer = self.head
... |
print('{} DESAFIO 29 {}'.format('='*10, '='*10))
vel = float(input('Digite a velocidade do caro (Km/h): '))
if vel <= 80.0:
print('Você está dentro do limite!')
else:
dif = vel - 80
print('Você ultrapassou o limite!\nTerá de paga uma multa de R$7,00 para cada Km rodado, no total será R${:.2f}!'.format(dif *... |
version = '0.6.4'
version_cmd = 'consul -v'
depends = ['unzip']
download_url = 'https://releases.hashicorp.com/consul/VERSION/consul_VERSION_linux_amd64.zip'
install_script = """
unzip -o consul_VERSION_linux_amd64.zip
mv -f consul /usr/local/bin/consul
"""
|
'''input
2000
'''
inp = int(input(''))
print(int((inp-1)*inp*(inp+1)/6+inp)) |
"""
def find_next_wildcard(s, n):
for i in range(n, len(s)):
if s[i] == '?':
index = i
break
else:
index = i+1
return index
def wildcard_main(s):
#print(len(s), [n for n in range(3,2)])
wildcard(s, find_next_wildcard(s, 0))
def wildcard(s, n):
if... |
"""
=========
Associate
=========
Widgets for association rules.
"""
# Category description for the widget registry
NAME = "WISE 2 Tools"
DESCRIPTION = "Widgets for WISE 2"
BACKGROUND = "#FD8D8D"
ICON = "icons/tools.png"
PRIORITY = 303
|
#File name: SUDOKU.py
#Finding unsige cell
def FindUnsignedLocation(Board, l):
for row in range(0,9):
for col in range(0,9):
if (Board[row][col] == 0):
l[0] = row
l[1] = col
return True
return False
def InRow(Board, row, num):
... |
[
[0.02175933, 0.03332428, 0.04187784, 0.03716728, 0.0308031, 0.01415677],
[0.02346025, 0.03427124, 0.04290557, 0.0354381, 0.02346025, 0.01953654],
]
|
def limits(signed, bit_size):
signed_limit = 2 ** (bit_size - 1)
return (-signed_limit, signed_limit - 1) if signed else (0, 2 * signed_limit - 1)
def str_int(signed, bit_size):
s = "u" if not signed else ""
s += "int"
s += "%s" % bit_size
return s
def assert_int_in_range(value, signed, bit_... |
def alternatingCharacters(s):
deleted = 0
for i in range(0,len(s)):
while True:
if i+1 < len(s):
if s[i] == s[i+1]:
s.pop(i+1)
deleted += 1
else:
break
else:
return del... |
class Solution:
# @param {integer[]} nums
# @return {integer[]}
def singleNumber(self, nums):
xor = reduce(operator.xor, nums)
res = reduce(operator.xor, (x for x in nums if x & xor & -xor))
return [res, res ^ xor]
|
"""
处理方法
"""
# 处理打印
def println(str):
print(str)
# 验证是否非法
def inputConditionValidata(condition, inputTup):
# 非法判断
try:
inputNumT = int(condition)
# 参数非法 -- 为空
if inputNumT is None:
return False
# 输入参数不包含
ifExist = inputNumT in inputTup
if not i... |
class Solution:
def num_decodings(self, s: str) -> int:
self.memoize = {}
return self.find(s)
def find(self, s):
if s in self.memoize:
return self.memoize[s]
elif s == '':
return 1
else:
qty = 0
if int(s[:1]) > 0:
... |
"""
FUNCTIONS:
1. Write a Python function to find the Max of three numbers.
2. Write a Python program to reverse a string.
Sample String : "1234abcd"
Expected Output : "dcba4321"
3. Write a Python function to sum all the numbers in a list.
Sample List : (8, 2, 3, 0, 7)
Expected Output : 20
4. Write a Python functi... |
side = 1080
frames = 48
def shape(thickness):
fill(0)
stroke(1)
strokeWidth(1)
with savedState():
rotate(startAngle + f * (endAngle - startAngle), (thickness*0.1, thickness*0.1))
rect(0 - (thickness/2), 0 - (thickness/2), thickness, thickness)
for i in range(frames):
phase = 2 * pi... |
#define a dictionary data structure
#dictionaries have a key : value pair for elements
example_dict = {
"class":"Astr 119",
"prof":"Brant",
"awesomeness":10
}
print(type(example_dict))
#get a value using a key
course = example_dict["class"]
print(course)
#change a value using a key
example_dict["awesomeness"]+=1... |
#Задачи на циклы и оператор условия------
#-------------------
'''
Задача 1.
Вывести на экран циклом пять строк из нулей, причем каждая строка должна быть пронумерована.
'''
# с
# for i in range(1, 6):
# print(f'{i} :', '000000000')
'''
Задача 2.
Пользователь в цикле вводит 10 цифр. Найти количество введеных польз... |
"""
Solution for Leet Code 657.
"""
class Solution:
def judgeCircle(moves):
i = j = 0
for move in moves:
if move is 'U':
i += 1
elif move is 'D':
i -= 1
elif move is 'L':
j += 1
else:
j ... |
class Solution:
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) == 0:
return 0
if len(nums) == 1:
return nums[0]
m = [0] * len(nums)
m[0] = nums[0]
m[1] = m[0] if m[0] > nums[1] else nums[1]... |
# Python 3 Program to find
# sum of Fibonacci numbers
# Computes value of first
# fibonacci numbers
def calculateSum(n) :
if (n <= 0) :
return 0
fibo =[0] * (n+1)
fibo[1] = 1
# Initialize result
sm = fibo[0] + fibo[1]
# Add remaining terms
for i in range(2,n+1) :
fibo[i] = fibo[i-1] + fibo[i-2]
sm = s... |
# Calculando descontos
produto = float(input('Qual o valor do produto ? R$ '))
novo = produto - (produto * 5 / 100)
print('O produto com 5% de desconto ficara : R$ {:.2f} '.format(novo))
|
def can_build(env, platform):
return platform=="android" or platform=="iphone"
def configure(env):
if (env['platform'] == 'android'):
env.android_add_dependency("implementation \"com.android.support:support-v4:28.0.0\"")
env.android_add_dependency("implementation \"com.google.android.gms:play-services-location:1... |
# 20191207
# Baekjoon Oneline Judge No.9095
# 1, 2, 3 더하기
nums = {1:1, 2:2, 3:4}
for i in range(4, 11+1):
nums[i]=nums[i-1]+nums[i-2]+nums[i-3]
n = int(input()) #테스트 케이스 수
for j in range(0, n):
key = int(input())
print(nums[key])
|
m = int(input('Digite um valor em metros: '))
km = m/1000
hm = m/100
dam = m/10
cm = m*100
dm = m*10
mm = m*1000
print('A medida de {}m corresponde à:\n{}mm\n{}cm\n{}dm\n{}dam\n{}hm\n{}km'.format(m, mm, cm, dm, dam, hm, km))
|
class Node(object):
TRUE = 't'
FALSE = 'f'
QUERY = '?'
NOTHING = '-'
def __init__(self, name):
self.name = name
self.status = self.NOTHING
self.cpt = []
self.index = None
self.__children = []
self.__parents = []
return
def __str__(self):... |
# -*- coding: utf-8 -*-
"""
WaterSat
author: Tim Martijn Hessels
Created on Tue Feb 26 08:17:10 2019
"""
def Globcover_LM(version = '1.0'):
ETlook_LM = {
11: 1, #Post-flooding or irrigated croplands (or aquatic)
14: 1, #Rainfed croplands
20: 1, #Mosaic cropland (50-70%) / vegetation (grassland/sh... |
print('Cálculo de area de um quadrado e em seguida multiplicar por 2')
l=int(input('Digite o lado do quadrado: '))
a= l*l
print('a area do qudrado é {}'.format(a*2))
|
# -*- coding: utf-8 -*-
'''
File name: code\su_doku\sol_96.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #96 :: Su Doku
#
# For more information see:
# https://projecteuler.net/problem=96
# Problem Statement
'''
Su Doku (Japanese mean... |
array = [list(map(int, input().split())) for i in range(5)]
check = [list(map(int, input().split())) for i in range(5)]
def checkBingo(arr):
bingoNum = 0
rightSlide = 0
leftSlide = 0
for i in range(5):
colZeroNum = 0
verZeroNum = 0
for j in range(5):
if... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.