0% found this document useful (0 votes)
36 views

Python Functions Cheat Sheet

This document is a cheat sheet for Python built-in functions, providing a list of commonly used functions along with examples of their usage. Functions include print(), input(), len(), type(), and many others, each with a brief description and an illustrative example. The cheat sheet serves as a quick reference for Python developers to understand and utilize these functions effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Python Functions Cheat Sheet

This document is a cheat sheet for Python built-in functions, providing a list of commonly used functions along with examples of their usage. Functions include print(), input(), len(), type(), and many others, each with a brief description and an illustrative example. The cheat sheet serves as a quick reference for Python developers to understand and utilize these functions effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Functions Cheat Sheet

### Built-in Functions


1. print() - Displays output on the screen.
Example: print("Hello, World!") -> Hello, World!

2. input() - Takes user input as a string.


Example: name = input("Enter your name: ")

3. len() - Returns the length of an object.


Example: len("Python") -> 6

4. type() - Returns the type of a variable.


Example: type(5.0) -> <class 'float'>

5. id() - Returns the memory address of an object.


Example: id(10)

6. isinstance() - Checks if an object is an instance of a specific class.


Example: isinstance(5, int) -> True

7. range() - Generates a sequence of numbers.


Example: list(range(1, 5)) -> [1, 2, 3, 4]

8. abs() - Returns the absolute value of a number.


Example: abs(-10) -> 10

9. round() - Rounds a number to a specified decimal places.


Example: round(3.456, 2) -> 3.46

10. pow() - Returns x raised to the power y.


Example: pow(2, 3) -> 8

11. sum() - Returns the sum of all elements in an iterable.


Example: sum([1, 2, 3]) -> 6
12. min() - Returns the smallest element in an iterable.
Example: min([4, 2, 8]) -> 2

13. max() - Returns the largest element in an iterable.


Example: max([4, 2, 8]) -> 8

14. sorted() - Returns a sorted list.


Example: sorted([3, 1, 2]) -> [1, 2, 3]

15. reversed() - Returns a reversed iterator.


Example: list(reversed([1, 2, 3])) -> [3, 2, 1]

16. enumerate() - Returns an index-value pair iterator.


Example: list(enumerate(['a', 'b'])) -> [(0, 'a'), (1, 'b')]

17. zip() - Combines multiple iterables into tuples.


Example: list(zip([1, 2], ['a', 'b'])) -> [(1, 'a'), (2, 'b')]

... (More functions continue)

You might also like