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?

  1. Variables are used to identify the module, class i.e., entity
  2. Variables are the names we used to store the values
  3. 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?

  1. Yes
  2. 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?

  1. Yes
  2. 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?

  1. Identifiers are used to identify the module, class i.e., entity
  2. Identifiers are the names we used to store the values
  3. 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?

  1. Yes
  2. 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?

  1. True="hello"
  2. A="hello"
  3. For="hello"
  4. 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?

  1. keywords are used to identify the module, class i.e., entity
  2. keywords are the names we used to store the values
  3. 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?

  1. Yes
  2. 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?

  1. _a = 1000
  2. 100_ = 1000
  3. _90 = 1000
  4. 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?

  1. a, b, c = 100
  2. a = b = c = 100
  3. 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
  1. Yes
  2. 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. 1
  2. 3
  3. 4
  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.

  1. Local
  2. 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?

  1. Yes
  2. No
  3. 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.

  1. Global
  2. 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?

  1. Global
  2. Local
  3. 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?

  1. global
  2. local
  3. 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?

  1. Yes
  2. 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?

  1. remove
  2. delete
  3. del
  4. 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?

  1. Literals
  2. Keywords
  3. Preprocessor
  4. 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



 
 


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.