0% found this document useful (0 votes)
2 views3 pages

Python Inbuilt Functions Cheat Sheet

This cheat sheet provides a comprehensive overview of Python's inbuilt functions and imports, categorized into sections such as Input/Output Functions, Type Conversion, Math Functions, String Methods, List Methods, Set Methods, Dictionary Methods, Utility Built-ins, and Useful Imports. Each section lists relevant functions and methods, along with examples for clarity. It serves as a quick reference for Python programming essentials.

Uploaded by

K Sathvik
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)
2 views3 pages

Python Inbuilt Functions Cheat Sheet

This cheat sheet provides a comprehensive overview of Python's inbuilt functions and imports, categorized into sections such as Input/Output Functions, Type Conversion, Math Functions, String Methods, List Methods, Set Methods, Dictionary Methods, Utility Built-ins, and Useful Imports. Each section lists relevant functions and methods, along with examples for clarity. It serves as a quick reference for Python programming essentials.

Uploaded by

K Sathvik
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/ 3

Python Inbuilt Functions and Imports - Cheat Sheet

1. Input/Output Functions

-------------------------

input() - take user input as string

print() - display output

2. Type Conversion

------------------

int(), float(), str(), list(), tuple(), set()

3. Math Functions (from math import ...)

----------------------------------------

from math import sqrt, ceil, floor, pow, factorial, gcd

Examples:

sqrt(25) -> 5.0

ceil(2.3) -> 3

floor(2.9) -> 2

pow(2, 3) -> 8.0

factorial(5) -> 120

gcd(12, 15) -> 3

4. String Methods

-----------------

lower(), upper(), strip(), split(), join(), replace(), isdigit(), isalpha()


5. List Methods

---------------

append(), extend(), insert(), remove(), pop(), sort(), reverse(), count(), index()

6. Set Methods

--------------

add(), remove(), union(), intersection(), difference()

7. Dictionary Methods

---------------------

keys(), values(), items(), get(), update()

8. Utility Built-ins

--------------------

len(), max(), min(), sum(), sorted(), reversed(), range()

9. Useful Imports (from __ import __)

-------------------------------------

from math import sqrt, ceil, gcd, factorial

from itertools import permutations, combinations, product

from collections import Counter, defaultdict, deque

from functools import reduce

from heapq import heappush, heappop, heapify

from random import randint, choice, shuffle

from string import ascii_lowercase, ascii_uppercase, digits


Examples:

Counter("banana") -> {'b':1, 'a':3, 'n':2}

list(permutations("abc", 2)) -> [('a','b'),('a','c'), ...]

reduce(lambda x,y: x*y, [1,2,3]) -> 6

heapify([3,1,2]); heappop() -> 1

choice([1,2,3]) -> random value from list

ascii_lowercase -> 'abcdefghijklmnopqrstuvwxyz'

You might also like