0% found this document useful (0 votes)
55 views

Python Question GCSE

Python Question GCSE

Uploaded by

smartmohamedx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Python Question GCSE

Python Question GCSE

Uploaded by

smartmohamedx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

PYTHON KNOWLEDGE

CHECK
KNOWLEDGE CHECK 1
Write a python program that calculates the Area of a Rectangle
- ask the user for the length
- ask the user for the width of a rectangle
- calculates the area
- output the area

Do you need help? Use this code to get started:


length = float(input("Enter the length of the rectangle: "))
YOUR ANSWER
KNOWLEDGE CHECK 2
Write a python program that adds two numbers together
- ask the user for number 1
- ask the user for number 2
- calculates the total
- outputs the answer

Do you need help? Use this code to get started:


num1 = float(input("Enter the first number: "))
YOUR ANSWER
KNOWLEDGE CHECK 3
Write a python program that checks if Number is Positive, Negative, or Zero
- ask the user for a number
- check if the number is positive, negative, or zero
- outputs the answer

Do you need help? Here is the start of the if statement (but you need to fugure
out the line before this!):
if number > 0:
YOUR ANSWER
KNOWLEDGE CHECK 4
Write a python program that converts Celsius to Fahrenheit
- ask the user for the Celsius
- calculates the Fahrenheit using the formula below
Fahrenheit=(Celsius×9/5)+32
- output the Fahrenheit

Do you need help? Use this code to get started:


celsius = float(input("Enter temperature in Celsius: "))
YOUR ANSWER
KNOWLEDGE CHECK 5
Write a python program that calculates the average of three numbers
- ask the user for three numbers
- calculates the average
- output the result

Do you need help? Use this code to get started:


num1 = float(input("Enter the first number: "))
YOUR ANSWER
KNOWLEDGE CHECK 6
Write a python program that acts as a simple calculator
- The user should enter two numbers
- The user should enter an operator +, -, *, /
- Calculate the answer by performing the calculation
- Output the result based on the operator

Do you need help? Use this code to get started:


num1 = float(input("Enter first number: "))
YOUR ANSWER
KNOWLEDGE CHECK 7
Write a python program that counts down from 10 using a loop
- counts down from 10 to 1
- displaying each number on a new line
- then output "Blast off!" at the end

Do you need help? Use this code to get started:


for i in range(10, 0, -1):
YOUR ANSWER
KNOWLEDGE CHECK 8
Write a python program that is guessing game
- The computer randomly selects a number between 1 and 100
- The user enters a guess
- If the guess is higher than number output “higher”
- If the guess is lower than number output “lower”
- If the guess is the same as the number output “correct”
- The program should continue until the user guesses correctly

Do you need help? Use this code to get started:


import random
number = random.randint(1, 100)
YOUR ANSWER
KNOWLEDGE CHECK 9

• Write a python program that takes an integer n and displays all prime
numbers up to n.
YOUR ANSWER
KNOWLEDGE CHECK 10

Write a Python program that displays the First 5 Multiples of a Number


- asks the user to enter a number
- then displays the first five multiples of that number

- E.g. If the user entered 5, the program would display, 5, 10, 15 and 20
- If the user entered 4, the program would display, 4, 8, 12, 16
YOUR ANSWER
KNOWLEDGE CHECK 11

Write a program that asks the user to enter five positive numbers, one at a time.
The program should validate that each entry is a positive number.

If an invalid input is given (e.g., a negative number or a non-numeric entry),


prompt the user to re-enter the value.

After all five valid numbers are entered, calculate and display the average.
YOUR ANSWER
KNOWLEDGE CHECK 12
Write a program that asks the user to enter a date in the format
DD/MM/YYYY.

The program should check if the entered date is valid:

•The day should be within the valid range for the given month (e.g., 1-31 for
January, 1-30 for April, etc.).

•Consider leap years (a year is a leap year if it’s divisible by 4, but not by 100,
except when it’s divisible by 400).

•If the date is invalid, display an error message and prompt the user to enter it
again.
YOUR ANSWER

You might also like