What is the correct way to get user input and store it in a variable named 'name'?
input('Enter your name:') = name
name = print('Enter your name:')
name = input('Enter your name:')
print('Enter your name:') = name
What will this code print?
for i in range(3): for j in range(2): print('*', end='') print()
** ** **
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
What is the correct way to write and run a Python script named 'my_script.py' from the command line?
python run my_script.py
run my_script.py
python my_script.py
execute my_script.py
What will this code snippet print?
x = 10 if x > 5: if x < 15: print('Yes') else: print('No')
An error message
Yes
YesNo
No
What is a lambda function in Python?
A function that recursively calls itself.
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.
What will the following Python code print to the console?
name = input("Enter your name: ") print("Hello,", name)
Enter your name: Hello, [user's input]
It will print nothing.
Hello, [user's input]
Enter your name:
Which method is used to add a new key-value pair to a dictionary?
append()
add()
insert()
update()
What is the purpose of the '#' symbol in Python code?
To define a variable
To indicate a code block
To write a comment
To execute a command
How can you retrieve the value associated with the key 'name' in a dictionary named 'my_dict'?
my_dict['name']
my_dict.get('name')
my_dict.name
Both option1 and option3