(copy)
Grade 9 Final Term Revision Questions
A. Theoretical Questions (Q and A)
What is programming?
Programming is the process of designing and building executable computer software to accomplish a specific task.
Example: Writing a code to calculate the sum of two numbers using Python.
def add_numbers(a, b):
return a + b
What are the various types of data in Python?
Python supports several data types: integers, floats, strings, booleans, lists, tuples, dictionaries, and sets.
Example Program using a List:
fruits = ['apple', 'banana', 'cherry']
print(fruits)
What is Type casting? What are its types?
Type casting is the conversion of one data type into another.
Types:
Implicit Casting: Automatically done by Python.
Explicit Casting: Manual conversion using constructors.
Example:
x = 1 # Integer
y = float(x) # Explicitly cast to float
What is a dictionary in Python?
A dictionary is a collection of key-value pairs.
Methods of a Dictionary:
dict.keys()dict.values()dict.items()dict.get(key)dict.pop(key)
What is a list in Python?
A list is an ordered collection of items which can be of different datatypes.
Methods of a List:
list.append(item)list.remove(item)list.insert(index, item)list.pop(index)list.sort()
How are the elements of a list in Python accessed?
Elements of a list are accessed using indexing. The index starts from 0.
Example:
my_list = [10, 20, 30]
print(my_list[0]) # Outputs 10
What is looping in Python?
Looping refers to executing a block of code repeatedly.
Example of a For Loop:
for i in range(5):
print(i)
What is iteration in Python?
Iteration is the process of executing a set of statements repeatedly.
Example:
items = [1, 2, 3]
for item in items:
print(item)
What are functions in Python?
Functions are blocks of reusable code that perform a specific task.
User-defined functions: Functions created by the user.
Built-in functions: Predefined functions in Python.
Example of a User-defined Function:
def greet(name):
return f"Hello, {name}!"
What is SDLC?
Software Development Life Cycle (SDLC) is a process framework for planning, creating, testing, and deploying information systems.
Diagram:
Requirement Analysis
Planning
Design
Implementation
Testing
Deployment
Maintenance
What is HTML?
HTML stands for HyperText Markup Language, the standard markup language for documents designed to be displayed in a web browser.
What are tags in HTML?
Tags are the fundamental building blocks of HTML that define the structure of web pages.
Types of HTML:
Structural Tags (e.g.,
<html>,<body>)Formatting Tags (e.g.,
<b>,<i>)List Tags (e.g.,
<ul>,<ol>,<li>)
Open and Closed Tags in HTML:
Open Tags: Tags that define the beginning of an element. Example:
<p>Closed Tags: Tags that define the end of an element. Example:
</p>
5 Open Tags and 5 Closed Tags in HTML:
Open Tags:
<html>,<body>,<div>,<h1>,<p>Closed Tags:
</html>,</body>,</div>,</h1>,</p>
Differences:
a.
<HTML>vs<HEAD>:<HTML>represents the entire HTML document, while<HEAD>contains metadata and links.
b.
<p>vs<img>:<p>is a block-level element for text, while<img>is used to embed images.
c.
<img>vs<a>:<img>is for images, while<a>is an anchor tag for hyperlinks.
d.
<li>vs<table>:<li>is used for list items, while<table>defines a table structure.
e.
<ul>vs<table>:<ul>defines an unordered list, while<table>is for tabular data.
f.
<ol>vs<li>:<ol>defines an ordered list, while<li>is used for list items in both ordered and unordered lists.
Full form of HTML: HyperText Markup Language
Full form of CSS: Cascading Style Sheets
Sample Structure of CSS in Web Development:
body {
background-color: lightblue;
}
h1 {
color: white;
}
Cyber Security:
Cyber Security refers to the practice of protecting systems, networks, and programs from digital attacks.
Cyber Bullying:
Cyber Bullying involves the use of electronic communication to bully a person, typically by sending messages of an intimidating or threatening nature.
Cyber Crime:
Cyber Crime encompasses any criminal activity that involves a computer and a network.
Firewall:
A Firewall is a network security device that monitors and controls incoming and outgoing network traffic based on predetermined security rules.
Digital Footprint:
A Digital Footprint is the trail of data you leave behind while using the internet.
Malware:
Malware is malicious software designed to harm, exploit, or otherwise compromise a computer system.
Antivirus:
Antivirus is software designed to detect and destroy computer viruses and other malicious software.
Differences Between Antivirus and Firewall:
a. Antivirus software scans for and removes malware, while a Firewall blocks unauthorized access to or from a private network.
b. Antivirus works mainly on individual computer systems, while a Firewall can be hardware or software protecting a network.
c. Antivirus can be installed on multiple devices, while Firewalls can protect entire networks.
Differences Between Virus and Malware:
a. A virus is a type of malware specifically designed to replicate and spread.
b. Malware is a more general term for any malicious software, while a virus specifically requires human action to propagate.
c. Some malware (such as spyware) does not replicate itself like a virus does.
Differences Between Ransomware and Malware:
a. Ransomware is malware that demands payment to restore access to data, while malware is a general term for malicious software.
b. Ransomware typically encrypts files, while other malware may steal data without encryption.
c. Ransomware primarily focuses on extorting money, while malware may serve various purposes, including data theft or damage.
Is Digital Footprint beneficial?
No, it has various disadvantages:
Privacy concerns as personal information may be exposed.
Potential for misuse of personal data by malicious users.
Long-term effects on reputation and employability.
What are web browsers?
Web browsers are software applications for accessing information on the World Wide Web.
Examples: Google Chrome, Mozilla Firefox.
What are Search Engines?
Search engines are systems designed to carry out web searches and provide results based on user queries.
Examples: Google, Bing.
Differences between email and messaging:
1. Emails can contain larger files and are typically used for formal communication, while messaging is more immediate and casual.
2. Email requires a subject line and can be slower, while messaging is often real-time with no subject required.
B. Short Theoretical Questions
What is a protocol in the internet?
A protocol is a set of rules that determine how data is transmitted and received over a network.
Write full forms of:
a. HTTP: HyperText Transfer Protocol
b. HTTPS: HyperText Transfer Protocol Secure
c. SMTP: Simple Mail Transfer Protocol
d. W3C: World Wide Web Consortium
e. ARPA: Advanced Research Projects Agency
f. FTP: File Transfer Protocol
g. CSS: Cascading Style Sheets
h. MFA: Multi-Factor Authentication
i. URL: Uniform Resource Locator
j. CPU: Central Processing Unit
k. RAM: Random Access Memory
Write 3 Antivirus software:
Norton Antivirus
McAfee
Avast
Define the following:
a. Netiquette: The code of acceptable online behavior.
b. Digital Citizenship: The ability to participate in society online responsibly and safely.
c. Online Privacy: The right to keep personal information private while using digital services.
d. Online Bullying: Bullying that takes place over digital devices through messaging, social media, and other online spaces.
Define Cyber Law in a single sentence:
Cyber Law refers to legal regulations governing the internet and digital communications.
Define these terms:
a. Application Software: Software designed to help the user perform specific tasks.
b. Internet: A global network of interconnected computers.
c. Keyboard: An input device used to type and enter data.
d. Computer Virus: A type of malicious software capable of replicating itself.
e. Dictionary: A collection of key-value pairs in Python.
f. Website: A collection of related web pages located under a single domain.
g. E-commerce: Buying and selling goods online.
h. Digital Citizenship: The norms of appropriate behavior while using technology.
i. Malware: Malicious software designed to disrupt, damage, or gain unauthorized access to systems.
j. List: An ordered collection of items in Python.
k. Web Page: A document on the World Wide Web which is displayed in a web browser.
l. Digital Marketing: Promoting products or services through digital channels.
m. Debugging: The process of finding and resolving defects in software or hardware.
n. Errors in Programming: Mistakes that prevent the software from working as intended.
C. Number System
a. Convert:
i.
(AEF)$_{16}$ to Binary:
A = 1010, E = 1110, F = 1111
Result: 101011101111
ii.
(663)$_{8}$ to Binary:
6 = 110, 6 = 110, 3 = 011
Result: 110110011
iii.
(1010111)$_{2}$ to Octal:
Group binary into threes: 1 010 111 -> 1 2 7
Result: 127
iv.
(1010111)$_{2}$ to Hexadecimal:
Group binary into fours: 0001 0101 0111 -> 1 5 7
Result: 157
v.
(1010111)$_{2}$ to Decimal:
$1 imes 2^6 + 0 imes 2^5 + 1 imes 2^4 + 0 imes 2^3 + 1 imes 2^2 + 1 imes 2^1 + 1 imes 2^0 = 64 + 16 + 4 + 2 + 1 = 83$
vi.
(123)$_{10}$ to Binary:
$123
ightarrow 1111011$
vii.
(123)$_{10}$ to Octal:
$123
ightarrow 173$
viii.
(123)$_{10}$ to Hexadecimal:
$123
ightarrow 7B$
b. Calculate:
i.
(1010110 - 10101) + 1000:
Step 1:
Step 2:
ii.
11010101 / 110:
Result:
iii.
10101 x 110:
Result:
D. Python Programming to Generate Following Series:
2, 4, 6, 8, 10 up to 20 terms:
for i in range(1, 21):
print(2 * i)
1, 1, 2, 3, 5, 8 up to 20 terms:
a, b = 0, 1
for _ in range(20):
print(b)
a, b = b, a + b
1, 2, 4, 8, 16 up to 20 terms:
for i in range(20):
print(2**i)
1, 4, 9, 16, 25:
for i in range(1, 6):
print(i**2)
1, 4, 7, 10 up to 20 terms:
for i in range(20):
print(1 + 3*i)
3, 10, 5, 16 up to 20 terms (requires clarification):
Assuming a pattern where numbers alternate.
series = [3]
for _ in range(19):
series.append(series[-1] + (7 if len(series) % 2 == 0 else -5))
print(series)
1, 11, 111, 1111, 11111:
for i in range(1, 6):
print(int('1' * i))
55, 555, 5555, 55555, 555555:
for i in range(1, 7):
print(5 * int('1' * i))
E. Dry-run Execution Table
num = 2543
Step
num
r
sum
1
2543
3
3
2
254
4
7
3
25
5
12
4
2
2
14
5
0
14
Final Output: Result is 14
num = 123
Step
num
r
rev
1
123
3
3
2
12
2
32
3
1
1
321
4
0
321
Final Output: Reverse number is 321
num = 246
Step
num
r
product
1
246
6
6
2
24
4
24
3
2
2
48
4
0
48
Final Output: Result is 48
numbers = [5, 12, 18, 21, 40]
Count numbers divisible by 3.
Output: Count = 2 (12 and 18)
numbers = [8, 15, 22, 33, 44]
Count sum of even numbers.
Output: Sum = 74 (8 + 22 + 44)
numbers = [11, 24, 36, 47, 50]
Count numbers greater than 30.
Output: Count = 3 (36, 47, 50)
F. Debug the Following Programs
Sum of digits:
num = 2564
sum = 0
while num > 0:
r = num % 10
sum = sum + r
num = num // 10
print("Sum is", sum)
Product of digits:
n = 345
product = 1
while n > 0:
r = n % 10
product = product * r
n = n // 10
print("Product is", product)
Count digits:
num = 7896
count = 0
while num > 0:
r = num % 10
count = count + 1
num = num // 10
print("Total digits are", count)
Count odd numbers in a list:
numbers = [10, 15, 22, 33, 40]
count = 0
for n in numbers:
if n % 2 == 1:
count = count + 1
print("Total odd numbers are", count)
Sum of numbers in a list:
nums = [5, 10, 15, 20]
sum = 0
for n in nums:
sum = sum + n
print("Sum is", sum)
Count numbers greater than 25:
numbers = [12, 30, 45, 10, 28]
count = 0
for n in numbers:
if n > 25:
count += 1
print("Count is", count)
G. Answer Given Questions after Studying Programs
students data structure:
Used: Dictionary
Output: Number of students passed: 3, Number of students failed: 1
a. Data Structure Used: Dictionary
b. Output of the Program: 3 passed, 1 failed
products data structure:
Used: Dictionary
Output: Expensive products: 2, Cheap products: 2
a. Data Structure Used: Dictionary
b. Output of the Program: 2 expensive, 2 cheap products
nums data structure:
Used: List
Values processed in 2nd and 4th loop: 5 (2nd loop), 7 (4th loop)
a. Data Structure Used: List
b. Values Processed: 5, 7
numbers data structure:
Used: List
Values processed in 1st and 5th loop: 3 (1st loop), 11 (5th loop)
a. Data Structure Used: List
b. Values Processed: 3, 11
H. Write Python Programs to:
Calculate Simple Interest:
def calculate_si(principal, rate, time):
return (principal * rate * time) / 100
Calculate the Area of Rectangle, Circle, and Square:
Rectangle:
def area_rectangle(length, width):
return length * width
Circle:
import math
def area_circle(radius):
return math.pi * (radius ** 2)
Square:
def area_square(side):
return side ** 2
Calculate the area of four walls and volume of a box:
def area_of_walls(length, width, height):
return 2 * (length + width) * height
def volume_of_box(length, width, height):
return length * width * height
Calculate Total Surface Area and Volume of a Cylinder:
def cylinder_surface_area(radius, height):
return 2 * math.pi * radius * (radius + height)
def cylinder_volume(radius, height):
return math.pi * (radius ** 2) * height
Check if a number is negative, positive, or zero:
def check_number(num):
if num > 0:
return "Positive"
elif num < 0:
return "Negative"
else:
return "Zero"
Print the lowest number among 3 given numbers:
def lowest_of_three(a, b, c):
return min(a, b, c)
Print squares of all numbers from 5 to 50:
for i in range(5, 51):
print(i ** 2)
Print product of all even digits from a multi-digit number:
def product_even_digits(num):
product = 1
for digit in str(num):
if int(digit) % 2 == 0:
product *= int(digit)
return product
Check if a number is Palindrome:
def is_palindrome(num):
return str(num) == str(num)[::-1]
Check if a number is Armstrong:
def is_armstrong(num):
order = len(str(num))
return num == sum(int(digit) ** order for digit in str(num))
Check if a number is Prime or Composite:
def is_prime(num):
if num <= 1:
return "Composite"
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
return "Composite"
return "Prime"
Print multiplication table of a given number:
def multiplication_table(num):
for i in range(1, 11):
print(f"{num} x {i} = {num * i}")
Print sum of all even numbers from 1 to 50:
even_sum = sum(i for i in range(1, 51) if i % 2 == 0)
print(even_sum)
Print sum of all multiples of 8 from 8 to 80:
multiples_of_eight_sum = sum(i for i in range(8, 81, 8))
print(multiples_of_eight_sum)
Print product of all multiples of 5 from 5 to 500:
product_of_fives = 1
for i in range(5, 501, 5):
product_of_fives *= i
print(product_of_fives)
Print factors of a given number:
def factors(num):
return [i for i in range(1, num + 1) if num % i == 0]
Print factorial of a given number:
import math
def factorial(num):
return math.factorial(num)
Hailstone series:
def hailstone_series(n):
series = []
for _ in range(10):
series.append(n)
if n % 2 == 0:
n //= 2
else:
n = 3 * n + 1
return series