Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Syntax of if-else Statement | Python if-else Statement
Conditional Statements in Python Clone
セクション 2.  2
single

single

bookSyntax of if-else Statement

メニューを表示するにはスワイプしてください

Let's briefly discuss the syntax of the if-else construct.

  • The syntax of the if statement remains unchanged;
if condition:
    action
  • Write the else keyword. Note that it is case sensitive, so it is not the same as Else so if you use Else you will get an error because it is not correct;
if True condition:
    action
else:           # if False condition
    other action
  • Furthermore, you don't need to specify a condition when using else since it inherently implies the opposite condition of the if part;
  • Simply use a colon;
  • Then, proceed with code indentation for the instructions executed within the else-block. These instructions are executed if our condition in the if statement evaluates to False.

Practice Time!

タスク

スワイプしてコーディングを開始

You have to find the greatest number of three numbers using an if-else statement.

Fill in the blanks.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  2
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt