1/76
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are the two basic approaches to programming?
Structured design and Object-oriented design.
What is structured design?
An approach that breaks down a system into smaller, manageable components, often represented as functions or modules.
What is the focus of structured design?
Top-down decomposition, control flow, and data flow.
What are common techniques used in structured design?
Data flow diagrams, structure charts, and Warnier-Orr diagrams.
What is object-oriented design (OOD)?
An approach that views a system as a collection of objects, each with its own data (attributes) and behavior (methods).
What are the key principles of object-oriented design?
Encapsulation, inheritance, polymorphism, and abstraction.
What is the purpose of a compiler in programming?
To translate a program written in a high-level language into the equivalent machine language.
What is the role of the Python Virtual Machine (PVM)?
It executes Python bytecode and acts as an abstraction layer between Python code and the underlying hardware.
What is a module in Python?
A way to organize code by grouping related functions and variables.
What are the basic data types in Python?
Numbers (integers, floats, complex), strings, lists, tuples, dictionaries, sets, and booleans.
What is the significance of the 'def' keyword in Python?
It is used to define functions.
What is the purpose of control flow statements in Python?
To execute code based on conditions and control the execution of loops.
What does Python's syntax emphasize?
A straightforward and readable style, similar to the English language, without the need for semicolons or curly brackets.
What is the history of Python's development?
Python was started in December 1989 by Guido Van Rossum and released its first version in February 1991.
What are some features of Python?
Easy to learn, large standard library, expressive language, GUI programming support, and interpreted language.
What is the advantage of Python being an interpreted language?
It makes debugging easier and allows for portability across platforms.
What is a class in Python?
A blueprint for creating objects that defines attributes and methods.
What is inheritance in object-oriented programming?
The ability to create new classes based on existing ones.
What is polymorphism in programming?
The ability for different objects to respond to the same method call in different ways.
What is a dictionary in Python?
An unordered collection of key-value pairs.
What is the purpose of the 'return' statement in a function?
To send values back from functions.
What are some popular frameworks for Python web development?
Django, Flask, and Pyramid.
What is the significance of the bytecode in Python?
It is an intermediate language that Python instructions are translated into before being executed by the machine language.
What are the common operators used in Python?
Arithmetic, comparison, and logical operators.
What is a set in Python?
An unordered collection of unique elements.
What is the difference between a list and a tuple in Python?
Lists are mutable (can be changed), while tuples are immutable (cannot be changed).
What is a key advantage of Python being an interpreted language?
It makes debugging easy and portable.
What does it mean that Python is a cross-platform language?
Python can run equally on different platforms such as Windows, Linux, and UNIX.
How does Python handle memory allocation for variables?
Python uses dynamic memory allocation, automatically allocating memory at runtime without needing to specify the data type.
What is meant by Python being embeddable?
Python code can be embedded within other programming languages.
What does it mean that Python is free and open source?
Python is freely available for everyone, allowing anyone to download its source code without payment.
What are the main characteristics of Python as an object-oriented language?
Python supports classes, objects, inheritance, polymorphism, and encapsulation.
What are tokens in Python?
Tokens are the smallest units of a Python program that have specific meanings, including keywords, identifiers, literals, operators, and delimiters.
What are keywords in Python?
Reserved words that have special meanings, such as if, else, for, while, def, and class.
What are identifiers in Python?
Names given to variables, functions, classes, and modules, which must start with a letter or underscore.
What are literals in Python?
Constant values that can be of different data types, such as integers, floats, strings, booleans, and None.
What are operators in Python?
Symbols used to perform operations on values, such as +, -, *, /, and %.
What are delimiters in Python?
Characters used to separate different parts of a Python program, like parentheses, brackets, and commas.
What are the rules for naming identifiers in Python?
Identifiers must start with a letter or underscore, cannot use reserved keywords, cannot contain spaces, and are case-sensitive.
What is the naming convention for variables and functions in Python?
Use snake_case, where words are separated by underscores and all letters are lowercase.
What is the naming convention for class names in Python?
Use PascalCase, where the first letter of each word is capitalized with no underscores.
What is the convention for naming constants in Python?
Use UPPER_SNAKE_CASE, where all letters are uppercase and words are separated by underscores.
What is PEP 8?
The official style guide for Python code, recommending naming conventions and code style.
What is a SyntaxError in Python?
An error that occurs when the code violates the syntax rules of Python, such as using invalid identifiers.
What is the purpose of the print() function in Python?
To display output to the console.
What is dynamic memory allocation in Python?
The process where memory for a variable is allocated at runtime based on the value assigned.
What is the significance of the underscore in Python identifiers?
It can indicate private or protected members and is used in naming conventions.
What is the role of whitespace in Python?
Whitespace is used to improve code readability and structure.
What does it mean for Python to be extensible?
It allows other languages like C/C++ to be used to compile the code.
What is the difference between reserved keywords and identifiers?
Reserved keywords have special meanings in Python and cannot be used as identifiers.
What is the significance of case sensitivity in Python?
Identifiers that differ only in case are considered different, e.g., myVariable and MyVariable.
What is an example of a valid identifier in Python?
my_variable or function_name.
What is an example of an illegal identifier in Python?
1st_variable (starts with a number) or my-variable (contains a hyphen).
What is the purpose of using underscores before a member in Python?
It signals that the member is intended for internal use only.
What are reserved keywords in Python?
Keywords that cannot be used as variable names, such as 'for' and 'global'.
How do whitespaces affect Python code?
Whitespaces improve code readability and structure but do not affect functionality.
What does the print() function do in Python?
It displays output to the console and can take multiple arguments separated by commas.
How can you format output using the format() method?
You can specify precision using {.precision} to set the number of decimal places.
What is the significance of indentation in Python?
Indentation defines code blocks and controls the flow of execution.
What is the recommended style for indentation in Python?
Use four spaces for indentation and avoid mixing tabs and spaces.
What is the purpose of the input() function in Python?
It prompts the user to enter input from the console and returns it as a string.
What are escape sequences in Python?
Special characters used to represent non-printable characters or characters with special meanings.
What are the three types of comments in Python?
Single-line comments, multi-line comments, and documentation strings (docstrings).
How do you create a single-line comment in Python?
By placing a hashtag (#) at the beginning of the line.
What is a Python docstring?
Strings enclosed in triple quotes that document modules, methods, classes, and functions.
What is the purpose of comments in Python?
To describe code, take notes, and improve code readability without affecting execution.
How can you format numbers using f-strings?
By directly including precision within the curly braces, e.g., f'{number:.2f}'.
What is a logic error in Python?
An error where the syntax is correct, but the program produces incorrect results.
How can you print multiple items on the same line in Python?
By separating arguments with commas or using the end parameter in the print() function.
What does the sep parameter do in the print() function?
It specifies the string to be inserted between multiple items when printed.
What is the purpose of using comments to restrict code execution?
To overlook specific code while evaluating other sections or to create pseudo-code.
What is the output of the following code: print(f'{number:.2f}')?
It formats the number to two decimal places.
What is the output of print('Hello', 'world', sep=' ')?
'Hello world'
What is the effect of excessive whitespace in Python code?
It can clutter the code and make it harder to read.
How do you comment out a statement in Python?
By placing a hashtag (#) before the statement.
What is the syntax for multi-line comments in Python?
Use multiple hashtags (#) or triple quotes for docstrings.
What does the format() method allow you to do?
It allows for more complex formatting scenarios, including specifying precision and alignment.