Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teste exercício 1 da lista de strings finalizado #69 #145

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions secao_06_exercicios_strings/ex_01_comparador_de_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@
String 2: Brasil! Hexa 2006!
Tamanho de "Brasil Hexa 2006": 16 caracteres
Tamanho de "Brasil! Hexa 2006!": 18 caracteres
As duas strings possuem tamanhos diferentes.
As duas strings possuem conteúdo diferentes.
>>> comparar('Hexa 2006', 'Hexa 2006')
String 1: Hexa 2006
String 2: Hexa 2006
Tamanho de "Hexa 2006": 9 caracteres
Tamanho de "Hexa 2006": 9 caracteres
As duas strings possuem tamanhos iguais.
As duas strings possuem conteúdo iguais.
>>> comparar('Hexa 2006', 'Hexa 2008')
String 1: Hexa 2006
String 2: Hexa 2008
Tamanho de "Hexa 2006": 9 caracteres
Tamanho de "Hexa 2008": 9 caracteres
As duas strings possuem tamanhos iguais.
As duas strings possuem conteúdo diferentes.
As duas strings são de tamanhos diferentes.
As duas strings possuem conteúdo diferente.
>>> comparar('Igual', 'Igual')
Expand All @@ -28,3 +44,18 @@

def comparar(s1: str, s2: str):
"""Escreva aqui em baixo a sua solução"""
print("String 1:", s1)
print("String 2:", s2)
tamanho1= len(s1)
tamanho2= len(s2)
print(f'Tamanho de "{s1}": {tamanho1} caracteres')
print(f'Tamanho de "{s2}": {tamanho2} caracteres')
if len(s1) == len(s2):
print("As duas strings possuem tamanhos iguais.")
else:
print("As duas strings possuem tamanhos diferentes.")
if s1 == s2:
print("As duas strings possuem conteúdo iguais.")
else:
print("As duas strings possuem conteúdo diferentes.")