Skip to content

Instantly share code, notes, and snippets.

from random import seed, randrange
def code_random(text): # El texto ha de ser letras de A-Z (sin la Ñ)
# o espacios.
if len(text) % 4 > 0:
text += ' ' * (4 - len(text) % 4) # Añade espacios al final si es
# necesario.
seq = []
tokens = [text[i:i+4] for i in range(0, len(text), 4)] # Divide el texto
# John Horton Conway Tribute 1937 - 2020
try:
from console import clear # Define "clear" para iOS
except:
import os
if os.name == 'posix':
def clear(): # Unix, Linux, Mac o
os.system('clear')
else:
from time import *
i = 1
pi = 0
ti = time()
while True:
pi = pi + 4 / i - 4 / (i + 2) # método 1
i += 4
if time() - ti >= 5:
@pablovv72
pablovv72 / RepartoGastos_1.pyui
Created November 26, 2018 22:46
RepartoGastos_1.pyui
[
{
"nodes" : [
{
"nodes" : [
],
"frame" : "{{64, 6}, {177, 32}}",
"class" : "Label",
"attributes" : {
@pablovv72
pablovv72 / RepartoGastos_1.py
Created November 26, 2018 22:45
RepartoGastos_1.py
# coding: utf-8
import ui
import clipboard
import console
import speech
def hablar(sender):
speech.say(v['textview1'].text)
@pablovv72
pablovv72 / gps.py
Last active December 16, 2018 16:30
gps.py
import ui
import location
import time
import motion
from math import *
cardinales = (
'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE',
'S', 'SSO', 'SO', 'OSO', 'O', 'ONO', 'NO', 'NNO'
)
@pablovv72
pablovv72 / gps.pyui
Created November 26, 2018 10:32
gps.pyui
[
{
"nodes" : [
{
"nodes" : [
],
"frame" : "{{0, 0}, {375, 563}}",
"class" : "View",
"attributes" : {
@pablovv72
pablovv72 / reto.py
Last active November 24, 2018 12:14
'''Hallar un número acabado en 2 que cumpla la condición de que si se desplaza
el 2 a la posición inicial el número resultante es el doble del inicial.'''
n = 42
exp = 2
while 2 * 10 ** (exp - 2) + n // 10 != n * 2:
n = (n * 20 + 2) - (n * 20 + 2) // 10 ** exp * 10 ** exp
exp += 1
print(n)
# Diseñe un algoritmo que calcule cuantos lotes de X mts. salen de X hectareas
while True:
metros_cuadrados = int(input('Número de hectareas: ')) * 10000
if metros_cuadrados == 0:
break
lote = int(input('Metros cuadrados por lote: '))
print(f'salen {int(metros_cuadrados / lote)} lotes.')
# Dibuja aleatoriamente polígonos con efecto caleidoscópico.
import turtle
from random import *
# Configuramos la pizarra para la tortuga.
t = turtle
clon = t.clone()