PCAP : Certified Associate in Python Programming : Part 03
-
Which of the following words can be used as a variable name? (Choose two.)
- for
- True
- true
- For
Explanation:
Reference: https://www.pluralsight.com/guides/python-basics-variables-assignment
-
Python strings can be “glued” together using the operator:
- .
- &
- _
- +
Explanation:Reference: https://docs.python.org/3/tutorial/introduction.html -
A keyword (Choose two.)
- can be used as an identifier
- is defined by Python’s lexis
- is also known as a reserved word
- cannot be used in the user’s code
Explanation:Reference: https://www.programiz.com/python-programming/keywords-identifier -
How many stars (*) does the snippet print?
- the code is erroneous
- five
- four
- two
-
Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Choose two.)
Expected output:
1 2 3
Code:
-
c, b, a = b, a, c
-
c, b, a = a, c, b
-
a, b, c = c, a, b
-
a, b, c = a, b, c
-
-
Assuming that the V variable holds an integer value to 2, which of the following operators should be used instead of OPER to make the expression equal to 1?
V OPER 1
- <<<
- >>>
- >>
- <<
-
How many stars (*) does the following snippet print?
- the code is erroneous
- five
- three
- four
Explanation:
-
UNICODE is:
- the name of an operating system
- a standard for encoding and handling texts
- the name of a programming language
- the name of a text processor
Explanation:Reference: https://docs.python.org/2/howto/unicode.html -
What is the expected output of the following snippet?
- *- **-**-**-*
- *-**-**-**-**-**-**-**-*
- *-*
- *-**-*
Explanation:
-
Which of the listed actions can be applied to the following tuple? (Choose two.)
- tup [:]
- tup.append (0)
- tup [0]
- del tup
-
Executing the following snippet
will cause the dct:
-
to hold two keys named ‘pi’ linked to 3.14 and 3.1415 respectively
-
to hold two key named ‘pi’ linked to 3.14 and 3.1415
-
to hold one key named ‘pi’ linked to 3.1415
-
to hold two keys named ‘pi’ linked to 3.1415
-
-
How many elements will the list1 list contain after execution of the following snippet?
- two
- zero
- one
- three
-
Which of the equations are True? (Choose two.)
- chr (ord (x)) = = x
- ord (ord (x)) = = x
- chr (chr (x)) = = x
- ord (chr (x)) = = x
-
If you want to transform a string into a list of words, what invocation would you use? (Choose two.)
Expected output:
Code:
-
s.split ()
-
split (s, ‘ ‘)
-
s.split (‘ ‘)
-
split (s)
-
-
Assuming that 1st is a four-element list is there any difference between these two statements?
- yes, there is, the first line empties the list, the second line deletes the list as a whole
- yes, there is, the first line deletes the list as a whole, the second line just empties the list
- no, there is no difference
- yes, there is, the first line deletes the list as a whole, the second line removes all the elements except the first one
-
What should you put instead of XXX to print out the module name?
- main
- _main_
- __main__
- ___main___
Explanation:Reference: https://www.geeksforgeeks.org/__name__-special-variable-python/ -
Files with the suffix .pyc contain:
- Python 4 source code
- backups
- temporary data
- semi-compiled Python code
-
Package source directories/folders can be:
- converted into the so-called pypck format
- packed as a ZIP file and distributed as one file
- rebuilt to a flat form and distributed as one directory/folder
- removed as Python compiles them into an internal portable format
-
What can you deduce from the line below? (Choose two.)
- import a.b.c should be placed before that line
- f () is located in subpackage c of subpackage b of package a
- the line is incorrect
- the function being invoked is called a.b.c.f ()
-
A two-parameter lambda function raising its first parameter to the power of the second parameter should be declared as:
-
lambda (x, y) = x ** y
-
lambda (x, y): x ** y
-
def lambda (x, y): return x ** y
-
lambda x, y: x ** y
-
Subscribe
0 Comments
Newest