option
Cuestiones
ayuda
daypo
buscar.php

[PCAP 31-01] Exam1

COMENTARIOS ESTADÍSTICAS RÉCORDS
REALIZAR TEST
Título del Test:
[PCAP 31-01] Exam1

Descripción:
Test para la certificación PCAP 31-03 v5

Fecha de Creación: 2023/03/19

Categoría: Otros

Número Preguntas: 95

Valoración:(6)
COMPARTE EL TEST
Nuevo ComentarioNuevo Comentario
Comentarios
NO HAY REGISTROS
Temario:

Which of the following expressions evaluates to True and raises no exception?. '9' * 1 < 1 * 2. 'Al' * 2 != 2 * 'Al'. 10 != '1' + '0'. '9' * 3 > '9' * 9.

What is the default return value for a function that does not explicitly return any value?. None. Null. void. public. int.

Which of the following are valid Python string literals? (Select two answers.). 'All the king's horses'. "\". """The Knights Who Say 'Ni!'""". "King's Cross Station".

How many elements does the L list contain? L = [i for i in range(-1, -2)]. one. zero. three. two.

Which of the following lines contain valid Python code? (Select two answers.). lambda a,b: True. lambda(a,b): return a if a < b else b. lambda a,b: a if a < b else b. lambda a,b = a if a < b else b.

What is the expected output of the following code? 1. plane = "Cessna" 2. counter = 0 3. for c in plane * 2: 4. if c in ["e", "a"]: 5. counter += 1 6. print(counter). 4. The code is erroneous and cannot be run. 2. 0.

What is the expected output of the following code? 1. class A: 2. def __init__(self, name): 3. self.name = name 4. 5. 6. a = A('class') 7. 8. print(a). name. class. A number. A string ending with a long hexadecimal number.

What is the expected output of the following code? 1. class A: 2. def __init__(self, x=0): 3. self.x = x 4. 5. def func(self): 6. self.x += 1 7. 8. 9. class B(A): 10. def __init__(self, y=0): 11. A.__init__(self, 3) 12. self.y = y 13. 14. def func(self): 15. self.y += 1 16. 17. 18. b = B() 19. b.func() 20. print(b.x, b.y). 3 1. 4 1. 2 0. 4 0. 3 0.

Which of the following statements are true? (Select two answers.). There are three pre-opened file streams. (. The readlines() function returns a string. The first argument of the open() function is an integer value. The input() function reads data from the stdin stream.

How many stars will the following snippet print to the monitor? 1. i = 4 2. while i > 0: 3. i -= 2 4. print('*') 5. if i == 2: 6. break 7. else: 8. 9. print('*'). The snippet will enter an infinite loop. 0. 2. 1.

What is the expected output of the following code? 1. x = lambda a, b: a ** b 2. print(x(2, 10)). SyntaxError. 2222222222. 1024.

What will be the output of the following code snippet? 1. x = 2 2. y = 1 3. x *= y + 1 4. print(x). None. 3. 4. 1. 2.

Consider the following code snippet: 1. w = bool(23) 2. x = bool('') 3. y = bool(' ') 4. z = bool([False]) Which of the variables will contain False?. w. z. y. x.

What is the expected output of the following code? 1. num = '7' * '7' 2. print(num). 7777777. 77. 49. The code is erroneous.

What is the expected output of the following code? 1. def func(x): 2. try: 3. x = x / x 4. except: 5. print('a', end='') 6. else: 7. print('b', end='') 8. finally: 9. print('c', end='') 10. 11. 12. func(1) 13. func(0). bca. bcbc. acac. bcac. bac.

What is the output of the following code snippet? 1. def test(x=1, y=2): 2. x = x + y 3. y += 1 4. print(x, y) 5. 6. test(2, 1). 2 3. 3 2. The code is erroneous. 3 3. 1 3.

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

What is the expected output of the following code? 1. class Cat: 2. Species = 1 3. 4. def get_species(self): 5. return 'kitty' 6. 7. 8. class Tiger(Cat): 9. def get_species(self): 10. return 'tiggy' 11. 12. def set_species(self): 13. pass 14. 15. 16. creature = Tiger() 17. print(hasattr(creature, "Species"), 18. hasattr(Cat, "set_species")). True False. False True. True True. False False.

What is the expected output of the following code? 1. class A: 2. def __init__(self): 3. self.i = 0 4. self.calc(10) 5. print('i from A is', self.i) 6. 7. def calc(self, i): 8. self.i = 2 * i 9. 10. 11. class B(A): 12. def __init__(self): 13. super().__init__() 14. 15. def calc(self, i): 16. self.i = 3 * i 17. 18. 19. b = B(). i from A is 20. i from B is 30. i from A is 30. i from A is 0.

What is the expected output of the following code? print(list('hello')). None of the above. ['h', 'e', 'l', 'l', 'o']. hello. ['h' 'e' 'l' 'l' 'o']. [h, e, l, l, o].

Which of the following statements are true about the __pycache__ directory/folder? (Select two answers.). It contains semi-compiled module code. It has to be created manually by the module's creator. It has to be created manually by the module's user. It is created automatically.

What will be the output of the following code snippet? 1. a = [1, 2, 3, 4, 5, 6, 7, 8, 9] 2. print(a[::2]). [8, 9]. [1, 3, 5, 7, 9]. [1, 2]. [1, 2, 3].

What is the expected output of the following code? 1. x = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] 2. 3. def func(data): 4. res = data[0][0] 5. for da in data: 6. for d in da: 7. if res < d: 8. res = d 9. return res 10. 11. print(func(x[0])). The code is erroneous. 8. 2. 6. 4.

What is the correct command to shuffle the following list? 1. import random 2. people = ['Peter', 'Paul', 'Mary', 'Jane']. random.shuffle(people). people.shuffle(). shuffle(people). random.shuffleList(people).

What is the expected output of the following code? 1. nums = [3, 4, 5, 20, 5, 25, 1, 3] 2. nums.pop(1) 3. print(nums). [3, 1, 25, 5, 20, 5, 4]. [3, 4, 5, 20, 5, 25, 1, 3]. [1, 3, 4, 5, 20, 5, 25]. [3, 5, 20, 5, 25, 1, 3]. [1, 3, 3, 4, 5, 5, 20, 25].

What is the expected output of the following code? 1. import math 2. 3. result = math.e != math.pow(2, 4) 4. print(int(result)). False. 1. True. 0.

What value will be assigned to the x variable? 1. z = 3 2. y = 7 3. x = y < z and z > y or y > z and z < y. False. 1. 0. True.

What is the expected output of the following code? 1. def func(text, num): 2. while num > 0: 3. print(text) 4. num = num - 1 5. 6. 7. func('Hello', 3). 1. Hello 2. Hello 3. Hello 4. Hello. An infinite loop. 1. Hello 2. Hello 3. Hello. 1. Hello 2. Hello.

You want to check, whether the variable obj contains an object of the class A Which of the following statements can you use?. isinstance(obj, A). A.isinstance(obj). isinstance(A, obj). obj.isinstance(A).

What will be the output of the following code snippet? print(3 / 5). None of the above. 0. 0.6. 6/10.

The part of your code where you think an exception may occur should be placed inside: the exception: branch. the try: branch. the except: branch.

The digraph written as #! is used to: tell a Unix or Unix-like OS how to execute the contents of a Python file. tell an MS Windows OS how to execute the contents of a Python file. make a particular module entity a private one. create a docstring.

Which of the following commands can be used to read n characters from a file?. n = file.readline(). file.readline(n). n = file.read(). file.read(n).

Assuming that the open() invocation has gone successfully, the following snippet will: 1. for x in open('file', 'rt'): 2. print(x). cause an exception. read the file line by line. read the whole file at once. read the file character by character.

What would you insert instead of ??? so that the program checks for even numbers? 1. if ???: 2. print('x is an even number'). x % 2 == 1. x % 'even' == True. x % 1 == 2. x % x == 0. x % 2 == 0.

What is the expected output of the following code? 1. class Economy: 2. def __init__(self): 3. self.econ_attr = True 4. 5. 6. class Business(Economy): 7. def __init__(self): 8. super().__init__() 9. self.busn_attr = False 10. 11. 12. econ_a = Economy() 13. econ_b = Economy() 14. busn_a = Business() 15. busn_b = busn_a 16. print(isinstance(busn_a, Economy) 17. and isinstance(econ_a, Business), end=" ") 18. print(busn_b is busn_a or econ_a is econ_b). False True. False False. True True. True False.

What is the expected output of the following code? 1. num = 1 2. 3. 4. def func(): 5. num = num + 3 6. print(num) 7. 8. 9. func() 10. 11. print(num). 4 1. 1 4. 1 1. The code is erroneous. 4 4.

What is the expected output of the following code? 1. file = open('data.txt', 'w+') 2. print('Name of the file: ', file.name) 3. 4. s = 'Peter Wellert\nHello everybody' 5. file.write(s) 6. file.seek(0) 7. for line in file: 8. print(line) 9. 10. file.close(). 1. Peter Wellert 2. Hello everybody. The code is erroneous. 1. Name of the file: data.txt 2. Peter Wellert 3. 4. Hello everybody. 1. Peter Wellert Hello everybody.

What is the expected behavior of the following snippet? 1. class Team: 2. def show_ID(self): 3. print(self.get_ID()) 4. 5. def get_ID(self): 6. return "anonymous" 7. 8. 9. class A(Team): 10. def get_ID(self): 11. return "Alpha" 12. 13. 14. a = A() 15. a.show_ID(). It outputs an empty line. It outputs anonymous. It outputs Alpha. It raises an exception.

What will be the output of the following code snippet? 1. d = {} 2. d[1] = 1 3. d['1'] = 2 4. d[1] += 1 5. 6. sum = 0 7. 8. for k in d: 9. sum += d[k] 10. 11. print(sum). 4. 3. 1. 2.

What is the expected output of the following code? 1. data = [261, 321] 2. try: 3. print(data[-3]) 4. except Exception as exception: 5. print(exception.args) 6. else: 7. print("('success',)"). 1. ('list index out of range',). 1. 261. 1. 321. 1. ('success',).

What is the output of the following program if the user enters kangaroo at the first prompt and 0 at the second prompt? 1. try: 2. first_prompt = input("Enter the first value: ") 3. a = len(first_prompt) 4. second_prompt = input("Enter the second value: ") 5. b = len(second_prompt) * 2 6. print(a/b) 7. except ZeroDivisionError: 8. print("Do not divide by zero!") 9. except ValueError: 10. print("Wrong value.") 11. except: 12. print("Error.Error.Error."). 1. Do not divide by zero!. 1. 4.0. 1. Wrong value. 1. Error.Error.Error.

The value thirty point eleven times ten raised to the power of nine should be written as: 30.11E9. 30.11E9.0. 30E11.9. 30.11*10^9.

Which method is used to break the connection between the file handle and a physical file?. close(). shutup(). lock(). disconnect().

Which of the following for loops would output the below number pattern? 1. 11111 2. 22222 3. 33333 4. 44444 5. 55555. 1. for i in range(1, 5): 2. print(str(i) * 5). 1. for i in range(1, 6): 2. print(str(i) * 5). 1. for i in range(1, 6): 2. print(i, i, i, i, i). 1. for i in range(0, 5): 2. print(str(i) * 5).

The ABC organics company needs a simple program that their call center will use to enter survey data for a new coffee variety. The program must accept input and return the average rating based on a five-star scale. The output must be rounded to two decimal places. You need to complete the code to meet the requirements. 1. sum = count = done = 0 2. average = 0.0 3. 4. while done != -1: 5. rating = XXX 6. if rating == -1: 7. break 8. sum += rating 9. count += 1 10. 11. average = float(sum / count) 12. 13. YYY + ZZZ What should you insert instead of XXX, YYY and ZZZ?. 1. XXX -> input('Enter next rating (1-5), -1 for done') 2. YYY -> print('The average star rating for the new coffee is: ' 3. ZZZ -> format(average, '.2d')). 1. XXX -> float(input('Enter next rating (1-5), -1 for done')) 2. YYY -> output('The average star rating for the new coffee is: ' 3. ZZZ -> format(average, '.2d')). 1. XXX -> float(input('Enter next rating (1-5), -1 for done')) 2. YYY -> print('The average star rating for the new coffee is: ' 3. ZZZ -> format(average, '.2f')). 1. XXX -> print(input('Enter next rating (1-5), -1 for done')) 2. YYY -> print('The average star rating for the new coffee is: ' 3. ZZZ -> format(average, '.2f')). 1. XXX -> float(input('Enter next rating (1-5), -1 for done')) 2. YYY -> print('The average star rating for the new coffee is: ' 3. ZZZ -> format(average, '.2d')). 1. XXX -> float(input('Enter next rating (1-5), -1 for done')) 2. YYY -> printline('The average star rating for the new coffee is: ' 3. ZZZ -> format(average, '.2f')).

What is the expected output of the following code? 1. class Test: 2. def __init__(self, s='Welcome'): 3. self.s = s 4. 5. def print(self): 6. print(self.s) 7. 8. 9. x = Test() 10. x.print(). The code is erroneous, because the print method is called without an argument. The code is erroneous, because the constructor is called without an argument. Welcome. Nothing.

Given the code below, indicate a method which will correctly provide the value of the rack field? 1. class Storage: 2. def __init__(self): 3. self.rack = 1 4. 5. # Insert a method here 6. 7. 8. stuff = Storage() 9. print(stuff.get()). 1. def get(): 2. return self.rack. 1. def get(): 2. return rack. 1. def get(self): 2. return rack. 1. def get(self): 2. return self.rack.

What is the expected behavior of the following snippet? 1. x = 1 2. 3. 4. def a(x): 5. return 2 * x 6. 7. 8. x = 2 + a(x) # Line 8 9. print(a(x)) # Line 9 It will: print 6. print 4. cause a runtime exception on Line 8. cause a runtime exception on Line 9. print 8.

Knowing that a function named randint() resides in the module named random choose the proper way to import it: import randint. from random import randint. from randint import random. import randint from random.

What is the expected output of the following code? 1. def func(): 2. try: 3. print(23) 4. finally: 5. print(42) 6. 7. 8. func(). 1. 42 2. 23. 23. 42. 1. 23 2. 42.

What happens if you run the following code, assuming that the d directory already exists? 1. import os 2. os.mkdir("a/b/c/d"). A DirectoryExistsError exception will be raised. A FileExistsError exception will be raised. Python will overwrite the existing directory.

You want to write a code snippet to read the total data from a text file and print it to the monitor. What snippet would you insert in the line indicated below: 1. try: 2. file = open('data.txt', 'r') 3. # insert your code here 4. print(data) 5. except: 6. print('Something went wrong!'). data = file.readline(). data = file.load(). data = file.readlines(). data = file.read().

What is the expected output of the following code? 1. list1 = [1, 3] 2. list2 = list1 3. list1[0] = 4 4. print(list2). [1, 4]. [1, 3, 4]. [1, 3]. [4, 3].

You need to find information about your hardware and operating system. Which methods from the module platform can you use? (Select two answers.). 1. hardware(). 1. processor(). 1. platform(). 1. node().

What is the expected output of the following code? 1. z = y = x = 1 2. print(x, y, z, sep='*'). x y z. x*y*z. 111*. The code is erroneous. 1 1 1. 1*1*1.

Select the true statements. Choose two. The system function from the platform module returns a string with your OS name. The version function from the platform module returns a string with your OS version. The processor function from the platform module returns an integer with the number of processes currently running in your OS.. The version function from the platform module returns a string with your Python version.

What is the expected output of the following code? 1. def func(x): 2. return 1 if x % 2 != 0 else 2 3. 4. 5. print(func(func(1))). None. The code is erroneous. 2. 1.

What is the expected output of the following code? 1. class Test: 2. def __init__(self, id): 3. self.id = id 4. id = 100 5. 6. 7. x = Test(23) 8. 9. print(x.id). None of the above. 23. The code is erroneous. 100.

You develop a Python application for your company. You have the following code. 1. def main(a, b, c, d): 2. value = a + b * c - d 3. return value Which of the following expressions is equivalent to the expression in the function?. a + ((b * c) - d). (a + b) * (c - d). None of the above. (a + (b * c)) - d.

Entering the try: block implies that: none of the instructions from this block will be executed. the block will be omitted. some of the instructions from this block may not be executed. all of the instructions from this block will be executed.

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

When a module is imported, its contents: are ignored. are executed once. are executed as many times as they are imported. are executed depending on the contents.

Which of the following snippets outputs 123 to the screen? (Select two answers.). 1. tmp = "321".sort() 2. print(str(tmp)). 1. print(''.join(sorted("321"))). 1. tmp = list("321") 2. tmp.sort() 3. print(''.join(tmp)). 1. print(sorted("321")).

What is true about updating already installed Python packages?. It's an automatic process which doesn't require any user attention. It can be done only by uninstalling the package once again. It's performed by the install command accompanied by the -U option. It can be done by reinstalling the package using the reinstall command.

What is the expected output of the following code? x = 1 / 2 + 3 // 3 + 4 ** 2 print(x). 17.5. 8.5. 8. 17.

What is the expected output of the following code? 1. x = True 2. y = False 3. z = False 4. 5. if not x or y: 6. print(1) 7. elif not x or not y and z: 8. print(2) 9. elif not x or y or not y and x: 10. print(3) 11. else: 12. print(4). 1. 3. 4. 2.

Which of the following variable names is illegal?. in_. in. IN. In.

A subclass is usually: A twin of its superclass. More specialized than its superclass. More general than its superclass.

What is the expected output of the following code? 1. class A: 2. pass 3. 4. 5. class B(A): 6. pass 7. 8. 9. class C(B): 10. pass 11. 12. 13. print(issubclass(C, A)). True. 0. The code is erroneous. 1. False.

What is the expected output of the following code? 1. data = ['Peter', 404, 3.03, 'Wellert', 33.3] 2. print(data[1:3]). ['Peter', 404, 3.03, 'Wellert', 33.3]. None of the above. [404, 3.03]. ['Peter', 'Wellert'].

What is the expected behavior of the following program? 1. try: 2. print(5/0) 3. break 4. except: 5. print("Sorry, something went wrong...") 6. except (ValueError, ZeroDivisionError): 7. print("Too bad..."). The program will cause a ZeroDivisionError exception and output a default error message. The program will cause a ValueError exception and output a default error message. The program will cause a ValueError exception and output the following message: Too bad... The program will raise an exception handled by the first except block. The program will cause a SyntaxError exception. The program will cause a ZeroDivisionError exception and output the following message: Too bad...

What is the expected output of the following code? 1. v = [1, 2, 3] 2. 3. 4. def g(a,b,m): 5. return m(a,b) 6. 7. 8. print(g(1, 1, lambda x,y: v[ x:y+1 ])). [2]. []. [1]. [3].

How many stars will the following code print to the monitor? 1. i = 0 2. while i <= 3: 3. i += 2 4. print('*'). one. three. zero. two.

What will be the output of the following code snippet? 1. x = 1 2. y = 2 3. z = x 4. x = y 5. y = z 6. print(x, y). 1 2. 2 2. 1 1. 2 1.

The function body is missing. What snippet would you insert in the line indicated below: 1. def func(number): 2. # insert your code here 3. 4. 5. print(func(7)). return 'number'. print(number). print('number'). return number.

A function named f() is included in a module named m and the module is part of a package named p Which of the following code snippets allows you to properly invoke the function? (Select two answers.). 1. from p.m import f 2. 3. f(). 1. import p 2. 3. m.f(). 1. import p.m 2. 3. p.m.f(). 1. import p.m.f 2. 3. f().

isalnum() checks if a string contains only letters and digits, and this is: A method. A function. A module.

Which of the following variables will Python consider to be private?. 1. _privatedata_. 1. __privatedata. 1. private_data. 1. privatedata__.

What is the expected output of the following code? x = 1 // 5 + 1 / 5 print(x). 0.2. 0. 0.0. 0.4.

What is the expected output of the following code? 1. foo = [i + i for i in range(5)] 2. print(foo). [0, 2, 4, 6, 8]. 1. 0 2. 2 3. 4 4. 6 5. 8. [1, 3, 5, 7, 9].

What is the expected output of the following code? 1. x = 1 2. y = 2 3. x, y, z = x, x, y 4. z, y, z = x, y, z 5. print(x, y, z). 1 2 2. 1 1 2. 2 1 2. 1 2 1.

A PWG-lead repository, collecting open-source Python code, is called: PWGR. PyPI. PyCR. PyRep.

Select the true statements about the map() function. Choose two. The second map() function argument can be a list. The first map() function argument can be a list. The map() function can accept only two arguments. The map() function can accept more than two arguments.

What is the expected output of the following code? 1. class Content: 2. title = "None" 3. 4. def __init__(self, this): 5. self.name = this + " than " + Content.title 6. 7. text_1 = Content("Paper") 8. text_2 = Content("Article") 9. print(text_1.title == text_2.name). It outputs False. It outputs True. It outputs None. The code is erroneous and will raise an exception.

What is the expected output of the following code? 1. class A: 2. def __init__(self, x): 3. self.__a = x + 1 4. 5. 6. a = A(0) 7. print(a.__a). 2. The code will raise an AttributeError exception. 0. 1.

What is the expected output of the following code if the user enters 2 and 4? 1. x = input() 2. y = input() 3. print(x + y). 24. 2. 4. 6.

The Exception class contains a property named args and it is a: dictionary. string. tuple. list.

What is the expected output of the following code? 1. x = [0, 1, 2] 2. x.insert(0, 1) 3. del x[1] 4. print(sum(x)). 2. 3. 4. 5.

Consider the following file module.py. 1. module.py: 2. print(__name__) What will be the output, if you run it?. __module__. module. __main__. main.

The system that allows you to diagnose input/output errors in Python is called: 1. error_number. 1. errno. 1. error_string. 1. errcode.

What is the expected output of the following code? 1. def func(p1, p2): 2. p1 = 1 3. p2[0] = 42 4. 5. 6. x = 3 7. y = [1, 2, 3] 8. 9. func(x, y) 10. 11. print(x, y[0]). The code is erroneous. 3 1. 1 42. 1 1. 3 42.

What is the expected output of the following code? 1. x = '\'' 2. print(len(x)). 1. The code is erroneous. 2. 0.

What is the expected output of the following code? 1. def func(num): 2. res = '*' 3. for _ in range(num): 4. res += res 5. return res 6. 7. 8. for x in func(2): 9. print(x, end=''). The code is erroneous. ****. *. **.

Which module in Python supports regular expressions?. pyregex. None of the above. regex. re.

Denunciar Test