Chapter 2 Exercise Set 2: PCEP Practice¶
print()
and its arguments¶
Modify the first
print
statement in this code:print("Python", "for", "Web") print("Developers")
using
sep
andend
keyword arguments so that together they print:Python++for++Web**Developers
Ways to write numbers¶
Convert each of the following into digit only integers in base 10:
12_345_681
0o12
0O_21
0x12
0X21
Convert the following into base 10 decimal numbers without exponents.
4e2
23e-3
Comparing True
and False
¶
Describe and explain the output of the following two statements:
print(True > False) print(True < False)
Quotes in strings¶
Write a single line
print
statement that produces the following output:"I'm" ""learning to"" ''program'' with """Python"""
Types of literals¶
What is the type of each of the following literals?
"Python"
"42"
42
42.
False
'False'
Operators, precedence, and left-sided and right-sided binding¶
How will the Python interpreter evaluate each of the following expressions?
>>> print((-3 / 6), (3 / 6), (3 // 6), (-3 // 6))
>>> print((2 % -4), (2 % 4), (2 ** 3 ** 2))
Variables¶
What two things does every Python variable have?