Python Strings | 3/100 Days of Python Algo trading

Python Strings

Congratulations on reaching this stage!

If you’re here, it means you’re truly dedicated to mastering Python. Directly below, you’ll find a quiz designed to help you reinforce what you’ve just learned. This isn’t just about recalling facts; it’s about deeply understanding the concepts. Take a moment to answer the questions and see how well you can apply the knowledge from the video. You’re doing great—every question you tackle brings you one step closer to becoming a Python expert!

Day 3: Python Strings

1. Consider the code: my_string = "Summer 2024". Which of the following expressions would correctly extract the year?
2. What is the output of the following code?
Python
text = "Python Programming"new_text = text.replace("Programming", "Finance")
print(new_text)
3. What is the purpose of the following code?
Python
ticker = "  AAPL  "clean_ticker = ticker.strip()
4. Which code correctly checks if a string starts with a specific substring?
Python
message = "Welcome to the course"
5. How would you split the string portfolio = "AAPL-MSFT-GOOG" into a list of individual ticker symbols using the hyphen as the separator?
6. What is the output of the following code?
Python
name = "Jane"age = 30info = f"Name: {name}, Age: {age}"print(info)
7. What data type does the .split() method return?
8. How would you convert a list of strings into a single string joined by commas?
9. Which method would you use to find the first occurrence of the letter "o" in the string text = "coding"?
10. What does the isalnum() string method do?
11. You have a string price = "$123.45". How would you remove the dollar sign?
12. What is the output of the following code?

Python
text = "Coding is fun"result = text[::-1]
print(result)
13. How do you check if a string is entirely lowercase?
14. What is the difference between string.find() and string.index()?
15. How would you format a floating-point number to two decimal places in a string?
16. What does the isdigit() string method do?
17. How would you convert the string my_string = "hello world" to title case (first letter of each word capitalized)?
18. What is the purpose of the rfind() string method?
19. Which method reverses the order of items in a list?
20. Given the string text = " Hello, world! ", what is the result of text.strip().split(",")?