# Final Review

## Terms and Ideas

Understand and be able to reasonably define the following terms:

• algorithm
• variable
• type
• string
• int
• float
• boolean
• list
• library
• function

## Control Structures

What does the following program print?


for i in range(25):
if i % 2 == 1:
print(i)





Write a program to ask the user for a number between 1 and 10. It should keep looping until a number in that range is given.





## Lists

What does the following program print?


nums = [88, 35, 99, 12]
print(nums[2])






nums = [88, 35, 99, 12]

for num in nums:
print(num - 10)





Given the following list of names:


names = ["Harold", "Anne", "Keyshawn", "Donna", "Joe", "Beatrice"]


Write a program to print out all of the names which are longer than 5 letters.





## Functions

What is the reason for writing functions in a program?





Write a function called max which takes two parameters. It should return whichever of the two is biggest.





It's harder than you probably think to determine if a year is a leap year or not — it's not just every 4 years. The rules are:

1. If the year is divisible by 400 it's a leap year
2. Else if it's divisible by 100 it's not a leap year
3. Else if it's divisible by 4 it is a leap year
4. Otherwise it's not a leap year

Write a function called isLeap which takes a year as a parameter. It should return a boolean for whether the year it's given is a leap year or not.





Write a function called allValid which takes a list of strings as a parameter. It should check if all of the strings have a length of at least 1 (i.e. not empty strings). If so it should return True. If any strings are empty, it should return False.





## Graphics

How are colors represented in a graphical program?





Where is the origin point (0, 0) in a graphical window?