# A
# abs()
num = -5
absolute_value = abs(num)
print(absolute_value)
# aiter()
async def my_async_function():
for i in range(3):
yield i
async_iterator = my_async_function().__aiter__()
print(await async_iterator.__anext__())
# all()
my_list = [True, False, True]
result = all(my_list)
print(result)
# any()
my_list = [False, False, True]
result = any(my_list)
print(result)
# anext()
my_list = [1, 2, 3]
my_iterator = iter(my_list)
print(next(my_iterator)) # Output: 1
# ascii()
string = "Hello, world!"
print(ascii(string))
# B
# bin()
num = 10
binary_representation = bin(num)
print(binary_representation)
# bool()
value = 0
print(bool(value))
# breakpoint()
def my_function():
x = 5
breakpoint() # Execution will pause here, and you can interactively debug
my_function()
# bytearray()
byte_array = bytearray([65, 66, 67])
print(byte_array)
# bytes()
byte_string = bytes([65, 66, 67])
print(byte_string)
# C
# callable()
def my_function():
print("Hello, world!")
print(callable(my_function)) # Output: True
# chr()
char_code = 65
character = chr(char_code)
print(character)
# classmethod()
class MyClass:
@classmethod
def my_method(cls):
print("This is a class method.")
MyClass.my_method()
# compile()
source_code = "print('Hello, world!')"
compiled_code = compile(source_code, filename="", mode="exec")
exec(compiled_code)
# complex()
complex_num = complex(3, 4)
print(complex_num)
# D
# delattr()
class MyClass:
def __init__(self):
self.x = 10
obj = MyClass()
delattr(obj, 'x')
# dict()
my_dict = {'name': 'John', 'age': 30}
print(my_dict)
# dir()
my_list = [1, 2, 3]
print(dir(my_list))
# divmod()
result = divmod(9, 2)
print(result)
# E
# enumerate()
my_list = ['a', 'b', 'c']
enumerated_list = enumerate(my_list)
print(list(enumerated_list))
# eval()
expression = "2 + 3 * 5"
result = eval(expression)
print(result)
# exec()
source_code = "print('Hello, world!')"
exec(source_code)
# F
# filter()
my_list = [1, 2, 3, 4, 5]
filtered_list = filter(lambda x: x % 2 == 0, my_list)
print(list(filtered_list))
# float()
value = "3.14"
float_value = float(value)
print(float_value)
# format()
name = "John"
age = 30
formatted_string = "My name is {} and I am {} years old.".format(name, age)
print(formatted_string)
# frozenset()
my_set = {1, 2, 3}
frozen_set = frozenset(my_set)
print(frozen_set)
# G
# getattr()
class MyClass:
def __init__(self):
self.x = 10
obj = MyClass()
value = getattr(obj, 'x')
print(value)
# globals()
print(globals())
# H
# hasattr()
class MyClass:
def __init__(self):
self.x = 10
obj = MyClass()
has_x = hasattr(obj, 'x')
print(has_x)
# hash()
my_set = {1, 2, 3}
hash_value = hash(my_set)
print(hash_value)
# help()
help(list)
# hex()
number = 255
hex_value = hex(number)
print(hex_value)
# I
# id()
my_list = [1, 2, 3]
print(id(my_list))
# input()
name = input("Enter your name: ")
print("Hello,", name)
# int()
value = "42"
integer_value = int(value)
print(integer_value)
# isinstance()
value = 42
print(isinstance(value, int))
# issubclass()
class MyBaseClass:
pass
class MyDerivedClass(MyBaseClass):
pass
print(issubclass(MyDerivedClass, MyBaseClass))
# iter()
my_list = [1, 2, 3]
my_iterator = iter(my_list)
print(next(my_iterator))
# L
# len()
my_list = [1, 2, 3, 4, 5]
length = len(my_list)
print(length)
# list()
my_list = [1, 2, 3]
print(my_list)
# locals()
def my_function():
x = 10
print(locals())
my_function()
# M
# map()
my_list = [1, 2, 3]
mapped_list = map(lambda x: x * 2, my_list)
print(list(mapped_list))
# max()
my_list = [1, 5, 3, 8, 2]
max_value = max(my_list)
print(max_value)
# memoryview()
my_bytes = b"Hello"
memory_view = memoryview(my_bytes)
print(memory_view)
# min()
my_list = [1, 5, 3, 8, 2]
min_value = min(my_list)
print(min_value)
# N
# next()
my_list = [1, 2, 3]
my_iterator = iter(my_list)
print(next(my_iterator))
# O
# object()
class MyClass:
pass
obj = MyClass()
print(isinstance(obj, object))
# oct()
number = 255
oct_value = oct(number)
print(oct_value)
# open()
with open('example.txt', 'w') as file:
file.write('Hello, world!')
# ord()
character = 'A'
ord_value = ord(character)
print(ord_value)
# P
# pow()
base = 2
exponent = 3
result = pow(base, exponent)
print(result)
# print()
print("Hello, world!")
# property()
class MyClass:
def __init__(self):
self._x = 10
@property
def x(self):
return self._x
obj = MyClass()
print(obj.x)
# R
# range()
my_range = range(5)
print(list(my_range))
# repr()
my_list = [1, 2, 3]
representation = repr(my_list)
print(representation)
# reversed()
my_list = [1, 2, 3]
reversed_list = reversed(my_list)
print(list(reversed_list))
# round()
number = 3.14159
rounded_value = round(number, 2)
print(rounded_value)
# S
# set()
my_set = {1, 2, 3}
print(my_set)
# setattr()
class MyClass:
pass
obj = MyClass()
setattr(obj, 'x', 10)
# slice()
my_list = [1, 2, 3, 4, 5]
my_slice = slice(1, 4)
print(my_list[my_slice])
# sorted()
my_list = [3, 1, 2]
sorted_list = sorted(my_list)
print(sorted_list)
# staticmethod()
class MyClass:
@staticmethod
def my_method():
print("This is a static method.")
MyClass.my_method()
# str()
number = 42
string_representation = str(number)
print(string_representation)
# sum()
my_list = [1, 2, 3]
sum_value = sum(my_list)
print(sum_value)
# super()
class MyBaseClass:
def greet(self):
print("Hello!")
class MyDerivedClass(MyBaseClass):
def greet(self):
super().greet()
print("World!")
obj = MyDerivedClass()
obj.greet()
# T
# tuple()
my_tuple = (1, 2, 3)
print(my_tuple)
# type()
my_list = [1, 2, 3]
print(type(my_list))
# V
# vars()
class MyClass:
def __init__(self):
self.x = 10
self.y = 20
obj = MyClass()
print(vars(obj))
# Z
# zip()
list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']
zipped = zip(list1, list2)
print(list(zipped))
# _
# This is a special variable that stores the result of the last expression
result = 2 + 3
print(_) # Output: 5
# __import__()
import math as my_math
print(my_math.sqrt(16))