From df21e99c3f273849b0d1cec78d3f4cdf362f9464 Mon Sep 17 00:00:00 2001 From: Advik Sharma <70201060+advik-student-dev@users.noreply.github.com> Date: Wed, 12 Oct 2022 21:14:48 -0700 Subject: [PATCH 1/3] Add files via upload --- physics/Wave Formula Calculations.py | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 physics/Wave Formula Calculations.py diff --git a/physics/Wave Formula Calculations.py b/physics/Wave Formula Calculations.py new file mode 100644 index 000000000000..9ba4c692ccad --- /dev/null +++ b/physics/Wave Formula Calculations.py @@ -0,0 +1,80 @@ +# Wave Formula Calculations + +v = 0 # Wave Speed/Velocity +wavelength = 0 +frequency = 0 + +# Constant +CALC_TO_DO_STATEMENT = """ +Would you like to :- +1. Calculate Speed of a Wave +2. Calculate Wavelength of a Wave +3. Calculate Frequency of a Wave + +Input 1, 2, 3 or three for the respective wave calculation. +> """ + +calc_to_do = input(CALC_TO_DO_STATEMENT) + +while type(calc_to_do) != int: + if calc_to_do == "1" or calc_to_do == "2" or calc_to_do == "3": + calc_to_do = int(calc_to_do) + else: + print("Choice out of scope") + calc_to_do = input(CALC_TO_DO_STATEMENT) + +if calc_to_do == 1: + + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + while wavelength <= 0: + print("Wavelength must be greater than zero.") + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + + frequency = float(input("Enter the frequency of the wave (Hz): ")) + while frequency <= 0: + print("Frequency must be greater than zero.") + frequency = float(input("Enter the Frequency of the wave (Hz): ")) + + # Wave Speed Formula + v = wavelength * frequency + + # To remove pesky decimal point from values like 25.0 + if "." in str(v): + v = int(v) + print("Wave Speed =", str(v) + 'm/s') + +if calc_to_do == 2: + + v = float(input("Enter the speed of the wave (meters/second): ")) + while v <= 0: + print("Speed must be greater than zero.") + v = float(input("Enter the Speed of the wave (meters/second): ")) + + frequency = float(input("Enter the frequency of the wave (Hz): ")) + while frequency <= 0: + print("Frequency must be greater than zero.") + frequency = float(input("Enter the Frequency of the wave (Hz): ")) + + # Wavelength Formula + wavelength = v / frequency + if "." in str(wavelength): + wavelength = int(wavelength) + print("Wavelength =", str(wavelength) + "m") + +if calc_to_do == 3: + + v = float(input("Enter the speed of the wave (meters/second): ")) + while v <= 0: + print("Speed must be greater than zero.") + v = float(input("Enter the Speed of the wave (meters/second): ")) + + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + while wavelength <= 0: + print("Wavelength must be greater than zero.") + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + + # Frequency Formula + frequency = v / wavelength + if "." in str(frequency): + frequency = int(frequency) + print("Frequency =", str(frequency) + "Hz") \ No newline at end of file From 835c0c1e85655f886034e3e3ec34e2c6f19db99e Mon Sep 17 00:00:00 2001 From: Advik Sharma <70201060+advik-student-dev@users.noreply.github.com> Date: Wed, 12 Oct 2022 21:16:45 -0700 Subject: [PATCH 2/3] Delete Wave Formula Calculations.py --- physics/Wave Formula Calculations.py | 80 ---------------------------- 1 file changed, 80 deletions(-) delete mode 100644 physics/Wave Formula Calculations.py diff --git a/physics/Wave Formula Calculations.py b/physics/Wave Formula Calculations.py deleted file mode 100644 index 9ba4c692ccad..000000000000 --- a/physics/Wave Formula Calculations.py +++ /dev/null @@ -1,80 +0,0 @@ -# Wave Formula Calculations - -v = 0 # Wave Speed/Velocity -wavelength = 0 -frequency = 0 - -# Constant -CALC_TO_DO_STATEMENT = """ -Would you like to :- -1. Calculate Speed of a Wave -2. Calculate Wavelength of a Wave -3. Calculate Frequency of a Wave - -Input 1, 2, 3 or three for the respective wave calculation. -> """ - -calc_to_do = input(CALC_TO_DO_STATEMENT) - -while type(calc_to_do) != int: - if calc_to_do == "1" or calc_to_do == "2" or calc_to_do == "3": - calc_to_do = int(calc_to_do) - else: - print("Choice out of scope") - calc_to_do = input(CALC_TO_DO_STATEMENT) - -if calc_to_do == 1: - - wavelength = float(input("Enter the wavelength of the wave (meters): ")) - while wavelength <= 0: - print("Wavelength must be greater than zero.") - wavelength = float(input("Enter the wavelength of the wave (meters): ")) - - frequency = float(input("Enter the frequency of the wave (Hz): ")) - while frequency <= 0: - print("Frequency must be greater than zero.") - frequency = float(input("Enter the Frequency of the wave (Hz): ")) - - # Wave Speed Formula - v = wavelength * frequency - - # To remove pesky decimal point from values like 25.0 - if "." in str(v): - v = int(v) - print("Wave Speed =", str(v) + 'm/s') - -if calc_to_do == 2: - - v = float(input("Enter the speed of the wave (meters/second): ")) - while v <= 0: - print("Speed must be greater than zero.") - v = float(input("Enter the Speed of the wave (meters/second): ")) - - frequency = float(input("Enter the frequency of the wave (Hz): ")) - while frequency <= 0: - print("Frequency must be greater than zero.") - frequency = float(input("Enter the Frequency of the wave (Hz): ")) - - # Wavelength Formula - wavelength = v / frequency - if "." in str(wavelength): - wavelength = int(wavelength) - print("Wavelength =", str(wavelength) + "m") - -if calc_to_do == 3: - - v = float(input("Enter the speed of the wave (meters/second): ")) - while v <= 0: - print("Speed must be greater than zero.") - v = float(input("Enter the Speed of the wave (meters/second): ")) - - wavelength = float(input("Enter the wavelength of the wave (meters): ")) - while wavelength <= 0: - print("Wavelength must be greater than zero.") - wavelength = float(input("Enter the wavelength of the wave (meters): ")) - - # Frequency Formula - frequency = v / wavelength - if "." in str(frequency): - frequency = int(frequency) - print("Frequency =", str(frequency) + "Hz") \ No newline at end of file From fa72219b57f8b10a888e0514318abd54107730f7 Mon Sep 17 00:00:00 2001 From: Advik Sharma <70201060+advik-student-dev@users.noreply.github.com> Date: Wed, 12 Oct 2022 21:24:22 -0700 Subject: [PATCH 3/3] Add files via upload --- physics/wave_formula_calculations.py | 100 +++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 physics/wave_formula_calculations.py diff --git a/physics/wave_formula_calculations.py b/physics/wave_formula_calculations.py new file mode 100644 index 000000000000..fa2b362a984f --- /dev/null +++ b/physics/wave_formula_calculations.py @@ -0,0 +1,100 @@ +# Wave Formula Calculations + +""" +Background: +The Wave Formulas are for calculating the characteristics +of a wave. + +Used for stuff like the:- + +1. Speed of a wave in water +2. Frequency of wave a in air +3. Frequency of an electromagnetic - basically like light - wave + +Note:- Above are just some of the many cases this formula can be applied to. + +This calculator is not really meant for light. +It can be used for it, just know that you will need to input the speed of light +again and again because no constant has been assigned to it. + +Not sure if this can work for really big numbers. +""" + +v = 0 # Wave Speed/Velocity +wavelength = 0 +frequency = 0 + +# Constant +CALC_TO_DO_STATEMENT = """ +Would you like to :- +1. Calculate Speed of a Wave +2. Calculate Wavelength of a Wave +3. Calculate Frequency of a Wave + +Input 1, 2, 3 or three for the respective wave calculation. +> """ + +calc_to_do = input(CALC_TO_DO_STATEMENT) + +while type(calc_to_do) != int: + if calc_to_do == "1" or calc_to_do == "2" or calc_to_do == "3": + calc_to_do = int(calc_to_do) + else: + print("Choice out of scope") + calc_to_do = input(CALC_TO_DO_STATEMENT) + +if calc_to_do == 1: + + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + while wavelength <= 0: + print("Wavelength must be greater than zero.") + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + + frequency = float(input("Enter the frequency of the wave (Hz): ")) + while frequency <= 0: + print("Frequency must be greater than zero.") + frequency = float(input("Enter the Frequency of the wave (Hz): ")) + + # Wave Speed Formula + v = wavelength * frequency + + # To remove pesky decimal point from values like 25.0 + if "." in str(v): + v = int(v) + print("Wave Speed =", str(v) + 'm/s') + +if calc_to_do == 2: + + v = float(input("Enter the speed of the wave (meters/second): ")) + while v <= 0: + print("Speed must be greater than zero.") + v = float(input("Enter the Speed of the wave (meters/second): ")) + + frequency = float(input("Enter the frequency of the wave (Hz): ")) + while frequency <= 0: + print("Frequency must be greater than zero.") + frequency = float(input("Enter the Frequency of the wave (Hz): ")) + + # Wavelength Formula + wavelength = v / frequency + if "." in str(wavelength): + wavelength = int(wavelength) + print("Wavelength =", str(wavelength) + "m") + +if calc_to_do == 3: + + v = float(input("Enter the speed of the wave (meters/second): ")) + while v <= 0: + print("Speed must be greater than zero.") + v = float(input("Enter the Speed of the wave (meters/second): ")) + + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + while wavelength <= 0: + print("Wavelength must be greater than zero.") + wavelength = float(input("Enter the wavelength of the wave (meters): ")) + + # Frequency Formula + frequency = v / wavelength + if "." in str(frequency): + frequency = int(frequency) + print("Frequency =", str(frequency) + "Hz") \ No newline at end of file