Question
Prompt the user to enter their username and store it in a variable.
Prompt the user to enter their password and store it in a new variable.
Prompt the user to enter their age, and store it in a third variable.
Print a message that says: USERNAME: followed by the username they entered.
Print a message that says: PASSWORD: followed by the password they entered.
Print a message that says: Ten years ago you were, followed by the user's age minus 10.
Hint: You’ll need to convert the user’s age to an integer using int( ) before doing any math.
Prompt the user to enter their password and store it in a new variable.
Prompt the user to enter their age, and store it in a third variable.
Print a message that says: USERNAME: followed by the username they entered.
Print a message that says: PASSWORD: followed by the password they entered.
Print a message that says: Ten years ago you were, followed by the user's age minus 10.
Hint: You’ll need to convert the user’s age to an integer using int( ) before doing any math.
Answers
GPT-4o mini
Here’s a simple implementation of the prompt and output in Python:
```python
# Prompt the user to enter their username
username = input("Please enter your username: ")
# Prompt the user to enter their password
password = input("Please enter your password: ")
# Prompt the user to enter their age
age = input("Please enter your age: ")
# Convert the age to an integer
age = int(age)
# Print the messages
print("USERNAME:", username)
print("PASSWORD:", password)
print("Ten years ago you were", age - 10)
```
When you run this code, it will ask the user for their username, password, and age, and then output the requested information accordingly.
```python
# Prompt the user to enter their username
username = input("Please enter your username: ")
# Prompt the user to enter their password
password = input("Please enter your password: ")
# Prompt the user to enter their age
age = input("Please enter your age: ")
# Convert the age to an integer
age = int(age)
# Print the messages
print("USERNAME:", username)
print("PASSWORD:", password)
print("Ten years ago you were", age - 10)
```
When you run this code, it will ask the user for their username, password, and age, and then output the requested information accordingly.