Python代写 | assignment – CS3342 assignment3

CS3342 assignment3

Python代写 | assignment – 该题目是一个常规的Python的练习题目代写, 是有一定代表意义的Python等代写方向, 该题目是值得借鉴的assignment代写的题目

ass代做 assignment代写 代写assignment

CS3342   assignment 3
(SRAs cannot be used to extend the due date further)
  1. (25pt) Consider the following program:
int a;
s(n) { a = n; }
p() { print a; }
f() { s(1); p(); }
g() { int a; s(2); p(); }
s(0); f(); p(); g(); p();
(a) (10pt) Give the output of the program if static scoping is used
(b) (15pt) Give the output of the program if dynamic scoping is used.
Run the program step by step to explain the output.
  1. (25pt) Consider the Python program:
def A(I, P):
def B():
print(I)
if I > 3:
P()
elif I > 2:
A(4, P)
elif I > 1:
A(3, B)
else:
A(2, B)
def C():
print(0)
A(1, C)
What does this program print? Explain your answer. Draw the run-time stack. You can use in
Pythonprint(P)andprint(B)from withinAto identify the procedures uniquely.
  1. (25pt) We have modelled the non-negative integers and operations with-expressions:
nfc.f(f ...(f(f
  
nfs
c))...)
+mnab.ma(nab)
mna.m(na)
Prove, using both call-by-value and call-by-name reduction, that:
(a) (10pt) 1 + 3 = 4
(b) (15pt) 02 = 0

1

  1. (25pt) We modelled also boolean logic:Txy.x,Fxy.y. We define a new operator,xor, that computes the exclusive or of two boolean values, as follows:
xorxy.x(yF T)y
Prove, using both call-by-value and call-by-name reduction, that:
xor T T=F
Q3,4 note: For all computations you perform, indicate clearly the reduction being being done by underlying
the abstraction used and the argument it is applied to: (x.M)N. Do not use anything already
computed in the notes; compute everything from scratch.

READ ME!Submit your answers as asingle pdf filein OWL. Solutions should be typed but readable (by others!) hand-written solutions are acceptable. Source code, if required, is submitted as separate files.

LATEX:For those interested, the best program for scientific writing is LATEX. It is far superior to
all the other programs, it is free, and you can start using it in minutes; here is an introduction:
https://tobi.oetiker.ch/lshort/lshort.pdf

2