From 283397cba482b36ab179c68e7c4d25c3c219a106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sun, 30 Oct 2022 17:01:30 -0300 Subject: [PATCH] =?UTF-8?q?Opera=C3=A7=C3=A3o=20tern=C3=A1ria=20com=20Pyth?= =?UTF-8?q?on=20(if=20e=20else=20de=20uma=20linha)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula60.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 aula60.py diff --git a/aula60.py b/aula60.py new file mode 100644 index 0000000..a95680c --- /dev/null +++ b/aula60.py @@ -0,0 +1,12 @@ +""" +Operação ternária (condicional de uma linha) + if else +""" +# condicao = 10 == 11 +# variavel = 'Valor' if condicao else 'Outro valor' +# print(variavel) +# digito = 9 # > 9 = 0 +# novo_digito = digito if digito <= 9 else 0 +# novo_digito = 0 if digito > 9 else digito +# print(novo_digito) +print('Valor' if False else 'Outro valor' if False else 'Fim')