option
Cuestiones
ayuda
daypo
buscar.php

[PCAP 31-01] Exam2

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

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

Fecha de Creación: 2023/03/19

Categoría: Otros

Número Preguntas: 96

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

A programmer needs to use the following functions: machine(), choice(), and system(). Which modules have to be imported to make this possible? (Select two answers.). 1. tkinter. 1. math. 1. platform. 1. random.

What is the expected output of the following code? 1. class Aircraft: 2. def start(self): 3. return "default" 4. 5. def take_off(self): 6. self.start() 7. 8. 9. class FixedWing(Aircraft): 10. pass 11. 12. 13. class RotorCraft(Aircraft): 14. def start(self): 15. return "spin" 16. 17. 18. fleet = [FixedWing(), RotorCraft()] 19. for airship in fleet: 20. print(airship.start(), end=" "). 1. default default. 1. spin default. 1. spin spin. 1. default spin.

What is the expected output of the following code? 1. class Aircraft: 2. def start(self): 3. return "default" 4. 5. def take_off(self): 6. self.start() 7. 8. 9. class FixedWing(Aircraft): 10. pass 11. 12. 13. class RotorCraft(Aircraft): 14. def start(self): 15. return "spin" 16. 17. 18. fleet = [FixedWing(), RotorCraft()] 19. for airship in fleet: 20. print(airship.start(), end=" "). 1. default default. 1. spin default. 1. spin spin. 1. default spin.

The += operator, when applied to strings, performs: Concatenation. Subtraction. Multiplication.

What is the expected output of the following code? x = 1 + 1 // 2 + 1 / 2 + 2 print(x). 3.5. 4. 4.0. 3.

What is the expected output of the following code? print(1 // 2 * 3). 0.16666666666666666. 4.5. 0.0. 0.

What is the expected output of the following code? 1. x, y = 3.0, 0.0 2. try: 3. z = x / y 4. except ArithmeticError: 5. z = -1 6. else: 7. z = -2 8. print(z). 1. -1. An error message appears on the screen. 1. -2. 1. -INF.

Consider the following code. 1. class Test: 2. def __init__(self, x=0): 3. self.x = x Which of the assignments below is invalid?. obj = Test(). obj = Test('1'). obj = Test(1, 2). obj = Test(1).

The part of your code where the handling of an exception takes place should be placed inside: the exception: branch. the except: branch. the try: branch.

What is the expected output of the following code? 1. class A: 2. def __init__(self, x=2, y=3): 3. self.x = x 4. self.y = y 5. 6. def __str__(self): 7. return 'A' 8. 9. def __eq__(self, other): 10. return self.x * self.y == other.x * other.y 11. 12. 13. a = A(1, 2) 14. b = A(2, 1) 15. print(a == b). False. 1. True. 2.

What is the expected output of the following snippet? 1. s = 'python' 2. for i in range(len(s)): 3. i = s[i].upper() 4. print(s, end=''). P Y T H O N. The code is erroneous. P y t h o n. PYTHON. Python. python.

What is the expected output of the following code? print('Peter' 'Wellert'). Peter. Wellert. PeterWellert. The code is erroneous.

What is the expected output of the following code if there is no file named non_existing_file in the working directory/folder, and the open() function invocation is successful? 1. try: 2. f = open("non_existing_file", "w") 3. print(1, end=" ") 4. s = f.readline() 5. print(2, end=" ") 6. except IOError as error: 7. print(3, end=" ") 8. else: 9. f.close() 10. print(4, end=" "). 1. 1 3. 1. 1 2 3 4. 1. 2 4. 1. 1 2 4.

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

Which of the following expressions evaluates to True and raises no exception? (Select two answers.). 'xyz' not in 'uvwxyz'. 'bc' in 'abc'. '' in 'alphabet'. '' not in ''.

Which of the following statements are true? (Select two answers.). The second argument of the open() function is an integer value. The open() function returns False when its operation fails. The print() function writes its output to the stdout stream. stdin, stdout, stderr are names of pre-opened streams.

Given the code below, which of the expressions will evaluate to True? 1. class Control: 2. my_ID = 1 3. 4. def say(self): 5. return self.my_ID 6. 7. 8. class Button(Control): 9. my_ID = 2 10. 11. 12. class Radio(Button): 13. def say(self): 14. return -self.my_ID 15. 16. 17. selection = Radio() 18. element = Control() 19. start = Button() (Select two answers.). 1. start.my_ID == -2. 1. selection.my_ID == 2. 1. isinstance(start, Button). 1. selection is element.

What is the expected result of the following code? 1. b = bytearray(3) 2. print(b). 3. bytearray(b'3'). bytearray(0, 0, 0). bytearray(b'\x00\x00\x00').

What is the expected output of the following code? 1. data = [[0, 1, 2, 3] for i in range(2)] 2. print(data[2][0]). 2. The code is erroneous. 0. 1.

The ABC Video company needs a way to determine the cost that a customer will pay for renting a DVD. The cost is dependent on the time of day the DVD is returned. However, there are also special rates on Thursdays and Sundays. The fee structure is shown in the following list: The cost is $1.59 per night. If the DVD is returned after 8 PM, the customer will be charged an extra day. If the video is rented on a Sunday, the customer gets 30% off for as long as they keep the video. If the video is rented on a Thursday, the customer gets 50% off for as long as they keep the video. You need to write code to meet the requirements. 1. # ABC Video, DVD Rental Calculator 2. 3. ontime = input('Was the video returned before 8 pm? y or n').lower() 4. days_rented = int(input('How many days was the video rented?')) 5. day_rented = input('What day was the video rented?').capitalize() 6. 7. cost_per_day = 1.59 8. 9. if ontime XXX 10. days_rented += 1 11. if day_rented YYY 12. total = (days_rented * cost_per_day) * .7 13. elif day_rented ZZZ 14. total = (days_rented * cost_per_day) * .5 15. else: 16. total = (days_rented * cost_per_day) 17. 18. print('Cost of the DVD rental is: $', total) What should you insert instead of XXX, YYY and ZZZ?. 1. XXX -> == 'y': 2. YYY -> >= 'Sunday': 3. ZZZ -> >= 'Thursday':. 1. XXX -> != 'n': 2. YYY -> is 'Sunday': 3. ZZZ -> is 'Thursday':. 1. XXX -> == 'n': 2. YYY -> is 'Sunday': 3. ZZZ -> is 'Thursday':. 1. XXX -> == 'n': 2. YYY -> == 'Sunday': 3. ZZZ -> == 'Thursday':. 1. XXX -> == 'y': 2. YYY -> == 'Sunday': 3. ZZZ -> == 'Thursday':.

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

What is the expected output of the following code? 1. import os 2. 3. os.mkdir('thumbnails') 4. os.chdir('thumbnails') 5. 6. sizes = ['small', 'medium', 'large'] 7. 8. for size in sizes: 9. os.mkdir(size) 10. 11. print(os.listdir()). ['.', 'large', 'medium', 'small']. ['.', '..', 'large', 'medium', 'small']. []. ['large', 'medium', 'small'].

What is the expected output of the following code? 1. try: 2. raise Exception(1, 2, 3) 3. except Exception as e: 4. print(len(e.args)). The code is erroneous. 3. 1. 2.

What is the expected output of the following code? 1. x = True 2. y = False 3. x = x or y 4. y = x and y 5. x = x or y 6. print(x, y). True False. False False. True True. False True.

Which of the following items are present in the function header?. parameter list. function name and parameter list. function name. return value.

Is there a way to check if a class is a subclass of another class?. Yes, there is a function able to do that. It may be possible, but only under special conditions. No.

UTF-8 is ... a synonym for "byte". the 9th version of the UTF Standard. a Python version name. an encoding form of the Unicode Standard.

Which of the following function calls can be used to invoke the below function definition? def test(a, b, c, d): Choose three. test(a=1, b=2, c=3, d=4). test(1, 2, 3, d=4). test(a=1, b=2, c=3, 4). test(1, 2, 3, 4). test(a=1, 2, 3, 4). test(a=1, 2, c=3, 4).

If the class’s constructor is declared as below, which one of the assignments is valid? 1. class Class: 2. def __init__(self): 3. pass. object = Class(self). object = Class(). object = Class. object = Class(object).

Consider the following code. 1. for n in range(1, 6, 1): 2. print(??? * 5) What would you insert instead of ??? so that the program prints the following pattern to the monitor? 1. 11111 2. 22222 3. 33333 4. 44444 5. 55555. 1. -1. str(n). 2. n.

Which of the following are not valid Python string literals? (Select two answers.). 1. "this is a quote: \"". 1. 'Whether 'tis nobler in the mind to suffer'. 1. '''To be, or not to be, 2. that is the question""". 1. "\\".

PyPI is often referred to as: Py Software Store. Python Play. pyTT. Cheese Shop.

Which of the following is an example of a Python built-in concrete exception?. BaseException. IndexError. ImportError. ArithmeticError.

Which of the following statements are true? (Select two answers.). A source file named __init__.py is used to mark a directory/folder as containing a Python package, and to initiate the package. The variable named __name__ is a string containing the module name. The .pby extension marks files that contain Python semi-compiled byte-code. A programmer is obliged to manually create a directory/folder named __pycache__ inside every package.

A code point is: A point used to write a code. A code containing a point. A number which makes up a character.

You develop a Python application for your company. A list named employees contains 200 employee names, the last five being company management. You need to slice the list to display all employees excluding management. Which code segments can you use? Choose two. employees[:-5]. employees[1:-4]. employees[0:-4]. employees[0:-5]. employees[1:-5].

What is the expected output of the following code? 1. class A: 2. 3. def __init__(self, v=2): 4. self.v = v 5. 6. def set(self, v=1): 7. self.v += v 8. return self.v 9. 10. 11. a = A() 12. b = a 13. b.set() 14. 15. print(a.v). 2. 1. 0. 3.

What is the expected output of the following code? 1. try: 2. print('try') 3. except: 4. print('except') 5. finally: 6. print('finally'). 1. try 2. finally. 1. finally 2. except. 1. except 2. finally. 1. finally 2. try.

Which of the following is false?. A try statement can have one or more except clauses. A try statement can have one or more finally clauses. A try statement can have a finally clause without an except clause. A try statement can have a finally clause and an except clause.

What is the expected output of the following code? 1. class Test: 2. def __init__(self, s): 3. self.s = s 4. 5. def print(self): 6. print(s) 7. 8. 9. x = Test('Hello Python') 10. x.print(). Hello Python. TypeError: Test() takes no arguments. AttributeError: 'Test' object has no attribute 's'. NameError: name 's' is not defined.

What is the expected output of the following code? 1. data = 'abbabadaadbbaccabc' 2. print(data.count('ab', 1)). 2. 4. 3. 5.

What is the expected output of the following code? print(chr(ord('z') - 2)). y. a. z. x.

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

What is the expected output of the following code? 1. def increment(c, num): 2. c.count += 1 3. num += 1 4. 5. 6. class Counter: 7. def __init__(self): 8. self.count = 0 9. 10. 11. counter = Counter() 12. number = 0 13. 14. for i in range(0, 100): 15. increment(counter, number) 16. 17. print( 18. "counter is " 19. + str(counter.count) 20. + ", number of times is " 21. + str(number) 22. ). counter is 100, number of times is 0. counter is 101, number of times is 0. counter is 100, number of times is 100. counter is 101, number of times is 101.

Consider the following code. 1. x = 1 2. x = x == x The value eventually assigned to x is equal to: 1. True. 0. False.

What is the expected output of the following code? 1. colors = ['red\n', 'yellow\n', 'blue\n'] 2. file = open('wellert.txt', 'w+') 3. file.writelines(colors) 4. file.close() 5. file.seek(0) 6. for line in file: 7. print(line). 1. red 2. 3. yellow 4. 5. blue. The code is erroneous. redyellowblue. ['red\n', 'yellow\n', 'blue\n'].

What is the expected output of the following code? 1. with open('data.txt', 'w') as f: 2. f.write("I'm gonna make him an offer he can't refuse.") 3. 4. with open('data.txt', 'r') as f: 5. data = f.readlines() 6. for line in data: 7. words = line.split() 8. print(words). I'm gonna make him an offer he can't refuse. The code is erroneous. ["I'm", 'gonna', 'make', 'him', 'an', 'offer', 'he', "can't", 'refuse.']. I.

What is the expected output of the following code? 1. class A: 2. 3. A = 7 4. 5. def __init__(self): 6. self.a = 0 7. 8. 9. print(hasattr(A, 'A')). 0. The code is erroneous. False. True.

What is the expected output of the following code? 1. data = {'1': '0', '0': '1'} 2. 3. for d in data.vals(): 4. print(d, end=' '). 0 0. 1 0. The code is erroneous. 0 1.

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

What can you do to indicate that a module entity should be treated as private? Choose two. You can mark the entity with the # (hashtag) prefix. You can mark the entity with the __ (double underscore) prefix. Nothing - all module entities are private by default. You can mark the entity with the _ (single underscore) prefix.

What is the expected output of the following code? 1. people = {} 2. 3. 4. def add_person(index): 5. if index in people: 6. people[index] += 1 7. else: 8. people[index] = 1 9. 10. 11. add_person('Peter') 12. add_person('Paul') 13. add_person('peter') 14. 15. print(len(people)). The code is erroneous. 2. 1. 3.

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

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

Given the code below, complete the print() method body in a way that will ensure that the get() method is properly invoked. 1. class Storage: 2. def __init__(self): 3. self.rack = 1 4. 5. def get(self): 6. return self.rack 7. 8. def print(self): 9. # Insert a method here 10. 11. 12. stuff = Storage() 13. stuff.print() (Select two answers.). 1. print(self.get()). 1. print(Storage.get()). 1. print(get()). 1. print(Storage.get(self)).

Assuming that the following code has been executed successfully, indicate the expressions which evaluate to True and don't raise any exceptions. 1. class Collection: 2. stamps = 2 3. 4. def __init__(self, stuff): 5. self.stuff = stuff 6. 7. def dispose(self): 8. del self.stuff 9. 10. 11. binder = Collection(1) 12. binder.dispose() (Select two answers.). 1. 'stuff' in binder.__dict__. 1. len(binder.__dict__) != len(Collection.__dict__). 1. len(binder.__dict__) > 0. 1. 'stamps' in Collection.__dict__.

A list of package's dependencies can be obtained from pip using its command named: dir. deps. show. list.

What is the expected output of the following code? 1. strng = "John,Doe,42" 2. strng = "".join(strng.split(",")) 3. print(strng[-2]). 1. 2. 1. 4. 1. ;. 1. e.

Which of the following statements is false?. Multiplication precedes addition. The result of the / operator is always an integer value. The right argument of the % operator can not be zero. The ** operator has right-to-left associativity.

What is the expected output of the following code? print(float('1.3')). The code is erroneous. 1,3. 13. 1.3.

Which of the following functions immediately terminates a program?. None. sys.stop(). sys.exit(). sys.terminate(). sys.halt().

What is the expected output of the following code? 1. def f(a, b): 2. return a(b) 3. 4. 5. print(f(lambda x: x and True, 1 > 0)). 1. True. 1. 0. 1. False. 1. None.

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

What is the expected output of the following code? 1. import math 2. 3. x = -1.7 4. print(-abs(math.floor(x) + math.ceil(x))). 1. -3. 1. -2. 1. 3. 1. 2.

Select the true statements about the filter() function. Choose two. The filter() function does not return an iterator. The filter() function has the following syntax: filter(iterable, function). The filter() function returns an iterator. The filter() function has the following syntax: filter(function, iterable).

Which of the following statements is false?. The None value can be compared with variables. The None value can be assigned to variables. The None value can not be used as an argument of arithmetic operators. The None value may not be used outside functions.

What is the expected output of the following code? 1. data = 'abcdefg' 2. 3. 4. def func(text): 5. del text[2] 6. return text 7. 8. 9. print(func(data)). acdef. abcef. abdef. The code is erroneous.

Select the true statements. Choose two. The lambda function can accept a maximum of two arguments. The lambda function can evaluate multiple expressions. The lambda function can accept any number of arguments. The lambda function can evaluate only one expressions.

How many stars will the following code print to the monitor? 1. i = 0 2. while i < i + 2: 3. i += 1 4. print('*') 5. else: 6. print('*'). one. zero. The snippet will enter an infinite loop. two.

What is the expected output of the following code? 1. x = 9 2. y = 12 3. result = x // 2 * 2 / 2 + y % 2 ** 3 4. print(result). 9.0. 7.0. 8. 8.0.

What is the expected output of the following code? 1. data = {} 2. 3. 4. def func(d, key, value): 5. d[key] = value 6. 7. 8. print(func(data, '1', 'Peter')). value. None. Peter. The code is erroneous. 1.

Which of the following function headers is correct?. def func(a=1, b=1, c=2, d):. def func(a=1, b, c=2):. def func(a=1, b=1, c=2):. def func(a=1, b):.

What is the expected output of the following code? 1. a = [1, 2, 3, 4, 5] 2. print(a[3:0:-1]). The code is erroneous. [4, 3, 2, 1]. [4, 3]. [4, 3, 2].

Which of the following statements are true? (Select two answers.). The open() function raises an exception when its operation fails. Trying to write a file opened in read-only mode removes its contents. The second argument of the open() function is a string. read, write, and delete are the names of file open modes.

Which of the following variable names is illegal?. true. tRUE. TRUE. True.

The errno.ENOENT symbol refers to an error described as: Permission denied. No child processes. Operation not permitted. No such file or directory.

How many stars will the following code send to the monitor? 1. x = 0 2. while x < 6: 3. x += 1 4. if x % 2 == 0: 5. continue 6. print('*'). two. three. zero. one.

What is the expected output of the following code? 1. data = [1, 2, 3, 4, 5, 6] 2. 3. for i in range(1, 6): 4. data[i - 1] = data[i] 5. 6. for i in range(0, 6): 7. print(data[i], end=' '). 2 3 4 5 6 6. 2 3 4 5 6 1. 1 2 3 4 5 6. 1 1 2 3 4 5.

If you want to import pi from math, which line will you use?. import pi from math. from math import pi. from pi import math.

What is the expected output of the following code? 1. vect = ["alpha", "bravo", "charlie"] 2. new_vect = filter(lambda s: s[-1].upper() in ["A", "O"], vect) 3. for x in new_vect: 4. print(x[1], end=""). RH. LR. rh. lr.

What is the expected output of the following code? 1. def func(message, num=1): 2. print(message * num) 3. 4. 5. func('Hello') 6. func('Welcome', 3). 1. Hello 2. WelcomeWelcomeWelcome. 1. Hello 2. Welcome Welcome Welcome. 1. Hello. 1. Hello 2. Welcome,Welcome,Welcome. 1. Hello 2. Viewers.

The following statement ... assert x == 0. is erroneous. will stop the program if x is not equal to 0. has no effect. will stop the program if x is equal to 0.

What is the expected output of the following code? 1. class Ceil: 2. Token = 1 3. 4. def get_token(self): 5. return 1 6. 7. 8. class Floor(Ceil): 9. def get_token(self): 10. return 2 11. 12. def set_token(self): 13. pass 14. 15. 16. holder = Floor() 17. print(hasattr(holder, "Token"), hasattr(Ceil, "set_token")). 1. True True. 1. False True. 1. False False. 1. True False.

Consider the following code. from x.y import z The code causes the import of ... entity z from module y from package x. entity y from module x from package z. entity z from module x from package y. entity x from module y from package z.

Which of the following sentences correctly describes the output of the below Python code? 1. data = [4, 2, 3, 2, 1] 2. res = data[0] 3. 4. for d in data: 5. if d < res: 6. res = d 7. 8. print(res). res is the average of all the number in the list. res is the sum of all the number in the list. None of the above. res is the smallest number in the list. res is the largest number in the list.

You know that a function named func() resides in a module named mod The module has been imported using the following line: import mod How can you invoke the function?. func(). mod::func(). mod.func(). mod->func().

What is the expected output of the following code? 1. def func(data): 2. for d in data[::2]: 3. yield d 4. 5. for x in func('abcdef'): 6. print(x, end=''). ace. An empty line. abcdef. bdf.

What is the expected output of the following code? 1. data = [ 2. [1, 2, 3, 4], 3. [5, 6, 7, 8], 4. [9, 10, 11, 12], 5. [13, 14, 15, 16] 6. ] 7. for i in range(0, 4): 8. print(data[i].pop(), end=' '). 13 14 15 16. 4 8 12 16. 1 2 3 4. 1 5 9 13.

What is the expected output of the following code? 1. data = set([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) 2. print(len(data)). 4. 2. 0. 1. 10. 3.

How many stars will the following code print to the monitor? 1. x = 1 2. while x < 10: 3. print('*') 4. x = x << 1. one. two. eight. four.

What is true about object-oriented programming (OOP)? (Select two answers.). A relation between superclass and its subclass is known as fraternity. Polymorphism is a phenomenon which allows you to have many classes of the same name. A class may exist without its objects, while objects cannot exist without their class. A class is like a blueprint used to construct objects.

What is the expected output of the following code? print(1 / 1). 1. This can not be evaluated. 1.0. This can not be predicted.

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

What is the expected behavior of the following program? 1. foo = (1, 2, 3) 2. foo.index(0). The program will cause a AttributeError exception. The program will cause a TypeError exception. The program will cause a SyntaxError exception. The program will output 1 to the screen. The program will cause a ValueError exception.

What is the expected result of the following code? 1. try: 2. raise Exception 3. except: 4. print("c") 5. except BaseException: 6. print("a") 7. except Exception: 8. print("b"). The code will cause a syntax error. b. 1. a.

Consider the following code. 1. import random 2. data = [10, 20, 30] 3. random.shuffle(data) 4. print(data) Which of the following statements best describes the behavior of the random.shuffle() method?. It will not modify the list. This function is just a placeholder and yet to be implemented. It shuffles the elements for the number of times equal to the size of the list. It shuffles the elements of the list in-place. It returns a list where the elements 10, 20 and 30 would be at a random positions.

Denunciar Test