Which of the following comparison operators means 'not equal to' in Python?
==
!=
=
<>
What is the correct way to take integer input from the user in Python?
input()
input(int())
int(input())
raw_input()
What will the following Python code snippet print?
def greet(name): print(f"Hello, {name}!") greet("Alice")
An error message.
greet("Alice")
Hello, Alice!
Hello, name!
What is the value of the expression: '5' + '3'?
'5' + '3'
8
Error
53
15
How can you retrieve the value associated with the key 'name' in a dictionary named 'my_dict'?
my_dict['name']
my_dict.name
Both option1 and option3
my_dict.get('name')
What is the value of the expression: 10 > 5 and 3 < 1?
10 > 5 and 3 < 1
None
10
False
True
What is the correct way to add a new key-value pair to an existing dictionary in Python?
my_dict['city'] = 'New York'
my_dict + {'city': 'New York'}
my_dict.append('city', 'New York')
my_dict.insert('city', 'New York')
What is the purpose of the break statement in a loop?
break
It exits the loop entirely.
It defines a new variable within the loop.
It skips the current iteration and continues to the next.
It prints the current value of the loop variable.
What will the following code print?
my_set = {1, 2, 3} my_set.add(3) print(my_set)
{3, 1, 2}
{1, 2, 3}
{1, 2, 3, 3}
What is the correct way to print 'Hello, World!' in Python?
echo 'Hello, World!'
console.log('Hello, World!')
System.out.println('Hello, World!')
print('Hello, World!')