Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Built-in Functions | Functions & Modularity
Introduction to Python with Cursor

bookBuilt-in Functions

メニューを表示するにはスワイプしてください

Python comes with dozens of built-in functions — no import needed. They help you transform, measure, or convert values in one line of code.

Functions are grouped by purpose: numbers, text, types, and collections.

Converting Data Types

These functions helps to convert between basic types:

  • int() — to integer;
  • float() — to float;
  • str() — to string;
  • bool() — to boolean.

Useful when working with input, formatting, or expressions.

Working with Numbers

These help clean or adjust numeric values:

  • abs() — absolute value (removes minus sign);
  • round() — rounds floats to nearest whole or to decimals.

Working with Strings

These are commonly used for cleaning and formatting text:

  • lower() — make all letters lowercase;
  • upper() — make all letters uppercase;
  • strip() — remove spaces at the beginning and end;
  • replace() — replace part of a string with another;
  • split() — turn a string into a list of words;
  • join() — combine list items into one string.

Collection Inspection

These return information about a list, tuple, or other iterable:

  • len() — count items;
  • max() — largest value;
  • min() — smallest value;
  • sum() — total of all numbers.

Collection Transformation

These are helpful when looping, combining, or transforming collections:

  • sorted() — returns sorted list;
  • enumerate() — adds index numbers;
  • zip() — pairs items from multiple lists;
  • range() — creates a sequence of numbers;
  • map() — applies a function to each item;
  • filter() — keeps items that meet a condition.

Summary

  • Python's built-in functions save you time and code;
  • You can convert data, adjust text, transform collections, and get answers instantly;
  • These tools become essential as you build more complex programs.
question mark

What does len("Python") return?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 4.  1

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 4.  1
some-alt