Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 16 Select all of the following statements that are true. Question 16 options: A) Type checking determines whether and when types are verified. Static

Question 16

Select all of the following statements that are true.

Question 16 options:

A)

Type checking determines whether and when types are verified. Static checking means that type errors are reported based on a program's text (source code). Dynamic checking means that type errors are reported based on a program's dynamic (run-time) behavior.

B)

Some programming languages do not have static type-checking. In many such languages, it is easy to write programs which would be rejected by most static type-checkers. For example, a variable might store either a number or the Boolean value "false". Some programmers refer to these languages as "weakly typed", since they do not seem to enforce the "strong" type discipline found in a language with a static type-checker.

C)

If simple operations do not behave in a way that one would expect, a programming language can be said to be "weakly typed". For example, consider the following program:

x = "5" + 6

Different languages will assign a different value to x:

One language might convert 6 to a string, and concatenate the two arguments to produce the string "56" (e.g. JavaScript)

Another language might convert "5" to a number, and add the two arguments to produce the number 11 (e.g. Perl, PHP)

Yet another language might represent the string "5" as a pointer to the first character of the string within memory, and add 6 to that pointer to produce another address (e.g. C)

And yet another language might simply fail to compile this program or report run-time errors saying that the two operands have incompatible type (e.g. Ruby, Python, BASIC)

D)

A "strong type system" is described as one in which there is no possibility of an unchecked run-time type error. In other words, the absence of unchecked run-time errors is referred to as safety or type safety

Question 17

Select all of the following statements that are true.

Question 17 options:

A)

The Python statement x = 1 will act like Scheme's (define x 1) if there is no storage location already named x.

B)

Every algorithm or problem solution we could describe using Python can also be described in Scheme.

C)

Scheme is designed primarily for a functional programming style. This means most of a Scheme program is applying and defining functions. Python is designed primarily for an imperative programming style.

D)

Multiple consecutive whitespace characters (such as spaces, tabs, and new lines) outside literal quotations have meaning in Scheme programs.

Save

Question 18

Select all of the following statements that are true.

Question 18 options:

A)

The Scheme statement,

(lambda (a b) (+ a b))

is equivalent to the Python statement,

lambda a, b: a + b

B)

Like Scheme, Python has latent (invisible) types that are checked dynamically.

C)

The Scheme statements,

(define lst (list 10 20 30)) (car (cdr (cdr lst)))

are equivalent to the Python statements,

lst = [10, 20, 30] print lst[2]

D)

The Scheme statement,

(define square (lambda (x) (* x x)))

is equivalent to the Python statement,

def square (x): return x * x

Question 19

Select all of the following statements that are true.

Question 19 options:

A)

The Scheme constructor, cons, is used when you already have a list and you want to add one new element. Cons takes two arguments, an element and a list (in that order), and returns a new list whose car is the first argument and whose cdr is the second.

B)

In Python, a dictionary is a collection of (key, value) pairs. The key can be any "immutable" object (e.g. tuples, strings, numbers), and the value can be any Python object.

C)

The Scheme statement,

(map (lambda (x)(* (car x) (length x))) '((9) (8) (7 6)))

evaluates to the list,

'(81 64 49 36)

D)

The following Racket function, func, uses similar logic to the Scheme standard map function when map is used with only one list argument. The type of the parameter f can be any valid Scheme function that accepts exactly one argument.

(define (func f lst)

(cond

[(empty? lst) empty]

[else (cons (f (first lst)) (func f (rest lst)))]

)

)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago