Python Certification Exam Preparation

Problems encountered during test preparation.

Python 3.13.4 (tags/v3.13.4:8a526ec, Jun 3 2025, 17:46:04) [MSC v.1943 64 bit (AMD64)] on win32
Enter "help" below or click "Help" above for more information.
>>> my_bool = False + 5 - True + 35//4
>>> my_bool
12
>>> print('Here is what I have: ', (7/2) + (False or True) + (9%3))
Here is what Ihave: 4.5
>>> 7/2
3.5
>>> (7/2) + (False or True)
4.5
>>> 9%3
0
>>> x = 3
>>> text = 'I have ' + x + '\ncars in my garage.'
Traceback (most recent call last):
File "<pyshell#1>", line 1, in
text = 'I have ' + x + '\ncars in my garage.'
TypeError: can only concatenate str (not "int") to str
>>> y = 4 + 2i
SyntaxError: invalid decimal literal
>>> y
>>> y = 4 + 2j
(4+2j)
>>> type(y)
<class 'complex'>
>>> True and False
False
>>> test = "TEST"
>>> result = test[0] + test[-1]
>>> result
'TT'
>>> content = 'Learning Python is interesting especially when using strings'
>>> x = content.find('in', 6)
>>> x
19
>>> result = content[x:30].capitalize()
>>> result
'Interesting'
>>> print(str.rfind.__doc__)
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
Optional arguments start and end are interpreted as in slice notation.
>>> print(str.find.__doc__)
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].
Optional arguments start and end are interpreted as in slice notation.
>>> "This" is "This".upper()
False
>>> math.isqrt(17)
4
>>> math.sqrt(16)
4.0
>>> math.isnan(float('nan'))
True
>>> amount = 1250
>>> print("{:10.2f}".format(amount))
___250.00
:0)