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

Python Advanced Guide Updated

The document provides a comprehensive guide to built-in Python functions, demonstrating their usage with code examples. It covers a wide range of functions including abs(), all(), any(), and many others, showcasing their applications in various contexts. This guide is aimed at beginners to higher-intermediate Python users looking to enhance their understanding of built-in functionalities.

Uploaded by

mrrobotmunna234
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 views2 pages

Python Advanced Guide Updated

The document provides a comprehensive guide to built-in Python functions, demonstrating their usage with code examples. It covers a wide range of functions including abs(), all(), any(), and many others, showcasing their applications in various contexts. This guide is aimed at beginners to higher-intermediate Python users looking to enhance their understanding of built-in functionalities.

Uploaded by

mrrobotmunna234
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 Contest Guide: Beginner to Higher-Intermediate

Python Guide - Continued

### 9. Complete Built-in Function Usages

```python
print(abs(-5)) # abs()
print(all([True, True])) # all()
print(any([False, True])) # any()
print(ascii('ñ')) # ascii()
print(bin(5)) # bin()
print(bool(1)) # bool()
print(callable(len)) # callable()
print(chr(97)) # chr()
print(dict(a=1, b=2)) # dict()
print(dir([])) # dir()
print(divmod(7,3)) # divmod()
print(list(enumerate(['a','b']))) # enumerate()
print(eval('1+2')) # eval()
exec('a=5\nprint(a)') # exec()
print(list(filter(lambda x:x>2,[1,2,3]))) # filter()
print(float('3.14')) # float()
print(format(1234, ",")) # format()
print(frozenset([1,2,3])) # frozenset()
print(getattr(str, 'upper')) # getattr()
# print(globals()) # globals() - avoids output flooding
print(hasattr(str, 'lower')) # hasattr()
print(hash("abc")) # hash()
# help(print) # help() - interactive
print(hex(255)) # hex()
print(id(100)) # id()
# input("Enter: ") # input() - requires user input
print(int('12')) # int()
print(isinstance(5, int)) # isinstance()
print(issubclass(bool, int)) # issubclass()
print(iter([1,2])) # iter()
print(len("hello")) # len()
print(list((1,2))) # list()
# print(locals()) # locals() - runtime-specific
print(list(map(str, [1,2]))) # map()
print(max([1,2,3])) # max()
print(memoryview(b"abc")) # memoryview()
print(min([1,2,3])) # min()
print(next(iter([1,2]))) # next()
print(object()) # object()
print(oct(8)) # oct()
# open(), ord(), pow(), print(), property() - open() requires files
print(list(range(3))) # range()
print(repr(5)) # repr()
print(list(reversed([1,2,3]))) # reversed()
print(round(3.14159, 2)) # round()
Python Contest Guide: Beginner to Higher-Intermediate
print(set([1,2,2])) # set()

class Dog:
pass

setattr(Dog, 'age', 5)
print(Dog.age) # setattr()

print(slice(1,3)) # slice()
print(sorted([3,1,2])) # sorted()
print(staticmethod(lambda:5)) # staticmethod()
print(str(123)) # str()
print(sum([1,2,3])) # sum()
# print(super()) # super() - context-dependent
print(tuple([1,2])) # tuple()
print(type(5)) # type()
# print(vars()) # vars() - runtime-specific
print(list(zip([1,2],[3,4]))) # zip()
```

You might also like