Syntax, Variables & Dynamic Typing — Concept Check
Questions on Syntax, Variables & Dynamic Typing. Python variables are names bound to objects. Indentation defines blocks, snake_case is the convention, and everything — numbers, strings, functions — is an object.
Questions in this quiz
8 questions on Syntax, Variables & Dynamic Typing — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.In Python, what happens when you execute the following code? `a = [1, 2, 3]; b = a; b.append(4); print(a)`
- Aa prints [4]
- Ba prints [1, 2, 3, 4]
- Ca prints [1, 2, 3]
- Da results in an error
2.You have two lists, a and c, both initialized as `[1, 2, 3, 4]`. What does `print(a is c)` output?
- AFalse
- BTrue
- CNone
- DError
3.Given `x, y = 10, 20` and `x, y = y, x`, what are the values of x and y after execution?
- Ax = 20, y = 10
- Bx = 10, y = 10
- Cx = 20, y = 20
- Dx = 10, y = 20
4.What will the following code output? `marks = 82; if marks >= 75: grade = 'Distinction'; else: grade = 'Pass'; print(grade)`
- ADistinction
- BPass
- CNone
- DError
5.Why does the code `if marks > 40: print('pass')` result in a SyntaxError?
- AIncorrect indentation
- BMissing parentheses around condition
- CMissing colon after the if statement
- DIncorrect variable name
6.What is the result of `print(a == c)` if `a = [1, 2, 3, 4]` and `c = [1, 2, 3, 4]`?
- ATrue
- BError
- CNone
- DFalse
7.Which of the following statements is true about Python variables?
- AVariables are immutable
- BVariables are labels that point to objects
- CVariables must be declared before assignment
- DVariables store copies of data
8.What does the `is` operator do in Python?
- ACompares object values
- BChecks for variable existence
- CCompares object identity
- DChecks for type equality