phys_calculations
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.11 Ko KB
Mis en ligne Uploaded: 18/09/2025 - 20:18:53
Uploadeur Uploader: kboiiii (Profil)
Téléchargements Downloads: 1
Visibilité Visibility: Archive publique
Shortlink : https://tipla.net/a4848188
Type : Classeur 3.0.1
Page(s) : 1
Taille Size: 5.11 Ko KB
Mis en ligne Uploaded: 18/09/2025 - 20:18:53
Uploadeur Uploader: kboiiii (Profil)
Téléchargements Downloads: 1
Visibilité Visibility: Archive publique
Shortlink : https://tipla.net/a4848188
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) # Version 2.1: Replaced docstrings with standard comments for maximum compatibility. import math # --- Helper Functions --- def get_vector_input(vector_name): # Prompts user for a 3D vector and handles errors. print("\n--- Enter components for Vector {} ---".format(vector_name)) while True: try: x = float(input("Enter {}x: ".format(vector_name))) y = float(input("Enter {}y: ".format(vector_name))) z = float(input("Enter {}z: ".format(vector_name))) 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("Area = {}".format(area)) print("Perimeter = {}".format(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("Volume = {}".format(volume)) print("Surface Area = {}".format(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("Volume = {}".format(volume)) print("Surface Area = {}".format(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("Magnitude |A| = {}".format(mag)) if mag != 0: unit_vector = [a[0]/mag, a[1]/mag, a[2]/mag] print("Unit Vector  = <{:.4f}, {:.4f}, {:.4f}>".format(unit_vector[0], unit_vector[1], unit_vector[2])) 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("Dot Product A · B = {}".format(dot_prod)) def calc_cross_product(): # Calculates the cross product of two vectors. a = get_vector_input("A") b = get_vector_input("B") 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("Cross Product A x B = <{}, {}, {}>".format(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") 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]) magnitude = math.sqrt(cross_x**2 + cross_y**2 + cross_z**2) print("\n----- RESULTS -----") print("Magnitude |A x B| = {}".format(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: cos_theta = dot_prod / (mag_a * mag_b) if cos_theta
[...]
>>
Compatible OS 3.0 et ultérieurs.
<<
# TI-Nspire CX II Python App # Physics Vector & Math Calculator # For Takeshi @ Iowa State (PHYS 2310/2310H) # Version 2.1: Replaced docstrings with standard comments for maximum compatibility. import math # --- Helper Functions --- def get_vector_input(vector_name): # Prompts user for a 3D vector and handles errors. print("\n--- Enter components for Vector {} ---".format(vector_name)) while True: try: x = float(input("Enter {}x: ".format(vector_name))) y = float(input("Enter {}y: ".format(vector_name))) z = float(input("Enter {}z: ".format(vector_name))) 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("Area = {}".format(area)) print("Perimeter = {}".format(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("Volume = {}".format(volume)) print("Surface Area = {}".format(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("Volume = {}".format(volume)) print("Surface Area = {}".format(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("Magnitude |A| = {}".format(mag)) if mag != 0: unit_vector = [a[0]/mag, a[1]/mag, a[2]/mag] print("Unit Vector  = <{:.4f}, {:.4f}, {:.4f}>".format(unit_vector[0], unit_vector[1], unit_vector[2])) 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("Dot Product A · B = {}".format(dot_prod)) def calc_cross_product(): # Calculates the cross product of two vectors. a = get_vector_input("A") b = get_vector_input("B") 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("Cross Product A x B = <{}, {}, {}>".format(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") 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]) magnitude = math.sqrt(cross_x**2 + cross_y**2 + cross_z**2) print("\n----- RESULTS -----") print("Magnitude |A x B| = {}".format(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: cos_theta = dot_prod / (mag_a * mag_b) if cos_theta
[...]
>>