0% found this document useful (0 votes)
22 views6 pages

Grade 8 Task 3 Worksheet

This document is a Grade 8 assessment worksheet focused on Python programming concepts. It includes multiple-choice questions, true or false statements, fill-in-the-blank exercises, and error identification tasks related to Python syntax and functionality. The content covers variable assignment, data types, function definitions, and control flow structures.

Uploaded by

r7bpbcjn8g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views6 pages

Grade 8 Task 3 Worksheet

This document is a Grade 8 assessment worksheet focused on Python programming concepts. It includes multiple-choice questions, true or false statements, fill-in-the-blank exercises, and error identification tasks related to Python syntax and functionality. The content covers variable assignment, data types, function definitions, and control flow structures.

Uploaded by

r7bpbcjn8g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Grade 8 Assessment task 3 worksheet

1. What happens when you assign a new value to an existing


variable in Python?
a. Python raises an error.
b. The new value replaces the old one.
c. The variable stores both values.
d. Python ignores the new value.
Answer: b
2. Why can’t you use if as a variable name?
a. It is a reserved keyword.
b. It starts with an underscore.
c. Python doesn’t allow lowercase names.
d. It contains a number.
Answer: a
3. Which of the following is a valid float value in Python?
a. "3.14"
b. 5+3
c. 3.14
d. 5
Answer: c
4. Which statement executes when the if condition is false in if
else statement?
a. None
b. The elif block
c. The if block
d. The else block
Answer: d
5. What is the difference between if and elif in Python?
a. There is no difference.
b. if is used for the first condition; elif is for additional conditions.
c. elif executes regardless of the if condition.
d. if only works in loops, while elif works independently.
Answer: b
6. Which of the following is a float in Python?
a. 10
b. 10.5
c. "10.5"
d. 100
Answer: b) 10.5
7. Which of the following is the correct way to write an if
statement in Python?
a. if x == 5:
b. if(x == 5)
c. if x = 5:
d. if 5 == x:
Answer: a) if x = = 5:
8. Which function is used to get input from the user in Python?
a. input()
b. raw_input()
c. get_input()
d. read_input()
Answer: a) input()
9. Which of the following statements correctly assigns a string
value to a variable?
a. name = "Alaa"
b. 15 = name
c. name : "Alaa"
d. "Alaa" = name
Answer: a) name = "Alaa"

10. What is the correct way to define a function in Python?


a. def function_name():
b. function function_name():
c. func function_name():
d. def: function_name()
Answer: a) def function_name():

11. Which keyword is used to define a function in Python?


a. func
b. define
c. def
d. function
Answer: c) def

12. What is the purpose of the input () function?


a. To get input from the user.
b. To display output.
c. To calculate a value.
d. To return a value.
Answer: a) To get input from the user
13. Can a variable in Python start with a number?
a. Yes, as long as it has a letter after the number
b. No, it cannot start with a number
c. Yes, it can start with any number
d. Yes, but only if the number is between 1 and 9
Answer: b) No, it cannot start with a number

14. Which of the following is a string?


a. 10
b. 5.0
c. 'Hello'
d. True
Answer: c) 'Hello'

True or false:

1. Python is case-sensitive.
a) True
b) False
Answer: a) True
2. You can use spaces in Python variable names.
a) True
b) False
Answer: b) False
3. A variable in Python is a container for storing data values.
a) True
b) False
4. The variable MyVar and myvar refer to the same variable in
Python.
a) True
b) False
Answer: b) False

5. A string in Python is enclosed in either single or double


quotes.
a) True
b) False
Answer: a) True
6. The value "5" is a string, not an integer.
a) True
b) False
Answer: a) True
7. The condition in an if statement must always evaluate to True
or False.
a) True
b) False
Answer: a) True
8. The def keyword is used to define a function in Python.
a) True
b) False
Answer: a) True

fill in the blanks:

1. A __________ data type represents whole numbers. (Answer: integer)

2. A __________ is a number with decimal points. (Answer: float)

3. The __________ data type is used to represent text in Python. (Answer: string)

4. The __________ operator is used to assign a value to a variable. (Answer: =)

5. An __________ statement is used to make decisions in a Python program. (Answer:

if)

6. The __________ statement runs when the condition in the (if else) block is false.

(Answer: else)

7. A function is defined using the __________ keyword. (Answer: def)


The following Python codes has two errors. Find the line number of
each error, identify the type of error and write the corrected
version of the line.

Error # Line Number Error Type Corrected Code


1️ 2 Missing colon : if number >0:
2️ 5 Missing quotation "" print("The number is negative")

Error # Line Number Error Type Corrected Code


1️ 2 Missing quotation "" Input(‘ Enter the second number’)
2️ 3 Missing colon : If number1> number2:

3 7 Missing colon : else:


Good Luck My Girls

You might also like