Which of the following is an example of a built-in function in Python?
a) print()
b) my_function()
c) loop()
d) variable()
Answer:
a) print()
Explanation:
print()
is an example of a built-in function in Python. Built-in functions are pre-defined functions that are available by default in Python without the need for importing any additional modules. They perform a wide range of tasks, from displaying output to performing calculations and handling data types.
print("Hello, world!") # This prints the string to the console
Python includes a rich set of built-in functions like len()
, type()
, sum()
, and many more, which are designed to simplify common programming tasks.
Familiarity with these built-in functions is essential for writing efficient and effective Python code.