What are other Python functions?

QuestionsQuestions8 SkillsProYour First Python LabNov, 10 2025
0109

Python has many built-in functions that perform various tasks. Here are some commonly used ones:

  1. len(): Returns the length of an object (like a string, list, or tuple).

    length = len("Hello")  # Returns 5
  2. type(): Returns the type of an object.

    obj_type = type(5)  # Returns <class 'int'>
  3. str(): Converts an object to a string.

    string_value = str(100)  # Returns '100'
  4. int(): Converts a value to an integer.

    integer_value = int("10")  # Returns 10
  5. float(): Converts a value to a float.

    float_value = float("3.14")  # Returns 3.14
  6. sorted(): Returns a sorted list from the specified iterable.

    sorted_list = sorted([3, 1, 2])  # Returns [1, 2, 3]
  7. sum(): Returns the sum of all items in an iterable.

    total = sum([1, 2, 3])  # Returns 6
  8. max(): Returns the largest item in an iterable.

    largest = max([1, 2, 3])  # Returns 3
  9. min(): Returns the smallest item in an iterable.

    smallest = min([1, 2, 3])  # Returns 1
  10. input(): Allows user input from the console.

    user_input = input("Enter your name: ")  # Prompts user for input

These functions are just a starting point. Python has many more built-in functions that can help you perform various tasks efficiently. If you want to learn more about a specific function or topic, let me know!

0 Comments

no data
Be the first to share your comment!