Form 4 - Computer
2023-2024
Mr. Peter
Computer Exam on June 18
F4 Exam Coverage:
- List data structure
- While loop statements
- if statements, if...else statements, and if...elif...else statements
- Operators: and & or, arithmetic and relational operators
- Functions: input(), print(), int(), str(), float(), len()
1
Exam Revision01
Parallax Number Increment
Write a Python program that uses a while loop to generate and print two sequences of numbers:
Expected outcome after your program executed
1 2
3 4
......
17 18
19 20
Save the file as "XX_YYYY_revision01.py"
1. Odd numbers starting from 1 and increasing by 2, up to and including 19.
2. Even numbers starting from 2 and increasing by 2, up to and including 20.
Exam Revision02
GDP Growth in China
Assuming China has a GDP of 5,000 billion dollars, and it grows at a constant rate of 6% per year. In the first year, the GDP grows to 5,300 billion dollars. In the second year, the GDP grows by 6% again, resulting in 5,618 billion dollars. The question is, how much will China's GDP have accumulated to after growing continuously for 30 years?
Expected outcome after your program executed
The accumulated GDP after 30 years is: 28717.46 billion dollars
Save the file as "XX_YYYY_revision02.py"
Exam Revision03
Extracting Characters at Odd Indices from a String
Write a Python program that creates a variable storing the string "ILoveComputer", uses a while loop to iterate over the string accessing only the characters at odd indices (1, 3, 5, etc.), merges these characters into a new string, and outputs the new string consisting of the characters from the original string at odd indices.
Expected outcome after your program executed
The new string with characters at odd indices is: LvCmue
Save the file as "XX_YYYY_revision03.py"
F4 Python - Exam Revision
By Mr Peter
F4 Python - Exam Revision
- 231