Which method is used to add a new key-value pair to a dictionary?
insert()
add()
append()
update()
What will the following code snippet print?
tuple1 = (1, 2, 3) tuple2 = (4, 5, 6) print(tuple1 + tuple2)
[1, 2, 3, 4, 5, 6]
Error
(1, 2, 3, 4, 5, 6)
(1, 2, 3)(4, 5, 6)
Which assignment operator in Python is used to perform floor division and assign the result?
//=
=
/=
%=
Which function is used to convert a string to an integer in Python?
float()
bool()
int()
str()
What is the output of the following Python code snippet?
print(type(5.0))
<class 'float'>
<class 'int'>
<class 'number'>
<class 'str'>
What is the correct way to print 'Hello, World!' in Python?
echo 'Hello, World!'
console.log('Hello, World!')
print('Hello, World!')
System.out.println('Hello, World!')
What is the purpose of the '#' symbol in Python code?
To execute a command
To indicate a code block
To write a comment
To define a variable
What is the value of the expression: 10 > 5 and 3 < 1?
10 > 5 and 3 < 1
False
None
True
10
What is the correct way to create a string literal containing both single and double quotes in Python?
'He said, "Hello!"'
"He said, 'Hello!'"
Both option 1 and 2 are correct
How can you retrieve the value associated with the key 'name' in a dictionary named 'my_dict'?
my_dict.get('name')
my_dict.name
Both option1 and option3
my_dict['name']