Jump to content

Desafio CasadoDev 01.


Recommended Posts

  • Administradores

Atenção Devs! 

Vou lançar aqui um desafio de Phyton e quero ver quem vai acertar 😄👀

for num in range (2,-5,-1): 
print(num, end=", ")

Qual seria a resposta correta?

a) 2, 1, 0 
b) 2, 1, 0, -1, -2, -3, -4, -5
c) 2, 1, 0, -1, -2, -3, -4
d) Nenhuma das alternativas.

 

 Comenta aí a alternativa que você acha certa e explique porque chegou nessa resposta 😜

  • Curtir 1
Link to comment
Share on other sites

  • Administradores

Ow locooo hein! hahahaha tentei começar leve 🤣 brinks

Aí gente o @Marcelo Luiz Baraldi sugeriu um novo desafioo aqui hein, essa é mais dífícil hein:

- Crie uma função que retorne o número de true valores que existem em uma matriz.

Exemplos: 

countTrue([true, false, false, true, false])  2

countTrue([false, false, false, false])  0

countTrue([])  0

Notas:

  • Retorne 0 se for fornecido um array vazio.
  • Todos os itens da matriz são do tipo bool (true ou false).

Para ajudar, qual dessas alternativas é a correta? 😜

a) const countTrue = r => r.Array.filter(True).length
b) const countTrue = r => r.filter(Boolean).length
c) const countTrue = r => r.filter(r=<r).length
d) const countTrue = r => r.filter(x=>x!=true).length 

  • Curtir 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...