Cards (57)

  • What are variables used for in programming?
    To store data referenced during execution
  • What is a variable in programming?
    A name assigned to a value
  • Do Python variables require explicit type declaration?
    No, type is inferred from assigned value
  • What characters can variable names contain?
    Letters, digits, and underscores
  • Can a variable name start with a digit?
    No, it cannot start with a digit
  • Are variable names in Python case-sensitive?
    Yes, myVar and myvar are different
  • What should be avoided when naming variables?
    Using Python keywords like if, else, for
  • What are the rules for naming variables in Python?
    • Can contain letters, digits, underscores
    • Cannot start with a digit
    • Case-sensitive
    • Avoid Python keywords
  • How are values assigned to variables in Python?
    Using the = operator
  • What does dynamic typing mean in Python?
    Same variable can hold different types
  • Can multiple variables be assigned values in one line?
    Yes, Python allows multiple assignments
  • What is the benefit of assigning the same value to multiple variables?
    It initializes variables with the same value
  • What does type casting refer to?
    Converting one data type into another
  • What are some built-in functions for type casting in Python?
    int(), float(), str()
  • How can you determine the type of a variable in Python?
    Using the type() function
  • What are the two scopes of variables in Python?
    Local and global
  • Where are local variables defined?
    Inside a function
  • Where are global variables defined?
    Outside any function
  • How can global variables be accessed inside functions?
    Using the global keyword
  • What does the del keyword do in Python?
    Removes a variable from the namespace
  • What happens after a variable is deleted using del?
    Accessing it results in a NameError
  • What is an operator in programming?
    A symbol that operates on values
  • What forms when data and operators are connected?
    Expressions
  • What is the exponentiation operator in Python?
    ** (double asterisk)
  • What does the exponentiation operator do?
    Raises the left argument to the right argument
  • What is the result type when at least one argument of ** is a float?
    Float
  • What is the result type when both arguments of ** are integers?
    Integer
  • What is the multiplication operator in Python?
    * (asterisk)
  • What is the division operator in Python?
    / (slash)
  • What does the integer division operator (//) do?
    Returns the integer part of the division
  • What is the result of integer division with integers?
    Integer result
  • What happens when integer division involves floats?
    Result is always a float
  • How is the result of integer division rounded?
    To the nearest lesser integer
  • What does the % (percent) sign represent?
    The remainder after integer division
  • What is another name for the % operator in programming?
    Modulo
  • What is the addition operator in Python?
    + (plus sign)
  • What is the subtraction operator in Python?
    • (minus sign)
  • What is the hierarchy of priorities in Python?
    Defines which operators act first
  • What does left-sided binding mean in Python?
    Calculations are conducted from left to right
  • How can the same expression yield different results?
    Based on the order of operations applied