













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
PCEP - Certified Entry-Level Python Programmer Study Cards. Questions & Correct Answers Latest 2026-2027. Graded A
Typology: Study Guides, Projects, Research
1 / 21
This page cannot be seen from the preview
Don't miss anything!














A function is able to... - ANScause some effect (e.g., send text to the terminal, create a file, draw an image, play a sound, etc.); this is something completely unheard of in the world of mathematics; evaluate a value (e.g., the square root of a value or the length of a given text) and return it as the function's result; this is what makes Python functions the relatives of mathematical concepts. A function name should be... - ANSSignificant A keyword argument consists of what elemests? - ANSa keyword identifying the argument (ex. end); an equal sign (=); and a value assigned to that argument; Advantages to compilation? - ANS- the execution of the translated code is usually faster;
-the translated code is stored using machine language - as it is very hard to understand it, your own inventions and programming tricks are likely to remain your secret. Advantages to interpretation? - ANS- you can run the code as soon as you complete it - there are no additional phases of translation;
-both you and the end user have to have the interpreter to run your code. Do lists in Python support indexing? - ANSYes, you can refer to any position in a list by using the number. Give an example of a nested comprehension to create a 2 dimensional array. - ANSboard = [[EMPTY for i in range(8)] for j in range(8)] How are the shift operators depicted in Python? - ANSThe shift operators in Python are a pair of digraphs: << and >>, clearly suggesting in which direction the shift will act. How can you delete an element from a list? - ANSUse the del keyword. It is an instruction: del numbers[1] How can you print the following message without producing errors? I like "Monty Python" - ANSThe backslash can be used to escape quotes. Or Python can use an apostrophe instead of a quote. Examples: print("I like "Monty Python"") or print('I like "Monty Python"')
How can you represent 3 x 10^8 without writing out so many zeros? - ANS3E8 or 3e How can you represent the number eleven million one hundred and eleven thousand one hundred and eleven in Python as an integer? - ANSYou can write this number either like this: 11111111, or like that: 11_111_111. How can you swap 2 variables without using a third auxiliary variable? - ANSvariable_1 = 1 variable_2 = 2 variable_1, variable_2 = variable_2, variable_ How do we code negative numbers in Python? - ANSAs usual - by adding a minus. You can write: -11111111, or -11_111_ How do you declare a list with a set length? - ANSlist_1 = [x] where x is the length of the list. How do you represent a hexadecimal number in Python? - ANSSuch numbers should be preceded by the prefix 0x or 0X (zero-x). 0x123 is a hexadecimal number with a (decimal) value equal to 291. How do you represent an octal number in Python? - ANSIf an integer number is preceded by an 0O or 0o prefix (zero-o), it will be treated as an octal value. This means that the number must contain digits taken from the [0..7] range only.
How many instructions are required in an if, while or for statement? - ANSAt least 1. If the first condition of a conditional statement is not met, what keywords can you use to indicate a "Plan B"? - ANSelse, elif In an expression, parenthesis can be used to... - ANSChange the natural order of operations and or improve readability. Lexis - ANS(aka a dictionary) a set of words the language offers its users (e.g., the word "computer" comes from the English language dictionary, while "cmoptrue" doesn't; the word "chat" is present both in English and French dictionaries, but their meanings are different) Numbers handled by modern computers are of what two types? - ANSintegers, that is, those which are devoid of the fractional part; and floating-point numbers (or simply floats), that contain (or are able to contain) the fractional part. Semantics - ANSa set of rules determining if a certain phrase makes sense (e.g., "I ate a doughnut" makes sense, but "A doughnut ate me" doesn't) Source code - ANSA program written in a high-level programming language (in contrast to the machine code executed by computers)
Source file - ANSthe file containing the source code Syntax - ANSa set of rules (formal or informal, written or felt intuitively) used to determine if a certain string of words forms a valid sentence (e.g., "I am a python" is a syntactically correct phrase, while "I a python am" isn't) The characteristic of the numeric value which determines its kind, range, and application, is called the... - ANStype True or False: a print() function invoked with more than one argument outputs them all on one line; - ANSTrue True or False: any keyword arguments can be put before the last positional argument - ANSFalse: any keyword arguments have to be put AFTER the last positional argument True or False: Are you allowed to use more than 1 keyword argument? - ANSTrue. Example: Code: print("My", "name", "is", sep="_", end="") Output: My_name_is
What are the rules you must follow when giving a variable a name? - ANS1) the name of the variable must be composed of upper-case or lower- case letters, digits, and the character _ (underscore)
What arguments does print() expect? - ANSprint() is able to operate with virtually all types of data offered by Python. Strings, numbers, characters, logical values, objects - any of these may be successfully passed to print(). What compositions must a computer program have to make sense? - ANSA computer program must make sense: alphabetically - a program needs to be written in a recognizable script, such as Roman, Cyrillic, etc. lexically - each programming language has its dictionary and you need to master it; thankfully, it's much simpler and smaller than the dictionary of any natural language; syntactically - each language has its rules and they must be obeyed; semantically - the program has to make sense. What do the "in" and "not in" operators do? - ANS(in) checks if a given element (its left argument) is currently stored somewhere inside the list (the right argument) elem in my_list The second (not in) checks if a given element (its left argument) is absent in a list
elem not in my_list What does a control variable do when used in a for loop? - ANSit counts the loop's turns, and does it automatically; What does an escape character do? - ANSThe word escape should be understood specifically - it means that the series of characters in the string escapes for the moment (a very short moment) to introduce a special inclusion. What does e stand for when representing scientific notation in Python? - ANSE or e stand for exponent. Ex: 3E8 or 3e8 = 3 x 10^ What does the "break" keyword do? - ANSExits the loop it is in immediately. What does the "continue" keyword do? - ANSbehaves as if the program has suddenly reached the end of the body What does the "pass" keyword do? - ANSNothing. It is simply an empty instruction. What does the append() method do when called on a list? - ANSIt takes its argument's value and puts it at the end of the list which owns the method.
Code: print("Monty", "Python.", sep="-") Output: Monty-Python What does the len() function do? - ANSReturns the number of elements in a list. What does the n after a backslash ( \n ) in a string mean? What is the name of their combination? And what does it do? - ANSn stands for newline and their combination is called a new line character. \n tells the console to start a new output line. What does the range() function do? What is the 3rd argument used for? - ANSthe range() function generates a sequence of integers. The range() function starts its job from 0 and finishes it one step (one integer number) before the value of its argument. A third argument will choose what to increment the list by. What does the reverse() method do when called on a list? - ANSreverse() will reverse all the values in a list. What does the sort() method do when called on a list? - ANSsort() will sort a list as quickly as possible. What does the str() do? - ANSstr() accepts a number and converts it into a string.
What does the type() function do? - ANStype() accepts any variable and returns the class of the variable. What is a literal? - ANSA literal is data whose values are determined by the literal itself. What is an instruction list? - ANSa complete set of known commands. What is an interpreter? - ANSa computer program that directly executes instructions written in a programming language. What is compilation? - ANSThe translation of source code into machine code. What is interpretation? - ANSyou (or any user of the code) can translate the source program each time it has to be run; the program performing this kind of transformation is called an interpreter. What is needed to create a conditional statement? - ANS- the if keyword; -one or more white spaces; -an expression (a question or an answer) whose value will be interpreted solely in terms of True (when its value is non-zero) and False (when it is equal to zero);
What is the equal equal operator? - ANS== What is the equivalent statement for the following statements? list(10:), list(:10) and list(:) - ANSlist(10:(len(list)-1)), list(0:10) and list(0:(len(list)-1)) What is the format of a while loop? - ANSwhile conditional_expression: instruction What is the hierarchy of priorities? - ANSIt determines how operators will act. Ex. multiplications precede additions What is the meaning of keyword arguments? - ANSthe meaning of these arguments is taken not from its location (position) but from the special word (keyword) used to identify them. What is the not equal operator? - ANS!= What is the positional way? - ANSthe fact that the meaning of the argument is dictated by its position, e.g., the second argument will be outputted after the first, not the other way round What is the replication operator and where is it used? - ANSIt is the "*" symbol. It will only operate as a replicator if 1 value is a string and the second value is a number.
What is the slice element of Python syntax? What is it used for? - ANS: - A slice is an element of Python syntax that allows you to make a brand new copy of a list, or parts of a list. What kind of binding do <, <=, >, >=, == and != have? - ANSLeft side binding. What kind of binding does the exponentiation operator use? - ANSThe exponentiation operator uses right-sided binding. What priority do these operators have <, <=, >, >= - ANS What priority do these operators have ==, != - ANS What value does the print() function return? - ANSprint() returns no value, it simply outputs data to the console. What will be the result of print(2+2)? - ANS When used in a string the backslash( \ ) is called an... - ANSescape character Where do the functions come from? - ANSThey may come from Python itself; the print function is one of this kind; such a function is an added value received together with Python and its environment (it is built-in)