Software Engineering - Python Flashcards
What is Python?
Python is a
high-level
interpreted
general-purpose programming language
known for its
simplicity
readability
versatility
What are the key features of Python?
Easy to learn and read,
dynamically typed
interpreted
multi-paradigm (supports object-oriented
procedural, and functional programming)
and has a large standard library
third-party ecosystem
What are the main differences between Python 2 and Python 3?
Python 3 introduced changes in
print syntax
integer division
Unicode support
and some renamed or removed functions.
Python 2 is no longer maintained as of January 2020.
What are the basic data types in Python?
Numeric types (int, float, complex)
sequences (list, tuple, range)
text type (str)
binary types (bytes, bytearray)
mapping type (dict)
set types (set, frozenset)
and boolean type (bool)
What is the difference between a list and a tuple in Python?
Lists are mutable (can be modified)
and defined with square brackets [],
while tuples are immutable (cannot be modified)
and defined with parentheses ().
What is a dictionary in Python?
A dictionary is an unordered collection of key-value pairs,
defined with curly braces {}
and accessed by keys.
What are the main control flow statements in Python?
if/elif/else for conditional execution
for and while loops for iteration
break, continue, and pass for loop control
What is a function in Python?
A function is a
reusable block of code that performs a specific task
defined with the def keyword
called by its name followed by
parentheses ().
What are the differences between positional and keyword arguments in Python functions?
Positional arguments
are passed by position and must be provided in the correct order
keyword arguments
are passed by name and can be provided in any order
What is a lambda function in Python?
A lambda function is a
small, anonymous function defined with the lambda keyword,
often used for short, one-line operations.
What is a module in Python?
A module is a
file containing Python definitions and statements,
which can be imported into other Python files
or the interactive interpreter.
What is a package in Python?
A package is a way of organizing related modules into a directory hierarchy, with a special init.py file to mark the directory as a package.
What is object-oriented programming (OOP) in Python?
OOP is a programming paradigm based on the concept of objects, which can contain data (attributes) and code (methods). Python supports OOP with classes and inheritance.
What is the difference between a class and an instance in Python?
A class is a blueprint or template for creating objects, while an instance is a specific object created from a class.
What is inheritance in Python?
Inheritance is a mechanism that allows a new class to be based on an existing class, inheriting its attributes and methods.