Grattis

Intermediate Python för utvecklare

Jasmin Ludolf

Senior Data Science Content Developer

Sammanfattning kapitel 1

  • Inbyggda funktioner:
    • print(), help(), type()
    • max(), min(), sum()
    • len(), round(), sorted()
  • Moduler:
    • string, os

 

$$

  • Paket:
    • pandas
Intermediate Python för utvecklare

Sammanfattning kapitel 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 för utvecklare

Sammanfattning kapitel 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 för utvecklare

Sammanfattning kapitel 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 för utvecklare

Sammanfattning kapitel 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 för utvecklare

Sammanfattning kapitel 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 för utvecklare

Sammanfattning kapitel 3

ValueError-utdata som bekräftar att strängen 'Hello' inte kan konverteras till ett flyttal

$$

  • try
  • except
  • raise
Intermediate Python för utvecklare

Nästa steg

  • Fler inbyggda funktioner:

    • zip()
    • input()
    • reduce()
    • filter()
  • Fler paket och moduler:

    • time
    • venv
    • requests
    • fastapi

Introduktion till objektorienterad programmering

  • Grundläggande för att bygga programvara i större skala
Intermediate Python för utvecklare

Grattis!

Intermediate Python för utvecklare

Preparing Video For Download...