Ad
Fundamentals

This fonction analyze records of temperature to find the closest to zero.

If two numbers are equally close to zero, positive integer has to be considered closest to zero (for instance, if the temperatures are -5 and 5, then display 5)

Display 0 (zero) if no temperatures are provided. Otherwise, display the temperature closest to 0.

def TempCloseTo0(arr):
    if len(arr)==0:  return 0
    else : 
        j=max(arr)
        for i in arr:
            if abs(i)<j :
                j=abs(i)
        return j
Code
Diff
  • def primemaker(x):
      primes = []
      if x < 2 : return []
      else:  
        for possibleprimes in range(2,(x+1)):
            isprime = True
            for n in range(2,possibleprimes):
                if possibleprimes % n == 0:
                    isprime = False
            if isprime:
                primes.append(possibleprimes)
        return primes
    
    
    • def primemaker(x):
    • primes = []
    • isprime = True
    • for possibleprimes in range(2,x):
    • primes = []
    • if x < 2 : return []
    • else:
    • for possibleprimes in range(2,(x+1)):
    • isprime = True
    • for n in range(2,possibleprimes):
    • if possibleprimes % num == 0:
    • if possibleprimes % n == 0:
    • isprime = False
    • if isprime:
    • primes.append(possibleprimes)
    • print(primes)
    • return primes