Computer Technology and Society

advertisement
08.71.16
Computer Technology and Society
Assignment 9
Bing Xi
270378-2349
1. Chapter 6, page 320, 1. What does it mean to say that a programming
language is a machine independent?
It means that the language does not refer to the attributes of any particular
machine, and it can be used on any machine by simply applying a appropriate
compiler.
2. Chapter 6 on page 320, 7. Suppose the function f expects two numeric values as its inputs
and returns the smaller of the two values as its output value. If w, x, y, and z represent
numeric values, what is the result returned by f(f(w,x), f(y,z)?
It returns the smallest value of w, x, y, and z.
3. Draw the parse tree for the expression x - y * z + y * x based on the syntax
diagrams in Figure 6.16 on page 299.
4. Download Python 2.5 and read the introduction to the IDLE programming
environment that comes with Python 2.5.
1) Enter the following Python program (note that spaces at the beginning of
the line make a difference in Python):
temp = input("What is the temperature?")
if temp < 5:
1
08.71.16
Computer Technology and Society
print "It is rather cold."
Bing Xi
270378-2349
else:
print "This is fine."
I entered the code in a new IDLE window and saved it, then I clicked “Run” =>
“Run Module”. In the main IDLE window a line of text “What is the
temperature?” popped out, I input 5 and entered, another line popped up – “This is
fine.”. I ran the module again but this time I input “3” and I got a response – “It is
rather cold.”.
2) Change the program such that it checks if the temperature is higher than 30
and if so then prints out appropriate message.
temp = input("What is the temperature? ")
if temp < 5:
print "It is rather cold."
elif temp > 30:
print "It is ridiculously hot."
else:
print "This is fine."
5. Chapter 6, 325, social issue 4. To what extent is a programmer who helps
develop a violent computer game responsible for any consequences of that
game? Should children’s access to computer games be restricted? If so, how
and by whom? What about other groups in society, such as convicted
criminals?
A programmer bears responsibilities for the consequences of the game if it is
violent. Although a programmer is not necessarily a designer; however, he can
always reduce the harm (directly mental. indirectly physical, since the player
might do in real life what he does in the game) that can be caused by the game
during the implementation. Nevertheless, not to a great extend, since the
programmer is simply the implementer, not the designer, who is much more
responsible for the consequences.
Children’s access to benign computer games is reasonable, but their access to
malign or violent games should be strictly restricted. Because children tend to
2
08.71.16
Bing Xi
Computer Technology and Society
270378-2349
learn what they see around them, they might very much try to do the things
they do in the games. The restrictions should not only come from schools,
parents, but also from the government or the legislature. Only by establishing
rules or even laws the restrictions can truly be regarded.
Whether criminals’ access to violent games should also be restricted is hard to
determine. On the one hand, allowing them to have access to violent game
might give them a platform as an outlet of their criminal desires. On the other
hand, those game might also bring them more desires of committing more
crimes in real life.
3
Download