GitHub Repository Submission

When using GitHub mode, paste your repository URL below and click Save URL to store it. The saved URL will be automatically included with every message you send until you choose to clear it. Learn more

Your GitHub repository URL is saved. LSBot will automatically fetch your latest code from this repository for each message. To change the URL, clear it first and save a new one.

Exercise 11

Without running the following code, determine what each line should print.

print('johnson' in 'Joe Johnson')
print('sen' not in 'Joe Johnson')
print('Joe J' in 'Joe Johnson')
print(5 in range(5))
print(5 in range(6))
print(5 not in range(5, 10))
print(0 in range(10, 0, -1))
print(4 in {6, 5, 4, 3, 2, 1})
print({1, 2, 3} in {1, 2, 3})
print({3, 2} in {1, frozenset({2, 3})})

Solution

print('johnson' in 'Joe Johnson')      # False
print('sen' not in 'Joe Johnson')      # True
print('Joe J' in 'Joe Johnson')        # True
print(5 in range(5))                   # False
print(5 in range(6))                   # True
print(5 not in range(5, 10))           # False
print(0 in range(10, 0, -1))           # False
print(4 in {6, 5, 4, 3, 2, 1})         # True
print({1, 2, 3} in {1, 2, 3})          # False
print({3, 2} in {1, frozenset({2, 3})}) # True
  • Line 1: in with strings is case sensitive.
  • Line 4: range(5) does not include 5; it ranges from 0 to 4.
  • Line 7: range(10, 0, -1) does not include 0; it ranges from 10 to 1.
  • Line 9: in with sets only checks whether a specific value is in the set.
  • Line 10: {3, 2} and frozenset({2, 3}) are considered equal sets.

Video Walkthrough

Hi! I'm LSBot. I can help you think through the selected exercise by giving you hints and guidance without revealing the solution. Your code from the editor will be automatically detected. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...

Submit your solution for LSBot review.

Hi! I'm LSBot. Your code from the editor will be automatically detected. I'll review your solution and provide feedback to help you improve. Ask questions about your solution or request a comprehensive code review. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...