# Python For GCSE Section B Exercises

In a school test, you need to score more than 20 marks to pass the test. The program asks the user to enter a test score. If they score more than 20 marks, the user is told that the test has been passed. Here is a Scratch program that does this job,

Write a Python program that performs the same task.

In a school test, you need to score more than 20 marks to pass the test. The program asks the user to enter a test score. If they score more than 20 marks, the user is told that the test has been passed, if not they are told that they have failed. Here is a Scratch program doing the job.

Write a Python program that performs the same task.

A person can legally drive a car if they are 17 or over and have passed their driving test. The program asks the user for their age and if they have passed their test. These two pieces of information are used to determine if the person is allowed to drive or not.

The key part of this program is the AND block. Look at the Python code and finish off by replacing the red splodges with the correct code.

A program has a menu of choices. The user must enter a number from 1 to 5 in order to access the menu choices. If the user enters a number lower than 1 or higher than 5, the program tells them they have made a mistake.

When you test this program, you might notice that it doesn't work properly if you enter letters. The key part of this program is the OR block. As before, complete the Python code,

Write a program that asks the user for two numbers. Depending on the numbers entered, output one of the following messages.

• The two numbers are equal
• The first number is larger than the second
• The second number is larger than the first

Ask the user to enter the current month, the program should output whether the month is in Winter, Spring, Summer or Autumn.

The basic pseudocode for determining whether a year is a leap year or common year is,

```if year is not divisible by 4 then    common year else if year is not divisible by 100 then    leap year else if year is divisible by 400 then    leap year else    common year```

Write a Python program that tells you whether an integer input by the user represents a leap year or not.

Ask the user to input the number of a month. Display the name of the corresponding month.

Write a program that allows the user to enter an examination score as an integer in the range 0 - 65. Convert the score into a grade using the boundaries specified below.

A - 47, B - 42, C - 37, D - 33, E – 29

Write a program which asks the user to enter their name. If the name that is entered is the same as yours, tell them that they have a cool name. If not, tell them that they should consider changing their name from whatever their name is to whatever your name is.

The following table shows a list of ages and one of the legal rights that a person gets when they reach that age. Use this information to write a program where the user can enter their age and see a list of the legal rights they have.

• 12: See a 12A-rated film at the cinema without an adult.
• 14: Have a job which can be described as 'light work'.
• 15: See a 15-rated film at the cinema without an adult.
• 16: Enter a pub on your own. You cannot buy alcoholic drinks.
• 17: Donate blood.
• 18: Serve on a jury.