Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4.) 5 points 1. All this function should do is receive a string and return a new

ID: 3591419 • Letter: 4

Question

4.) 5 points 1. All this function should do is receive a string and return a new string consisting of the first character of the input string plus a period For example, if call initial ( . Montclair. ) it should return . M. If I call initial('Computer Science' ) it should return "c 5.) 5 points hon function named squareAndDivide. This function should receive two arguments, both of them floating point numbers (that's a number with a decimal point in it, like 3.14159) The job of your function is to square the first argument and then divide the result by the second argument. The final result of both these operations should be returned by your function For 4 bonus points: add a safeguard to your function. Mathematics do not allow division by ro, so have your function first check whether the second argument is equal to 0.0. If it is, then the f unction should return zero. Otherwise, proceed with the operations described above. 6.) 5 points In Assembly Language, write a short program which stores the value 1 in register A, 2 in register B, 3 in register C, and 4 in register D, and then halts. (Remember, you are encouraged to test and run anything you want to in the Assembly Simulatorl) 7.) 10 points In Assembly Language, write a program which counts from 0 to 15 using register D. (In other words, your program must loop, incrementing the value in D each time, and halt with fifteen in D. That's "15" in decimal, and "OF" in hexadecimal. You must use a loop so that if we change the target value, we can count up to any other number.) For 5 bonus points: write another draft of this same program which counts by twos from 0 to 16

Explanation / Answer

{Ans 4} Following is the python function toreturn initial:

def initial (str):
return (str[0] + '.')

{Ans 5} Following is the python function for square and divide with zero check:

def squareAndDivide (sq,div):
if (int(div) is not 0):
return ((sq * sq) / div)
return 0

{Ans 6} Assembly code to assign registers with the given values

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote