0% found this document useful (0 votes)
6 views9 pages

Class 8 Comp_24-25 Notes

The document contains revision notes for Class VIII Computer Science, focusing on loops and functions in Python. It includes multiple-choice questions, coding exercises, and explanations of concepts like loop control statements, function definitions, and app development using MIT App Inventor. Additionally, it covers practical applications of programming concepts and components within the app development environment.

Uploaded by

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

Class 8 Comp_24-25 Notes

The document contains revision notes for Class VIII Computer Science, focusing on loops and functions in Python. It includes multiple-choice questions, coding exercises, and explanations of concepts like loop control statements, function definitions, and app development using MIT App Inventor. Additionally, it covers practical applications of programming concepts and components within the app development environment.

Uploaded by

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

SAI International School

Class - VIII, Session 2024-25


Computer Science
Revision Notes

CHAPTER-4: LOOPS
Q.1 What is the purpose of using a loop in python?

a) To create graphical user interfaces

b) To execute code only once

c) To perform repetitive tasks efficiently

d) To handle exceptions in the code

Q.2 Which type of loop is used to iterate over a sequence in a python?

a) for loop

b) while loop

c) if loop

d) do-while loop

Q.3 What will be the output of the following code?

for i in range(3):

print(i, end=" ")

a) 2 1 2

b) 0 1 2

c) 1 2 3

d) 0 1

Q.4 In a while loop, what happens if the loop condition is initially false?

a) The loop will not execute at all.

b) The loop will execute infinitely

c) The loop will raise an exception.

d) The loop will execute only once

Q.5 What is the purpose of the brig statement in a loop?


a) To end the loop and continue with the next iteration.
b) To skip the current iteration and move to the next one.
Class_VIII_Comp.Sci_24-25 1/9
c) To force the loop to execute at least once.
d) To continue executing the loop as long as the condition is True.
Q6 Which loop control statement is used to skip the current iteration and move to the next one?
a) continue
b) break
c) exit
d) skip

Q7 What will be the output of the following code?


count=0
while count<5:
print(count,end=" ")
count+=1
a) 0 1 2 3 4 5

b) 1 2 3 4 5

c) 0 1 2 3 4

d) 1 2 3 4

Q8 Which type of loop is best used when the number of iterations is known beforehand?
a) for loop

b) while loop

c) if loop

d) do while loop

Q9 What will be the output of the following code?


for i in range(5, 0,-1):
print(I, end=" ")
a) 12345

b) 54321

c) 5432

d) 1234

Q10 Which loop control statement is used to terminate a loop prematurely when a certain
condition is met?

Class_VIII_Comp.Sci_24-25 2/9
a) terminate

b) stop

c) exit

d) break

1. Find the output:


for i in range(3):
print(i, end=" ")

2. Write a program in python to find the following patterns.


a.
1 Ans.
12 for i in range(1,6):
123 for j in range(1,i+1):
1234 print(j,end=' ')
12345 print('')

b.
54321 Ans.
4321 for i in range(5,0,-1):
321 for j in range(i,0,-1):
21 print(j,end="")
1 print()

c.
* Ans.
** for i in range(1,5):
*** for j in range(1,i+1):
**** print(“*”,end=' ')
print('')
d.
12345 Ans.
1234 for i in range(6,0,-1):
123 for j in range(1,i):
12 print(j,end=' ')
1 print('')
e.
0 Ans.
22 for i in range(0,7,2):
444 for j in range(-1,i):

Class_VIII_Comp.Sci_24-25 3/9
6666 print(i,end=' ')
print('')

3. Write a python program to display a multiplication table of 9.


for i in range(1,11):
print("9 x ",i,"= ",9*i)
4. WAP to display all number from 100 to 1(inclusive)
for i in range(1,101):
print(i)
5. WAP to display all odd numbers upto 100.
for i in range(1,101,2):
print(i)
6. WAP to display all the numbers divisible by 2 and 3 between 1 and 100(exclusive).
for i in range(1,101):
if(i%2 ==0 and i%3==0):
print(i)

Class_VIII_Comp.Sci_24-25 4/9
CHAPTER-5: FUNCTIONS
Q.1 What is a function in python?
a) A single line of code.
b) A group of variables.
c) A block of organized reusable code to perform a specific task.
d) A sequence of characters.
Q.2 How Do you define a function in python?
a) def function_name:
b) function function_name():
c) function_name def:
d) def function_name():
Q.3 What Is the purpose of parameters in a function?
a) To store the function’s return value.
b) To specify the function’s name.
c) To provide input values to the function.
d) To define the function’s block of code.
Q.4 What is the keyword used to call a function in python?
a) run.
b) call.
c) start.
d) return.
Q.5 How can a function return a value to the caller?
a) By using output keyboard
b) By using the exit statement
c) By using the return statement
d) By using the send method
Q6 What is the scope of the variable declared inside a function?
a) Global scope - accessible throughout the program.
b) Local scope - accessible only inside the function.
c) Enclosed scope - accessible within nested functions
d) Class scope - accessible within a class
Q7 What does code reusability mean in the context of functions?

Class_VIII_Comp.Sci_24-25 5/9
a) Writing code once and never using it again.
b) Writing code that can be executed multiple times in different parts of the
program.
c) Writing code that can only be used by specific functions.
d) Writing code that is not accessible by other functions.
Q8 Which type of function does not require any arguments to be passed?
a) Default function
b) Empty function
c) Parameterless function
d) Null function
Q9 What will be the output of the following code?
def multiply(a,b):
return a*b
result=multiply(5,7)
print(result)
a) 35
b) 57
c) 12
d) Error:The function is missing a return statement.
Q10 What is the output of the following function?
def square(x):
return x**2
result=square(4)+square(3)
print(result)
a) 7
b) 16
c) 25
d) 49

1. Find the output:


a. def multiply(a,b=2):
return a*b

Class_VIII_Comp.Sci_24-25 6/9
result_1=multiply(5)
result_2=multiply(5,3)
print(result_1,result_2)
b. def add(a,b):
return a+b
def multiply(a,b):
return a*b
result=add(5, multiply(2,3))
print(result)

2. WAP to calculate the area of a rhombus using a user defined function.

3. WAP to calculate the area of a circle using a user defined function.

4. WAP to calculate the area of a rectangle using a user defined function.

Class_VIII_Comp.Sci_24-25 7/9
5. WAP to calculate the area of a Simple Interest using a user defined function.

CREYA

1. What do you mean by an application? Where do we generally use it? Explain with
examples.

Ans: An application, is a type of software that can be installed and run on a computer, tablet or other
electronic devices. It is used to fulfil specific tasks in those devices.

• Apps like WhatsApp, Messenger etc lets you communicate with people from all over the world.

• Apps like Microsoft office, WPS office etc lets you create and use documents for work.

• Apps like Siri, Google Assistant help you interact and work with your electronic devices easily.

• Apps like Google Maps, Maps, Google Earth help you navigate or travel without the fear of getting
lost in new places. [Any one of the above Examples should be mentioned]

2. What is App Development? In our project which platform we use for App Development?
What are the advantages of using the said Platform?

Ans: The process of creating and modifying an application to serve a purpose is called App
Development. In our project we use MIT app inventor for App Development.

The advantages of said platform are User friendliness, Free of cost, Use of block coding (no need of
learning any programming language).

3. What is the use of the Speech Recognizer option in MIT app inventor? Under which section
do we find this button?

Ans: Speech Recognizer is a component which is used for Voice recognition to convert from speech
to text.Under the media section we find this button.

4. What is the use of ‘Button’ in MIT app inventor? Under which section do we find this?

Class_VIII_Comp.Sci_24-25 8/9
Ans: In MIT App Inventor, a Button is a component that allows users to interact with the app by
tapping or clicking it. When a button is clicked, it triggers an event that can perform various actions.
Under User Interface section we find this option.

5. Write down the steps to login to MIT App Inventor.

6. What is Horizontal Arrangement in MIT App Inventor?

Ans: Horizontal Arrangement is a formatting element which places components to be displayed from
left to right.

7. Why do we use the FontBold option in MIT App Inventor?

Ans: FontBold is used to make the selected text Bold.

8. What is the purpose of Yandex Translator in MIT App Inventor?

Ans: The purpose of Yandex Translator in MIT App Inventor is to provide a translation service within
the app. It helps the user to use the Application in his own language and at the same time getting
instant translation of text inputs of the desired language.

9. What is the use of TextBox in MIT app inventor?

Ans: In MIT App Inventor, a TextBox is a user interface (UI) component that allows users to input or
display text within an app.

10. What is the use of Table_Arrangement in MIT app inventor?

Ans: Table Arrangement is a formatting element that places components to be displayed one below
another.

Class_VIII_Comp.Sci_24-25 9/9

You might also like