Quiz for:
Python Syntax Overview

Question 1

Which operator is used for string concatenation?

Question 2

How do you handle exceptions in Python?

Question 3

How would you comment multiple lines in Python?

Question 4

What does 'str(5)' return?

Question 5

What is the output of 'print("hello" * 3)'?

Question 6

Which keyword can be used to import all functions from a module?

Question 7

Which method removes all items from a set?

Question 8

How can you ensure some code runs regardless of whether an exception was raised or not?

Question 9

How can you create a lambda function for adding two numbers?

Question 10

In an if-else statement, which part will execute if the condition is False?

Question 11

How do you generate a range of numbers starting from 1 to 10?

Question 12

How do you check if a function is being run as the main program?

Question 13

What will the following code return: 'spam[0:2]' if spam=['cat', 'bat', 'rat']?

Question 14

What will 'len("hello")' return?

Question 15

How do you increase the loop counter in a while loop by 1?