Python Institute Entry Level

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

What Python version is covered in this course?

Python 3

The 0x prefix means that the number after it is denoted as

a hexadecimal

The result of the following division: 1 /1

is equal to 1.0

The result of the following addition: 123 + 0.0

is equal to 123.0

Assuming that my_tuple is a correctly created tuple, the fact that tupels are immutable means that the following instruction: my_tuple[1] = my_tuple[1] + my_tuple[0]

is illegal

The following snippet: def func_1(a): return a ** a def func_2(a): return func_1(a) * funct_1(a) print(func_2(2))

will output 16

An operator able to check where two values are not equal is coded as:

!=

What is true about compilation?

- It tends to be faster than interpretation - The code is converted directly into machine code executable

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

- Python it free, open-source, and multiplatform - Python is a good choice for creating and executing tests for applications

Which of the following statements are true? (select two) - The return keyword forces the function to restart its execution - The return keyword may cause the function to return a value - 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

Which of the following statements are true? (select two) - The right argument of the % operator cannot be zero - The ** operator uses right-sided binding - Addition precedes multiplication - The result of the / operator is always an integer value

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

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

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

Take a look at the snippet, and choose the true statements (select two) nums = [1, 2, 3] vals = nums del vals[1:2] - nums is replicated and assigned to vals - nums and vals are of the same length - nums is longer than vals - nums and vals refer to the same list

- nums and vals are of the same length - nums and vals refer to the same list

Which of the following sentences are true? (select two) nums = [1 ,2 ,3] vals = nums[-1:-2] -nums and vals are of the same length - nums is longer than vals - nums and vals are two different lists - vals is longer than nums

- nums is longer than vals - nums and vals are two different lists

Left-sided binding determines that the result of the following expression 1 // 2 * 3 is equal to:

0

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

What is the output of the following snippet if the user enters two lines containing 11 and 4 respectively? x = int(input()) y = int(input()) x = x % y x = x % y y = y % x print(y)

1

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

1

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

1*1*1

What is the output of the following snippet? x = 1 / 2 + 3 // 3 +4 ** s print(x)

17.5

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

What is the output of the following snippet? tup = (1,2,4,8) tup = tup[1:-1] tup = tup[0] print(tup)

2

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

2 1

The value twenty point twelve times ten raised to the power of eight should be written as:

20.12E8

What is the output of the following snippet? def any(): print(var + 1, end = '') var = 1 any() print(var)

21

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x = input() y = input() print(x+y)

24

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

After execution of the following snippet, the sum of all vals elements will be equal to: vals = [0, 1, 2] vals.insert(0, 1) del vals[1]

4

After execution of the following snippet, the sum of all vals elements will be equal to: vals = [0, 1, 2] vals.insert(0,1) del vals[1]

4

What is the output of the following snippet? def fun(x): global y y = x * x return y fun(2) print(y)

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

What is the output of the following snippet? tup = (1, ) + (1, ) tup = tup + tup print(len(tup))

4

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()) print(x + y)

6

What is the output of the following snippet? t = [[3-1 for i in range (3)] for j in range (3)]: s = 0 for i in range(3) s+= t[i][i] print(s)

6

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

The None keyword designates:

A None value

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

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

What is machine code?

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

What is IDLE?

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

What are the four fundamental elements that make a language?

An alphabet, a lexis, phonetics, and semantics

What do you call a computer program which directly executes instructions written in a programming language?

An interpreter

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

Python is an example of:

High-level programming language

What is the best definition of a script?

It's a text file that contains instructions which make up a Python program

What is CPython?

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

What is CPython (Quiz)?

The default implementation of the Python programming language

What is the expected behavior of the following program? prin("Goodbye!")

The program will generate an error message on the screen

What is the expected behavior of the following program? print("Hello!")

The program will output: Hello! to the screen

The value eventually assigned to x is equal to:

True

What value will be assigned to the x variable? z = 10 y = 0 x = y < z and z > y or y > z and z < y

True

What value will be assigned to the x variable? z = 10 y = 0 x = z > y or z == y

True

What is the output of the following snippet? my_list = [1, 2, 3] for v in range(len(my_list)): my_list.insert(1, my_list[v]) print(my_list)

[1, 1, 1, 1, 2, 3]

What is the output of the following code? my_list = [3,1,-1] mylist[-1] = my_list[-2] print(my_list)

[3, 1, 1]

What is the output of the following snippet? my_list_1 = [1, 2, 3] my_list_2 = [] for v in my_list_1: my_list_2.insert(0, v) print( my_list_2)

[3, 2, 1]

A value returned by the input() function is:

a string

A complete set of known commands is called:

an instruction list

The print() function can output values of:

any number of arguments (including zero)

The \n digraph forces the print() function to:

break the output line

The escape character owes its name to the fact that it:

changes the meaning of the character next to it

A function definition starts with a the keyword

def

Which one of the following lines properly starts a parameterless function definition?

def fun():

Which of the following lines properly starts a function using two parameters, both with zeroed default values?

def fun(a=0, b=0):

The second assignment: vals = [0,1,2] vals[0], vals[1] = vals[1], vals[2]

doesn't change the list's length

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

four

Right-sided binding means that the following expression: 1 ** 2 ** 3 will be evaluated:

from right to left

A variable defined outside a function:

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

Only one of the following statements is true: - addition precedes multiplication - multiplication precedes addition - neither statement can be evaluated

multiplication precedes addition

A function definition:

must be placed before the first invocation

Take a look at the snippet and choose one of the following statements which is true: nums = [] vals = nums vals.append(1)

num and vals are of the same length

The 0o prefix means that the number after it is denoted as:

octal

How many stars(*) will the following snippet send to the console? i = 0 while i <= 5: i += 1 if i % 2 == 0: break print("*")

one

A function parameter is a kind of variable accessible

only inside the function

The ** operator:

performs exponentiation

The // operator

performs integer division

The meaning of the positional parameter is determined by its:

position

A way of argument passing in which the order of the arguments determines the initial parameter's values is referred to as:

positional

Which one of the following is an example of a Python file extension?

py

The second assignment: vals = [0, 1, 2] vals[0], vals[2] = vals[2], vals[0]

reverses the list

The meaning of the keyword parameter is determined by:

the argument's name specified along with its value

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 // y print(y)

the code will cause a runtime error

What is the output of the following snippet? def fun(x): if x % 2 == 0: return 1 else: return print(fun(fun(2)) + 1)

the code will cause a runtime error

What is the output of the following snippet? def fun(in = 2, out = 3): return in * out print(fun(3))

the snippet is erroneous (invalid syntax)

What is the output of the following snippet? my_list = [[0, 1 ,2 , 3] for i in range(2)] print(my_list[2][0])

the snippet will cause a runtime error

What is the output of the following snippet? y = 2 + 3 * 5. print(Y)

the snippet will cause an execution error

The most important difference between integer and floating-point numbers lies in the fact that:

they are stored differently in the computer memory

How many hashes (#) will the following snippet send to the console? var = 0 while var < 6: var +=1 if var % 2 == 0: continue print("#")

three

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

two

How many hashes (#) will the following snippet send to the console? for i in range(1): print("#") else: print("#")

two

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

two

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

two

How many stars(*) will the following snippet send to the console? i = 0 while i <= 3: i+=2 print("*")

two

Take a look at the snippet and choose one of the following statements which is true: nums = [] vals = nums[:] vals.append(1)

vals is longer than nums

If a list is passed into a function as an argument, deleting any of its elements inside the function using the del instruction:

will affect the argument

What is a source code?

A program written in a high-level programming language

How many elements does the my_list_contain?

three

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

- True - and

An operator able to check whether two values are equal is coded as:

==

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

A source file


Kaugnay na mga set ng pag-aaral

Ch. 37 Child with a Communicable Disease

View Set

Washington Fundamentals Exam Review

View Set

Law of Contract - End of Section Questions

View Set

Pharmacology Comprehensive Study Guide: Section 2

View Set

Chapter 2 - Evaluating Nutrition Information

View Set