content stringlengths 7 1.05M |
|---|
class Scale:
def __init__(self, tonic):
if tonic in ["F", "Bb", "Eb", "Ab", "Db", "Gb", "d", "g", "c", "f", "bb", "eb", ]:
notes = ["A", "Bb", "B", "C", "Db", "D",
"Eb", "E", "F", "Gb", "G", "Ab", ]
else:
notes = ["A", "A#", "B", "C", "C#", "D",
... |
'''
Exercício Python 105: Faça um programa que tenha uma função notas() que
pode receber várias notas de alunos e vai retornar um dicionário com as
seguintes informações:
– Quantidade de notas
– A maior nota
– A menor nota
– A média da turma
– A situação (opcional)
'''
def notas(*n, sit=False):
"""
-> Fu... |
"""
Crie um programa que vai ler vários números e coloca em uma lista.
Depois disso, cire duas listas extras que vão conter apenas os valores PARES e os valores ÍMPARES digitados, respectiva-
mente. Ao final, mostre o conteúdo das três listas geradas.
"""
valores = []
while True:
valores.append(int(input('Digite um... |
# binStrToBytes : Converts a binary string to an array of bytes.
# @param bin : The binary string to be converted to byte array.
# @return : The byte array representation of the provided binary string.
def binStrToBytes(bin):
if (not isinstance(bin, str)):
raise TypeError("Unexpected type, expected 'str'")... |
# Hidden Street - Ardentmill :: 910001000
# Gere :: Master of Smithing :: 9031003
MINING_SKILL = 92010000
SMITHING_CRAFT_SKILL = 92020000
ACCESSORY_CRAFT_SKILL = 92030000
ALCHEMY_CRAFT_SKILL = 92040000
FEE = [5000, 15000, 25000, 40000, 60000, 85000, 115000, 150000, 190000, 235000]
if not sm.hasSkill(SMITHING_CRAFT_SK... |
# -*-coding:utf-8 -*
ALPHABETS = ['Hiragana', 'Katakana', 'Kanji']
# The order must match with the input of selectKanasSubset
KANAS_SUBSETS = ["simple Kanas", "Dakuon",
"Handakuon", "combo Kanas", "Kanas"]
SIMPLE_KANAS_ROMA = {
"": ["a", "i", "u", "e", "o"],
"K": ["ka", "ki", "ku",... |
''' Dataset 1
# This cases have displaced or incorrect annotation files
# Some maybe be corrected using the map below
skipCase = ['LUNG1-034',
'LUNG1-040',
'LUNG1-044',
'LUNG1-068',
'LUNG1-083',
'LUNG1-084',
'LUNG1-094',
'LUNG1-096',
... |
(5)(3)
l = [a, 21, l]
l(3)
a(20, 21, *n, b=m)
|
ages = [5, 12, 17, 18, 24, 32]
def myFunc(x):
if x < 18:
return False
else:
return True
adults = filter(myFunc, ages)
for x in adults:
print(x) |
def fraction(a, b):
try:
return "%.1f" % (float(a) / float(b))
except (ValueError, ZeroDivisionError):
return "ERR"
|
# M-1
x1 = 12
y1 = 5
z1 = x1*y1
print(z1)
# M-2
eggs = 12
unit_price = 5
total_price = eggs*unit_price
print(total_price)
# M-3
a12345 = 12
b12345 = 5
c12345 = a12345*b12345
print(c12345)
|
# SAVE PATIENTS
n = int(input())
strength = list(map(int, input().split()))
patient = list(map(int, input().split()))
strength.sort()
patient.sort()
for i in range(n):
if strength[i]<patient[i]:
print("No")
break
else:
print("Yes")
|
num = soma = cont = 0
while True:
print('Digite 999 para sair dor programa!! ')
num = int(input('Digite um número: '))
if num == 999:
break
cont += 1
soma += num
print(f'Foram digitados {cont} e a soma entre eles é de {soma}')
print(3 * ' -* ' + 'Abacou' + 3 * ' *- ')
|
# 06 Magic Methods
# https://rszalski.github.io/magicmethods/
# Magiv Methods are called automaticly by Python interpreter, depending on how we use our object and class
class Point:
point_color = "Red"
@classmethod
def zero(cls):
return cls(0, 0, 0)
def __init__(self, x, y, z):
self... |
# Implement Rand10() Using Rand7()
'''
Given the API rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10. You can only call the API rand7 and you shouldn't call any other API. Please don't use the system's Math.random... |
def BST_nearest_val(data, val):
"""Nearest Value in a Binary Seach Tree."""
nearest = abs(val - data.root.val)
hour = data.root.val
def _walk(node=None):
nonlocal nearest, hour
if node is None:
return
if node.left is not None:
_walk(node.left)
#... |
#EP:1
"""
import math
r = eval(raw_input('Please enter the length from the center to a vertex: '))
s = 2 * r * math.sin(math.pi/5)
area = 5 * s * s / (4*math.tan(math.pi/5))
print('The area of the pentagon is: {:.2f}'.format(area)) """
#EP:2
"""
import math
x1,y1 = eval(raw_input('Please enter point 1 (latitude and ... |
# Python vs. C++ Example 4
# Rachel J. Morris, 2013 - RachelJMorris@gmail.com, Moosader.com, github.com/Moosader
# MIT License
# Generally, these shouldn't be stored in separate lists; we would create
# a class to store name & age, but we will do this in a later example.
lstStudentNames = []
lstStudentAges = []
doneW... |
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param root, a tree node
# @return an integer
def sumNumbers(self, root):
if not root:
return 0
qu... |
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Simple test on a grid texture
command = testshade("-t 1 -groupname Beatles -layer Cake test")
command += testshade("-t 1 -g ... |
"""The holiest cli template system
tmplr provides modules for working with tmplr templates, called Temples. Most
Temples are represented by actual files on disk, so a convenience function is
provided to create a Temple from a path. Programmatic access is also provided.
Modules:
temple -- provides the Temple class... |
tabela = ('Atletico-MG', 'Palmeiras', 'Fortaleza', 'Bragantino', 'Flamengo',
'Atletico=PR', 'Ceará SC', 'Santos', 'Atletico-GO', 'Bahia',
'Internacional', 'Corinthians', 'Fluminense', 'Juventude', 'Sport Recife',
'São Paulo', 'América-MG', 'Cuiaba', 'Grêmio', 'Chapecoense')
print('=' * 400... |
#!/usr/bin/env python
"""
/*******************************************************************************
* Copyright (c) cortical.io GmbH. All rights reserved.
*
* This software is confidential and proprietary information.
* You shall use it only in accordance with the terms of the
* license agreement you ente... |
a = range(5) #产生0-4的range对象
b = list(a) #将range转化为列表
for i in a:
print(i)
for j in range(2, 10): #产生2-9的range
print(j)
for k in range(3, 30, 4): #产生3到29,步进为4的数
print(k)
|
count=0
for b in range(1,11):
for g in range(1,21):
count+=1
print(f"第{count}号搭配方案:{b}号男生和{g}号女生")
print(f"总共有{count}种搭配方案") |
######################################
# general weight sampling
######################################
def gaussPertubation(weight,weightStt,offsetStd=0.0,out=None,n=1):
"""" very stupid sampling"""
pass
######################################
# general weight sampling
#####################################... |
table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
flag = [ord("X") for i in range(0x64)]
flag[0] = ord(table[0x1c])
flag[1] = ord(table[0x36])
flag[2] = ord(table[(0x1c + 0x36) >> 2])
flag[10] = flag[2]
flag[3] = 0x6a
flag[4] = flag[0] + 1
for p in [0xc, 0x16, 0x18]:
flag[p] = flag[4] - 1
fl... |
class Configuration:
DB = 'aiohttpdemo_polls'
USER = 'aiohttpdemo_user'
PASS = 'aiohttpdemo_pass'
HOST = 'localhost'
PORT = '5432'
|
class Provider(object):
base_url = None
def __init__(self, url: str) -> None:
self.base_url = url
def watch(self):
pass |
#
# PySNMP MIB module XYLAN-BASE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYLAN-BASE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:44:24 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... |
pares, impares, positivos, negativos = 0, 0, 0, 0
for i in range(5):
num = int(input())
if num % 2 == 0:
pares += 1
else:
impares += 1
if num > 0:
positivos += 1
elif num < 0:
negativos += 1
print('{} valor(es) par(es)'.format(pares))
print('{} valor(es) i... |
arquivo = open('argv.py', 'r')
for line in arquivo:
print(line.rstrip())
|
class D(object):
pass
class E(object):
pass
class F(object):
pass
class B(E, D):
pass
class C(D, F):
pass
class A(B, C):
pass
|
def null(X):
null_list = X.isnull().sum()
return null_list
|
def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse,... |
'''
Crie uma tupla preenchida com os 20 primeiros colocados
da Tabela do Campeonato Brasileiro de Futebol.
Na ordem de classificação. Depois mostre:
A) Apenas os 5 primeiros colocados.
B) Os últimos 4 colocados da tabela
C) Uma lista com os times em ordem alfabética
D) Em que posição na tabela está o time da Chapecoen... |
class Question(object):
def __init__(self, id, title, text):
self._id = id
self._title = title
self._text = text
self._answers = []
self._chosen_answer = None
@property
def id(self):
return self._id
@id.setter
def id(self, id):
self._id = i... |
class MinStack(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.data=[]
self.minData=[] # to store the min
def push(self, x):
"""
to add a number to the stack, and add min to minData
:type x: int
:rtype: Non... |
# -*- coding: utf-8 -*-
name = 'usdview'
version = '18.11'
requires = [
'pyside-1.2',
'usd-18.11'
]
def commands():
env.DEFAULT_USD.set('{root}/bin/DefaultUSD.usda')
|
# 7. Write a program that asks the user to enter a word and determines whether the word is a
# palindrome or not. A palindrome is a word that reads the same backwards as forwards.
s = input('Enter a string: ')
new_string = s[::-1] # a negative step reverses the string
if s == new_string:
print('It is a palindro... |
# example of raise usage
try:
raise IndexError('spam') # storage arguments
except IndexError:
print('propagating')
raise # reusage of exception
"""
propagating
Traceback (most recent call last):
File "propagation_of_exception.py", line 4, in <module>
raise IndexError('spam') # storage arguments
IndexError... |
moveSet1 = 'R1009,D117,L888,D799,L611,U766,L832,U859,L892,D79,R645,U191,L681,D787,R447,D429,L988,U536,L486,D832,R221,D619,R268,D545,L706,U234,L528,D453,R493,D24,L688,U658,L74,D281,R910,D849,L5,U16,R935,D399,L417,U609,R22,D782,L432,D83,L357,D982,L902,U294,L338,U102,R342,D621,R106,U979,L238,U158,R930,D948,L700,D808,R445,... |
##
##
##
def exec(conexao):
cursor = conexao.cursor()
print("RULE 16 - Inicializando",end=' ')
update = " UPDATE principal SET "
update = update + " r25 = \"50\", "
update = update + " r31 = \"50\" "
update = update + " WHERE 1=1 "
update = update + " AND r1 = \"C170\" "
update =... |
#!/usr/bin/env python
# Import modules
# Read settings file
settings_file = open('./odin_fix_settings.txt')
input_file = settings_file.readline().rstrip()
output_file = settings_file.readline().rstrip()
parsed_file = open(output_file,'w')
parsed_file.write('Date\tTime\tDust\tRH\tTemp\tBatt\n')
with open(input_file,'r')... |
class Solution(object):
def grayCode(self, n):
"""
:type n: int
:rtype: List[int]
"""
res = [0,1]
if n == 1:
return res
elif n == 0:
return [0]
order = 1
while order<n:
count = len(res)
... |
t = int(input())
for ___ in range(t):
length = int(input())
a = [int(k) for k in input().split(' ')]
max_boost = 0
summm = 0
for k in range(length):
if k%2 == 0:
summm += a[k]
for l in range(length-1):
if l%2 == 0:
vygoda = 0
sum_nech, sum_ch =... |
#desafio12: algoritmo que leia o preço de um produto e mostre seu novo preço, com 5% de desconto
#
po=float(input('Qual o preço deste produto? R$'))
pn = po-(po*(5/100))
print('O preço deste mesmo produto com 5% de desconto é de R${:.2f}'.format(pn)) |
class Solution:
def __init__(self) :
self.store = {
0 : [],
1 : ["()"]
}
def AllParenthesis(self,n):
if n in self.store :
return self.store[n]
ans = set()
for i in range(n) :
if i == 0 :
for co... |
"""
004
Ask the user to enter
two numbers. Add
them together and
display the answer as
The total is
[answer].
"""
number1 = float(input("Enter two numbers plz :"))
number2 = float (input())
sum = number1 + number2
print("The total is \n",sum) |
"""
In a town, there are N people labelled from 1 to N. There is a
rumor that one of these people is secretly the town judge.
If the town judge exists, then:
The town judge trusts nobody
Everybody (except for the town judge) trusts the town judge
There is exactly one person that satisfies properties 1 an... |
####################################################
# Problem 4, chapter 1, Bioinformatics VI finding
# mutations.
# Multiple pattern matching, using suffix tree,
# and Longest Repeat Problem
# Input: ATATCGTTTTATCGTT
# Output: TATCGTT
# ---------------------------------------------
#
# Use t... |
def translate(value, leftMin, leftMax, rightMin, rightMax):
leftSpan = leftMax - leftMin
rightSpan = rightMax - rightMin
valueScaled = float(value - leftMin) / float(leftSpan)
result = rightMin + (valueScaled * rightSpan)
return result
def reversed_iterator(iter):
return reversed(list(iter))
|
t = int(input())
def find_max_level(n: int):
sums = [1]
i = 1
while max(sums) < n:
sums.append(2 * sums[i - 1] + 1)
i += 1
return i
def create_binomial_matrix(level: int):
mat = [[1 if j == i or j == 0 else 0 for j in range(0,level)] for i in range(0,level)]
for i in range... |
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Check with 'pylint' command to code rating.
'''
A very simple script.
'''
def func():
'''
A simple function
'''
first = 1
second = 2
print(first)
print(second)
func()
|
_CLASH_ERR = "Cannot have more than one '{}' stanza (Clashing files: {})"
_VALID_ERR = "The data in the '{}' stanza from '{}' failed validation rules."
class MetaloaderError(RuntimeError):
pass
class ExclusiveStanzaClashError(MetaloaderError):
def __init__(self, key, clashing_files):
error_message =... |
class Solution:
def defangIPaddr(self, address: str) -> str:
# replace
return address.replace('.', '[.]')
# def defangIPaddr(self, address: str) -> str:
# # split and join
# return '[.]'.join(address.split('.'))
# def defangIPaddr(self, address: str) -> str:
# # repla... |
def somadig(n):
if n == 0:
return 0
else:
return (n % 10) + somadig(n // 10)
print(somadig(120))
#https://pt.stackoverflow.com/q/349093/101
|
# Odoo, Open Source Web Company Color
# Copyright (C) 2019 Alexandre Díaz <dev@redneboa.es>
#
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).#
{
"name": "Web Company Color",
"category": "web",
"version": "14.0.1.0.0",
"author": "Alexandre Díaz, Odoo Community Association (OCA)",
"we... |
class Node:
def __init__(self, data):
self.data = data
self.next_node = None
class LinkedList:
def __init__(self):
self.head = None
self.size = 0
def insert_at_start(self, data):
new_node = Node(data)
self.size += 1
if not self.head:
se... |
"""
This script is to be run on Tropo
"""
def wait_for_signal():
while True:
event = say("http://www.phono.com/audio/holdmusic.mp3 http://www.phono.com/audio/holdmusic.mp3") #, {onSignal: make_call_handler})
if event.name == 'signal':
yield event.value
else:
break
... |
# You are given the head of a linked list and two integers, i and j.
# You have to retain the first i nodes and then delete the next j nodes.
# Continue doing so until the end of the linked list.
# Example:
# linked-list = 1 2 3 4 5 6 7 8 9 10 11 12
# i = 2
# j = 3
# Output = 1 2 6 7 11 12
# LinkedList Node class f... |
celcius = float(input('informe a temperatura em ºC:'))
fahrenheit = (celcius*1.8)+32
print(f'A temperatura de {celcius}ºC corresponde a {fahrenheit}ºF!')
|
"""
https://leetcode.com/problems/palindrome-number/
Return True if a number is a palindrome
121 -> True
-121 -> False 121-
10 -> False 01
Bonus: Could you solve it without converting the int to a string?
I think I'll try converting the int into a list by using modulus.
Then make 2 pointers left and right to compar... |
# jmespath/_lrtable.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\xb4\x1bXD\x01\x03z\xbb\x19\xfc\rk\xd7x\x00\xa3'
_lr_action_items = {'STAR':([0,2,11,23,26,28,29,32,36,39,44,45,46,47,48,49,50,55,63,],[1,14,1,1,51,1,57,1,1,1,-16,-17,1,-18,-19,-1... |
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
load("@python3//:defs.bzl", "interpreter")
def _bitstreams_repo_impl(rctx):
rctx.execute(
[
rctx.path(rctx.attr.python_interpreter),
rct... |
# Reading data from file
f = open("student.txt", mode="r")
data1 = f.read(2)
data2 = f.read(2)
print(data1)
print(data2)
f.close()
print("complete!!!") |
#!/usr/bin/env python
#--------- Javascript escaping code lifted from Django (BSD)
_base_js_escapes = (
('\\', r'\u005C'),
('\'', r'\u0027'),
('"', r'\u0022'),
('>', r'\u003E'),
('<', r'\u003C'),
('&', r'\u0026'),
('=', r'\u003D'),
('-', r'\u002D'),
(';', r'\u003B'),
(u'\u2028',... |
class Solution(object):
def removeDuplicates(self, nums):
ht = {}
insert = 0
for num in nums:
if num in ht:
ht[num] += 1
else:
ht[num] = 1
if ht[num] > 2:
continue
else:
nums[in... |
"""
cl-sii Python lib
=================
"""
__version__ = '0.15.0'
|
def module2_1():
a = 2**0.5
print('%.6f' % (a))
def module2_2():
top = 10
bottom = 20
height = 8
area = (top+bottom)*height/2
print('Area of a Trapezoid:%.1f' % area)
def module2_3():
prime_number = [1]
for i in range(2,1001):
prime_flag = True
for prime in prime_nu... |
# list of file paths to ignore when decrypting
# any files that start with these names will not be dumped
nodecrypt = [
"data\\BehaviourCreator",
"data\\DirectXRedist",
"data\\RecommendedBuilds",
"data\\ReplayEncoder",
"data\\Replays",
"data\\Rofl",
"data\\Shaders",
"data\\Sound\\Music",... |
class CheckersBoard:
both = "B"
empty = " "
player_1 = "X"
player_2 = "O"
#
def __init__(self):
"""
Contains properties of CheckersBoard including dimensions, player
piece types, and board
"""
self.dimension = 10
self.player_1 = "X"
... |
def feet2inches(feet):
return feet * 12
def inches2feet(inches):
feet = inches / 12.0
remainder_inches = feet % 12.0
return feet, remainder_inches
def inches2meters(inches):
return inches * 39.37007874
def meters2inches(meters):
return meters / 0.0254
def meters2feet(meters):
inches = meters2inches(... |
#file --pair--
# Jakub Grobelny
# 2018
class pair:
def __init__(self, first, second):
self.first = first
self.second = second
def get(self, which):
if which == 0:
return self.first
elif which == 1:
return self.second
else:
... |
# WAP to show the use of for loop
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities: #city is the iteration variable, cities is the iterable being looped over
print(city)
print("Done!")
|
nombre = None
edad = None
apellido = None
def nombre_completo():
return nombre + ' ' + apellido
def cumplir_anios():
global edad
edad += 1
|
#!/usr/bin/python
"""
==============================================================================
Author: Tao Li (taoli@ucsd.edu)
Date: Jul 10, 2015
Question: 234-Palindrome-Linked-List
Link: https://leetcode.com/problems/palindrome-linked-list/
=============================================================... |
class Solution:
def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:
n = len(grid)
row_high = [0]*n
col_high = [0]*n
for i in range(n):
row_high[i] = max(grid[i])
col_high[i] = 0
for j in range(n):
col_hig... |
"""
PASSENGERS
"""
numPassengers = 3290
passenger_arriving = (
(2, 5, 7, 5, 3, 0, 6, 10, 6, 8, 1, 0), # 0
(2, 8, 4, 3, 2, 0, 8, 6, 5, 5, 4, 0), # 1
(5, 10, 6, 4, 3, 0, 2, 10, 7, 4, 2, 0), # 2
(2, 7, 3, 1, 2, 0, 6, 7, 3, 5, 3, 0), # 3
(5, 6, 4, 5, 1, 0, 5, 7, 5, 6, 0, 0), # 4
(3, 6, 6, 6, 1, 0, 11, 4, 7, 6... |
# coding:utf-8
"""
@author:weiwei
@time:2018.01.30
@version:0.1
"""
|
#!/usr/bin/env python3
# Write a program that computes the running sum from 1..n
# Also, have it compute the factorial of n while you're at it
# No, you may not use math.factorial()
# Use the same loop for both calculations
# your code goes here
n = 5
runsum = 0
runmult = 1
for i in range(1, n+1):
runsum += i
runm... |
def obfuscated_id(x):
y = x
z = y
return z
a = 42
b = obfuscated_id(a)
|
'''
Tipo String
Em Python, um dado é considerado do tipo string sempre que:
- Estiver entre aspas simples -> 'uma string', '234', 'a', 'True', '42.3'
- Estiver entre aspas duplas -> "uma string", "234", "a", "True", "42.3"
- Estiver entre aspas simples triplas;
- Estiver entre aspas simples duplas.
nome = 'Geek Univ... |
"""
Author : Drew Heasman
Date(last updated) : 05 June 2021
Description : Code used for geological calcuations.
"""
|
# noinspection PyUnusedLocal
# friend_name = unicode string
def hello(friend_name):
'''
:param Int1: Integer between 0 and 100 inclusive
:param Int2: Integer between 0 and 100 inclusive
:return: Sum of Int1 and Int2
>>> hello ('Bob') --> 'Hello Bob'
>>> sumR1 ('Alice') --> '... |
"""
pyJsConsole configuration file.
© Anime no Sekai - 2020
"""
## Choose your Browser Layer (between 'Selenium' and 'Pyppeteer')
layer = 'Selenium'
##### Works for both layers
executable_path = ''
no_sandbox = False
args = []
####### Only for Selenium
headless = True
browsername = 'Chrome'
"""
Default Configurati... |
# const
N_INPUTS = 2
N_OUTPUTS = 1
# supported values: 1000, 2000, 4000, 8000, 16000
BATCH_SIZE = 1000
# variables
N_LAYERS = 3
MAX_ITER = 1000
SEED = 41
N_UNITS = []
for i in range(N_LAYERS):
N_UNITS.append(16)
|
# Irupe Canet
# Check if one number divides another
p = 8
m = 2
if (p % m) == 0:
print(p, "divided by", m, "leaves a reminder of zero.")
print("I'll run too if the condition is True.")
else:
print(p, "divided by", m, "does not leaves a reminder of zero.")
print("I'll run no matter what.")
|
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
secrets = {
'ssid' : 'home_network',
'password' : 'ssid_password',
'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
'github_token' : 'fawfj... |
"""
@generated
cargo-raze generated Bazel file.
DO NOT EDIT! Replaced on runs of cargo-raze
"""
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//too... |
width = int(input())
lenght = int(input())
count = width * lenght
while count > 0:
line = input()
if line == "STOP":
break
else:
new_pieces = int(line)
count = count - new_pieces
if count > 0:
print(f"{count} pieces are left.")
else:
print(f"No more cake left! You need {ab... |
"""Summary."""
class Key:
"""Summary."""
def __init__(self, key_str: str):
"""Summary.
Args:
key_str (str): Description
"""
self._key = key_str
def __str__(self) -> str:
"""Summary.
Returns:
str: Description
"""
re... |
# Program to find GCD of the digits of a number
# Recursive function to return gcd of a and b
def gcd(a, b):
return a if (b == 0) else gcd(b, a % b)
def digitGCD(n):
ans = 0
while n > 0:
ans = gcd(n % 10, ans)
# If at any point GCD is 1, return
if gcd == 1:
return 1
... |
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
dic = collections.defaultdict(list)
for s in strs : dic["".join(sorted(s))].append(s)
return list(dic.values())
|
#!/usr/bin/env python
wc_arr = [0 for x in range(0, 14000/8)]
def _iswordchar(ch):
return (not (
ch <= 33
or ch == ord(';') or ch == ord('-') or ch == ord('"') or ch == ord('\'')
or (ch >= 35 and ch <= 38)
or (ch >= 40 and ch <= 44)
or (ch >= 46 and ch <= 47)
or ch == 58
or (ch >= 60 and ch <= 63)
... |
# The main module for the plugin.
# Note: In ALL plugins there must be a python file called [name-of-plugin].py in a folder called [name-of-plugin]!
def init(page, config):
# This code runs when the generate command is called.
print("Example plugin initialized!")
def site(page):
# This code run whenever a new Dars... |
def belongs_to_file(word, filename):
with open(filename) as f:
l = f.readlines()
for w in l:
if w.strip() == word:
return True
return False
print(belongs_to_file("renard", "words.txt"))
print(belongs_to_file("abbots", "words.txt"))
|
class LampTextureSlot:
color_factor = None
object = None
shadow_factor = None
texture_coords = None
use_map_color = None
use_map_shadow = None
|
'''
Created on Feb 24, 2018
@author: danie
'''
|
# Task 05. Faro Shuffle
def faro_shuffle(arr_input):
left_half = deck[:len(arr_input) // 2]
right_half = deck[len(arr_input) // 2:]
new_list = []
for ind in range(len(left_half)):
new_list.append(right_half[ind])
new_list.append(left_half[ind])
return new_list
deck = input().split... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.