#7 – Language Paradigms Flashcards
(11 cards)
What is a programming paradigm?
A programming paradigm is a style or way of programming, such as procedural, object-oriented, or functional.
What is procedural programming?
Procedural programming is based on sequences of instructions and function calls. It focuses on steps to achieve a task.
What is object-oriented programming (OOP)?
OOP organizes code using classes and objects. It focuses on encapsulation, inheritance, and polymorphism.
What is functional programming?
Functional programming treats computation as the evaluation of mathematical functions. It avoids state and mutable data.
Does Python support multiple paradigms?
Yes, Python supports procedural, object-oriented, and functional programming styles.
How is functional programming used in Python?
With functions like map()
, filter()
, reduce()
, and the use of lambda expressions.
What is a pure function?
A pure function always returns the same output for the same input and has no side effects.
What is a first-class function in Python?
A function that can be assigned to a variable, passed as an argument, or returned from another function.
What is the benefit of multiple paradigms in Python?
It allows programmers to choose the best approach for each problem, combining different styles as needed.
What Python features enable OOP?
class
, self
, inheritance, methods, dunder methods like \_\_init\_\_
, \_\_str\_\_
, and super()
.
What Python features enable functional programming?
lambda
, map
, filter
, reduce
, any
, all
, list comprehensions, and generator expressions.