ME/MSE 241 Engineering Computations Homework Task – 1
Directions:
1) Embrace feedback for each few traces (and even every line) of code as related.
2) Use a constant naming conference.
three) If utilizing Python scripts (.py), create one file for every drawback answer. Identify the recordsdata
four) If utilizing the pocket book format (.ipynb), use a single cell for every drawback answer. Identify the file
5) Don’t hesitate to ask for Help, there are not any trivial questions!
Notice: 1. All the issues will be solved utilizing the ideas we coated within the lectures.
2. Don’t use modules or create capabilities. Simply write plain scripts for this project.
Downside 1 (12 pts)
Write a easy program utilizing string indexing and slicing to change a given string (use the enter
operate). The modified string must be reversed besides the primary and final characters. For instance, if the
enter is “Pullman” the output must be “Pamllun”.
Downside 2 (12 + 12 + 12 pts)
Write a program utilizing a for loop to:
(a) Compute the reverse of a given string by accumulating it in a brand new string object (don’t use slicing
to reverse the string).
(b) Print the film quote under with every phrase reversed and uppercase characters changed by
lowercase characters (assume the punctuation characters are a part of the phrase):
“You see, on this world there’s two varieties of individuals, my good friend: These with loaded weapons and people
who dig. You dig.”
That is the anticipated output: “uoy ,ees ni siht dlrow s’ereht owt sdnik fo ,elpoep ym :dneirf esoht
htiw dedaol cosy dna esoht ohw .gid uoy .gid”
(c) Print the next sample consisting of asterisks separated by areas (you could have further
areas earlier than and after the sample).
Notice: Write a generic program that may be simply prolonged to comparable trying patterns, don’t
specialize for this particular sample. For instance, I ought to be capable to generate a wider sample by
simply altering a single worth in this system. The purpose of a program ought to at all times be automation.
Trace: Variables can be utilized in format specification. Instance:
w = 6
f”1.1545: >.2″
Downside three (12 + 20 + 20 pts)
Once more, use a for loop to do the next (don’t use the built-in operate sum):
(a) Write a brief program to find out the sum of the squares of first pure numbers the place is a consumer enter obtained by the enter operate.
(b) Given a set of temperatures in Fahrenheit as a tuple,
tempDataF = (36, 40, 28, 32, 22, 52, 44, 35, 40, 37)
write a program to transform the models to Celsius and compute the imply worth in Celsius and
Fahrenheit. Current the leads to a tabulated kind as proven under.
(c) Assemble a listing consisting of the primary 50 Fibonacci numbers by an accumulator. The
Fibonacci numbers fulfill these situations:
1 = 1, 2 = 1
+2 = +1 +
Right here, is the th quantity within the sequence.
The ratio of the adjoining Fibonacci numbers converges to the golden ratio, i.e.,
lim →∞
+1
= = 1 + √5
2 ≈ 1.618
Present this by accumulating the ratios into a listing and verifying that the final component is
roughly equal to .