#Python Pop Quiz 🐍❓

How do you get the following code to work? It should take in a number, return the square root and print it.

Answer? 

@driscollis sq_root is, for historical reasons*, called sqrt.

Alternatively, skip the import and just return number ** 0.5.

For a side quiz, why doesn't number ** 1/2 work?

*almost always the worst reason for anything.

Answer? 

@peterdrake @driscollis `64**(1/2)` works, but `64**1/2` returns `32.0`, because of operator precedence.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.