Quiz for:
Complete Python Language Series: Chapter 2

Question 1

Which method is used to concatenate two strings in Python?

Question 2

Which conditional keyword is used to handle multiple conditions sequentially?

Question 3

What is the output of `string.count('a')` if `string = 'banana'`?

Question 4

Which string function is used to check if a string ends with a specific substring?

Question 5

How do you find the first occurrence of a substring 'thon' in a string?

Question 6

What will the following code print if `light = 'green'`? ```python light = 'green' if light == 'red': print('Stop') elif light == 'green': print('Go') else: print('Look')```

Question 7

How can you create a multi-line string in Python?

Question 8

Which operator is used to check for equality in Python?

Question 9

How would you replace 'Python' with 'Java' in a string?

Question 10

What will `string[1:4]` return if `string = 'Python'`?

Question 11

What will the following code print? ```python age = 21 if age >= 18: print('Can vote and apply for license') else: print('Cannot vote')```

Question 12

Which escape sequence is used to insert a new line inside a string?

Question 13

How do you access the last character of a string `string` using negative indexing?

Question 14

What will the following code print? `string = 'Programming'; print(string[0:5].upper())`

Question 15

What does the `len()` function do when applied to a string?