Spaces:
Sleeping
Sleeping
File size: 2,384 Bytes
54a69e6 59718f3 54a69e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import streamlit as st
import numpy as np
# App title
st.title('NumPy Concepts: From Scratch to Advanced')
# Sidebar for navigation
st.sidebar.title("Navigation")
options = st.sidebar.radio("Go to", ["Home", "Array Basics", "Advanced Operations", "Linear Algebra"])
# Home page
if options == "Home":
st.header("Welcome to NumPy Learning Hub!")
st.write("""
This app will guide you through various concepts of NumPy, starting from the basics to advanced levels.
Use the sidebar to navigate through different sections.
""")
# Array Basics page
elif options == "Array Basics":
st.header("Array Basics")
st.write("Learn about creating arrays and basic operations.")
# Creating arrays
st.subheader("Creating Arrays")
array1 = np.array([1, 2, 3, 4, 5])
st.write("1D Array:", array1)
array2 = np.array([[1, 2], [3, 4]])
st.write("2D Array:", array2)
# Basic operations
st.subheader("Basic Operations")
array_sum = np.sum(array1)
st.write("Sum of array:", array_sum)
array_mean = np.mean(array1)
st.write("Mean of array:", array_mean)
# Advanced Operations page
elif options == "Advanced Operations":
st.header("Advanced Operations")
st.write("Explore advanced NumPy operations like broadcasting and slicing.")
array3 = np.arange(10)
st.write("Original array:", array3)
st.subheader("Slicing")
st.write("Sliced array (2:5):", array3[2:5])
st.subheader("Broadcasting")
array4 = np.array([1, 2, 3])
array_broadcasted = array4 + 5
st.write("Broadcasted array:", array_broadcasted)
# Linear Algebra page
elif options == "Linear Algebra":
st.header("Linear Algebra")
st.write("Dive into linear algebra concepts with NumPy.")
# Matrix multiplication
st.subheader("Matrix Multiplication")
matrix1 = np.array([[1, 2], [3, 4]])
matrix2 = np.array([[5, 6], [7, 8]])
matrix_product = np.dot(matrix1, matrix2)
st.write("Matrix 1:", matrix1)
st.write("Matrix 2:", matrix2)
st.write("Matrix product:", matrix_product)
# Eigenvalues and eigenvectors
st.subheader("Eigenvalues and Eigenvectors")
matrix3 = np.array([[4, -2], [1, 1]])
eigenvalues, eigenvectors = np.linalg.eig(matrix3)
st.write("Matrix:", matrix3)
st.write("Eigenvalues:", eigenvalues)
st.write("Eigenvectors:", eigenvectors)
|