BaşlayınÜcretsiz Başlayın

Types of variables

There are a few basic types of data in Python: integers, floats, strings, and Booleans. There are also more complex types covered throughout the course. Knowing the data type of the variable you are working with is essential, not the least because the behavior of different operators depends on the data type. You can add two integers together, but if you try to add an integer to a string, you will get an error.

In this exercise, some data describing a bag of avocados is loaded: variety, count, price_each, and organic. You'll explore the data stored in each of these variables. You can use the function type() to identify the type of any Python variable. type() is equivalent to the MATLAB class() function.

Bu egzersiz

Python for MATLAB Users

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Print the variable
print(____)

# Print the type of the variable
print(type(____))
Kodu Düzenle ve Çalıştır