Understand and be able to reasonably define the following terms:
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.
What does the following program print?
nums = [88, 35, 99, 12]
print(nums[2])
What about this program:
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.
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:
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.
How are colors represented in a graphical program?
Where is the origin point (0, 0) in a graphical window?
Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.