Docsity

Python Exercises GCSE Computer Science, Exams of Computer science

Toggle sidebar
bg1
Practice Exercise 1
1. Write a program to print out the number of seconds in a 30 day month.
2. Write a program in Python to print out the number of seconds in a year.
3. Using Python as a calculator, work out the following problem:
a. A high-speed train can travel at an average speed of 150mph. How long will it take a
train travelling at this speed to travel from London to Glasgow which is 414 miles
away?
Give your answer in minutes.
………………………………………………………………………………………………………………………………
4. Using the help facility on Python. Type help() to start the online facility, then “keywords” to
view the keywords that are available in Python. Get help on the “if” keyword.
5. Use Python to calculate the following:
a. 49/7
b. 8**2
c. 20%3
d. 17//3
e. 7**3
6. Use Python to evaluate the following:
a. If you are going on holiday to France, how many Euros would you get when you
convert £500 at an exchange rate of £1 = €1.20
………………………………………………………………………………………………………………………….
b. On return from your holiday, you now have €320. How many GBP would you
receive at an exchange rate of £1 = €1.32.
………………………………………………………………………………………………………………………….
pf3
pf4

Partial preview of the text

Download Python Exercises GCSE Computer Science and more Exams Computer science in PDF only on Docsity!

Practice Exercise 1

  1. Write a program to print out the number of seconds in a 30 day month.
  2. Write a program in Python to print out the number of seconds in a year.
  3. Using Python as a calculator, work out the following problem: a. A high-speed train can travel at an average speed of 150mph. How long will it take a train travelling at this speed to travel from London to Glasgow which is 414 miles away? Give your answer in minutes. ………………………………………………………………………………………………………………………………
  4. Using the help facility on Python. Type help() to start the online facility, then “keywords” to view the keywords that are available in Python. Get help on the “if” keyword.
  5. Use Python to calculate the following: a. 49/ b. 8** c. 20% d. 17// e. 7**
  6. Use Python to evaluate the following: a. If you are going on holiday to France, how many Euros would you get when you convert £500 at an exchange rate of £1 = €1. …………………………………………………………………………………………………………………………. b. On return from your holiday, you now have €320. How many GBP would you receive at an exchange rate of £1 = €1.32. ………………………………………………………………………………………………………………………….
  1. The volume of a sphere is given by . Use Python to find the volume of a sphere with a radius of 10cm. ………………………………………………………………………………………………………………………………………….
  2. Insert brackets in the expression 36 / 9 -2 to get: a. 2 b. 5.

Practice Exercise 2

  1. Write a program that assigns the variables length and width as 18 and 7 respectively. Use the variables to calculate the perimeter and area of the rectangle.
  2. Write a Python program that defines a variable called days_in_school_each_year and assign 192 to the variable. The program should then print out the total hours that you spend in school from Year 7 to Year 11, assuming that each day you spend 6 hours in school.
  3. What value will be printed on the screen? marks = 25 marks = marks + 10 print(marks)

a. 365 = days_in_a_year b. There are 365 days in a year c. days in a year = 365 d. days_in_a_year = 365 e. daysInAYear = 365