Searching...
Flashcards in this deck (57)
  • What is the purpose of the Python review mentioned in the document?

    A very fast-paced review of Python basics

    A comprehensive guide to advanced Python

    An introduction to Python libraries

    A tutorial on Python web development

    python review
  • Where can you find Python downloads and documentation?

    http://www.python.com

    http://www.python.org

    http://www.learnpython.org

    http://www.dabeaz.com

    python resources
  • What does the Python interpreter provide?

    A text editor

    A graphical user interface

    A web server

    A read-eval loop

    python interpreter
  • What is the command to run a Python program from the command line?

    python helloworld.py

    run helloworld.py

    python3 helloworld.py

    execute helloworld.py

    python execution
  • How do comments start in Python?

    With a /* symbol

    With a -- symbol

    With a # symbol

    With a // symbol

    python comments
  • What is the correct syntax to create a variable in Python?

    height : 442

    var height = 442

    int height = 442

    height = 442

    python variables
  • Which operator in Python is used for power calculations?

    ^

    ^2

    *

    **

    python operators
  • What is the outcome of the expression 7 // 4 in Python?

    0

    1

    2

    1.75

    python math
  • How do you denote an if-else statement in Python?

    if condition: ... else: ...

    if condition then ... else ...

    if (condition) { ... } else { ... }

    if condition: ... elseif: ...

    python conditionals
  • What are the relational operators in Python?

    < > <= >= == !=

        • /

    == != < >

    and or not

    python operators
  • What does the 'if' statement do in Python?

    Prints text to console

    Ends a loop early

    Loops through items

    Executes code based on a condition

    python control_flow
  • What does the 'while' statement do?

    Iterates over items

    Loops on a condition

    Skips to next iteration

    Terminates a loop

    python looping
  • What does the 'break' statement do in a loop?

    Terminates the loop early

    Starts a new loop

    Exits the program

    Continues to next iteration

    python control_flow
  • What is the purpose of the 'continue' statement?

    Starts a new loop

    Prints text to console

    Skips to the next iteration

    Terminates the loop

    python control_flow
  • How does the print function separate items?

    By spaces

    By new lines

    By commas

    By tabs

    python printing
  • What is the purpose of the 'pass' statement in Python?

    Acts as a placeholder

    Terminates the program

    Prints a message

    Loops through items

    python control_flow
  • Which of the following is NOT a core Python datatype?

    String

    Set

    List

    Integer

    python datatypes
  • What does the open function do?

    Opens a file

    Closes a file

    Writes data

    Reads data

    python file_handling
  • What is the correct way to read a line from a file?

    line = f.read()

    line = f.readlines()

    line = f.readline()

    line = f.get()

    python file_handling
  • What is the purpose of the 'with' statement when opening a file?

    Reads data from the file

    Writes data to the file

    Automatically closes the file

    Opens multiple files

    python file_handling
  • Which method is used to write text to a file?

    g.append('some text')

    g.read('some text')

    g.open('some text')

    g.write('some text')

    python file_handling
  • What does the '.format()' method do in Python?

    Writes data

    Formats strings

    Loops through items

    Reads files

    python string_manipulation
  • What is the output of print(f'{name:>10s} {shares:>10d} {price:>10.2f}')?

    Integer output

    Formatted string output

    Raw string output

    List output

    python formatted_printing
  • How do you read an entire file into a string in Python?

    data = f.load()

    data = f.get()

    data = f.read()

    data = f.readall()

    file_handling reading_files
  • What mode should you use to write to a file in Python?

    'r'

    'rb'

    'a'

    'w'

    file_handling writing_files
  • Which encoding might you need to specify when reading text files?

    'ascii'

    'utf-16'

    'latin-1'

    'utf-8'

    file_handling encoding
  • What file mode is used for reading binary data?

    'ab'

    'rb'

    'w'

    'r'

    file_handling binary_files
  • What function is used to sum numbers from n to 1?

    total(n)

    sumcount(n)

    countsum(n)

    addcount(n)

    functions python
  • What indicates that an error has occurred in Python?

    a traceback

    a warning

    a failure

    an exception

    error_handling exceptions
  • How do you catch exceptions in Python?

    try-except statement

    while loop

    if-else statement

    for loop

    error_handling exceptions
  • Which statement is used to raise an exception?

    catch

    throw

    signal

    raise

    error_handling exceptions
  • What can be associated with most exceptions in Python?

    an associated value

    a code

    a message

    a type

    error_handling exceptions
  • How can you catch multiple exceptions at once?

    except ValueError, TypeError as e

    except all

    except (ValueError, TypeError) as e

    except (ValueError, TypeError)

    error_handling exceptions
  • What does the finally statement do in exception handling?

    Specifies code that may run if no exceptions occur

    Specifies code that only runs on exceptions

    Specifies code that runs if the program is successful

    Specifies code that must run regardless of exceptions

    error_handling exceptions
  • What does a finally statement specify in Python?

    Code that runs before an exception is raised

    Code that must run regardless of exception occurrence

    Code that runs only if no exceptions occur

    Code that runs only if an exception occurs

    python exceptions
  • What is the purpose of the lock in the example?

    To manage resources properly

    To define a class

    To create a new thread

    To handle exceptions

    python concurrency
  • What is Python primarily considered as?

    A procedural language

    A functional language

    A scripting language

    An object-oriented language

    python programming
  • What do all basic data types in Python represent?

    Modules

    Classes

    Objects

    Functions

    python data_types
  • What method is used to convert a string to uppercase in Python?

    upper()

    title()

    lower()

    capitalize()

    python strings
  • What is a class in Python?

    A blueprint for creating objects

    A module

    A data structure

    A type of function

    python classes
  • What does the init method do?

    Initializes a new instance of a class

    Creates a new module

    Defines a new class

    Handles exceptions

    python object-oriented
  • How do you create an instance of a class in Python?

    By calling the class as a function

    By defining a new method

    By importing the class

    By using the class name directly

    python instances
  • What is the first argument in a method defined in a class?

    self

    this

    object

    instance

    python methods
  • What is a module in Python?

    A built-in function

    Any Python source file

    A type of class

    A package of libraries

    python modules
  • What is a namespace in Python?

    A type of variable

    A module import

    A function definition

    A collection of named values

    python namespaces
  • What does the import statement do?

    Defines a new variable

    Loads and executes a module

    Creates a new module

    Compiles the code

    python import
  • What happens when you define the same variable name in different modules?

    They overwrite each other

    They do not conflict with each other

    They cause an error

    They merge into one variable

    python globals
  • What does the import as statement do?

    Defines a new variable

    Assigns a different name to a module object

    Creates a new module

    Imports multiple modules

    python import
  • What does the 'import as' statement do in Python?

    Assigns a different name to a module locally

    Defines the main module

    Imports all functions from a module

    Imports selected symbols only

    python import
  • What is the purpose of 'from module import'?

    Lifts selected symbols out of a module into local scope

    Defines the main module

    Assigns a different name to the module

    Imports the entire module

    python import
  • What does 'from module import *' do?

    Defines the main module

    Takes all symbols from a module into local scope

    Imports the module with a different name

    Lifts selected symbols into local scope

    python import
  • Why is 'from module import *' generally discouraged?

    It leads to poor code readability

    It is not compatible with Python 3

    It imports too many symbols

    It requires additional syntax

    python best_practices
  • What is the 'main' module in Python?

    A module that imports all others

    A function that executes first

    The source file that runs first

    The module that defines the main class

    python main_module
  • What does the 'name' check do?

    Checks for syntax errors

    Defines a new module

    Determines if the module is running as the main program

    Imports the main module

    python main_module
  • What is 'sys.path' used for?

    It lists all installed packages

    It contains the module search path

    It defines the main module

    It stores variable definitions

    python sys_path
  • How can you manually adjust the module search path?

    By appending to sys.path

    By renaming the module

    By importing the module directly

    By modifying the PYTHONPATH environment variable

    python sys_path
  • What is the summary of the document regarding Python modules?

    It lists all Python modules

    It explains advanced Python concepts

    It provides an overview of basics and hints at more depth later

    It focuses only on error handling

    python overview