Programming October Break Workbook
Programming October Break Workbook
Python 1 section
Name:
Class:
Created by Mr Suffar
Question 17
Answer:
Created by Mr Suffar
Question 19
?
?
?
?
?
Created by Mr Suffar
25. The program below must store 365 in a variable called daysinyear and then ask the
user for their age. Then display how many days, hours, minutes and seconds they lived.
daysinyear = ____
age = ____(_____("Enter your age"))
totaldays = daysinyear*____
print("You have lived",_____, "days")
hours = totaldays*____
print("You have lived",____, "hours")
_____ = hours*60
print("You have lived",_____, "minutes")
seconds = _____*____
print("You have lived",seconds, "______")
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
26. The program below must display a message to ask the user to calculate angle 3 in a
triangle then asks for angle1 and angle2 then displays the value of angle 3 in a full
sentence.
_____("The sum of the angles of a triangle is 180° ,calculate angle3")
angle1 = float(_____("Enter the value of angle 1"))
angle2 = _____(input("Enter the value of angle 1"))
angle3 = ____-_____-_____
print("Angle3 is "+str(_____)+"°")
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
27. Ask the user for 2 numbers then divide the first number by the
second number. Display the answer. To divide numbers use /
Paste your code below:
Created by Mr Suffar
49. Create a program that:
• Ask the user for 3 numbers.
• Create a variable called answer and store the value of the first number multiplied by
the second number.
• Create another variable called “finalanswer” and store the value of the “answer”
variable divided by the 3rd number.
• Display the value of finalanswer.
Paste your code below:
Created by Mr Suffar
50. A pay to win Fifa player is buying Fifa coins to buy players. Players receive 105 Fifa coins
per 1$.
Create a program that:
• Asks the user how much they want to spend on fifa coins in $. Hint: use float.
• Display the number of coins the player will receive rounded to the nearest whole
number.
Paste your code below:
Created by Mr Suffar
51. Create a program that:
• Ask how many apples the user wants.
• Ask how many people the user will share the apples with.
• Finds out how many apples will remain if you share the apples equally.
• Hint: use modulo % (finding the remainder).
• Display the how many apples remain in a full sentence.
Paste your code below:
Created by Mr Suffar
71. Copy the code below, run it and test it, then explain the purpose of the program/what
the program does.
Explain the purpose of the code below:
# Example purchase amount
purchase_amount = 150
# If statement to determine discount
if purchase_amount >= 1000:
discount = 0.2 # 20% discount
elif purchase_amount >= 500:
discount = 0.1 # 10% discount
elif purchase_amount >= 200:
discount = 0.05 # 5% discount
else:
discount = 0 # No discount
discount_amount = purchase_amount * discount
final_amount = purchase_amount - discount_amount
print("Purchase amount:", purchase_amount)
print("Discount:", discount_amount)
print("Final amount:", final_amount)
Answer:
Created by Mr Suffar
72. The program below must: Ask for a country name, display Pyramids if “Egypt” is
entered, displays COLD! If “Iceland” is entered, displays Taj Mahal if “India” is entered.
Display Accepted for any other choice.
Copy the code below, run it and fix the errors.
country = input("Enter a country name"
if country = "Egypt":
print("Pyramids")
elseif country == Iceland:
print("COLD!")
elif countrys == "India"
print(Taj Mahal")
else
prints("Accepted")
Paste the correct version below:
Created by Mr Suffar
73. The program below must: Ask the user for a score, then determines the grade.
Copy the code below, run it and fix the errors.
score = int(input("Enter the score"))
if score >= 90
grade = "A"
elif score => 80:
grade = "B"
elif score >= "70":
grade = "C"
elif score >= 60
grade = D
else:
grade = "F"
print("The grade is" grade)
Paste the correct version below:
Created by Mr Suffar
74. The program below must: ask for price and then set the category to
Low/Medium/High/Premium depending on the price. It then displays the category. Low is
below 10, medium is between 10 and 30, high is between 30 and 49. Premium is 50 or
above.
Copy the code below, run it and fix the errors.
price = floa(input("Enter price"))
# Nested if statement
if price < 10
category = Low"
elseif price < 50:
if price < 30:
category "Medium"
else:
category = "High"
else:
category = "Premium
print("Category:" category)
Paste the correct version below:
Created by Mr Suffar
Task 99
Answer:
Created by Mr Suffar
105. The program below must: The program must take 2 inputs, grade and income,
representing the student's grade and annual income, respectively. The if statement checks
the grade and income against specific criteria to determine the scholarship eligibility. If
the grade is 90 or above and the income is less than $60,000, the student is eligible for a
full scholarship. If the grade is 80 or above and the income is less than $80,000, the
student is eligible for a partial scholarship. If the criteria for either scholarship is not met,
the student is not eligible for a scholarship. Finally, it prints the scholarship eligibility
status.
Copy the code below, run it and fix the errors.
grade = int(inrput("Enter grade"))
income = int(input("Enter income")
# If statement to determine scholarship eligibility
if grade >= 90 and income < 60000
eligibility = "Eligible for Full Scholarship"
elif grade >= 80 or income < 80000:
eligibility = "Eligible for Partial Scholarship"
else
eligibility = "Not Eligible for Scholarship"
print("Scholarship eligibility:", eligibilityyy)
Paste the corrected version below
Created by Mr Suffar
106. Create a program that:
• Ask user for age, display “You are eligible for this program” if the user is between 18
and 30 inclusive. Otherwise display “You are not eligible for this program.”
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
107. Create a program that:
• Asks the user for a number, display “The number is even and positive” if the number is
even and also positive at the same time. Otherwise display “The number is not even
and positive.”
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
108. Create a program that:
• Gives users a message depending upon how happy they say they are.
Ask the user how happy they feel on a scale between 1 and 10. If the reply is 3 or less
it gives one message. Between 4 and 7 (including these numbers) they get another
message.
8 and above they get a different message.
Try to make the messages ones to make them happy all day long!
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
Task 118
Created by Mr Suffar
124) The following formula is used to convert Celsius to Fahrenheit: Y°F=(X°C × 9/5) + 32
The following formula is used to convert Fahrenheit to Celsius: X°C=(Y°F − 32) × 5/9
represents the value in Celsius and Y represent the value in Fahrenheit.
Use the formula above to create an algorithm that converts Celsius to Fahrenheit.
Your algorithm must:
• Ask the user whether they want to convert from (Celsius to Fahrenheit) or (Fahrenheit to
Celsius)
• Ask the user for the temperature.
• Converts the temperature into what the user picked.
• Displays the answer in a full sentence.
Paste your code below:
Created by Mr Suffar
125) Create a program that:
• Asks the user if it’s August or not.
• If they answer yes, display “Yay summer holiday”
• Otherwise ask them if it’s the weekend.
• If the answer is yes, display “Yay no school”.
• Otherwise display, “Bad luck, you have school today”.
• Use nested if statement (An if statement inside another if statement”)
Paste your code below:
Created by Mr Suffar
126) Create a program that: Asks the user to enter a decimal number. Round the decimal number to the
nearest whole number then display the number and also display whether that number is even or odd.
Paste your code below:
Created by Mr Suffar
127) Create a program that:
• Asks the user enter today’s day (Monday, Tuesday etc.…)
• Displays “Yay it’s the weekend” if the user enters Saturday or Sunday.
• Displays how many days left until the weekend. (Example: “5 days until the weekend if
the user enters Monday”)
• Use nested if statement (if statement inside another if statement)
Paste your code below:
Created by Mr Suffar
Task 143
Created by Mr Suffar
Task 144
Created by Mr Suffar
151. Create a program that:
• Asks the user for firstname.
• Asks the user for surname (use the firstname inside the question – example below)
• Using concatenation to display the firstname and surname in a full sentence.
• Use + sign to concatenate.
Paste your code below:
Created by Mr Suffar
152. Create a program that:
• Asks the user for their favourite drink.
• Store the length of the string in a variable called “drinkLength”
• Display the length of the drink on the screen in a full sentence.
Paste your code below:
Created by Mr Suffar
153. Create a program that:
• Asks the user for their firstname.
• Ask the user for their surname
• Concatenate the two strings(variables) together without space and store it in a variable
called “total”.
• Display the total length of firstname+surname.
Paste your code below:
Created by Mr Suffar
163. Create a program that:
• Ask the user to enter an animal that contains 4 letters.
• If the user enters the correct answer. Display “well done”
• Otherwise display “incorrect”.
Hint: len(animal)
Paste your code below:
Created by Mr Suffar
164. Create a program that:
• Ask the user to enter their first name.
• Ask the user to enter their surname.
• Ask the if they want to see the first letter of firstname&surname or the last letter of
firstname&surname.
• If they enter “first”, display the first letter of their first name and the first initial of their
surname joined together using concatenation.
• If they enter “last”, display the last letter of their first name and the last letter of their
surname.
• Otherwise, display “wrong option”
Paste your code below:
Created by Mr Suffar
172. In a school, a student username is created by extracting first 2 letters of firstname, first
3 letters of surname, last 2 numbers of the year and it adds a hashtag depending on the
number of other students with the same surname. For example: if a student named Bob
Liam joined in 2023 and there are 2 other people in the school with the surname Liam,
then the username of this student is: “BoLia23##”
• Create a program that asks the user for firstname, surname, year joined and number of
other students with same surname then display the username of the student.
Paste your code below:
Created by Mr Suffar
TASK 173
Answer:
Created by Mr Suffar
Task 174
Answer:
Created by Mr Suffar
175. A car registration code needs to be entered before a car can be registered. The
registration code must start with a capital letter and must be followed by a number
between 0 and 9.
Create a program that:
Asks the user to enter the registration code.
Checks and displays whether the code is valid or invalid.
Paste your code below:
Created by Mr Suffar
178. Create a program that:
Asks the user to enter 5 numbers, for each number, if the number is odd, display the
number followed by “is odd”. If the number is even, display the number followed by “is
even”.
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
179. https://youtu.be/m4feUCbSbIU
• Copy the code below and run it.
• Then change the % to a "$".
• Run it again then comment on the code to explain the purpose of the code.
Created by Mr Suffar
180. Use a for loop to display “welcome” 100 times. Then display “bye” ONCE.
Paste your code below:
Created by Mr Suffar
181. Ask the user for a number. Repeat ‘I like turtles’ a certain number of times, based on a
number entered by the user. (If the user enters 5, display I like turtles 5 times)
Paste your code below:
Created by Mr Suffar
201) Create a program that:
• Displays all odd numbers between 1 and 99.
Paste your code below:
Created by Mr Suffar
202) Create a program that:
• Displays all even numbers between 1 and 100.
Paste your code below:
Created by Mr Suffar
203. Create a program that counts and displays all numbers from 15 to 25.
Paste your code below:
Created by Mr Suffar
210. Copy the code below, run it and test it, then explain the purpose of the
program/what the program does.
Explain the purpose of the code below:
total = 0
for x in range(10):
num = int(input("Enter a number"))
if num % 2 == 0:
total = total + num
print("Sum of even numbers:", total)
Answer:
Created by Mr Suffar
211. The program below must: Display all numbers from 1 to 10 inclusive. Adds each
number to a total then displays the total at the end.
Copy the code below, run it and fix the errors.
total = 5
for num1 in range(1, 115)
print(num
total = num + total1
print("Sum of numbers:" total)
Paste the correct version below:
Created by Mr Suffar
212. The program below must: Asks the user to enter 10 numbers, counts how many
numbers entered are above 1000. Display the answer at the end.
Copy the code below, run it and fix the errors.
count = 4
for i in range(10:
num = int(input("Enter a number: ")
if num == 1000:
count = count - 1
print("The number of numbers above 1000 is:" count)
Paste the correct version below:
Created by Mr Suffar
213. Create a program that: Asks the user for 5 numbers, calculates and displays the
highest and lowest number
highest = ____
lowest=____
for x in range(___):
num = ___(___("Enter a number"))
if num > ___:
___ = num
if num < ___:
lowest = ___
print("Highest:",___)
print("Lowest:",___)
Copy the code above, fill the gaps then paste your code below:
Created by Mr Suffar
214. In python,
• use a count controlled loop (for loop) to ask the user for 10 numbers and add each number
to the total.
• Display the total after every number that is entered.
• Display the average of the 10 numbers at the end.
Paste your code below:
Created by Mr Suffar