ASasaA
DownloadTélécharger
Actions
Vote :
ScreenshotAperçu

Informations
Catégorie :Category: nCreator TI-Nspire
Auteur Author: kboiiii
Type : Classeur 3.0.1
Page(s) : 1
Taille Size: 5.29 Ko KB
Mis en ligne Uploaded: 18/09/2025 - 19:58:04
Uploadeur Uploader: kboiiii (Profil)
Téléchargements Downloads: 1
Visibilité Visibility: Archive publique
Shortlink : https://tipla.net/a4848149
Type : Classeur 3.0.1
Page(s) : 1
Taille Size: 5.29 Ko KB
Mis en ligne Uploaded: 18/09/2025 - 19:58:04
Uploadeur Uploader: kboiiii (Profil)
Téléchargements Downloads: 1
Visibilité Visibility: Archive publique
Shortlink : https://tipla.net/a4848149
Description
Fichier Nspire généré sur TI-Planet.org.
Compatible OS 3.0 et ultérieurs.
<<
# TI-Nspire CX II Python App # Physics Vector & Math Calculator # For Takeshi @ Iowa State (PHYS 2310/2310H) import math # --- Helper Functions --- def get_vector_input(vector_name): """Prompts user for a 3D vector and handles errors.""" print(f"\n--- Enter components for Vector {vector_name} ---") while True: try: x = float(input(f"Enter {vector_name}x: ")) y = float(input(f"Enter {vector_name}y: ")) z = float(input(f"Enter {vector_name}z: ")) return [x, y, z] except ValueError: print("Invalid input. Please enter numbers only.") # --- Geometry Calculation Functions --- def run_geometry_menu(): """Displays and handles the geometry calculation submenu.""" while True: print("\n" + "-"*25) print(" GEOMETRY CALCULATOR") print("-"*25) print("1. Circle (Area, Perimeter)") print("2. Sphere (Volume, Surface Area)") print("3. Cylinder (Volume, Surface Area)") print("4. Back to Main Menu") choice = input("Select an option (1-4): ") if choice == '1': try: r = float(input("\nEnter Radius (R): ")) area = math.pi * r**2 perimeter = 2 * math.pi * r print("\n--- Circle Results ---") print(f"Area = {area}") print(f"Perimeter = {perimeter}") except ValueError: print("Invalid input. Please enter a number.") elif choice == '2': try: r = float(input("\nEnter Radius (R): ")) volume = (4/3) * math.pi * r**3 surface_area = 4 * math.pi * r**2 print("\n--- Sphere Results ---") print(f"Volume = {volume}") print(f"Surface Area = {surface_area}") except ValueError: print("Invalid input. Please enter a number.") elif choice == '3': try: r = float(input("\nEnter Radius (R): ")) h = float(input("Enter Height (h): ")) volume = math.pi * r**2 * h surface_area = (2 * math.pi * r * h) + (2 * math.pi * r**2) print("\n--- Cylinder Results ---") print(f"Volume = {volume}") print(f"Surface Area = {surface_area}") except ValueError: print("Invalid input. Please enter a number.") elif choice == '4': break else: print("\nInvalid choice. Please enter a number from 1 to 4.") input("\nPress [enter] to return to the geometry menu.") # --- Vector & Math Calculation Functions --- def calc_magnitude(): """Calculates the magnitude and unit vector of a single vector.""" a = get_vector_input("A") mag = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) print("\n----- RESULTS -----") print(f"Magnitude |A| = {mag}") if mag != 0: unit_vector = [a[0]/mag, a[1]/mag, a[2]/mag] print(f"Unit Vector  = <{unit_vector[0]:.4f}, {unit_vector[1]:.4f}, {unit_vector[2]:.4f}>") else: print("Unit Vector is undefined for a zero vector.") def calc_dot_product(): """Calculates the dot product of two vectors.""" a = get_vector_input("A") b = get_vector_input("B") dot_prod = (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) print("\n----- RESULTS -----") print(f"Dot Product A · B = {dot_prod}") def calc_cross_product(): """Calculates the cross product of two vectors.""" a = get_vector_input("A") b = get_vector_input("B") # Formula: A x B = (AyBz - AzBy)i + (AzBx - AxBz)j + (AxBy - AyBx)k cross_x = (a[1]*b[2]) - (a[2]*b[1]) cross_y = (a[2]*b[0]) - (a[0]*b[2]) cross_z = (a[0]*b[1]) - (a[1]*b[0]) print("\n----- RESULTS -----") print(f"Cross Product A x B = <{cross_x}, {cross_y}, {cross_z}>") def calc_cross_product_magnitude(): """Calculates the magnitude of the cross product of two vectors.""" a = get_vector_input("A") b = get_vector_input("B") # First, calculate the cross product components cross_x = (a[1]*b[2]) - (a[2]*b[1]) cross_y = (a[2]*b[0]) - (a[0]*b[2]) cross_z = (a[0]*b[1]) - (a[1]*b[0]) # Then, calculate the magnitude of that resulting vector magnitude = math.sqrt(cross_x**2 + cross_y**2 + cross_z**2) print("\n----- RESULTS -----") print(f"Magnitude |A x B| = {magnitude}") def calc_angle_between(): """Calculates the angle between two vectors.""" a = get_vector_input("A") b = get_vector_input("B") dot_prod = (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) mag_a = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) mag_b = math.sqrt(b[0]**2 + b[1]**2 + b[2]**2) print("\n----- RESULTS -----") if mag_a == 0 or mag_b == 0: print("Cannot calculate angle with a zero vector.") else: # Prevent math domain error from floating point in
[...]
>>
Compatible OS 3.0 et ultérieurs.
<<
# TI-Nspire CX II Python App # Physics Vector & Math Calculator # For Takeshi @ Iowa State (PHYS 2310/2310H) import math # --- Helper Functions --- def get_vector_input(vector_name): """Prompts user for a 3D vector and handles errors.""" print(f"\n--- Enter components for Vector {vector_name} ---") while True: try: x = float(input(f"Enter {vector_name}x: ")) y = float(input(f"Enter {vector_name}y: ")) z = float(input(f"Enter {vector_name}z: ")) return [x, y, z] except ValueError: print("Invalid input. Please enter numbers only.") # --- Geometry Calculation Functions --- def run_geometry_menu(): """Displays and handles the geometry calculation submenu.""" while True: print("\n" + "-"*25) print(" GEOMETRY CALCULATOR") print("-"*25) print("1. Circle (Area, Perimeter)") print("2. Sphere (Volume, Surface Area)") print("3. Cylinder (Volume, Surface Area)") print("4. Back to Main Menu") choice = input("Select an option (1-4): ") if choice == '1': try: r = float(input("\nEnter Radius (R): ")) area = math.pi * r**2 perimeter = 2 * math.pi * r print("\n--- Circle Results ---") print(f"Area = {area}") print(f"Perimeter = {perimeter}") except ValueError: print("Invalid input. Please enter a number.") elif choice == '2': try: r = float(input("\nEnter Radius (R): ")) volume = (4/3) * math.pi * r**3 surface_area = 4 * math.pi * r**2 print("\n--- Sphere Results ---") print(f"Volume = {volume}") print(f"Surface Area = {surface_area}") except ValueError: print("Invalid input. Please enter a number.") elif choice == '3': try: r = float(input("\nEnter Radius (R): ")) h = float(input("Enter Height (h): ")) volume = math.pi * r**2 * h surface_area = (2 * math.pi * r * h) + (2 * math.pi * r**2) print("\n--- Cylinder Results ---") print(f"Volume = {volume}") print(f"Surface Area = {surface_area}") except ValueError: print("Invalid input. Please enter a number.") elif choice == '4': break else: print("\nInvalid choice. Please enter a number from 1 to 4.") input("\nPress [enter] to return to the geometry menu.") # --- Vector & Math Calculation Functions --- def calc_magnitude(): """Calculates the magnitude and unit vector of a single vector.""" a = get_vector_input("A") mag = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) print("\n----- RESULTS -----") print(f"Magnitude |A| = {mag}") if mag != 0: unit_vector = [a[0]/mag, a[1]/mag, a[2]/mag] print(f"Unit Vector  = <{unit_vector[0]:.4f}, {unit_vector[1]:.4f}, {unit_vector[2]:.4f}>") else: print("Unit Vector is undefined for a zero vector.") def calc_dot_product(): """Calculates the dot product of two vectors.""" a = get_vector_input("A") b = get_vector_input("B") dot_prod = (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) print("\n----- RESULTS -----") print(f"Dot Product A · B = {dot_prod}") def calc_cross_product(): """Calculates the cross product of two vectors.""" a = get_vector_input("A") b = get_vector_input("B") # Formula: A x B = (AyBz - AzBy)i + (AzBx - AxBz)j + (AxBy - AyBx)k cross_x = (a[1]*b[2]) - (a[2]*b[1]) cross_y = (a[2]*b[0]) - (a[0]*b[2]) cross_z = (a[0]*b[1]) - (a[1]*b[0]) print("\n----- RESULTS -----") print(f"Cross Product A x B = <{cross_x}, {cross_y}, {cross_z}>") def calc_cross_product_magnitude(): """Calculates the magnitude of the cross product of two vectors.""" a = get_vector_input("A") b = get_vector_input("B") # First, calculate the cross product components cross_x = (a[1]*b[2]) - (a[2]*b[1]) cross_y = (a[2]*b[0]) - (a[0]*b[2]) cross_z = (a[0]*b[1]) - (a[1]*b[0]) # Then, calculate the magnitude of that resulting vector magnitude = math.sqrt(cross_x**2 + cross_y**2 + cross_z**2) print("\n----- RESULTS -----") print(f"Magnitude |A x B| = {magnitude}") def calc_angle_between(): """Calculates the angle between two vectors.""" a = get_vector_input("A") b = get_vector_input("B") dot_prod = (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) mag_a = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) mag_b = math.sqrt(b[0]**2 + b[1]**2 + b[2]**2) print("\n----- RESULTS -----") if mag_a == 0 or mag_b == 0: print("Cannot calculate angle with a zero vector.") else: # Prevent math domain error from floating point in
[...]
>>