Gratulujeme

Intermediate Python for Developers

Jasmin Ludolf

Senior Data Science Content Developer

Rekapitulace kapitoly 1

  • Vestavěné funkce:
    • print(), help(), type()
    • max(), min(), sum()
    • len(), round(), sorted()
  • Moduly:
    • string, os

 

$$

  • Balíčky:
    • pandas
Intermediate Python for Developers

Rekapitulace kapitoly 2

# Create a custom function
def average(values):
    # Calculate the average
    average_value = sum(values) / len(values)

    # Round the results
    rounded_average = round(average_value, 2)

    # Return rounded_average as an output
    return rounded_average
Intermediate Python for Developers

Rekapitulace kapitoly 2

# Create a custom function
def average(values, rounded=False):

# Round average to two decimal places if rounded is True if rounded == True: average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
# Otherwise, don't round else: average_value = sum(values) / len(values) return average_value
Intermediate Python for Developers

Rekapitulace kapitoly 2

def average(values):
    """
    Find the mean in a sequence of values and round to two decimal places.

    Args:
        values (list): A list of numeric values.

    Returns:
        rounded_average (float): The mean of values, rounded to two decimal places.
    """

average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
Intermediate Python for Developers

Rekapitulace kapitoly 2

# Use arbitrary positional arguments
def average(*args):
    average_value = sum(args) / len(args)
    rounded_average = round(average_value, 2)
    return rounded_average

# Use arbitrary keyword arguments def average(**kwargs): average_value = sum(kwargs.values()) / len(kwargs.values()) rounded_average = round(average_value, 2) return rounded_average
Intermediate Python for Developers

Rekapitulace kapitoly 3

  • lambda arguments: expression
names = ["john", "sally", "leah"]

# Apply a lambda function inside map()
capitalize = map(lambda x: x.capitalize(), names)

# Convert to a list
print(list(capitalize))
['John', 'Sally', 'Leah']
Intermediate Python for Developers

Rekapitulace kapitoly 3

Výstup ValueError potvrzující, že řetězec 'Hello' nelze převést na float

$$

  • try
  • except
  • raise
Intermediate Python for Developers

Další kroky

  • Další vestavěné funkce:

    • zip()
    • input()
    • reduce()
    • filter()
  • Další balíčky a moduly:

    • time
    • venv
    • requests
    • fastapi

Úvod do objektově orientovaného programování

  • Klíčové pro vývoj softwaru ve velkém měřítku
Intermediate Python for Developers

Gratulujeme!

Intermediate Python for Developers

Preparing Video For Download...