0

i made a code like this. and i learnedimport *calling all module in math but i don't know mean of '*' the result is diffrent with the thing i think

i thinked answer of 'd*e' is 16 also, answer of 'd**e' is 64 and so, sqrt(d**e) will be 8

i searched google but i don know the mean of *

d = 8
e = 2

from math import *

print(d*e)
print(d**e)
sqrt(d ** e)

but, result was 16.88210319127114

what is the mean of '*' ??

여시형
  • 11
  • 1
  • Your confusion comes from e being overwritten with Euler's constant when you imported math. – Swifty Nov 20 '22 at 16:16
  • 1
    And that's why the [Style Guide for Python Code](https://peps.python.org/pep-0008/#imports) says: "Wildcard imports (`from import *`) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools.". Here we have a wonderful example where this happenss. – Matthias Nov 20 '22 at 17:27

1 Answers1

1

* is a wildcard that loads all of the functions in that library into your local namespace.

i0x539
  • 4,763
  • 2
  • 20
  • 28