Introduction to Python

Form 3 - Computer

2023-2024

Floor 4 - Computer Room

Mr. Peter

Computer Exam on June 25

F3 Exam Coverage:
- 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(), upper(), lower()

1

While Loop Statement

1.

2.

Tab

while Condition :

Command1

1.

2.

Exam Revision01

Generating a Sequence of Asterisk Patterns in Python with Incremental Steps

Write a Python program that prints a series of lines, each containing a number of asterisks (*) starting from 1 and increasing by 5 until it reaches 100 or less. Each line should show the step count and the corresponding number of asterisks.

Expected outcome after your program executed

Save the file as "XX_YYYY_revision01.py"

*
******
***********
****************
*********************
**************************
*******************************
************************************
*****************************************
**********************************************
***************************************************
********************************************************
*************************************************************
******************************************************************
***********************************************************************
****************************************************************************
*********************************************************************************
**************************************************************************************
*******************************************************************************************
************************************************************************************************

1.

2.

Exam Revision01

Generating a Sequence of Asterisk Patterns in Python with Incremental Steps

Write a Python program that prints a series of lines, each containing a number of asterisks (*) starting from 1 and increasing by 5 until it reaches 100 or less. Each line should show the step count and the corresponding number of asterisks.

Expected outcome after your program executed

Save the file as "XX_YYYY_revision01.py"

*
******
***********
****************
*********************
**************************
*******************************
************************************
*****************************************
**********************************************
***************************************************
********************************************************
*************************************************************
******************************************************************
***********************************************************************
****************************************************************************
*********************************************************************************
**************************************************************************************
*******************************************************************************************
************************************************************************************************

1.

2.

Exam Revision02

Creating a Diamond Shape with Asterisks

Write a Python program that prints a diamond shape made of asterisks (*). The diamond should have the first part consisting of lines with an increasing number of asterisks from 1 to 6, centered with appropriate spaces, and the second part should have lines with a decreasing number of asterisks from 5 to 1, also centered with appropriate spaces.

Expected outcome after your program executed

Save the file as "XX_YYYY_revision02.py"

     *
    ***
   *****
  *******
 *********
***********
 *********
  *******
   *****
    ***
     *

F3 Python - Exam Revision

By Mr Peter

F3 Python - Exam Revision

  • 204