Question

In: Computer Science

I'm looking for a program, written in vPython, that simulates the movement of a spherical mass,...

I'm looking for a program, written in vPython, that simulates the movement of a spherical mass, suspended from a ceiling, tied to a spring. We are supposed to take the gravitaional force into account but are allowed to ignore the effects of air-resistance (for now).

I am a newbie at vPython so comments within the program to explain what certain parts of the code do would be appreciated!

Solutions

Expert Solution

'''
The motion of a spherical mass will be simple harmonic, given it is suspended from the ceiling via. spring. Now if an external force, 'F', is exerted on the system the mass starts moving up-down in a Simple Harmonic Motion.
Let,
the spring constant be 'k'
the mass be 'm'
Now,
F = kx
So, the Time-period, 'T', of the simple harmonic motion is given by,
T = 2*(pie)*(m/k)1/2,
here,
'pie' is 3.14

For simplicity, we have taken all the units w.r.t. S.I. units.
At first we have to take inputs from the user of the unknown parameters:-
'''

#First take input of the value of 'm' and 'k'
m = float(input("Enter the value of the Spherical-mass in kg : "))
k = float(input("Enter the value of the spring-constant in N/m : "))

#Store the value of pie=22/7 in a variable 'pie'
pie = 22/7

#Now, compute the time-periord 'T' of the S.H.M.
T = 2 * pie * ((m/k)**(0.5)) #Here, ** symbolizes to the power in python

print('The given motion is a Simple Harmonic Motion with Time-Periord : ',T)

Fair Copy:-

Python, Source Code without any explanations...

m = float(input("Enter the value of the Spherical-mass in kg : "))
k = float(input("Enter the value of the spring-constant in N/m : "))

pie = 22/7

T = 2 * pie * ((m/k)**(0.5)) #Here, ** symbolizes to the power in python

print('The given motion is a Simple Harmonic Motion with Time-Periord : ',T)


Related Solutions

I'm trying to write a feet to meters and centimeters program and I'm looking for a...
I'm trying to write a feet to meters and centimeters program and I'm looking for a little help so I can see how close I got. It should do the following: Write a convertToMetric class that has the following field: standard - holds a double, standard length value in feet. The class should have the following methods: Constructor - that accepts a length in feet (as a double) and stores it in the standard field. setStandard - accepts a standard...
I'm currently looking at this figure, but I'm not sure how to interpret it. If I'm...
I'm currently looking at this figure, but I'm not sure how to interpret it. If I'm not mistaken, the energy loss of the muon (This is a muon that penetrates copper) is on the y-axis. But does that just mean, that if my muon has energy of around 0.5 GeV, then it has a stopping power around 2 MeV cm2/g (Minimum ionization), which means it loses that amount of energy pr. cm2/g? To me that just seems a bit "linear"....
This is just a very basic program/problem in Java I'm looking for some second opinions on....
This is just a very basic program/problem in Java I'm looking for some second opinions on. 1. Ask the user for a year input (positive integer - should be between 1500 and 2019, inclusive). 2. If the year input is not between 1500 and 2019, do not check for leap year, rather print that this year cannot be checked. 3. Take a year input from the user (should be between 1500 and 2019) 4. If the input year is a...
In C++  Write a program that simulates coin tossing. For each toss of the coin the program...
In C++  Write a program that simulates coin tossing. For each toss of the coin the program should print heads or tails. Let the program toss the coin 100 times and count the number times each side of the coin appears. Print the results. 0 represents tails and 1 for heads.
Java - Create a program that simulates a slot machine. When the program runs, it should...
Java - Create a program that simulates a slot machine. When the program runs, it should do the following: - Ask the user to enter the amount of money he or she wants to enter into the slot machine. - Instead of displaying images, have the program randomly select a word from the following list: Cherries, Oranges, Plums, Bells, Melons, Bars (To select a word, the program can generate a random number in the range of 0 through 5. If...
Roll dice java program The program simulates a dice roll by generating a random integer between...
Roll dice java program The program simulates a dice roll by generating a random integer between 1 and 6
Write a Java program 1-)write a program that simulates a vending machine, takes input from the...
Write a Java program 1-)write a program that simulates a vending machine, takes input from the user (money), and returns the change to the user. The change means Quarter =   25 cent Dime = 10 cent Nickels = 5 cent Pinneies = 1 cent 2-) What is the output produced by the following code? int result = 11; result /= 2; System.out.println("resu lt is " + result);
This program is in Python ### simulates packets of data arriving at irregular times. The data...
This program is in Python ### simulates packets of data arriving at irregular times. The data gets ### read from the file and then you must place it in a queue where it will wait ### its turn to get processed. The "processing" happens in a threaded subroutine ### called "process_input_data". That function should pull data from the queue, ### hash the student ID number, and then store the data in a hash table which ### you have to implement....
Write a java program that simulates thousands of games and then calculate the probabilities from the...
Write a java program that simulates thousands of games and then calculate the probabilities from the simulation results. Specifically in the game, throw two dice, the possible summations of the results are: 2, 3, ..., 12. You need to use arrays to count the occurrence and store the probabilities of all possible summations. Try to simulate rolling two dice 100, 1000, 10,0000 times, or more if needed. Choose one simulation number so that the probabilities you calculated is within 1%...
3. Write a program that simulates a vending machine.   The user will be prompted to enter...
3. Write a program that simulates a vending machine.   The user will be prompted to enter a number then a letter. As part of the prompt you must display a message to indicate the number and letter, along with the possible choices. That is, what selections will give user which item.   If the user enters a number or a letter that is not valid, then display the message “Bad Entry” and end the program. (100 pts) Selections with messages. 1a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT