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

Storing variables

You're building your first Python project - a recipe scaler! Before you can scale recipes, you need to learn how to store ingredient information. In Python, you use variables to store values you'll use multiple times. For recipes, you'll need to store ingredient names (text, called strings) and quantities (whole numbers, called integers). Let's start by storing information for a pasta recipe.

Bu egzersiz

Introduction to Python for Developers

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

Egzersiz talimatları

  • Create a variable called pasta_type and store the string "spaghetti" in it.
  • Create a variable called quantity and store the integer 80 in it, for grams.
  • Print both variables to verify they were stored correctly.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Store the pasta type as a string
pasta_type = "____"

# Store the quantity as an integer
quantity = ____

# Print the pasta type
____(pasta_type)

# Print the quantity
____(quantity)
Kodu Düzenle ve Çalıştır