Pair work Ch 1.3
- Due Jan 28, 2022 by 9:50am
- Points 1
- Available after Jan 28, 2022 at 9am
- The Library of Congress stores its holdings on 838 miles of shelves. Assuming an average book is one inch thick, how many books would this hold? Write Python code to solve this problem.
- Suppose we want to swap the values of two variables named word1 and word2. Will the following code swap their values? If not, why?
word1 = 'hi'
word2 = 'bye'
# Swap word1 and word2
word1 = word2
word2 = word1
print(word1) # Should be 'bye'
print(word2) # Should be 'hi' -
Show how you can use the
int
function to find the fractional part of any positive floating point number. For example, if the value 3.14 is assigned to number, you want to output 0.14. Your expression should work with any value of number.
These questions are based on problems from Havill, Ch. 1.3