diff --git a/exercicio3.py b/exercicio3.py new file mode 100644 index 0000000..d5df2cf --- /dev/null +++ b/exercicio3.py @@ -0,0 +1 @@ +print(["Maçã", "Banana", "Laranja", "Uva", "Abacaxi"][:3]) \ No newline at end of file diff --git a/exercicio4.py b/exercicio4.py new file mode 100644 index 0000000..4fffc82 --- /dev/null +++ b/exercicio4.py @@ -0,0 +1 @@ +print({"título": "Dom Quixote", "autor": "Miguel de Cervantes", "ano": 1605}["autor"]) diff --git a/exercicio5.py b/exercicio5.py new file mode 100644 index 0000000..9ffef26 --- /dev/null +++ b/exercicio5.py @@ -0,0 +1,4 @@ +def soma_pares(lista): + return sum(x for x in lista if x % 2 == 0) + +print(soma_pares([1, 2, 3, 4, 5, 6])) # Saída: 12 diff --git a/exercicios.py b/exercicios.py new file mode 100644 index 0000000..30f5440 --- /dev/null +++ b/exercicios.py @@ -0,0 +1,10 @@ +def dobro(n): + return n * 2 + +print(dobro(2)) # 4 +print(dobro(5)) # 10 +print(dobro(-3)) # -6 +print(dobro(0)) # 0 + + + diff --git a/exercicios2.py b/exercicios2.py new file mode 100644 index 0000000..d4fbcff --- /dev/null +++ b/exercicios2.py @@ -0,0 +1,6 @@ +nome = input("Digite seu nome: ") +while not (idade := input("Digite sua idade: ")).isdigit(): + print("Digite um número inteiro válido.") +idade = int(idade) +print(f"Bem-vindo(a), {nome}! Você tem {idade} anos.") +