-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ajitonelsonn/dev
operasaun logika no boolean
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# operasaun logika no boolean | ||
|
||
Operasaun logika no boolean iha Python hanesan mekanizmu ne'ebé uza ba teste no kontrola fluxu iha programa. Ita bele utiliza operadores logika hanesan `and`, `or`, no `not` atu kombine kondisaun sira no hatudu rezultadu ho valor lógiku (`True` ka `False`). | ||
|
||
Operadores logika sira iha Python: | ||
|
||
1. `and`: Retorna `True` bainhira ambu operador sira ne'ebé kombine mak `True`. | ||
2. `or`: Retorna `True` bainhira iha pelo menus ida husi ambu operador ne'ebé kombine mak `True`. | ||
3. `not`: Inverte valor lógiku; `True` ba `False` no `False` ba `True`. | ||
|
||
Ezemplu sira: | ||
|
||
```python | ||
# Operador "and" | ||
print(True and True) # Sai True | ||
print(True and False) # Sai False | ||
print(False and True) # Sai False | ||
print(False and False) # Sai False | ||
|
||
# Operador "or" | ||
print(True or True) # Sai True | ||
print(True or False) # Sai True | ||
print(False or True) # Sai True | ||
print(False or False) # Sai False | ||
|
||
# Operador "not" | ||
print(not True) # Sai False | ||
print(not False) # Sai True | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
### Exerciciu I | ||
|
||
Alguns exercísiu sira hodi pratika operadores logika no boolean iha Python: | ||
|
||
1. **Exercísiu 1**: Verifika se númeru iha entre limites ne'ebé determina (5 no 10). | ||
|
||
```python | ||
num = int(input("Foti númeru: ")) | ||
|
||
# Verifika se númeru entre 5 no 10 | ||
between_limits = num >= 5 and num <= 10 | ||
|
||
print("Númeru entre 5 no 10:", between_limits) | ||
``` | ||
|
||
2. **Exercísiu 2**: Verifika se uma iha tinan legal ba halo atividade desportu (tinan legal mak 18 ka tinan ki'ik liu). | ||
|
||
```python | ||
idade = int(input("Foti ita nia idade: ")) | ||
|
||
# Verifika se idade legal atu halo atividade desportu | ||
pode_halodeporte = idade >= 18 | ||
|
||
print("Ita bele halo atividade desportu:", pode_halodeporte) | ||
``` | ||
|
||
3. **Exercísiu 3**: Verifika se usuário iha permissaun ba halo edição iha sistema (permissaun bele mak `admin`). | ||
|
||
```python | ||
permissaun = input("Foti ita nia permissaun: ") | ||
|
||
# Verifika se usuario iha permissaun administrador | ||
tem_permissoes = permissaun == "admin" | ||
|
||
print("Ita iha permissaun administrador:", tem_permissoes) | ||
``` | ||
|
||
4. **Exercísiu 4**: Verifika se cliente bele hola deskontu espesiál iha loja (terdaftar no cliente lojal). | ||
|
||
```python | ||
terdaftar = True | ||
cliente_lojal = True | ||
|
||
# Verifika se cliente bele hola deskontu espesiál | ||
bele_deskontu = terdaftar and cliente_lojal | ||
|
||
print("Cliente bele hola deskontu espesiál:", bele_deskontu) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Operador "and" | ||
print(True and True) # Sai True | ||
print(True and False) # Sai False | ||
print(False and True) # Sai False | ||
print(False and False) # Sai False | ||
|
||
# Operador "or" | ||
print(True or True) # Sai True | ||
print(True or False) # Sai True | ||
print(False or True) # Sai True | ||
print(False or False) # Sai False | ||
|
||
# Operador "not" | ||
print(not True) # Sai False | ||
print(not False) # Sai True |