Python Certification
An operator able to check whether two values are not equal is coded as
!=
an operator able to check whether two values are not equal is coded as
!=
what is the output of the following snippet? def fun (x,y,z): return x+ 2 * y +3 *z print (fun(0, z=1, y=3))
0
what is the output of the following snippet? my_list= [ 0, 1, 2, 3] x=1 for element 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 code? 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 will be the output of the following snippet? a= 1 b= 0 a= a^b b= a^ b a= a^b print (alb)
11
what is the output of the following piece of code? x=1 y=2 x,y,z= x,x,y z,y,z= x,y,z print(x,y,z)
121
What is the output of the following snippet? x= 1/2+3//3+4**2 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? my_list= [1,2,3,4] print(my_list[-3:-2])
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
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? dct= {} dct['1'] = (1,2) dct['2']= (2,1) for x in dct.keys(): print (dct[x][1], end= "")
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 BECAUSE STRINGS
what is the output of the following snippet? def fun(inp=2, out=3) return inp* out print(fun(out=2))
4
what is the output of the following snippet? def fun(inp=2, out=3): return inp * out print (fun ( out=2))
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? def f(x): if x==0: return 0 return x+ f(x-1) print(f(3))
6
An operator able to check whether two values are equal is coded
==
What is IDLE?
An acronym that stands for Integrated Development and Learning Environment for Python
A built in function is a function which
Comes with Python, and is an integral part of Python
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)
Error
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
Select the true statements about the try except block in relation to the example
If you suspect that a snippet may raise an exception, you should place it in the try block; the code that follows the except statement will be executed if the code in the try clause runs into an 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)
None
What Python version is covered in this course?
Python 3
What is CPython?
The default implementation of the Python programming language
Which of the following statements are true?
The right argument of the % operator cannot be zero; the ** operator uses right-sided binding
the value eventually assigned to x is equal to: x=1 x= x==x
True
will value will be assigned to the x variable? z= 10 y= 0 x= z>y or z==y
True
Which of the following variable names are illegal?
True and
lists do not support del ex) del my_list[3]
TypeError 'function' object does not support Type deletion
try: value= input( "Enter a value: ") print(value/value) except Value Error: print("Bad input...") except ZeroDivision Error: print("Very bad input...") except TypeError: print("Very very bad input...") except: print("Booo!")
Very very bad input...
What is the output of the following code? my_list= [3,1,-1] my_list[-1]= my_list [-2] print(my_list)
[ 3, 1, 1 ]
the None keyword designates
a None value
What do you call a computer program which directly executes instructions written in a programming language?
a compiler
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
The 0x prefix means that the number after it is denoted as:
a hexadecimal
Python is an example of:
a high-level programming language
What is source code?
a program written in a high-level programming language
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
a keyword is a word that:
cannot be used as a function name, cannot be used as a variable name
The escapee character owes its name to the fact that it:
changes the meaning of the character next to it
A function definition starts with the keyword
def
which 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):
del tuple
del will delete the entire tuple
vals = [0, 1, 2] vals[0] , vals[1] = vals[1], vals[2]
doesn't change the list's length
end= ""
end character needs to be identified from white space, not new line
which of the following snippets shows the correct way of handling multiple exceptions in a single except clause?
except (TypeError, ValueError, ZeroDivision Error):
Right sided binding means that the following expression: 1**2**3 will be evaluated
from right to left
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 tuples are immutable means that the following instruction: my_tuple[1] = my_tuple [1] + my_tuple[0]
is illegal
the meaning of a positional argument is determined by
its position within the argument list
a variable defined outside a function
may be read, but not written
Only one of the following statements is true: which one?
multiplication precedes addition
a function defined in the following way: def function (x=0): return x
must be invoked without any argument ;may be invoked without any argument
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)
nums and vals are of the same length
which of the following sentences are true? nums= [1,2,3] vals= nums[-1:-2]
nums and vals are two different lists, nums is longer than vals
choose the true statement nums= [1,2,3] vals= nums del vals[:]
nums and vals have 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
my_list= ['mary', 'had', 'a', 'little', 'lamb'] def my_list (my_list): del my_list[3] my_list[3]= 'ram' print(my_list(my_list))
output is erroneous
The ** operator:
performs exponentiation
The // operator
performs integer division
The meaning of the positional parameter is determined by its:
position
a way of passing arguments in which the order of the arguments determines the initial parameters' value is referred to as
positional
dictionary= {} my_list= ['a', 'b', 'c', 'd'] for i in range(len(my_list)-1 ): dictionary [my_list[i]]= (my_list[i], ) for i in sorted (dictionary.keys()): k= dictionary [i]
print(k[0])
Which of the following is an example of a Python file extension?
py
which of the following statements are true?
the None value can be compared with variables; the None value can be assigned to variables
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//x print(y)
the code will cause a runtime error
what is the expected behavior of the following program is the user enters 0? value= input( "Enter a value: ") print(10/value)
the program will raise a TypeError exception
which of the following statements are true?
the return keyword may cause the function to return a value; the return keyword forces the function's execution to terminate
What is the output of the following snippet? y= 2 + 3 *5. print(Y)
the snipped will cause an execution 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 result 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
The most important difference between integer and floating-point numbers lies in the fact that:
they are stored differently in the computer memory
the fact that types belong to sequence types means that
they can be indexed and sliced like lists
how many elements does my_list contain? my_list = [ I for I in range(-1,2)]
three
How many stars will the following snippet send to the console? I = 2 while I>=0: print("*") I - = 2
two
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,1): print ('#')
two
what is the output of the following snippet? dictionary= {'one': 'two', 'three' : 'one', 'two': 'three'} v=dictionary['one'] for k in range(len(dictionary)): v= dictionary[v] print(v)
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
the following snippet: def func_1 (a): return a**a def func_2 (a): return func_1(a) * func_1(a) print(func_2(2))
will output 16
how many elements does the lst list contain? lst= [I for I in range (-1,-2)]
zero