@valoro/

alternos_con_excepciones_1

Python

http://altocodigo.blogspot.com/2018/08/alternos-con-excepciones.html

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.1432228204270647","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"I0ltcHJpbWlyIGRpZXogbsO6bWVyb3MgYWxlYXRvcmlvcyBzaW4gcmVwZXRpY2nDs24gZW50cmUgMTAwIHkgMTMwLAojZXhjZXB0byBsb3MgbsO6bWVyb3MgMTEwLCAxMTUsIDEyMCB5CiNhbHRlcm5hbmRvIHBhciwgaW1wYXIsIGNvbWVuemFuZG8gcG9yIHBhcgpmcm9tIHJhbmRvbSBpbXBvcnQgcmFuZGludApuPTAKTD1bXQp3aGlsZSBuPDEwOgogIHQ9cmFuZGludCgxMDAsMTMxKQogIGlmIHQgbm90IGluICgxMTAsIDExNSwgMTIwKSBhbmQgdCBub3QgaW4gTDoKICAgIGlmIHQlMj09MCBhbmQgbiUyPT0wOiAjcGFyIHkgdG9jYSBwYXIKICAgICAgTC5hcHBlbmQodCkKICAgICAgbis9MQogICAgZWxpZiB0JTIhPTAgYW5kIG4lMiE9MDogI2ltcGFyIHkgdG9jYSBpbXBhcgogICAgICBMLmFwcGVuZCh0KQogICAgICBuKz0xCnByaW50KEwpCkwuc29ydCgpCnByaW50KEwp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Imprimir diez números aleatorios sin repetición entre 100 y 130,
#excepto los números 110, 115, 120 y
#alternando par, impar, comenzando por par
from random import randint
n=0
L=[]
while n<10:
  t=randint(100,131)
  if t not in (110, 115, 120) and t not in L:
    if t%2==0 and n%2==0: #par y toca par
      L.append(t)
      n+=1
    elif t%2!=0 and n%2!=0: #impar y toca impar
      L.append(t)
      n+=1
print(L)
L.sort()
print(L)