Compu Tech Final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Left-side binding determines that the result of the following expression: 1 // 2 * 3 is equal to: - 0.0 - 4.5 - 0.16666666666666666666 - 0

0

What is the output of the following snippet? a=1 b=0 c=a&b d=a | b e=a^b print(c + d + e) - 2 - 1 - 3 - 0

2

Exercise What is the output? var = 2 var = 3 print(var)

3

What value will be assigned to x? z = 10 y = 0 x = z > y or z == y - False - True - 1

True

The escape character owes its name to the fact that it: - changes the meaning of the character next to it - escapes from source files into the computer memory - cannot be caught due to its high speed

escapes from source files into the computer memory

What is the output? y = 2 + 3 * 5. print(y) - 17 - 17.0 - 25. - execution error

execution error (period after 5)

Right-side binding means that the following expression: 1 ** 2 ** 3 will be evaluated: - in random order - from right to left - from left to right

from right to left

What is the best definition of a script? - it's a text file that contains instructions which make up a python program - it's an error message generated by the interpreter - it's an error message generated by the compiler - it's a text file that contains sequences of zeros and ones

it's a text file that contains instructions which make up a python program

What is the output of the following code? import sympy x, y = sympy.symbols('x y') equation = sympy.Eq(x + y, 0) solution = sympy.solve(equation) print(solution) - {x: -y} - -y - {x:0, y:0} - an error message

{x: -y}

The None keyword designates: - an empty instruction - a None value - a function which doesn't return a value

a None value

The result of the following addition: 123 + 0.0 - cannot be evaluated - is equal to 123 - is equal to 123.0

is equal to 123.0

An operator able to check whether two values are not equal is coded as: - != - <> - not ==

!=

Which of the following variable names are illegal? (pick 2) - true - True - TRUE - and

- and - True

A keyword is a word that: (pick 2) - is the most important word in the whole program - cannot be used as a function name - cannot be used as a variable name

- cannot be used as a function name - cannot be used as a variable name

The \n digraph forced the print() function to: - stop its execution - duplicate the character next to the digraph - break the output line - output exactly two characters: \ and n

break the output line

A function definition starts with the keyword: - def - fun - function - define

def

A function definition starts with the keyword: - fun - def - function

def

The second assignment: vals = [0, 1, 2] vals[0], vals[1] = vals[1], vals[2] - shortens the list - extends the list - doesn't change the list's length

doesn't change the list's length

The result of the 1/1: - cannot be evaluated - cannot be predicted - equal to 1.0 - equal to 1

equal to 1.0

What is the expected behavior of the following program? prin("goodbye!") - output goodbye! - output ("goodbye!") - output "goodbye!" - error

error

The 0o prefix means that the number after it is denoted as: - decimal - octal - hexadecimal - binary

octal

Select 2 true statements about compilation: - it tends to be faster than interpretation - it tends to be slower than interpretation - the code is converted directly into machine code executable by the processor - both you and the end user must have the complier to run your code

- it tends to be faster than interpretation - the code is converted directly into machine code executable by the processor

Select 2 true statements: - python is a good choice for low-level programming ex: when you want to implement an effective driver - python is a good choice for creating and executing tests for applications - python 3 is backwards compatible with python 2 - python is free, open-source, and multiplatform

- python is a good choice for low-level programming ex: when you want to implement an effective driver - python is free, open-source, and multiplatform

Which two following statements are true? - the results of the / operator is always an integer value - addition precedes multiplication - the ** operator uses right-side binding - the right argument of the % operator cannot be zero

- the ** operator uses right-side binding - the right argument of the % operator cannot be zero

Which 2 of the following statements are true? - the return keyword may cause the function to return a value - the return keyword forces the function to restart its execution - the return keyword forces the function's execution to terminate

- the return keyword may cause the function to return a value - the return keyword forces the function's execution to terminate

Exercise What is the output? print((-2 / 4), (2 / 4), (2 // 4), (-2 // 4))

-0.5 0.5 0 -1

Exercise What is the output? print((2 % -4), (2 % 4), (2 ** 3 ** 2))

-2 2 512

What is the output of the following snippet? my_list = [0, 1, 2, 3] x=1 for elem in my_list: x *= elem print(x) - 0 - 1 - 6 - an error message

0

What is the output? my_list = [0, 1, 2, 3] x = 1 for elem in my_list: x *= elem print(x) - 1 - 6 - 0

0

What is the output of the following snippet if the user enters 11 and 4 respectively? x = int(input()) y = int(input()) x = x % y x = x % y y = y % x print(y) - 1 - 3 - 4 - 2

1

What is the output of the following snippet? z=y=z=1 print(x,y,z,sep='*') - 1*1*1 - 1,1,1 - 1 1 1 - x,y,z,*

1*1*1

What is the output? z = y = x =1 print(x, y, z, sep='*') - 1*1*1 - 1 1 1 - x y z - x*y*z

1*1*1

Exercise What is the output? a = '1' b = "1" print(a + b)

11

What is the output of the following snippet? def fun(x,y,z): return x+2*y+3*z print(fun(0,1,3)) print(fun(0,z=1,y=3)) - 11 and 9 - 11 and 11 - 9 and 9 - an error message

11 and 9

Exercise What is the decimal value of the following binary number? 1011

11, because (2**0) + (2**1) + (2**3) = 11

Exercise What is the output? print((2 ** 4), (2 * 4.), (2 * 4))

16 8.0 8

What is the output? x = 1 / 2 + 3 // 3 + 4 ** 2 print(x) - 8 - 17 - 8.5 - 17.5

17.5

What is the output of the following snippet? x=1 y=2 z=x x=y y=z print(x,y) - 2 1 - 1 2 - 1 1 - 2 2

2 1

What is the output? x = 1 y = 2 z = x x = y y = z print(x, y) - 2 1 - 2 2 - 1 1 - 1 2

2 1

The value twenty point twelve times ten raised to the power of eight should be written as: - 20.12E8.0 - 20.12E8 - 20.12*10^8 - 20E12.8

20.12E8

What is the output of the following snippet if the user enters 2 and 4 respectively? x = (input()) y = (input()) print(x + y) - 24 - 6 - 4 - 2

24

What is the output of the following snippet if the user enters 3 and 6 respectively? x = input()) y = int(input()) print(x * y) - 36 - 333333 - 666 - 18

333333

What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively? x=input() y=int(input()) print(x*y) - 333333 - 666 - 18 - an error message

333333

How many hashes (#) will the following snippet send to the console? var = 1 while var < 10: print("#") var = var << 1 - 4 - 2 - 8 - 1 - 10

4

What is the output of the following snippet? def fun(x): global y y=x*x return y fun(2) print(y) - 4 - none - an error message

4

What is the output of the following snippet? def fun(x): x += 1 return x x=2 x = fun(x + 1) print(x) - 4 - 3 - 2

4

What is the output of the following program if the user enters kangaroo at the first prompt and 0 at the second prompt? try: first_prompt = input("Enter the first value: ") a = len(first_prompt) second_prompt = input("Enter the second value: ") b = len(second_prompt) * 2 print(a/b) except ZeroDivisionError: print("Do not divide by zero!") except ValueError: print("Wrong value.") except: print("Error.Error.Error.") - 4.0 - 4 - 0.0 - 0 - an error message

4.0

Exercise What is the output? x = int(input("Enter a number: ")) # The user enters 2 print(x * "5")

55

What is the output of the following snippet if the user enters 2 and 4 respectively? x = int(input()) y = int(input()) print(x + y) - 6 - 2 - 24 - 4

6

What is the output of the following snippet? t = [[3-i for i in range (3)] for j in range (3)] s=0 for i in range(3): s += t[i][i] print(s) - 6 - 4 - 7 - an error message

6

What is the output of the following snippet if the user enters 2 and 4 respectively? x = int(input()) y = int(input()) x = x / y y = y / x print(y) - 2.0 - 4.0 - 8.0 - runtime error

8.0

Boolean operands (and, or, not) and: conjunction 2 true=both true, 1 false=both false, 2 false=both false or: disjunction 2 true=both true, 1 false=both true, 2 false=both false not: negation true=false, false=true Bitwise operands (& | ^) & - bitwise conjunction (and) | - bitwise disjunction (or) ~ bitwise negation (not) ^ bitwise exclusive (xor)

A=0 B=0 A&B=0 A|B=0 A^B=0 A=0 B=1 A=1 B=0 A&B=0 A|B=1 A^B=1 A=1 B=1 A&B=1 A|B=1 A^B=0

Exercise What's the output? x = 5 y = 10 z = 8 print(x > y) print(y > z)

False True

Exercise What's the output? x, y, z = 5, 10, 8 print(x > z) print((y - 5) == x)

False True

How did Python, the programming language, get its name? - Guido van Rossum named it to honor Monty Python's Flying Circus, a BBC comedy series popular in the 1970s - Guido van Rossum named it after the Pythonidae - a family of large, nonvenomous snakes - Guido van Rossum named it to honor Python of Catana, a dramatic poet of the time of Alexander the Great

Guido van Rossum named it to honor Monty Python's Flying Circus, a BBC comedy series popular in the 1970s

What Python version is covered in this course? - Python 1 - Python 2 - Python 3

Python 3

What is the output? my_list = [3, 1, -1] my_list[-1] = my_list[-1] print(my_list) - [3, 1, 1] - [3, -1, 1] - [1, 1, -1]

[3, 1, 1]

What do you call a command-line interpreter which lets you interact with your OS and execute Python commands and scripts? - a complier - a console - Jython - an editor

a console

What do you call a tool that lets you launch your code step-by-step and inspect it at each moment of execution? - a debugger - an editor - a console

a debugger

The 0x prefix means that the number after it is denoted as: - an octal - a decimal - a hexadecimal

a hexadecimal

Python is an example of: - a machine language - a high-level programming language - a natural language

a high-level programming language

What is machine code? - a low-level programming language consisting of binary digits/bits that the computer reads and understands - a high-level programming language consisting of instruction lists that humans can read and understand - a low-level programming language consisting of hexadecimal digits that make up high-level language instructions - a medium-level programming language consisting of the assembly code designed for the computer processor

a low-level programming language consisting of binary digits/bits that the computer reads and understands

What is a source code? - a program written in a high-level programming language - another name for a source file - machine code executed by computers

a program written in a high-level programming language

What do you call a file containing a program written in a high-level programming language? - a code file - a source file - a machine file - a target file

a source file

A value returned by the input() function is: - an integer - a string - a float

a string

What is IDLE? - an acronym that stands for Interactive Development and Learning Extension - an acronym that stands for Integrated Development and Learning Environment for Python - a version of Python

an acronym that stands for Integrated Development and Learning Environment for Python

What is IDLE? - an acronym that stands for Python's Integrated Development and Learning Environment - an acronym that stands for Python's Integrated Development and Learning Extension - an acronym that stands for Python's Interactive Development and Learning Extension - none of the above

an acronym that stands for Python's Integrated Development and Learning Environment

What are the four fundamental elements that make a language => - an alphabet, a lexis, a syntax, and semantics - an alphabet, morphology, phonetics, and semantics - an alphabet, a lexis, phonetics, and semantics - an alphabet, phonetics, phonology, and semantics

an alphabet, a lexis, a syntax, and semantics

What are the four fundamental elements that make a language? - an alphabet, a lexis, a syntax, and semantics - an alphabet, a lexis, phonetics, and semantics - an alphabet, morphology, phonetics, and semantics - an alphabet, a lexis, morphology, and semantics

an alphabet, a lexis, a syntax, and semantics

What is the output of the following snippet? def fun(in2,out=3) return in*out print(fun(3)) - 6 - 9 - 3 - an error message

an error message

A complete set of known commands is called: - a machine list - a low-level list - an instruction list

an instruction list

What do you call a computer program which directly executes instructions written in a programming language? - an interpreter - a complier - a translator

an interpreter

The print() function can output values of: - any number of arguments (including zero) - any number of arguments (excluding zero) - not more than five arguments - just one argument

any number of arguments (including zero)

What is CPython? - it's a programming language that is a superset of the C language, designed to produce Python-like performance with code written in C - it's the default, reference implementation of the C language, written in python - it's a programming language that is a superset of Python, designed to produce C-like performance with code written in python - it's the default, reference implementation of Python, written in C language

it's the default, reference implementation of Python, written in C language

A variable defined outside a function: - may be freely accessed inside the function - may not be accessed in any way inside the function - may be read, but not written (something more is needed to do so)

may be read, but not written (something more is needed to do so)

Which statement is true? - addition precedes multiplication - multiplication precedes addition - neither statement

multiplication precedes addition

A function definition: - must be placed before the first invocation - cannot be places among other code - may be places anywhere inside the code after the first invocation

must be placed before the first invocation

Choose one of the following statements that is true about the snippet: nums = [] vals = nums vals.append(1) - nums is longer than vals - nums and vals are of the same length - vals is longer than nums

nums and vals are of the same length

A function parameter is a kind of variable accessible: - only inside the function - only after the function definition's completion -anywhere in the code

only inside the function

What is the expected behavior of the following program? print("hello!") - output hello! - output ("hello!") - output "hello!" - error

output hello!

The ** operator: - performs floating-point multiplication - performs exponentiation - performs duplicated multiplication - does not exist

performs exponentiation

The // operator: - performs integer division - performs regular division - does not exist

performs integer division

The meaning of the positional parameter is determined by its: - position - name - appearance

position

A way of passing arguments in which the order of the arguments determines the initial parameters' values is referred to as: - sequential - ordered - positional

positional

Which one of the following is an example of a Python file extension? - pi - p - py

py

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x = int(input()) y = int(input()) x = x // y y = y // x print(y) - 8.0 - 4.0 - 2.0 - runtime error

runtime error

Exercise What types of literals are the following four examples? "1.5", 2.0, 528, False

string, numerical literal (float), numerical literal (integer), boolean literal

edube module 1

tests and quizzes

The meaning of the keyword parameter is determined by: - the argument's name specified along with its value - its position within the argument list - its value - its connection with existing variables

the argument's name specified along with its value

What is CPython? - the default implementation of the Python programming language - a complied language used to preform high-level programming functions - another name for Cython, a superset of the Python programming language

the default implementation of the Python programming language

The most important difference between integer and floating-point numbers lies in the fact that: - integers cannot be literals, while floats can - they are stored differently in the computer memory - they cannot be used simultaneously

they are stored differently in the computer memory

Exercise What types of literals are the following two examples? "Hello", "007"

they're both strings/string literals

What is the purpose of the if statement in Python? - to execute a set of statements only if a specified condition is met - to print a message to the console - to create a loop - none of the above

to execute a set of statements only if a specified condition is met

How many elements does the my_list list contain? my_list = [0 for i in range (1, 3)] - one - two - three

two

How many hashes will the following snippet send to the console? for i in range (-1, 1): print("#") - one - two - three

two

How many stars will the following snippet send to the console? i = 2 while i >= 0: print("*") i -= 2 - one - two - three

two

Choose one of the following statements that is true about the snippet: nums = [] vals = nums[:] vals.append(1) - nums is longer than vals - nums and vals are of the same length - vals is longer than nums

vals is longer than nums

What is the output of the following code? import sympy x, y = sympy.symbols('x y') print(x + y) - x+y - x - y - an error message

x+y


Ensembles d'études connexes

Salesforce Admin Practice Questions

View Set

CHAPTER 29: AGENCY FORMATION AND TERMINATION

View Set

Ch. 5 Tax - Gross Income and Exclusions

View Set

BIOLOGY 346 Microbes and society

View Set