PYTHON FINAL EXAM ANSWERS(2012)
1.8.0 % 4
3 / 4
2. 1
3. 40
A Blog On Recent Topics Happening Around The World.
def mystery(s):
""" (str) -> bool
"""
matches = 0
for i in range(len(s) // 2):
if s[i] == s[len(s) - 1 - i]: # <-- How many times is this line reached?
matches = matches + 1
return matches == (len(s) // 2)
mystery('civil')
Trace the function call mystery('civil')
using the Python Visualizer. How many times is the line marked above reached?values = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]Using
values
and indexing with non-negative indices, write an expression that evaluates to 5
. Do not use addition, subtraction, or parentheses ( )
(brackets [ ]
are required).breakfast = [['French', 'toast'], ['blueberry', 'pancakes'], ['scrambled', 'eggs']]
Using breakfast
and indexing with only negative indices, write an expression that evaluates to 'blueberry'
. Do not use addition, subtraction, or parentheses ( )
(brackets[ ]
are required).