2011-03-29 3 views
0

저는 파이썬으로 시작하는 초급 프로그래머입니다. 내 프로그램에서 math.log10 (x)를 사용하려하지만 "NameError : name 'math'이 정의되지 않았습니다."오류가 계속 발생합니다. 타이핑하는 동안 인텔리 센스가 튀어 나와 사용할 수 있어야합니다. 지금까지 읽은 가이드는 제대로 모듈을 올리는 방법에 대해 거의 말하지 않았기 때문에 다소 잃어 버렸습니다. 나는 이것이 매우 엔트리 레벨 질문 알고파이썬 3.X에서 내장 수학 모듈을 사용하는 방법은 무엇입니까?

print("Enter an integer 'n' that is greater than 1: ") 
n = int(input()) 

Primes = [2] 
#List of Prime Numbers 
Candidate = 3 
#Number tested for Primeness 
Product = 1 
#Running product of prime numbers < n 
Logarithm = True 
#Will be the log of the product of the primes 
##Ratio = True 
## #Will be the ratio of the Logarithm to n 

while Primes[len(Primes)-1] <= n: 
    #Continue only while Primes < n 
IsPrime = True 
i=0 
while i < len(Primes): 
    if Candidate%Primes[i] == 0: 
     IsPrime = False 
    else: 
     Product = Product * Candidate 
     #Multiplies the current product by the newest prime < n 
    i = i + 1 
if IsPrime: 
    Primes.append(Candidate) 
    #Adds newest prime to the list 
Candidate = Candidate + 1 

Logarithm = math.log10(Product) 

,하지만 난 도움을 사용할 수 있습니다

여기에 내 현재 프로그램입니다. 고맙습니다!

+0

파이썬을 배우기 위해 사용하는 튜토리얼은 무엇입니까? –

답변

2

유형 "import math"는 프로그램 상단에 있습니다.

+0

감사합니다. 나는 그것이 단순했다는 것을 알고있다 : ... / – Artemis

관련 문제