Python and Scheme

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A tuple is great for storing data as you can easily change its values. True or False.

False.

Parentheses are required for an if statement in Python. True or False.

False.

Python does not support Operator Overloading. True or False.

False.

Sequence of values that can be changed.

List

An operator that combines Boolean expressions: and, or, and not.

Logical operator

An operation that is performed on each member of a list, yielding a new list.

Map

An operation performed on each member of a list, yielding a single ourput.

Reduce

Suppose that the first line in a Python program is import Math Which of the below will access the constant that contains the value of pi? a - Math.pi b - pi c - It is not possible to access the value of pi from the module without using from Math import pi.

A

What will the following expression produce? (cons 1 empty) a - list b - number c - string d - pair

A

A path that starts from the topmost directory in the file system.

Absolute path

According to the text, which of the following are the main differences between formal and natural lanuages? a - Ambiguity b - Redundancy c - Literalness

All three.

In the statement below, we are assigning values to ___ of the object time. time. = 5.0 a - subclasses b - attributes c - variables d - constants

B

Which of the below best describes what a lambda expression produces? a - A type of function with no parameters b - An anonymous function c - A way to create objects in Racket d - A placeholder variable

B

a = [1, 2, 3] b = a a[0] = 3 What is b[0]? a - 1 b - 3 c - 5 d - None

B

An expression whose value is either True or False.

Boolean expression

How does Python determine where the block of code controlled by an if statement ends? a - Using curly braces like most languages. b - Using the end command to end the block. c - By examining which lines are indented a level more than the if statement.

C

Suppose that the following line is the first line in a Python program. What does the line do? a = 5 a - declare that a is a float variable that contains 5 b - declare that a is an integer variable that contains 5 c - declare that a is a variable that contains the integer value 5 d - cause a syntax error because a has not been declared yet e - the line is not a valid line of Python code

C

What command can be used inside of a loop in order to close the loop? a - stop b - close c - break d - end

C

What is a Stack Diagram? a - A file that contains a collection of related functions and other definitions. b - The sequence of statements inside a function definition c - A graphical representation of a stack of functions, their variables, and the values they refer to d - A list of the functions that are executing, printed when an exception occurs

C

What is the difference between lists and tuples? a - When creating a list, values are separated by commas, but not in tuple. b - Lists are immutable, and tuples are mutable. c - Lists are mutable, and tuples are immutable. d - List values are indexed, and tuples are not.

C

Controls the flow of execution.

Conditional statement

What is scaffolding? a - The outer function or method around code b - Import statements to help build the code c - Comments made throughout code to help explain functions d - Code used in the program development but not the final version

D

Which of the below accurately describes the Python programming language? a - Designed to compile machine code normally b - Can only be used for small programs c - Requires values to be declared prior to use d - None of the above

D

Which of the following cannot be an argument in a function in Racket? a - Integers b - Objects c - Functions d - None of the above

D

Data structure that can map from a key (of any type) to a value.

Dictionary

Concatenates a new first item to a list

cons

If str = 'abcd', what does str[-1] return?

d

Binds a name to a value with global scope

define

yields the first item from a list

first

What does lambda do? a - Declares a function without binding it to a name b - Binds a variable to a value c - Makes a small bleating sound d - Lambda is not used in Racket e - Lambda is used in Racket but not covered in this class

A

What does the following block of code output? shows = ['Breaking Bad', 'The Office', 'Community', 'Parks and Recreation'] print(shows[3][6:-7]) a - and Rec b - unity c - a d - creation

A

What would the following code print? s = "Banana_stand" print(s[:7]) a - "Banana_" b - "Banana" c - "_stand" d - The code will produce an error

A

Which of the following is a valid function declaration line in Python? a - def foo(n): b - def foo(int n): c - def foo(int n) { d - def foo(int n) e - Python does not allow function to be declared since it only supports methods

A

Which of the following will create a list in Racket? a - (list 1 2 3 4) b - list("red" "blue" "orange") c - new List() {0, 45, 57, 100) d - '(list "apples" "bananas" "pears")

A

An operation performed on each member of a list, yielding a smaller list of items that meet the specified predicate.

Filter

An operator that compares its operands.

Relational operator

A path that starts from the current directory.

Relative path

Classes in Python can have methods. True or False.

True.

When an else clause begins with an if, Python uses the elif keyword. True or False.

True.

Sequence of immutable variables.

Tuple

Which of the following list operations are facilitated by using lambdas? i. concatenate ii. map iii. filter

ii and iii

binds variables to values within a local scope

let

yields a list with the first item removed

rest

Tail Call Optimization allows: i. Certain recursive function to execute in linear space ii. Certain recursive function to execute faster iii. Better optimization of function which call other functions

i or i and ii

The _____ function uses the per-element results to create a new list. a - map b - filter c - foldl d - iterate

A

To prematurely end a while loop, use a ___ statement. a - break b - continue c - done d - end

A

Which of the following are true about indices in Python. a - Any integer expression can be used as an index. b - If you try to read or write an element that does not exist, you get an IndexError. c - If an index has a negative value, it counts backward from the end of the list.

All three

Which of the following is a correct syntax for defining a function named interact which accepts one argument x in Racket? a - def interact(x): <function body> b - (define (interact x) <function body> c - define interact (x) ( <function body> d - (define interact (x) <function body>)

B

A lambda statement produces an a - Objects b - Class c - Function d - Variable

C

How many recursions will Python do before it generates a runtime error? a - 256 b - 2024 c - 1000 d - 50

C

Which of the below is a valid method signature for a method overriding the addition operator? a - def add(self, other): b - funct add(self, other): c - def __add__(other): d - def __add__(self, other):

D

A file whose contents are organized like a dictionary with keys that correspond to a values.

Database

A named collection of files, also called a folder.

Directory

"let" binding clauses can refer to each other: True or False?

False

A list can be used as a key in a dictionary. True or False.

False

Line breaks and indentation are significant when parsing Racket programs: True or False?

False

Recursion leads to poor performance in Racket True or False?

False


Kaugnay na mga set ng pag-aaral

Evolve: Fundamentals Basics of Nursing Practice

View Set

SSD- Morphosyntax intervention approach.

View Set

Investment Management - Final Exam

View Set

PAST SIMPLE VERSUS PRESENT PERFECT AND PRESENT PERFECT CONTINUOS

View Set

Abeka 9th grade Health Chapter 7 Review section review 7.1

View Set

AP World Chapter 32-33 Study Guide

View Set