wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz on Variables in Programming

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a variable?

a)

A fixed value in a program

b)

A storage location identified for data that can change

c)

A type of hardware component

d)

A constant in mathematics

2.

What does an environment variable provide?

a)

Hardware specifications

b)

Network configurations

c)

Settings and configurations

d)

User interface design

3.

What is a shell variable?

a)

A variable inherited by child shells and processes

b)

A variable that is not inherited by child shells and processes

c)

A variable used in web development

d)

A variable that stores user passwords

4.

What is a local variable?

a)

A variable that is always available

b)

A variable defined in scripts and script functions

c)

A variable used for network settings

d)

A variable that stores system logs

5.

What does the HISTSIZE variable determine?

a)

The size of the user's home directory

b)

The number of lines or commands stored in a history list

c)

The number of active users

d)

The size of the system memory

6.

What does OLDPWD represent?

a)

The current working directory

b)

The previous directory the user accessed

c)

The user's password

d)

The user's email address

7.

What does the HISTFILE variable store?

a)

User passwords

b)

Past commands

c)

User emails

d)

System logs

8.

Which variable is typically defined in scripts and does not exist after the script is run?

a)

Environment variable

b)

Shell variable

c)

Local variable

d)

User variable

9.

What does the command `export [name]=[value]` do?

a)

Deletes an environment variable.

b)

Creates a new environment variable.

c)

Lists all environment variables.

d)

Displays the value of a variable.

10.

How does the command `echo $[name]` function in a shell?

a)

Deletes a variable.

b)

Displays the contents of a variable.

c)

Creates a new variable.

d)

Lists all variables.

11.

What is the function of the `env` or `printenv` command?

a)

Deletes environment variables.

b)

Displays current environment variables and their values.

c)

Creates new environment variables.

d)

Modifies existing environment variables.

12.

What does the `set` command do in a shell environment?

a)

Deletes all variables.

b)

Displays a list of all variables and functions.

c)

Creates a new shell function.

d)

Modifies the shell prompt.

13.

What is the purpose of the `unset [name]` command?

a)

Creates a new variable.

b)

Displays the value of a variable.

c)

Removes a variable and its value.

d)

Lists all environment variables.

14.

What does `/etc/profile` do in a shell environment?

a)

Deletes a global environment variable.

b)

Modifies a global environment variable.

c)

Lists all global environment variables.

d)

Displays the current directory.

15.

What is the role of `~./bash_profile` in a shell?

a)

Deletes a global environment variable.

b)

Modifies a global environment variable.

c)

Lists all global environment variables.

d)

Displays the current directory.