ICT Grade 7 Worksheet Chapter 3 -Answer Key
ICT Grade 7 Worksheet Chapter 3 -Answer Key
a) An 'Event' block
b) A variable block
c) An operator block
d) A say block
6. In the algorithm for adding two numbers, what are the key inputs?
a) Number 1 and Result
b) Number 2 and Operator
c) Number 1 and Number 2
d) Result and Input
7. An algorithm sets out the inputs and outputs of a program. What else does it set out?
a) The programming language
b) The hardware requirements
c) The processes to transform inputs into outputs
d) The cost of development
a) result
b) answer
c) number 1
d) number 2
2
10. Scratch provides two ready-made Variables are
1. The Scratch programming language allows users to create colorful interfaces. True
2. An algorithm is a plan to solve a problem. True
3. Variables in Scratch cannot store values. False
4. The program starts when the user clicks on Green Flag in Scratch. True
5. The 'my variable' in Scratch is an event block. False
1. Arithmetic Operators are symbols and terms used in programming and used to perform
mathematical calculations.
8. Variable Name is used to remind you what value the variable will store.
3
Question 4: Answer the Following:
1. Explain the purpose of an event block from scratch.
6. How can you use the 'ask' block to get user input in Scratch?
The 'ask' block is used to display a question to the user.
It pauses the program and waits for the user to type an answer.
The user's response is stored in the "answer" variable.
This response can be used in subsequent parts of the program.
a) +
b) -
c) =
d) *
5. What does the following Python command do? name = input("What is your name? ")
a) It assigns "What is your name?" to the variable name.
b) It prints the question and stores the user's input in the variable name.
c) It prints the variable name.
d) It creates a variable with a default value of "What is your name?".
5
6. What is Python?
a) A type of computer hardware
b) A text-based programming language
c) A graphical user interface
d) A web browser
8. Which of the following is a correct way to assign the value "Hello, world!" to a variable
named greeting?
a) greeting = "Hello, world!"
b) "Hello, world!" = greeting
c) set greeting to "Hello, world!"
d) print("Hello, world!")
6
11. What should you do if you receive an error message in Python?
a) Ignore it and continue
b) Read it to understand the mistake and correct it
c) Restart the Python Shell
1. The text inside the brackets of the Input function is called the prompt
2. When you start Python, a window opens, this is called Python Shell
7
Question 4: Answer the Following:
1. How do you get user input in Python?
You use the input() function to get user input.
For example, name = input("Enter your name: ") prompts the user to enter their name and
stores it in the variable name.
The text inside the parentheses of input() is the prompt shown to the user.
2. What should you do if you make a mistake when typing a Python command?
Read the error message provided by Python to identify the issue.
Correct the mistake and retype the command.
Re-run your program: Test the corrected code to ensure it works as expected.
The Python Shell is an interactive environment where you can execute Python code line by
line.
It allows you to quickly test small parts of code.
It provides immediate feedback, making it useful for debugging and learning Python
✓ Error messages identify mistakes in your code and provide information about what went
wrong.
✓ They often include the type of error and the line number where it occurred, helping you
pinpoint the issue.
✓ By learning from error messages, you improve your coding skills and avoid similar mistakes
in the future.
• Start with a letter: Variable names must begin with a letter (uppercase or lowercase).
• Use only letters, numbers, and underscores: Avoid using special characters like $, %, or
@.
• Case-sensitive: myVariable and myvariable are different variables.
• No spaces: Use underscores to separate words in variable names (e.g., my_variable).
7. Write the Python command to create a variable called city with the value "Paris".
city = "Paris"
8
8. Write the Python command to ask the user "How old are you?", get their input, and
store it as the variable age.
9. Write a Python program that asks the user for their name and age. Then, print a
message that greets the user and tells them their age in 5 years
future_age = age + 5
print("Hello,", name)
9
LESSON -3.3
Question 1: Choose the correct answer from the options given:
1. What is the advantage of making a program file instead of typing commands in the
Python Shell?
2. Which menu do you use to create a new file in the Python Shell?
a) Edit
b) File
c) Run
3. What do different colors in the Python program file window help you identify?
4. What error message would you see if you forget to put quote marks around a text
string?
b) A text editor
c) A web browser
10
6. What does the error message "NameError: name 'variable' is not defined" mean?
8. Which menu option do you use in the Python Shell to create a new file?
9. What happens when you click on ‘Run Module’ in the Python IDE?
10. In the Python program file window, what color are text strings displayed?
a) Black
b) Purple
c) Green
11. Which of the following is the correct way to print "hello" in Python?
a) Print(hello)
b) print(hello)
c) print("hello")
11
12. Which of the following is NOT a feature of the Python IDE?
A) Syntax highlighting
Question 2: State whether the following statements are true (T) or false (F):
1.In the Python program file window, variable names are displayed in green F
2. Text strings in Python are shown in purple in the program file window F
3. Errors in Python can prevent a program from running. T
4. A program file in Python can be edited and saved multiple times. T
5.The 'Print' command in Python should start with a capital letter. F
EOL while
print Web page IDE File NameError scanning
string literal.
1. The software used to write and run programs in Python is called an Integrated
Development Environment (IDE).
4. The File menu in the Python Shell is used to create and save new program files.
5. When you forget to put quote marks, the error message says NameError.
6. When you forget to close a string with a second set of quote marks, the error message
says EOL while scanning string literal.
12
Question 4: Answer the Following:
1. What should you do to fix the error in the command 'Print(hello)'?
2. What is the advantage of making a program file instead of typing commands in the
Python Shell?
it allows you to save and reuse your code. This saves time and effort, as you don't have to
retype the same commands each time you want to run the program. Additionally, it helps you
organize your code and makes it easier to debug and modify.
3. What are the different colors used in the Python program file window, and what do they
represent?
5. Explain two different ways you can find errors in your Python programs.
• the color of the commands you type, help you find errors in your commands. The color
of the text shows you that the words are typed incorrectly. For example, Print (hello)
The word print should be purple. The word 'hello" should be green.
13
• Python provides detailed error messages when a program runs into issues. These
• Type of Error: This tells you what kind of error has occurred (e.g., Syntax Error,
NameError, etc.). Location: The message often indicates the line number and the
specific part of the code where the error occurred. Description: A brief explanation of
why the error happened, which helps in understanding what needs to be fixed.
6. Describe one difference between the IDE for Scratch and the IDE for Python.
One difference between the IDE for Scratch and the Python IDE is that Scratch uses a visual
block-based programming interface, while Python IDEs typically use a text-based interface. This
means that in Scratch, you drag and drop blocks to create your program, while in Python, you
write code using text and specific syntax.
14
LESSON -3.4
Question 1: Choose the correct answer from the options given:
1. What is a data type in Python?
a) a way to organize your code
b) a category that defines how data is stored and used
c) a special keyword used in functions
6. Why did a python program output "8090" instead of the sum of 80 and 90?
a) forgot to add a print statement.
b) Input values are stored as strings by default in Python.
c) Python does not support addition of numbers entered as input.
15
7. Which Python function converts a string to an integer?
a) str()
b) int()
c) input()
8 .What will the following code output? print("Python" * 3)
a) "PythonPythonPython"
b) "Python 3"
c) "Python"
12. If you enter the command total = number1 + number2 in Python, what does it do?
b) It creates a variable called total and assigns it the sum of number1 and number2.
a) 170
b) 8090
c) Error
a) variable = str(variable)
b) variable = float(variable)
c) variable = int(variable)
a) String
b) Integer
c) Float
a) 1variable = 10
b) variable1 = 10
c) variable 1 = 10
17
Question 2: State whether the following statements are true or false:
1. A variable that stores a decimal number is typically of the float data type.
18
Question 4: Answer the Following:
number_str = "10"
number_int = int(number_str)
3. What are the steps to create a Python program that adds two numbers together?
1. Get input: Use the input () function to get two numbers from the user and store them in variables.
2. Convert to integers: Convert the input strings to integer data types using the int() function.
3. Perform addition: Add the two integers and store the result in a new variable.
4. Print the result: Use the print () function to display the calculated sum.
4. Write a command to convert the points variable to any numerical data type (integer or float).
points = int(points)
points = float(points)
19
5. Write the Python command to assign value 9.99 to a variable called price.
price = 9.99
6. Write a Python expression to calculate the area of a rectangle with width 5 and height 3.
area = 5 * 3
print("-" * Number1)
20