1. Home
  2. Explore
  3. Computer Science
  4. Python Programming Tutorial

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Python Programming Tutorial

  • 95Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Python Foundations
Python is described as a
programming language because it can be used across many application domains.

95 questions

  1. 1
    Python is described as a
    _____
    programming language because it can be used across many application domains.
    Hint

    Think of a language that is not limited to one specialty.

    Answer

    general purpose

    Explanation

    A general purpose language can be used to write software in various application domains rather than being restricted to a particular domain.

  2. 2
    Python is a
    _____
    language, meaning its syntax uses natural-language elements that make code easier to read and understand.
    Hint

    This describes how closely a language’s syntax relates to human-readable language.

    Answer

    high level

    Explanation

    A high level language uses natural-language elements and automates significant parts of computing, such as memory allocation and management.

  3. 3
    Python is called an
    _____
    language because scripts are saved and executed in the format in which they were created.
    Hint

    Contrast this with languages whose code is translated into machine-specific instructions before execution.

    Answer

    interpreted

    Explanation

    An interpreted language executes the script in its original format, rather than first producing a machine-specific executable file.

  4. 4
    Python is
    _____
    typed because its parser infers a variable’s type from the data assigned to it.
    Hint

    The type is identified automatically rather than declared in advance.

    Answer

    dynamically

    Explanation

    In a dynamically typed language, Python identifies a variable’s type based on the value assigned to it.

  5. 5
    The creator of Python named in the content is
    _____
    .
    Hint

    Recall the person credited with creating the language.

    Answer

    Guido van Rossum

    Explanation

    The content identifies Guido van Rossum as the creator of Python.

  6. 6
    Unlike a domain-specific language, a general purpose language is not restricted to
    _____
    application domain.
    Hint

    Think about whether the language is confined to one specialty.

    Answer

    a particular

    Explanation

    General purpose languages can be used in various application domains without being restricted to a particular domain.

  7. 7
    A high level language can automate memory allocation and
    _____
    while coding.
    Hint

    This word completes the phrase describing what happens to memory.

    Answer

    management

    Explanation

    The content says high level languages automate significant computing tasks, including memory allocation and management.

  8. 8
    In Python, assigning a new kind of value to a variable does not require the programmer to declare its
    _____
    first.
    Hint

    This is the category that Python infers from the assigned value.

    Answer

    data type

    Explanation

    Python’s dynamic typing means the parser infers the variable’s type from its assigned data, so the programmer does not need to declare it first.

  9. 9
    The content contrasts interpreted languages with languages whose code is translated into machine-specific
    _____
    before being saved as an executable.
    Hint

    These are the operations a computer processor can execute.

    Answer

    instructions

    Explanation

    In the contrast described, code is translated into machine-specific instructions and then saved as an executable file.

  10. 10
    A variable assigned a string and then an integer illustrates Python’s ability to infer a variable’s type from its current
    _____
    .
    Hint

    Consider what the parser examines to determine the type.

    Answer

    assigned data

    Explanation

    Python automatically infers the type of a variable based on the data assigned to it.

  11. 11
    Python is widely used in areas such as web development, machine learning, data science, and
    _____
    .
    Hint

    This application area often involves carrying out repetitive tasks automatically.

    Answer

    automation

    Explanation

    The content lists automation among Python’s varied application domains.

  12. 12
    The content describes Python’s English-like and elegant
    _____
    as a reason it stands out from other languages.
    Hint

    This refers to the rules and structure used to write code.

    Answer

    syntax

    Explanation

    Python’s English-like, elegant syntax is presented as a feature that makes it especially understandable.

  13. 13
    One reason beginners may find Python approachable is that it is designed to be easy to read and
    _____
    .
    Hint

    What do programmers do when creating source code?

    Answer

    write

    Explanation

    The content emphasizes that Python is designed to be easy to read and write, including for beginners.

  14. 14
    Python is free and open source, so the public can download, use, modify, and
    _____
    its source code.
    Hint

    This is what users can do when sharing a modified or original copy.

    Answer

    distribute

    Explanation

    The content says the public can download, use, modify, and distribute Python’s source code.

  15. 15
    Python’s open-source nature allows its source code to be available to the
    _____
    .
    Hint

    This refers to everyone outside a private organization.

    Answer

    public

    Explanation

    Open source means the source code is available for the public to access and use.

  16. 16
    Writing fewer lines of code can reduce the
    _____
    needed to write a program.
    Hint

    Less code can mean less of this resource is spent during development.

    Answer

    time

    Explanation

    The content connects Python’s shorter code with reduced time needed to write programs.

  17. 17
    The example in the content says a Hello World program can take one line in Python, compared with at least
    _____
    lines in other languages.
    Hint

    Recall the approximate range given for the comparison.

    Answer

    two to three

    Explanation

    The content contrasts Python’s one-line Hello World example with at least two to three lines in other languages.

  18. 18
    Python’s large
    _____
    can help programmers find assistance when they get stuck.
    Hint

    This is the group of people who use and support the language.

    Answer

    community

    Explanation

    A large community gives Python users people they can reach out to for help.

  19. 19
    Python is increasingly preferred for data science partly because of its
    _____
    nature.
    Hint

    This means it can be applied in many different ways.

    Answer

    versatile

    Explanation

    The content describes Python as versatile and connects that quality to its popularity in data science.

  20. 20
    Python supports the object-oriented programming
    _____
    .
    Hint

    This is the model or approach to organizing programs around objects.

    Answer

    paradigm

    Explanation

    Python follows the object-oriented programming paradigm, allowing programs to be organized into individual objects.

  21. 21
    Grouping and bundling a program into individual objects can make its code look neat and easy to
    _____
    .
    Hint

    The benefit concerns how clearly people can interpret the code.

    Answer

    understand

    Explanation

    The content says object-oriented organization can make code neat and easy to understand.

  22. 22
    A Python program written on Windows can also run on Linux with little or no
    _____
    .
    Hint

    This refers to changes needed when moving a program between systems.

    Answer

    modifications

    Explanation

    Python is cross platform, so a program written on Windows can run on Linux with little or no modifications.

  23. 23
    Python can be integrated with languages such as C, C++, and
    _____
    .
    Hint

    This is another programming language named in the content.

    Answer

    Java

    Explanation

    The content notes that Python can be integrated with C, C++, Java, and other languages.

  24. 24
    Python’s libraries are described as large, rich, and
    _____
    platform compatible.
    Hint

    The word refers to compatibility across different operating systems.

    Answer

    cross

    Explanation

    The content emphasizes that Python has a large collection of libraries that are cross platform compatible.

  25. 25
    Python can create web applications with different levels of
    _____
    .
    Hint

    This describes how simple or intricate an application may be.

    Answer

    complexity

    Explanation

    The content says Python is used to create web applications of different levels of complexity.

  26. 26
    Python supports data analysis in part through libraries such as NumPy and
    _____
    .
    Hint

    This library is named alongside NumPy in the content.

    Answer

    pandas

    Explanation

    The content identifies NumPy and pandas as examples of libraries used for data analysis.

  27. 27
    Python can implement predictive analysis for machine learning using libraries such as scikit-learn and
    _____
    .
    Hint

    This machine-learning library is named alongside scikit-learn.

    Answer

    TensorFlow

    Explanation

    The content lists scikit-learn and TensorFlow among Python’s machine-learning libraries for predictive analysis.

  28. 28
    The Python module named in the content for game development is
    _____
    .
    Hint

    It is a game-development module whose name combines Python with “game.”

    Answer

    Pygame

    Explanation

    The content identifies Pygame as a module used for game development.

  29. 29
    Automating repetitive work in Python can include sending emails, opening a browser, and posting a
    _____
    status.
    Hint

    The example refers to a social media platform.

    Answer

    Facebook

    Explanation

    The content gives posting a Facebook status as an example of repetitive work Python can automate.

  30. 30
    The content connects Python’s many applications across domains with a wide range of career
    _____
    .
    Hint

    These are possibilities for employment and professional growth.

    Answer

    opportunities

    Explanation

    Because Python has applications in many domains, the content says it can open up many career opportunities.

  31. 31
    For a beginner choosing between Python 2 and Python 3, the recommendation in the content is to learn Python
    _____
    .
    Hint

    The content says the other major version is becoming obsolete.

    Answer

    3

    Explanation

    The content recommends Python 3 because more companies were moving away from Python 2 and community support for Python 3 was stronger.

  32. 32
    In the version discussion, Python 2.7 is described as becoming
    _____
    .
    Hint

    This means it is increasingly outdated and no longer the recommended choice.

    Answer

    obsolete

    Explanation

    The content advises beginners not to spend time learning a version that is becoming obsolete, referring to Python 2.7.

  33. 33
    The content says more companies were moving from Python 2 to Python
    _____
    .
    Hint

    This is the newer major version recommended for beginners in the lesson.

    Answer

    3

    Explanation

    The content describes companies moving from Python 2 to Python 3.

  34. 34
    The Instagram example says that in 2017 it migrated most of its Python code base from Python 2.7 to Python
    _____
    .
    Hint

    This is the newer major version in the migration example.

    Answer

    3

    Explanation

    The content states that Instagram migrated the majority of its Python code base from Python 2.7 to Python 3 in 2017.

  35. 35
    The content says the Python 3 community support is
    _____
    than the support for Python 2.
    Hint

    This is a comparative description of the level of community support.

    Answer

    better

    Explanation

    The lesson gives better community support for Python 3 as a reason to choose it.

  36. 36
    The default way to interact with Python mentioned in the content is the Python
    _____
    .
    Hint

    This abbreviation means command-line interface.

    Answer

    CLI

    Explanation

    The content says that by default, users can use the Python CLI to write and execute code.

  37. 37
    Anaconda is recommended because its distribution includes Python, Jupyter Notebook, and commonly used
    _____
    .
    Hint

    These are reusable software components often installed with a programming environment.

    Answer

    packages

    Explanation

    The content recommends Anaconda because it includes Python, Jupyter Notebook, and other commonly used packages.

  38. 38
    Jupyter Notebook is a
    _____
    based application for writing Python code.
    Hint

    It opens in a browser rather than being described as a desktop-only interface.

    Answer

    web

    Explanation

    The content describes Jupyter Notebook as a web based application for writing Python code.

  39. 39
    Jupyter Notebook provides an interactive
    _____
    science environment.
    Hint

    This field involves analyzing and interpreting data.

    Answer

    data

    Explanation

    The content says Jupyter Notebook offers an interactive data science environment.

  40. 40
    The lesson says Python IDEs can help with coding and
    _____
    .
    Hint

    This is the process of finding and fixing problems in a program.

    Answer

    debugging

    Explanation

    The content notes that IDEs such as those available with Anaconda can help with coding and debugging.

  41. 41
    A Python token is the smallest meaningful component of the source
    _____
    .
    Hint

    Tokens are the basic components that make up a program’s written form.

    Answer

    code

    Explanation

    The content defines a Python token as a basic, smallest meaningful component of source code.

  42. 42
    The four token categories listed are keywords, literals, identifiers, and
    _____
    .
    Hint

    This category includes symbols or words that perform tasks such as addition or comparison.

    Answer

    operators

    Explanation

    The content groups Python tokens into keywords, literals, identifiers, and operators.

  43. 43
    A Python keyword is a reserved word designed for a specific
    _____
    .
    Hint

    A keyword has a defined role in the language.

    Answer

    purpose

    Explanation

    Keywords are reserved words with specific purposes and meanings in Python.

  44. 44
    The name given to a variable, function, or class is an
    _____
    .
    Hint

    This is the programming term for a name used to identify an element in code.

    Answer

    identifier

    Explanation

    An identifier is the name assigned to a variable, function, or class.

  45. 45
    Python identifiers may contain letters, digits, and the underscore, but no other
    _____
    characters.
    Hint

    The rule excludes punctuation symbols other than the permitted underscore.

    Answer

    special

    Explanation

    The content states that no character except the underscore can be used as a special character in an identifier.

  46. 46
    A Python identifier cannot begin with an
    _____
    .
    Hint

    The first character must instead be a letter or underscore.

    Answer

    integer

    Explanation

    The content says an identifier’s first character may be a character or underscore, but not an integer.

  47. 47
    Python is case sensitive, so identifiers a and A are treated as
    _____
    names.
    Hint

    Changing capitalization affects whether Python sees the names as identical.

    Answer

    different

    Explanation

    In Python, lowercase and uppercase versions of a name are distinct identifiers.

  48. 48
    Because keywords are reserved, words such as if and while cannot be used as variable
    _____
    .
    Hint

    This is what an identifier provides to a variable.

    Answer

    names

    Explanation

    Keywords have specific meanings in Python and cannot be used as identifier names, including variable names.

  49. 49
    In a = 10, Python infers that a is an
    _____
    from the assigned value.
    Hint

    The assigned value is a whole number with no decimal point.

    Answer

    integer

    Explanation

    Python infers the data type from the assigned value; the lesson identifies 10 as an integer.

  50. 50
    In name = "Victor", Python infers that name is a
    _____
    because it stores text.
    Hint

    This data type represents text enclosed in quotation marks.

    Answer

    string

    Explanation

    The content explains that Python identifies a variable as a string when it stores a string value.

  51. 51
    A value such as 2000.23 is inferred as a
    _____
    data type.
    Hint

    This numerical type represents values with a decimal point.

    Answer

    float

    Explanation

    A number with a decimal point is identified as a floating-point value, or float.

  52. 52
    Python allows the same value to be assigned to several variables at once using chained
    _____
    .
    Hint

    This technique assigns values to variables in a single statement.

    Answer

    assignment

    Explanation

    The content shows a = b = c = 10 as a way to assign one value to several variables at once.

  53. 53
    Different values can be assigned to multiple variables in one statement by matching comma-separated names with comma-separated
    _____
    .
    Hint

    Each name is paired with the corresponding item on the right side of the assignment.

    Answer

    values

    Explanation

    The content demonstrates assigning different values to several variables by listing names and values in corresponding comma-separated sequences.

  54. 54
    A string literal can be created by enclosing text in either single or double
    _____
    .
    Hint

    These punctuation marks surround the text value.

    Answer

    quotes

    Explanation

    Python string literals can be written using either single quotes or double quotes.

  55. 55
    In the content, a multiline string is demonstrated by enclosing text in triple
    _____
    .
    Hint

    The delimiter uses three repeated marks around the text.

    Answer

    quotes

    Explanation

    The lesson demonstrates multiline string input using triple quotes.

  56. 56
    The four numeric literal types listed are integer, long integer, floating number, and
    _____
    number.
    Hint

    This numerical category can include an imaginary component.

    Answer

    complex

    Explanation

    The content lists integer, long integer, floating number, and complex number as numeric literal types.

  57. 57
    A numerical literal containing no decimal point is treated as an
    _____
    .
    Hint

    This type represents whole-number values in the lesson’s explanation.

    Answer

    integer

    Explanation

    The content says that a numerical literal without a decimal point is an integer.

  58. 58
    A numerical literal containing a decimal point is treated as a
    _____
    .
    Hint

    This numerical type represents values with a fractional part.

    Answer

    float

    Explanation

    The content says that a numerical literal with a decimal point becomes a float.

  59. 59
    The content says a number can contain only one
    _____
    point.
    Hint

    This punctuation separates the whole-number and fractional parts of a decimal value.

    Answer

    decimal

    Explanation

    A numeric literal may contain a decimal point, but the content states that it can have only one.

  60. 60
    Python integers can grow according to the limit of the available
    _____
    .
    Hint

    This is the computer resource used to store values.

    Answer

    memory

    Explanation

    The content says integer values are not restricted by a fixed width and can expand to the limit of available memory.

  61. 61
    A Boolean literal in Python has one of two values: True or
    _____
    .
    Hint

    This is the opposite Boolean value to True.

    Answer

    False

    Explanation

    The content identifies True and False as the two Boolean literal values.

  62. 62
    Because True and False are keywords, they cannot be used as identifier
    _____
    .
    Hint

    This is what variable, function, and class identifiers are used for.

    Answer

    names

    Explanation

    The content notes that Boolean values are also keywords, so they cannot be used as identifiers.

  63. 63
    The special literal used to specify a value that is not created is
    _____
    .
    Hint

    It is Python’s special value for the absence of a value in the lesson.

    Answer

    None

    Explanation

    The content says Python has one special literal, None, used to specify a value that is not created.

  64. 64
    The content compares Python’s None to the null keyword in C, C++, and
    _____
    .
    Hint

    This is the third language named in the comparison.

    Answer

    Java

    Explanation

    The lesson presents None as equivalent to the null keyword in C, C++, or Java.

  65. 65
    Numbers, strings, and tuples are classified in the content as
    _____
    data types.
    Hint

    These values cannot be changed or modified in place, according to the lesson.

    Answer

    immutable

    Explanation

    The content groups numbers, strings, and tuples as immutable data types.

  66. 66
    Lists, dictionaries, and sets are classified as
    _____
    data types.
    Hint

    These data structures can be changed after they are created.

    Answer

    mutable

    Explanation

    The content identifies lists, dictionaries, and sets as mutable data types.

  67. 67
    The type function can be used to find a variable’s data
    _____
    .
    Hint

    The function’s name indicates the information it reports.

    Answer

    type

    Explanation

    The lesson demonstrates using type to check whether variables are integers, strings, or floats.

  68. 68
    The int, float, and complex functions are examples of functions that can explicitly convert a value’s
    _____
    .
    Hint

    They can convert a value into a different category of data.

    Answer

    datatype

    Explanation

    The content says explicit conversion can be performed with functions such as int, float, and complex.

  69. 69
    Python has seven operator categories in the lesson: arithmetic, assignment, comparison, logical, bitwise, identity, and
    _____
    .
    Hint

    This category checks whether a value belongs to a sequence.

    Answer

    membership

    Explanation

    The content lists seven operator categories, with membership as the final category.

  70. 70
    The arithmetic operator in 2 + 3 is the
    _____
    sign.
    Hint

    This symbol performs addition.

    Answer

    plus

    Explanation

    The content identifies + as an arithmetic operator and uses it to add two operands.

  71. 71
    The arithmetic operator that finds the remainder after division is the
    _____
    operator.
    Hint

    It is often represented by the percent symbol in Python.

    Answer

    modulo

    Explanation

    The content lists modulo among the arithmetic operators, alongside addition, subtraction, multiplication, and division.

  72. 72
    The = operator assigns a
    _____
    to a variable.
    Hint

    In var = 10, this is the item placed into var.

    Answer

    value

    Explanation

    An assignment operator is used to assign a value to a variable.

  73. 73
    The shorthand statement var += 10 adds 10 to var and assigns the result back to
    _____
    .
    Hint

    The same variable appears on the left side of the shorthand update.

    Answer

    var

    Explanation

    The content explains that var += 10 is equivalent to var = var + 10.

  74. 74
    Comparison operators such as less than and not equal to return True or
    _____
    .
    Hint

    These operators produce one of the two Boolean outcomes.

    Answer

    False

    Explanation

    Comparison operators compare two values and return either True or False.

  75. 75
    If a = 10 and b = 20, the comparison a > b evaluates to
    _____
    .
    Hint

    Compare the size of 10 with the size of 20.

    Answer

    False

    Explanation

    Ten is not greater than twenty, so the comparison evaluates to False.

  76. 76
    The logical operators listed in the content are and, or, and
    _____
    .
    Hint

    This operator reverses a Boolean condition.

    Answer

    not

    Explanation

    The content identifies and, or, and not as Python’s logical operators.

  77. 77
    The logical expression False and True evaluates to
    _____
    .
    Hint

    For and to be true, both operands must be true.

    Answer

    False

    Explanation

    A logical and expression is true only when both conditions are true; since one operand is false, the result is false.

  78. 78
    Bitwise operators perform calculations on the binary
    _____
    of values.
    Hint

    These are the binary digits, 0 and 1.

    Answer

    bits

    Explanation

    The content describes bitwise operators as performing bitwise calculations on values.

  79. 79
    The bitwise or operation on 7 and 5 produces
    _____
    .
    Hint

    In binary, 7 is 111 and 5 is 101; combine corresponding bits with OR.

    Answer

    7

    Explanation

    Since the binary forms are 111 and 101, applying bitwise OR gives 111, which is 7.

  80. 80
    The bitwise and operation on 7 and 5 produces
    _____
    .
    Hint

    In binary, 111 AND 101 leaves only the positions where both bits are 1.

    Answer

    5

    Explanation

    The binary forms of 7 and 5 are 111 and 101; their bitwise AND is 101, which is 5.

  81. 81
    In the content’s example, the bitwise NOT operation on 7 produces
    _____
    .
    Hint

    The lesson shows that flipping the bits leads to this negative decimal result.

    Answer

    -8

    Explanation

    The content demonstrates that applying bitwise NOT to 7 gives -8.

  82. 82
    The example 10 >> 2 shifts the binary bits two places to the right and gives
    _____
    .
    Hint

    The binary form of 10 is 1010; move its bits two places right.

    Answer

    2

    Explanation

    Right-shifting the binary value 1010 by two places gives 0010, which is 2 in decimal.

  83. 83
    The example 10 << 2 shifts the binary bits two places to the left and gives
    _____
    .
    Hint

    Appending two zero bits to binary 1010 produces the resulting value.

    Answer

    40

    Explanation

    Left-shifting 10, whose binary form is 1010, by two places gives 101000, which equals 40.

  84. 84
    The identity operators is and is not test whether two operands share an
    _____
    .
    Hint

    They test whether operands are the same object, rather than compare their values.

    Answer

    identity

    Explanation

    The content says identity operators test whether two operands share an identity.

  85. 85
    The membership operators in and not in test whether a value belongs to a
    _____
    .
    Hint

    Examples named in the lesson include a list, string, or tuple.

    Answer

    sequence

    Explanation

    Membership operators check whether a value is a member of a sequence such as a list, string, or tuple.

  86. 86
    For the list dog, cat, and wolf, checking whether lion is in the list returns
    _____
    .
    Hint

    Check whether the named animal appears among the three listed entries.

    Answer

    False

    Explanation

    Since lion does not appear in the list, the membership test returns False.

  87. 87
    In a Python string, the first character is accessed using index
    _____
    .
    Hint

    Python string indexing begins at the starting position.

    Answer

    0

    Explanation

    The content demonstrates that the first character of a string is at index 0.

  88. 88
    In Python, the last character of a string can be accessed using index
    _____
    .
    Hint

    A negative index counts backward from the end of the string.

    Answer

    -1

    Explanation

    The content uses index -1 to access the last character of a string.

  89. 89
    When extracting a substring with a slice, the ending index is
    _____
    in the result.
    Hint

    The slice includes positions up to, but not including, its endpoint.

    Answer

    not included

    Explanation

    The content explains that a slice from index 0 to index 5 includes characters before index 5, but not the character at index 5.

  90. 90
    The string method that returns the position where a requested substring begins is `
    _____
    .`
    Hint

    Its name describes searching for a piece of text.

    Answer

    find

    Explanation

    The find function returns the position of the requested substring within a string.

  91. 91
    In the word attachment, the substring me begins at index
    _____
    .
    Hint

    Count from zero: the letters before m are a, t, t, a, c, h.

    Answer

    6

    Explanation

    With zero-based indexing, the m in attachment is at position 6, where the substring me begins.

  92. 92
    The string method used to replace one character or substring with another is `
    _____
    .`
    Hint

    Its name describes substituting one piece of text for another.

    Answer

    replace

    Explanation

    The replace function replaces one character or string with another.

  93. 93
    To change a string by replacing me with m, the lesson uses the string’s `
    _____
    .` method.
    Hint

    This method takes the old text and the replacement text as arguments.

    Answer

    replace

    Explanation

    The content demonstrates using the replace method to substitute m for the substring me.

  94. 94
    A string containing multiple lines can be represented in the demonstrated way using
    _____
    quotation marks at the beginning and end.
    Hint

    The delimiter uses a repeated quotation mark three times.

    Answer

    three

    Explanation

    The content shows multiline strings enclosed with three quotation marks at each end.

  95. 95
    In the string hello world, the slice from index 0 up to index 5 extracts
    _____
    .
    Hint

    The endpoint is excluded, so the slice includes the first five characters.

    Answer

    hello

    Explanation

    A slice from 0 to 5 includes indices 0 through 4, which spell hello.

1 of 95
Question 1 of 95

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent