CLASS - VII | CHAPTER - 4 ( Variable in Real Life ) (Worksheet)

CHAPTER-4
Variable in Real Life
Worksheets

Objective Type Questions

1. Process of assigning value to a variable before it is being used is called: 
a. Initialization 
b. Operation 
c. Realization 

 Answer: Initialization 


2.  int k1, k2 = 23 is an example of: 
a. Variable declaration 
b. Adding values in a function 
c. None of them 

 Answer: Variable declaration 


3.  Which of the following is NOT a correct variable name? 
a.  2bad 
b.  Zero 
c.  the Last Value But One 
d.  Year2000

Answer: 2bad


4 Which of the following declarations is NOT correct?
a. Double duty; 
b. Float loan = 12.3; 
c. Boolean value = 21; 
d. Int start = 45, end = 99; 

 Answer: Boolean value = 21; 


5. Which of the following shows the syntax of an assignment statement? 
a. VariableName = expression; 
b. Expression = expression; 
c. Expression = VariableName; 
d. datatype = VariableName; 

 Answer: VariableName = expression;

6. What is an expression? 
a. The same thing as a statement 
b. An expression is a list of statements that make up a program 
c. An expression is a combination of literals, operators, variables, and parentheses used to calculate a value 
d. An expression is a number expressed in digits. 

 Answer: c. An expression is a combination of literals, operators, variables, and parentheses used to calculate a value 



7. What is the value of the following expression? (2 - 6) / 2 + 9 
a.  7 
b.  8 
c.  9 
d.  10 

 Answer: 7

Question / Answers

1. What is variable initialization?

Answer: A variable that is not initialized ever has an undefined value. Such a variable cannot be used until it is assigned with a certain value. In a case where a variable is declared (read – created) but it is not initialized, we can assign it a value in later steps using assignment operators. In programming, a variable can be initialized using the below 

syntax: Datatype VariableName = Value;

Example of declaring variables in python 
a = 5 
b = “Hello”



2. What is the syntax to initialize a variable in programming?

Answer: Syntax: Datatype VariableName = Value;

Example of declaring variables in python 
a = 5 
b = “Hello”



3. Why do you think validating user input is important in programming?

Answer: * An important part of making sure that your program works fine is to validate that the user enters valid values in the places where you are expecting an input from the user.

*Similarly, in programming, whenever you create a variable with a specific data type, and you are expecting a user to enter a certain value in that data type, you should make sure that the user enters the right type of value, which won’t cause any error during program execution.

*Any deviation of data type in the user's input will result in an error by program.
*A very common way of validating user input in flagging out the wrong input.