開始使用免費開始

指派與相等性

在評估某人的財富時,區分現金與非現金有價證券很重要。活存與支票帳戶屬於現金資產;股票部位屬於非現金資產。 想像你在協助一位客戶做資產配置,被要求比較他們的現金與非現金資產。變數 non_cash 已提供,代表非現金資產的金額。

本練習屬於課程

Intermediate Python for Finance

檢視課程

練習說明

  • 將數值 19.11 指派給變數 cash
  • 檢查 cashnon_cash 是否具有相同的值。
  • non_cash 的值指派給 cash
  • 確認 cashnon_cash 相等。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Assign a value to cash.
____ ____ ____

# Check if cash is equal to non-cash
print(____ ____ ____)

# Assign the value of cash to be equal non-cash
____ ____ ____

# Check if cash is equal to non-cash
print(____ ____ ____)
編輯並執行程式碼