Jump to content
Fórum Script Brasil
  • 0

Python ( Urgente )



Elaborar um algoritmo para gerar aleatoriamente 50 números inteiros entre 1 (inclusive) e 50 (inclusive) armazenando-os em uma lista.

Posteriormente deve-se criar e imprimir um dicionário com os seguintes pares chave - valor: {'pares':[ lista de números pares ordenados], 'ímpares':[ lista de números ímpares ordenados]}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Boa noite man 😄

Eu fiz da seguinte forma:

import random

pares = []
impares = []

for _ in range(1, 51):
  num = random.randint(1, 50)
  if num % 2 == 0:

pares_impares = {
    'Pares': sorted(pares),
    "Ímpares": sorted(impares)


Edited by lucasbazan
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...