Here's a Python program to satisfy the tasks you've described. This program will prompt the user for their address, perform the necessary operations, and print the required outputs.
# Ask the user for their address
address = input("Please enter your address: ")
# Task 1: Store the address, which is a string data type
# Task 2: Calculate the length of the address and store it in an integer variable
address_length = len(address)
# Print the number of characters in the address
print(f"Your address is {address_length} characters long.")
# Task 3: Print the fifth character of the address (index 4)
if len(address) >= 5:
fifth_character = address[4]
print(f"The fifth character of your address is: '{fifth_character}'")
else:
print("Your address is too short to have a fifth character.")
# Task 4: Check if the word "Main" is in the address and store the result in a Boolean variable
contains_main = "Main" in address
# Print whether "Main" is in the address
if contains_main:
print("The word 'Main' is in your address.")
else:
print("The word 'Main' is not in your address.")
# Task 5: Print the address three times
print(f"Your address is:\n{address}\n{address}\n{address}")
Explanation of Data Types Used:
- Address: Stored as a string since it is a sequence of characters.
- Address Length: Stored as an integer, as it represents the number of characters.
- Fifth Character: Retrieved using string indexing (index 4).
- Contains Main: Stored as a Boolean to represent a true/false condition.
Notes:
- You must add this code into any Python environment such as PythonAnywhere.
- After running the code, follow the instructions to share the link as required.
Make sure to run the code, interact with it, and adjust any handling you feel is necessary depending on your preferences or additional requirements. After you have it working, run the program and share the link as instructed!