MulaiMulai sekarang secara gratis

Checking data types

As you build your recipe scaler project, you've started storing different types of ingredient information in variables. You have the number of garlic cloves as a whole number, the amount of olive oil as a decimal, and whether you need to shop for pasta or garlic as a yes/no value. Before you continue building your scaler, it's important to verify a variable is storing the correct data type. Python's type() function will help you check this. The variables olive_oil_tbsp and has_pasta have been loaded for you.

Latihan ini adalah bagian dari kursus

Introduction to Python for Developers

Lihat Kursus

Petunjuk latihan

  • Print the data type of the olive_oil_tbsp variable.
  • Print the data type of the has_pasta variable.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Check the data type of olive_oil_tbsp
print(____)

# Check the data type of has_pasta
print(____)
Edit dan Jalankan Kode