@valoro/

operaciones_basicas_2

Python

https://altocodigo.blogspot.com/2018/08/operaciones-con-numeros-en-python.html

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7346700143168217","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJhbmRvbQp4PXJhbmRvbS5yYW5kcmFuZ2UoMSwxMCwyKSAjZ2VuZXJhIGltcGFyZXMgZW50cmUgMSB5IDkKeT1yYW5kb20ucmFuZHJhbmdlKDMpICNnZW5lcmEgMCwxLDIKcHJpbnQoeCwnKycseSwnPScseCt5KQpwcmludCh4LCctJyx5LCc9Jyx4LXkpCnByaW50KHgsJyonLHksJz0nLHgqeSkKcHJpbnQoeCwnZWxldmFkbyBhJyx5LCc9Jyx4Kip5KQpkZWYgZGl2KHgseSk6CiAgICB0cnk6IHJldHVybiB4L3kKICAgIGV4Y2VwdCBaZXJvRGl2aXNpb25FcnJvcjogcmV0dXJuICdlcnJvcjogZGVub21pbmFkb3IgY2VybycKcHJpbnQoeCwnLycseSwnPScsZGl2KHgseSkpCmRlZiBkaXZlbnQoeCx5KToKICAgIHRyeTogcmV0dXJuIHgvL3kKICAgIGV4Y2VwdCBaZXJvRGl2aXNpb25FcnJvcjogcmV0dXJuICdlcnJvcjogZGVub21pbmFkb3IgY2VybycKcHJpbnQoeCwnZGl2aXNpw7NuIGVudGVyYSBlbnRyZScseSwnPScsZGl2ZW50KHgseSkpCmRlZiBtb2R1bG8oeCx5KToKICAgIHRyeTogcmV0dXJuIHgleQogICAgZXhjZXB0IFplcm9EaXZpc2lvbkVycm9yOiByZXR1cm4gJ2Vycm9yOiBkZW5vbWluYWRvciBjZXJvJwpwcmludCh4LCdtw7NkdWxvJyx5LCc9Jyxtb2R1bG8oeCx5KSk="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import random
x=random.randrange(1,10,2) #genera impares entre 1 y 9
y=random.randrange(3) #genera 0,1,2
print(x,'+',y,'=',x+y)
print(x,'-',y,'=',x-y)
print(x,'*',y,'=',x*y)
print(x,'elevado a',y,'=',x**y)
def div(x,y):
    try: return x/y
    except ZeroDivisionError: return 'error: denominador cero'
print(x,'/',y,'=',div(x,y))
def divent(x,y):
    try: return x//y
    except ZeroDivisionError: return 'error: denominador cero'
print(x,'división entera entre',y,'=',divent(x,y))
def modulo(x,y):
    try: return x%y
    except ZeroDivisionError: return 'error: denominador cero'
print(x,'módulo',y,'=',modulo(x,y))