Home »
Python
Python Variables MCQs
Python Variables MCQs: This section contains multiple-choice questions and answers on Python Variables. These MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of Python Variables.
List of Python Variables MCQs
1. What are variables?
- Variables are used to identify the module, class i.e., entity
- Variables are the names we used to store the values
- Variables are special inbuilt names
Answer: B) Variables are the names we used to store the values.
Explanation:
Variables are the names we used to store the values; these are the user-defined names that are used to assign the values.
Discuss this Question
2. Can you include digits in defining a variable name?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, variable names can include digits. Variables can include the group of characters and numbers.
Discuss this Question
3. Are variables names case-sensitive?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, variable names are case-sensitive. A and a are two different variables.
Discuss this Question
4. What are identifiers?
- Identifiers are used to identify the module, class i.e., entity
- Identifiers are the names we used to store the values
- Identifiers are special inbuilt names
Answer: A) Identifiers are used to identify the module, class i.e., entity.
Explanation:
Identifiers are used to identify the module, class i.e., entity.
Discuss this Question
5. Can you include special characters as variable names?
- Yes
- No
Answer: B) No
Explanation:
No, variable names cannot contain special characters.
Discuss this Question
6. Which of the following is the valid variable name?
- True="hello"
- A="hello"
- For="hello"
- Else="hello"
Answer: B) A="hello"
Explanation:
Among, all the given variables only option b is valid as other names are also keywords.
Discuss this Question
7. What are keywords?
- keywords are used to identify the module, class i.e., entity
- keywords are the names we used to store the values
- keywords are the special inbuilt names
Answer: C) keywords are the special inbuilt names.
Explanation:
Keywords are special inbuilt names.
Discuss this Question
8. Can you make keywords as variable names?
- Yes
- No
Answer: B) No
Explanation:
Keywords cannot be used as variable names. As keywords are the in-built names and if you will use them as the variable name you will get the error.
Discuss this Question
9. Which of the following is an invalid variable name?
- _a = 1000
- 100_ = 1000
- _90 = 1000
- a_ = 1000
Answer: B) 100_ = 1000
Explanation:
A variable name cannot start from a digit. It can start from the underscore.
Discuss this Question
10. How can you assign one value to different variables?
- a, b, c = 100
- a = b = c = 100
- a = b = c == 100
Answer: B) a = b = c = 100
Explanation:
a = b = c = 100, this is how you can assign a single value to multiple variables.
Discuss this Question
11. Check whether the given statement is correct or not
a, b, c = 10, 12, 12
- Yes
- No
Answer: A) Yes
Explanation:
a, b, c = 10, 12, 12 it is one of the methods to assign three different variables to three different values in a single line of code.
Discuss this Question
12. How many types of variables are there In Python
- 1
- 3
- 4
- 2
Answer: D) 2
Explanation:
In Python, there are two types of variables local variables and global variables.
Discuss this Question
13. ____ variable is the variable that is stored inside the function.
- Local
- Global
Answer: A) Local
Explanation:
In Python, the Local variable is the type of variable which are stored inside the function.
Discuss this Question
14. Can you use a local variable outside the function?
- Yes
- No
- Only in the special case
Answer: B) Java
Explanation:
In Python, Local variables cannot be used outside the function, if you will use them it will show you the name error.
Discuss this Question
15. ____ variables are the variables that can be used in the entire program.
- Global
- Local
Answer: A) Global
Explanation:
In Python, global variables are the variables that can be used all over the program.
Discuss this Question
16. Which keyword is used to assign a local variable?
- Global
- Local
- No, it has no keyword
Answer: C) No, it has no keyword.
Explanation:
In Python, Local variables are assigned directly no specified keywords are used with them.
Discuss this Question
17. Which keyword is used to assign a global variable?
- global
- local
- No, it has no keyword
Answer: A) global
Explanation:
In Python, the global keyword is used to define a global variable if you are making a global variable inside some function, else you don't require any keyword.
Discuss this Question
18. Can you delete the variable during a program?
- Yes
- No
Answer: A) Yes
Explanation:
In Python, you can easily delete the variable during a program, (if you don't want them).
Discuss this Question
19. Which keyword is used to delete the variable?
- remove
- delete
- del
- undo
Answer: C) del
Explanation:
In Python, the del keyword is used to delete the variable during a program.
Discuss this Question
20. ____ are the smallest unit inside a program and can be defined as reserved words and each word in a statement?
- Literals
- Keywords
- Preprocessor
- Tokens
Answer: D) Tokens
Explanation:
Tokens are the smallest unit inside a program and can be defined as reserved words and each word in a statement
Discuss this Question