import numpy as np a = np.array([[0, 1],[2, 3]]) fa = a.flatten() mv = np.max(fa) miv = np.min(fa) print("Original flattened array:") print(a) print("Maximum value of the above flattened array:") print(mv) print("Minimum value of the above flattened array:") print(miv)
12 Comments
Thank You for Sharing FYBCS HTML & CSS
ReplyDeleteThank you so much
ReplyDeleteimport numpy as np
ReplyDeletea = np.array([[0, 1],[2, 3]])
fa = a.flatten()
mv = np.max(fa)
miv = np.min(fa)
print("Original flattened array:")
print(a)
print("Maximum value of the above flattened array:")
print(mv)
print("Minimum value of the above flattened array:")
print(miv)
import numpy as np
ReplyDeletefrom numpy.linalg import norm
p1 = [1, 2, 3]
p2 = [4, 5, 6]
dist = norm(np.array(p1) - np.array(p2))
print("Euclidean distance between the two data points:", dist)
import pandas as pd
ReplyDeleteimport numpy as np
df = pd.DataFrame({'data': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
m = df['data'].mean()
r = df['data'].max() - df['data'].min()
iqr = df['data'].quantile(0.75) - df['data'].quantile(0.25)
print("Mean:", m)
print("Range:", r)
print("IQR:", iqr)
import itertools as i
ReplyDeletedef m_d(point1, point2):
return abs(point1[0] - point2[0]) + abs(point1[1]-point2[1])
def sum_of_m_d(points):
sum_of_d= 0
for point1,point2 in i.combinations(points, 2):
sum_of_d += m_d(point1, point2)
return sum_of_d
points = [(1, 2), (3, 4), (5, 6)]
print(sum_of_m_d(points))
import numpy as np
ReplyDeleteimport matplotlib.pyplot as plt
nums = [0.5, 0.7, 1.0, 1.2, 1.3, 2.1]
bins = [0, 1, 2, 3]
hist, bins = np.histogram(nums, bins=bins)
print("nums:", nums)
print("bins:", bins)
print("Result:", (hist, bins))
plt.bar(bins[:-1], hist, width=0.8)
plt.xlabel('Bins')
plt.ylabel('Frequency')
plt.title('Histogram of nums against the bins')
plt.show()
import pandas as pd
ReplyDeletestudents = pd.DataFrame({'Name': ['om1', 'om2', 'om3', 'om4', 'om5'],'Graduation Percentage': [85, 90, 75, 95, 80],'Age': [22, 21, 23, 20, 24]})
print("Average age of students:", students['Age'].mean())
print("Average of graduation percentage:", students['Graduation Percentage'].mean())
print(students.describe())
import pandas as pd
ReplyDeletei= pd.read_csv("D:\WT & FDS I\Revised Data Science_Workbook_ Assignment Solution\Data Science Assignment Solution\Iris.csv")
sample = i.sample(100)
print(sample.describe())
import pandas as pd
ReplyDeleteiris = pd.read_csv('D:\WT & FDS I\Revised Data Science_Workbook_ Assignment Solution\Data Science Assignment Solution\Iris.csv')
count = iris['Species'].value_counts()
print(count)
import pandas as pd
ReplyDeleteiris = pd.read_csv('D:\WT & FDS I\Revised Data Science_Workbook_ Assignment Solution\Data Science Assignment Solution\Iris.csv')
print(iris.mean())
print(iris.median())
#include
ReplyDeleteusing namespace std;
struct Node {
int data;
Node* prev;
Node* next;
};
Node* head = NULL;
// Insert at end
void insertEnd(int value) {
Node* newNode = new Node;
newNode->data = value;
newNode->next = NULL;
newNode->prev = NULL;
if (head == NULL) {
head = newNode;
return;
}
Node* temp = head;
while (temp->next != NULL)
temp = temp->next;
temp->next = newNode;
newNode->prev = temp;
}
// Delete by value
void deleteNode(int value) {
Node* temp = head;
while (temp != NULL && temp->data != value)
temp = temp->next;
if (temp == NULL) return; // Not found
if (temp->prev != NULL)
temp->prev->next = temp->next;
else
head = temp->next;
if (temp->next != NULL)
temp->next->prev = temp->prev;
delete temp;
}
// Traverse forward
void traverseForward() {
Node* temp = head;
while (temp != NULL) {
cout << temp->data << " ";
temp = temp->next;
}
cout << endl;
}
// Traverse backward
void traverseBackward() {
Node* temp = head;
if (!temp) return;
while (temp->next != NULL)
temp = temp->next;
while (temp != NULL) {
cout << temp->data << " ";
temp = temp->prev;
}
cout << endl;
}
int main() {
insertEnd(10);
insertEnd(20);
insertEnd(30);
cout << "Forward: ";
traverseForward();
cout << "Backward: ";
traverseBackward();
deleteNode(20);
cout << "After deletion (forward): ";
traverseForward();
cout << "After deletion (backward): ";
traverseBackward();
return 0;
}