This Python program receives a sample input and determines whether it represents a "bag".
The logic can be based on string matching, object type, or any custom rule depending on context.
For simplicity, we assume the input is a string and check whether it matches the word "bag".
def is_bag(sample: str) -> bool:
return sample.strip().lower() == "bag"
# Run the program
sample_input = input("Enter the sample: ")
if is_bag(sample_input):
print("The sample is a bag.")
else:
print("The sample is not a bag.")
The sample is a bag.
- The user enters a sample string
- The is_bag function trims whitespace and converts the input to lowercase
- It checks if the result equals "bag"
- The program prints whether the sample is a bag or not