operators

Cards (69)

  • What are operators used for in Python?
    To perform operations on variables
  • When do we use operators to add or change variable values?
    When we want to modify a variable's value
  • What is the purpose of comparison operators in Python?
    To compare variable values against something else
  • What does the assignment operator '=' do in Python?
    It assigns a value to a variable
  • How do you compare two variable values in Python?
    Using comparison operators like '>' or '<'
  • If you want to check if variable A is greater than variable B, which operator would you use?
    The '>' operator
  • How does the '>' operator function in Python?
    It checks if the left value is greater
  • What does the expression '2 > 1' evaluate to?
    True
  • What does the expression '2 >= 2' evaluate to?
    True
  • What does the expression '1 < 2' evaluate to?
    True
  • What does the expression '1 <= 2' evaluate to?
    True
  • What is the output of '2 < 1' in Python?
    False
  • What does the expression '2 == 2' check for?
    Equality of two values
  • What is the output of '2 == 1' in Python?
    False
  • What does the expression '2 != 1' evaluate to?
    True
  • What is the output of '2 != 2' in Python?
    False
  • What is the purpose of the 'input' function in Python?
    To take user input
  • What does the 'print' function do in Python?
    Displays output to the console
  • How do you print the value of a variable named 'x' in Python?
    Using print(x)
  • What is the syntax for defining a function in Python?
    def function_name():
  • What is the purpose of the 'def' keyword in Python?
    To define a new function
  • What is the output of 'print(2 + 2)' in Python?
    4
  • What does the expression 'input()' do in Python?
    It waits for user input
  • What is the output of 'print("Hello, World!")' in Python?
    Hello, World!
  • What does the expression 'input("Enter your name: ")' do?
    Prompts user for their name
  • What is the output of 'print(3 * 3)' in Python?
    9
  • What does the expression '3 * 3' evaluate to?
    9
  • What is the output of 'print(5 - 2)' in Python?
    3
  • What does the expression '5 - 2' evaluate to?
    3
  • What is the output of 'print(10 / 2)' in Python?
    5.0
  • What does the expression '10 / 2' evaluate to?
    5.0
  • What is the output of 'print(2 ** 3)' in Python?
    8
  • What does the expression '2 ** 3' evaluate to?
    8
  • What is the output of 'print(7 % 3)' in Python?
    1
  • What does the expression '7 % 3' evaluate to?

    1
  • What is the output of 'print(4 + 5 * 2)' in Python?
    14
  • What does the expression '4 + 5 * 2' evaluate to?
    14
  • What is the output of 'print((4 + 5) * 2)' in Python?
    18
  • What does the expression '(4 + 5) * 2' evaluate to?
    18
  • What is the output of 'print(10 - 3 + 2)' in Python?
    9