If e else Python

9
1 Structuring if statements Universidade Federal de Alagoas Discentes: Danilo Victor B. da Costa e Roberto Bartolomeu

description

If e else Python

Transcript of If e else Python

Page 1: If e else Python

1 Structuring if statements

Universidade Federal de Alagoas Discentes: Danilo Victor B. da Costa e

Roberto Bartolomeu

Page 2: If e else Python

OBJETIVOS:

1. Apresentar o significado do termos “If”, “elif” e “else”.

2. Apresentar a estrutura para o correto uso dos termos descritos.

2 Structuring if statements

Page 3: If e else Python

O QUE É “IF”?

A palavra “if/else”, assim como algumas outras, são reservadas em Python, isso quer dizer que ela não deve ser utilizada para nomear variáveis, classes e etc. A palavra “if” vem do inglês e quer dizer “se” no sentido condicional: "Se alguém estiver lendo eu continuo postando“.

https://under-linux.org/entry.php?b=1583

3 Structuring if statements

Page 4: If e else Python

Ao estruturar um código, fazendo o uso do “if”, devemos obedecer a seguinte sintaxe .

Exemplo 1:

4 Structuring if statements

Page 5: If e else Python

Na estrutura lógica condicional podemos fazer uso não só do “if”, mas também do “else” e do “elif”.

• else: se não.

• elif: uma junção do if mais o else, para assim simplificar o código.

5 Structuring if statements

Page 6: If e else Python

Uso do if e do else . Exemplo 2 :

6 Structuring if statements

Page 7: If e else Python

7

Uso do if ,do else e do elif . Exemplo 3 :

Structuring if statements

Page 8: If e else Python

BIBLIOGRAFIA:

• Guido van Rossum e Fred L. Drake, Jr.

Tutorial Python. Release 2.4.2

Tradução: Python Brasil

• https://under-linux.org/entry.php?b=1590

8 Structuring if statements

Page 9: If e else Python

PERGUNTAS?

9 Structuring if statements