Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Summarizing Data with Built-in Functions | Organizing and Summarizing Data
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Daily Tasks

bookSummarizing Data with Built-in Functions

When you work with collections of data in Python, such as lists of numbers, you often need to quickly summarize or analyze the information. Python provides several built-in functions that make these tasks simple and fast. The most commonly used functions for summarizing data in lists are sum(), len(), min(), and max().

  • The sum() function adds up all the numbers in a list;
  • The len() function returns the number of items in a list;
  • The min() function finds the smallest value in a list;
  • The max() function finds the largest value in a list.

These functions are easy to use and can help you make sense of your data without writing complex code.

1234567
# Calculate the total and average of weekly expenses expenses = [45, 30, 60, 25, 50, 40, 35] total = sum(expenses) average = total / len(expenses) print("Total expenses for the week:", total) print("Average daily expense:", average)
copy

Using these built-in functions, you can quickly get useful insights from everyday data. For example, by calculating the total and average of your weekly expenses, you can see how much you are spending and adjust your budget if needed. Similarly, you can use min() and max() to find the lowest and highest values in a list, such as daily temperatures or scores, which helps you spot trends or outliers in your data.

1234567
# Find the highest and lowest daily temperatures temperatures = [68, 71, 65, 70, 74, 69, 72] highest = max(temperatures) lowest = min(temperatures) print("Highest temperature of the week:", highest) print("Lowest temperature of the week:", lowest)
copy

1. Which function returns the number of items in a list?

2. How do you calculate the average of a list of numbers in Python?

3. Fill in the blanks to find the maximum value in a list.

question mark

Which function returns the number of items in a list?

Select the correct answer

question mark

How do you calculate the average of a list of numbers in Python?

Select the correct answer

question-icon

Fill in the blanks to find the maximum value in a list.

numbers = [3, 7, 2, 9, 4] result = (numbers) print(result)
9

Click or drag`n`drop items and fill in the blanks

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 4

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

bookSummarizing Data with Built-in Functions

Svep för att visa menyn

When you work with collections of data in Python, such as lists of numbers, you often need to quickly summarize or analyze the information. Python provides several built-in functions that make these tasks simple and fast. The most commonly used functions for summarizing data in lists are sum(), len(), min(), and max().

  • The sum() function adds up all the numbers in a list;
  • The len() function returns the number of items in a list;
  • The min() function finds the smallest value in a list;
  • The max() function finds the largest value in a list.

These functions are easy to use and can help you make sense of your data without writing complex code.

1234567
# Calculate the total and average of weekly expenses expenses = [45, 30, 60, 25, 50, 40, 35] total = sum(expenses) average = total / len(expenses) print("Total expenses for the week:", total) print("Average daily expense:", average)
copy

Using these built-in functions, you can quickly get useful insights from everyday data. For example, by calculating the total and average of your weekly expenses, you can see how much you are spending and adjust your budget if needed. Similarly, you can use min() and max() to find the lowest and highest values in a list, such as daily temperatures or scores, which helps you spot trends or outliers in your data.

1234567
# Find the highest and lowest daily temperatures temperatures = [68, 71, 65, 70, 74, 69, 72] highest = max(temperatures) lowest = min(temperatures) print("Highest temperature of the week:", highest) print("Lowest temperature of the week:", lowest)
copy

1. Which function returns the number of items in a list?

2. How do you calculate the average of a list of numbers in Python?

3. Fill in the blanks to find the maximum value in a list.

question mark

Which function returns the number of items in a list?

Select the correct answer

question mark

How do you calculate the average of a list of numbers in Python?

Select the correct answer

question-icon

Fill in the blanks to find the maximum value in a list.

numbers = [3, 7, 2, 9, 4] result = (numbers) print(result)
9

Click or drag`n`drop items and fill in the blanks

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 4
some-alt