Answer:

Explanation:
Given
On Earth

On the moon

Required
The astronaut's mass on the moon
The mass of an object do not change base on location
So, if the mass of the astronaut is 80kg on earth, it will be 80 kg on the moon.
Hence:

Answer:
Program to Plot the power in Watts
voltage=1:200;
resistance=1000;
current=voltage/resistance;
power=current.*voltage;
plot(voltage,power);
xlabel('Voltage in Volts');
ylabel('Power in Watts'); //plot of this program is attached
Program for power in dBW
voltage=1:200;
resistance=1000;
current=voltage/resistance;
power=current.*voltage;
powerdB=10*log10(power);
plot(voltage,powerdB);
xlabel('Voltage in Volts');
ylabel('Power in dBW'); // plot output is also attached
I hope it will help you!
Answer:
- def average_num_in_file(fileName):
- with open(fileName) as file:
- rows = file.readlines()
-
- sum = 0
- count = 0
- for x in rows:
- sum += float(x)
- count += 1
-
- average = sum / count
- return average
-
- print(average_num_in_file("cans.txt"))
Explanation:
The solution code is written in Python 3.
Firstly create a function that take one parameter, fileName (Line 1).
Open the file stream and use readlines method to read the data from the file (Line 2-3). Create variable sum and count to tract the total of the number from text files and number of data from the file (Line 5-6). Use a for loop to loop over each row of the read data and add the current value of each row to sum and increment the count by one (Line 7-9).
After the loop, calculate the average (Line 11) and return the result (Line 12).
At last, we can test the function by passing the cans.txt as argument (Line 14).