This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#codingsnap.tech | |
t = int(input("Enter number of test cases: ")) | |
for i in range(t): | |
n,m = [int(x) for i in input("Enter the dimensions :").split()] | |
c = int(input("Enter the cost for each cut made: ")) | |
min_cost = (n-1)*c + (m-1)*c | |
print("Amount that Dipesh need to pay for the cutting is: ",min_cost) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = int(input("Enter the number of the test cases: ")) | |
for i in range(t): #codingsnap.tech | |
n = int(input("Enter the number of lockers: ")) | |
m = int(input("Enter some random numbers to open the lockers: ")) | |
for i in range(1,n+1): | |
if (i%m==0): | |
continue | |
else: | |
print(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isprime(n): | |
if (n==1): | |
return False | |
elif (n==2): | |
return True | |
else: | |
for i in range(2,n//2+1): | |
if (n%i==0): | |
return False | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Numpy Array | |
a = np.arange(1000) | |
%timeit a**2 | |
Output: 3.54 µs ± 87.3 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) | |
#Python List | |
L = range(1000) | |
%timeit [i**2 for i in L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
a = np.array([1,2,3,4,5]) | |
print("A :",a) | |
Output: A : [1 2 3 4 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = np.arange(10) | |
b = np.arange(2,20,4) | |
print("Array A =",a) | |
print("Array B =",b) | |
Output: | |
Array A = [0 1 2 3 4 5 6 7 8 9] | |
Array B = [ 2 6 10 14 18] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = np.random.rand(5) #5 is the number of elements we want in the array | |
print(a) | |
Output: | |
[0.52759507 0.62328844 0.26818125 0.78392403 0.36929455] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = np.random.randint(0,20,15) | |
print(a) | |
Output: | |
[10 4 6 13 9 6 1 11 6 11 5 0 11 4 0] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = np.linspace(1,10,5) | |
print(a) | |
Output: | |
[ 1. 3.25 5.5 7.75 10. ] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = np.array([[1,2,3,4],[5,6,7,8]]) | |
print(a) | |
Output: | |
[[1 2 3 4] | |
[5 6 7 8]] | |
OlderNewer