vault backup: 2025-11-05 11:43:05
This commit is contained in:
parent
ebbded3518
commit
52aff9621f
47
1. Variáveis, entrada e saída.md
Normal file
47
1. Variáveis, entrada e saída.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
## Rosetta
|
||||||
|
```python
|
||||||
|
# Declarando variaveis
|
||||||
|
x = 1 # inteiro (int)
|
||||||
|
y = 1.2 # decimal (float)
|
||||||
|
p = True # booleano (bool)
|
||||||
|
s = "Ola" # texto (string)
|
||||||
|
l = [1, 2] # lista (list)
|
||||||
|
|
||||||
|
# Entrada e saida
|
||||||
|
texto = input()
|
||||||
|
inteiro = int( input() )
|
||||||
|
|
||||||
|
## Entrada com prompt
|
||||||
|
nome = input("Digite seu nome:")
|
||||||
|
idade = int( input("Digite sua idade:") )
|
||||||
|
|
||||||
|
print("Ola,", nome) # 'Olá, [seu nome]'
|
||||||
|
print("Sua idade eh", idade)
|
||||||
|
|
||||||
|
# Operadores
|
||||||
|
## Aritmética
|
||||||
|
soma = 1 + 2 # 3
|
||||||
|
multiplicacao = 3 * 7 # 21
|
||||||
|
divisao = 96 / 4 # 24.0
|
||||||
|
divisao_inteira = 45 // 2 # 22 (o decimal é ignorado, não arredondado)
|
||||||
|
resto_divisao = 23 % 10 #
|
||||||
|
|
||||||
|
## Comparadores
|
||||||
|
igualdade = 42 == 2 # False
|
||||||
|
maior_que = 2 > 4 # True
|
||||||
|
menor_que = 8 < 8 # False
|
||||||
|
|
||||||
|
maior_igual = 4 >= 4 # True
|
||||||
|
menor_igual = 1 <= 10 # True
|
||||||
|
|
||||||
|
## Algebra booleana
|
||||||
|
e_logico = True and True # True, somente se os dois lados forem True
|
||||||
|
e_exemplo = 1 > 2 and 10 > 7 # False, pois 1 > 2 = False
|
||||||
|
|
||||||
|
ou_logico = True or False # True, se qualquer lado for True
|
||||||
|
ou_exemplo = 1 > 2 or 10 > 7 # True, pois 10 > 7 = True
|
||||||
|
```
|
||||||
|
## Print, Input e strings
|
||||||
|
```python
|
||||||
|
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue
Block a user