Menu
CoddyTech

プログラムの終了

CoddyのPythonジャーニー「基礎」セクションの一部。レッスン 69/77。

challenge icon

チャレンジ

簡単

それでは、実際のプログラムを作成しましょう!

  1. ループの前に、ウェルカムメッセージとメニューを1回表示します(ループ内では繰り返されません)
  2. 無限のwhileループを作成します(方法がわからない場合はヒントを参照してください)
  3. ループの各反復で、ユーザーから入力を受け取ります。これは選択肢(メニューの1~5)になります
  4. 最初のケースを処理します。選択肢が5に等しい場合、プログラム(ループ)を終了し、次を出力します。
Exiting the Daily Expense Tracker. Goodbye!

自分で試してみよう

print("Welcome to the Daily Expense Tracker!")

# Display menu once
print("\nMenu:")
print("1. Add a new expense")
print("2. View all expenses")
print("3. Calculate total and average expense")
print("4. Clear all expenses")
print("5. Exit")

基礎のすべてのレッスン

自分で練習してみよう: Pythonオンラインコンパイラ