Explore the dependence of the period of a pendulum's motion as a function of its initial amplitude. Complete tasks inside the TODO #
import numpy as np
from scipy import interpolate
from scipy import integrate
import matplotlib.pyplot as plt
class pendulum:
''' defines a simple pendulum '''
def __init__(self, pendulum_length, mass):
# TODO: Assignment Task 1: write method body
# End of Task 1; proceed to task 2.
def set_g(self, g):
''' small g to be used in calculations '''
self._g = g
def dydt(self, y, t):
""" Calculate the derivatives for a pendulum
Parameters
----------
y: array-like
vector of unknowns for the ode equation at time t
t: float
time t
Returns
-------
ret: numpy array of float
the derivatives of y
"""
# TODO: Assignment Task 2: write method body
# End of Task 2; proceed to task 3.
def period(self, maximum_amplitude):
''' Calculate the period of the periodic motion.
For amplitude=0 the small amplitude analytical solution is returned.
Otherwise the period is calculated by integrating the ODE using
scipy.integrate.odeint() and determining the time between release at
maximum amplitude and the first angle=0 crossing. The exact zero
crossing is determined using scipy.interpolate.interp1d().
In the calculation it is assumed that the period has a value between
90% and 150% of the small amplitude period.
Parameters
----------
maximum_amplitude: float
maximum amplitude of the periodic motion
Returns
-------
p: float
the period
'''
# TODO: Assignment Task 3: write method body
# End of Task 3; no further tasks.
if __name__ == '__main__':
#some test code
pen = pendulum(1, 1)
pen.set_g(9.81)
#generate data for figure
angles = np.linspace(0, np.pi/2, 31)
period_ode = [pen.period(a) for a in angles]
# generate a plot
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(angles, period_ode, 'b', label='generated using ode')
ax.set_title('Period of a 1m Pendulum as a Function of Amplitude')
ax.set_xlabel('amplitude/rad')
ax.set_ylabel('period/s')
ax.legend(loc='upper left')
plt.show()
After your program has prompted the user for how many values should be in the array, generated those values, and printed the whole list, create and call a new function named sumArray. In this method, accept the array as the parameter. Inside, you should sum together all values and then return that value back to the original method call. Finally, print that sum of values.
How many values to add to the array:
8
[17, 99, 54, 88, 55, 47, 11, 97]
Total 468Computer Science
Write a program to control a set of 10 motors; the motors are operating under load balancing mechanism as
follows:
• Motors operate in pairs as follows: 1,10 then 2, 9 then 3,8 then 4,7 then 5,6 then repeat.
• The operating duration for each pair is 10,000 milliseconds.
• After each operating cycle, all motors must be OFF for 10,000 milliseconds then a new cycle starts.
• The operating sequence is running 24/7.
The company XYZ is offering painting services.
The cost for painting each window is 200 Rs.
The cost for painting each door is 500 Rs.
The company charges 33 Rs per square feet.
Additional service charges are 500 Rs per room.
To calculate the square feet of a room that is rectangular or square,
simply multiply the length of the room by the width.
Write a C program to calculate the painting cost of your room.
Requirements:
1. Capture length and width of the room.
2. Capture number of windows in room from user
3. Capture number of doors in room from user
4. Compute area of room in square feet.
5. Display area of room(sqft).
5. Compute painting cost with suitable expression.
6. Display painting cost.
Square at Alternate Indices
Given an array
Sample Input 1
[ 1, 2, 3, 4, 5 ]
Sample Output 1
[ 1, 2, 9, 4, 25 ]
Sample Input 2
[ 2, 4 ]
Sample Output 2
[ 4, 4 ]
Task Description
You are to present your findings in the form of a problem based report. This report should describe how you implemented the program (source code and screen shots).
Assignment Task
hour (also 60).
this number agree with the floating-point value from the previous question, aside from the final .0?
Objects with given Fruit
Given an array of objects
The input will be a single line containing a string
The output should be the array of objects matching the given
fruit
Sample Input 1
apple
Sample Output 1
[
{ fruit: 'apple', vegetable: 'broccoli' },
{ fruit: 'apple', vegetable: 'cauliflower' }
]
Sample Input 2
orange
Sample Output 2
[ { fruit: 'orange', vegetable: 'mushrooms' } ]
i want code in between write your code here
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
function main() {
const fruit = readLine();
const objectEntities = [
{
fruit: "apple",
vegetable: "broccoli"
},
{
fruit: "kiwi",
vegetable: "broccoli"
},
{
fruit: "apple",
vegetable: "cauliflower"
},
{
fruit: "orange",
vegetable: "mushrooms"
},
];
/* Write your code here */
}
Unite Family
Given three objects
Sample Input
{'surname' : 'Jones', 'city': 'Los Angeles'}
{'dish': 'puddings'}
{'pet': 'Peter'}
Sample Output
Mr and Mrs Jones went to a picnic in Los Angeles with a boy and a pet Peter. Mrs Jones made a special dish "puddings"
i want code in between write your code here
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
function main() {
const father = JSON.parse(readLine().replace(/'/g, '"'));
const mother = JSON.parse(readLine().replace(/'/g, '"'));
const child = JSON.parse(readLine().replace(/'/g, '"'));
/* Write your code here */
/* Please do not modify anything below this line */
console.log(`Mr and Mrs ${family.surname} went to a picnic in ${family.city} with a boy and a pet ${family.pet}. Mrs ${family.surname} made a special dish "${family.dish}"`);
}
Update Pickup Point
Given a previous pickup point in the prefilled code, and updated pickup point
Sample Input 1
Kukatpally
Hyderabad
Sample Output 1
Kukatpally Hyderabad
Sample Input 2
Jubilee Hills
Hyderabad
Sample Output 2
Jubilee Hills Hyderabad
i want code in between write code here
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
function createCabBooking(area, city) {
/* Write your code here */
}
/* Please do not modify anything below this line */
function main() {
const newArea = readLine();
const newCity = readLine();
const cabBooking1 = createCabBooking("Abids", "Hyderabad");
cabBooking1.updatePickupPoint(newArea, newCity);
console.log(`${cabBooking1.area} ${cabBooking1.city}`);
}
Hotel Bill
A Hotel is offering discounts to its customers.
Given charge per day
dayCharge based on category and numbers of days customer stayed days as inputs, write a JS arrow function to return the total bill with the discount.
Quick Tip
Apply discounts on the following basis,
Sample Input 1
200
3
Sample Output 1
570
Sample Input 2
180
1
Sample Output 2
180
i want the code in between write code here
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
function main() {
const dayCharge = JSON.parse(readLine());
const days = parseInt(readLine());
/* Write your code here */
}