試験PCEP-30-02 トピック8 問題12 スレッド
Python Institute PCEP-30-02のリアル試験問題集
問題 #: 12
トピック #: 8
問題 #: 12
トピック #: 8
Drag and drop the conditional expressions to obtain a code which outputs * to the screen.
(Note: some code boxes will not be used.)

(Note: some code boxes will not be used.)

おすすめの解答:

Explanation

One possible way to drag and drop the conditional expressions to obtain a code which outputs * to the screen is:
if pool > 0:
print("*")
elif pool < 0:
print("**")
else:
print("***")
This code uses the if, elif, and else keywords to create a conditional statement that checks the value of the variable pool. Depending on whether the value is greater than, less than, or equal to zero, the code will print a different pattern of asterisks to the screen. The print function is used to display the output. The code is indented to show the blocks of code that belong to each condition. The code will output * if the value of pool is positive, ** if the value of pool is negative, and *** if the value of pool is zero.
You can find more information about the conditional statements and the print function in Python in the following references:
[Python If ... Else]
[Python Print Function]
[Python Basic Syntax]
广瀬** 2025-02-04 07:08:29
コメント
他人の解答コメントを賛成するのも、その解答に一票を入れることになります。したがって、すでに同じ意見の投票コメントが存在する場合、新規コメントをする代わりに賛成することもできます。
コメントを通報する
コメント中
今すぐ 新規登録 / ログイン (無料です)。