Answers for "use numpy in python"

5

numpy example

>>> import numpy as np
>>> a = np.array([0, 1, 2, 3])
>>> a
array([0, 1, 2, 3])
Posted by: Guest on April-21-2020
1

how to import numpy in python

import numpy 
#or
import numpy as np
Posted by: Guest on February-13-2021
1

numpy

def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]
    return quicksort(left) + middle + quicksort(right)

print(quicksort([3,6,8,10,1,2,1]))
# Prints "[1, 1, 2, 3, 6, 8, 10]"
Posted by: Guest on July-30-2020
0

python use numphy

from decimal import Decimal
num1=Decimal('1.1')
num2=Decimal('1.563')
print(num1+num2)
Posted by: Guest on October-01-2021
-1

numpy

x = 3
print(type(x)) # Prints "<class 'int'>"
print(x)       # Prints "3"
print(x + 1)   # Addition; prints "4"
print(x - 1)   # Subtraction; prints "2"
print(x * 2)   # Multiplication; prints "6"
print(x ** 2)  # Exponentiation; prints "9"
x += 1
print(x)  # Prints "4"
x *= 2
print(x)  # Prints "8"
y = 2.5
print(type(y)) # Prints "<class 'float'>"
print(y, y + 1, y * 2, y ** 2) # Prints "2.5 3.5 5.0 6.25"
Posted by: Guest on July-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language