What is the value of 'x' after this code executes?
x = 5 if x == 5: x += 1 else: x -= 1
5
4
7
6
Which comparison operator is used to check if two values are not equal?
!=
==
<
What is a lambda function in Python?
A small, anonymous function defined using the 'lambda' keyword.
A function defined using the 'def' keyword.
A function that takes another function as an argument.
A function that recursively calls itself.
Which method is used to add a new key-value pair to a dictionary?
insert()
update()
append()
add()
What is the output of the following Python code?
string = 'Hello, world!' print(string[7:12])
Hello
world
world!
ello,
What is the primary characteristic of a set in Python?
Unordered and immutable
Unordered and mutable
Ordered and mutable
Ordered and immutable
Which of the following data structures in Python is mutable?
List
None of the above
String
Tuple
What is the output of the following Python code snippet?
print(type(5.0))
<class 'str'>
<class 'number'>
<class 'int'>
<class 'float'>
Which of the following is NOT a valid variable name in Python?
variable_name
variable123
123variable
my_variable
Which arithmetic operator is used to calculate the remainder of a division?
**
/
//
%