Deep Thought
“All right,” said the computer, and settled into silence again. The two men fidgeted. The tension was unbearable.
“You’re really not going to like it,” observed Deep Thought.
“Tell us!”
“All right,” said Deep Thought. “The Answer to the Great Question…”
“Yes…!”
“Of Life, the Universe and Everything…” said Deep Thought.
“Yes…!”
“Is…” said Deep Thought, and paused.
“Yes…!”
“Is…”
“Yes…!!!…?”
“Forty-two,” said Deep Thought, with infinite majesty and calm.”
— The Hitchhiker’s Guide to the Galaxy, Douglas Adams
In deep.py
, implement a program that prompts the user for the answer to the Great Question of Life, the Universe and Everything, outputting Yes
if the user inputs 42
or (case-insensitively) forty-two
or forty two
. Otherwise output No
.
Hints
- No need to convert the user’s input to an
int
if you check for equality with"42"
, astr
, rather than42
, anint
! - It’s okay if your output or the user’s wraps onto multiple lines.
Before You Begin
From the root of your repository execute cd conditionals
So your current working directory is ...
deep.py
where you’ll write your program.
Success
Your program must have a function call deep_thought
that takes 1 argument, a string. The function must return a boolean value of True
if the argument is equal to "42"
, case insensitive "Forty Two"
, or "forty-two"
, otherwise it returns False
. Your main()
function should call the function with user input, print the result of that function call to the console.
How to Test
Here’s how to test your code manually. At the deep/ $
prompt in your terminal: :
- Run your program with
python deep.py
. Type42
and press Enter. Your program should output: - Run your program with
python deep.py
. TypeForty Two
and press Enter. Your program should output: - Run your program with
python deep.py
. Typeforty-two
and press Enter. Your program should output: - Run your program with
python deep.py
. Type50
and press Enter. Your program should output:
You can execute the below to check your code using pytest
from the root directory.
A green output from running the test means it was successful. A red output means there is a bug in your code that you need to fix.
How to Submit
From github desktop or the command line, commit your changes and push them to your repository.
Codespaces
If you are using codespaces, you can commit your changes directly from the Codespace interface. Click on the Source Control icon in the left sidebar, then click on the "..." button and select "Commit to main". Enter a commit message and click "Commit".
Codespace terminal or your local terminal.
Note
You will need to have installed git-scm
for this to work locally
At the /datatypes $
prompt in your terminal:
Note
Remember to replace "your message here" with a meaningful commit message that describes your changes.