Complete the code to identify the type of a variable in a simple type checking rule.
if variable.type == [1]: print("Variable is an integer")
The type checking rule compares the variable's type to the string "int" to confirm it is an integer.
Complete the code to check if two variables have the same type before assignment.
if var1.type == var2.[1]: var1.value = var2.value
To ensure type safety, the code compares the types of both variables before assignment.
Fix the error in the type checking condition to allow only boolean variables.
if variable.type == [1]: print("Variable is boolean")
The correct type string for boolean variables is "bool" in most languages and type checkers.
Fill both blanks to create a type checking rule that allows assignment only if the source type is compatible with the target type.
if source.type [1] target.type or target.type == [2]: assign(source, target)
The rule allows assignment if types are equal or if the target type is "any", meaning it accepts any type.
Fill all three blanks to define a type checking rule that filters variables by type and value condition.
filtered_vars = {var: var.[1] for var in variables if var.[2] [3] 10}This dictionary comprehension selects variables by their type and filters those with values greater than 10.
