Gratulujeme!

Introduction to Python for Developers

Jasmin Ludolf

Senior Data Science Content Developer

Rekapitulace kapitoly 1

# Define quantity
quantity = 10

# Single quotes ingredient_name = 'pasta'
# Double quotes also work ingredient_name = "pasta"
Introduction to Python for Developers

Rekapitulace kapitoly 2

ingredient_name = "Basil Leaves"


# Convert to lowercase ingredient_name = ingredient_name.lower()
# List of ingredients
ingredients = ["pasta", "tomatoes", "garlic",
               "basil", "olive oil", "salt"]

# Get the value at the first index ingredients[0]
# Creating a dictionary
recipe_dict = {"pasta": 500,
               "tomatoes": 400, 
               "garlic": 15,
               "basil": 20, 
               "olive oil": 30,
               "salt": 5}
# Create a set
ingredients_set = {"pasta", "tomatoes", "pasta", 
                   "basil", "garlic", "olive oil",
                   "salt"}

# Create a tuple serving_sizes = (1, 2, 4, 6, 8)
Introduction to Python for Developers

Rekapitulace kapitoly 3

Operátor Funkce
== Rovno
!= Není rovno
> Větší než
>= Větší než nebo rovno
< Menší než
<= Menší než nebo rovno
Klíčové slovo Funkce Použití
if Pokud je podmínka splněna První v postupu
elif Jinak zkontroluj podmínku Po if
else Jinak proveď tuto akci Po elif
Introduction to Python for Developers

Rekapitulace kapitoly 3

# Ingredients list
ingredients = ["pasta", "tomatoes", "garlic", "basil", "olive oil", "salt"]


# Loop through and print each ingredient for ingredient in ingredients:
print(ingredient)
pasta
tomatoes
garlic
basil
olive oil
salt
Introduction to Python for Developers

Rekapitulace kapitoly 3

ingredients_to_add = 5
items_added = 0

while items_added < ingredients_to_add:
    items_added += 1
    remaining = ingredients_to_add - items_added

    if remaining > 3:
        print("Several ingredients remaining")
    elif remaining >= 1:
        print("Almost done!")
    else:
        print("Shopping list complete!")
Introduction to Python for Developers

Rekapitulace kapitoly 3

Klíčové slovo Funkce
and Vyhodnotí, zda platí více podmínek
or Vyhodnotí, zda platí jedna nebo více podmínek
in Vyhodnotí, zda je hodnota v datové struktuře
not Vyhodnotí, zda hodnota není v datové struktuře

 

  • list.append()
Introduction to Python for Developers

Další kroky

  • Další vestavěné funkce

    • zip()
    • enumerate()
  • Balíčky a moduly

    • os
    • time
    • venv
    • pandas
    • requests
    • numpy
  • Tvorba vlastních funkcí

$$

  • Kurz Intermediate Python for Developers na DataCamp
Introduction to Python for Developers

Gratulujeme!

Introduction to Python for Developers

Preparing Video For Download...