wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python and Unix

Total questions: 100

Worksheet time: 59mins

Name
Class
Date
1.

What is Unix?

a)

Unix is a programming language

b)

Unix is a software program

c)

Unix is an operating system

d)

Unix is a text editor

2.

In which language UNIX is written?

a)

C++

b)

C

c)

Java

d)

Python

3.

Which of the following is not a part of all the versions of Unix?

a)

System Calls

b)

Graphical user interface

c)

Kernel and Shell

d)

Commands and utilities

4.

Which Unix command is used for changing the current directory?

a)

pwd

b)

rm

c)

cd

d)

cp

5.

Which command is used for displaying the contents of a file in Unix?

a)

mkdir

b)

cat

c)

rm

d)

cp

6.

Which of the following commands is known as stream editor?

a)

grep

b)

tr

c)

sed

d)

td

7.

Which of the following is not a type of shell?

a)

The C Shell

b)

The Korn Shell

c)

The Bourne Shell

d)

The Perl Shell

8.

The prompt issued by the shell is called ______

a)

prompt

b)

command translator

c)

command prompt

d)

command executor

9.

What is the default symbol for command prompt in Bourne shell?

a)

!

b)

#

c)

$

d)

@

10.

What is a shell script?

a)

group of commands

b)

a file containing a series of commands

c)

group of functions

d)

a file containing special symbols

11.

Which of the following commands is used to display the directory attributes

a)

cat

b)

ls

c)

mkdir

d)

cp

12.

Which command is used to remove a file?

a)

remove

b)

del

c)

rm

d)

mv

13.

The following command can list out all the current active logins.

a)

A - whoami

b)

B - who am i

c)

C - who

d)

D - None of the above.

14.

The mv command changes

a)

Only the directory entry

b)

Only the directory entry and i-node

c)

Only the i-node number

d)

None of the above

15.

Unix is a

a)

Single User, Single tasking OS

b)

Single User, Multi-tasking OS

c)

Multi-User, Multi- tasking OS

d)

None

16.

To Display line of text/string that are passed as an argument with a command

a)

cat

b)

echo

c)

ls

d)

none of the above

17.

Unix shell command that lists directory contents of files and directories with hidden files.

a)

ls -d

b)

ls -F

c)

ls -a

d)

ls -l

18.

Which command is used to get information about currently logged in user on to system

a)

who am i

b)

who

c)

who i am

d)

None of the above

19.

Date command is used to support format specifier

a)

True

b)

False

20.

Which command in UNIX is used to change the user account passwords.

a)

pwd

b)

password

c)

passwd

d)

none of the above

21.

In Unix, Combining commands are

a)

& %

b)

&& %

c)

; &&

d)

; &

22.

which command is used to see the calendar of any specific month or a complete year

a)

calendar

b)

cal

c)

none of the above

23.

Shell scripts are executed in a separate child shell process.

a)

a) True

b)

b) False

24.

The first line in any shell script begins with a _____

a)

a) &

b)

b) !

c)

c) $

d)

d) #

25.

This is an important OS function

a)

Printing

b)

Resource (Memory, Processor, Device, etc) Management

c)

Video editing

d)

Scanning

e)

Gaming

26.

What year did Unix started?

a)

1969

b)

1981

c)

1979

d)

2015

27.

What is an example of a special character

a)

&

b)

A

c)

:

d)

K

28.
Unix OS was first developed by
a)
Dennis Ritchie
b)
Bjarne stroustrup
c)
Ken Thompson
d)
Brian Kernighan
29.
Unix OS was first developed at
a)
Microsoft corp. USA
b)
AT & T Bell Labs, USA
c)
IBM, USA
d)
Borland International, USA
30.
Shell Program is stored in a file called
a)
Unix
b)
Sh
c)
Dd
d)
Cc
31.

The --------------------- is responsible for the management of processes.

a)

Shell

b)

User

c)

Kernel

d)

Administrator

32.

What is the Python built-in function used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

33.

What is the output from the following code?

print ("hello world")

a)
Hello World
b)
hello world
c)
print hello world
34.

Which of the following code is a Python Comment?

a)

#this is a comment

b)

{ this is a comment }

c)

" this is a comment "

d)

( this is a comment )

35.

1==0

a)

True

b)

False

36.

A: Strings can be changed during execution

B. Strings can be enclosed within single, double or even triple quotes

C. Strings are immutable

a)

A,B & C are True

b)

A,B are True but C is False

c)

B, C are True but A is False

d)

A,C are True but B is False

37.

Find the output of the following code:

>>>str1='Save Soil'

>>>str1.isalnum( )

a)

Save Soil

b)

True

c)

False

38.

Identify the string membership operators of Python

a)

in, not in

b)

like, not like

c)

as, not as

d)

between, not between

39.

Predict the output:

>>>str1="Rajathi Raja"

>>>print(str1.count('Raja'))

a)

1

b)

2

c)

Error

d)

Raja

40.

Match the following:

1. \n A) Carriage return

2. \v B) BackSpace

3. \b C) new line

4. \r D) Vertical tab

a)

1-C, 2-D, 3-B, 4-A

b)

1-A, 2-C, 3-B, 4-D

c)

1-C, 2-D, 3-A, 4-B

d)

1-C, 2-A, 3-B, 4-D

41.

Predict the output:

>>>saint="Thiruvalluvar"

>>>print(saint[5:])

a)

valluvar

b)

Thiruvalluvar

c)

uvalluvar

d)

Thiru

42.

MATCH THE FOLLOWING:

1. concatenation A) +=

2. Append B) [ ]

3. String Slicing C) *

4. Repeating D) +

a)

1-B. 2-A, 3-C, 4-D

b)

1-D. 2-A, 3-B, 4-C

c)

1-A,2-B,3-C,4-D

d)

1-A,2-D,3-C,4-B

43.

The unexpected event happened during program execution should be handled by

a)

EXCEPTION

b)

EXPERIMENT

c)

ASSERTION

d)

EXTRAORDINARY

44.

try:

a=int(input("\n Enter a Value"))

b=int(input("\n Enter a Value "))

c=a/b

print (c)

except:

print("\n Something Went Wrong")


Assume a = 10 and b = 5, then the output will be

a)

5.0

b)

Something Went Wrong

c)

Arithmetic Error

d)

2.0

45.

Exception disrupts the

a)

Normal flow of the program

b)

Abnornal flow of the program

c)

Hard Disk

d)

None of the Above

46.

The suspicious code is put inside the

a)

Try Block

b)

Finally Block

c)

Else Block

d)

Except Block

47.

________ statement can also be used without specifying Exception.

a)

Try

b)

Finally

c)

Except

d)

Else

48.

try:

a=10/5

print (a)

except ArithmeticError:

print ("This statement is raising an exception" )

finally:

print (" final block executed " )

a)

2.0

final block executed

b)

This statement is raising an exception

final block executed

c)

final block executed

d)

2.0

49.

An exception can be manually triggered by the command

a)

raise

b)

try

c)

except

d)

trigger

50.

User defined Exceptions are created from the _________ Parent Class

a)

Exception

b)

Except

c)

Handler

d)

User Defined Exception

51.

How many except statements can a try-except block have?

a)

zero

b)

one

c)

more than one

d)

more than zero

52.

When will the else part of try-except-else be executed?

a)

a) always

b)

b) when an exception occurs

c)

c) when no exception occurs

d)

d) when an exception occurs in to except block

53.

Is the following Python code valid?


try:

# Do something

except:

# Do something

else:

# Do something

a)

no, there is no such thing as else

b)

no, else cannot be used with except

c)

no, else must come before except

d)

yes

54.

What will be the output of the following Python code?


lst = [1, 2, 3]

lst[3]

a)

a) NameError

b)

b) ValueError

c)

c) IndexError

d)

d) TypeError

55.
a)

IndexError: list index out of range

b)

13

c)

10

d)

12

e)

9

56.
a)

Orange

Mango

b)

Apple

Orange

Mango

c)

Mango

Orange

Apple

d)

Mango

Apple

e)

Apple

Mango

57.
a)

ValueError: list.remove(x): x not in list

b)

Apple

c)

Mango

d)

Orange

e)

orange

58.
a)

Kiwi

b)

Mango

c)

Orange

d)

Apple

e)

Error

59.
a)

Error

b)

[6.7, 7.7, 8.2, 8.1, 7.9, 5.8]

c)

[5.8, 6.7, 7.7, 8.2, 8.1, 7.9]

d)

[6.7, 7.7, 5.8, 8.2, 8.1, 7.9]

e)

[6.7, 7.7, 8.2, 8.1, 7.9]

60.
a)

(6.7, 7.7, 8.2, 8.1, 7.9)

b)

Error

c)

6.7, 7.7, 8.2, 8.1, 7.9

d)

[6.7, 7.7, 8.2, 8.1, 7.9]

e)

"6.7, 7.7, 8.2, 8.1, 7.9"

61.

Choose the appropriate code snippet which prints the following output.

My grade is 7

a)
b)
c)
d)
62.

# For the given code snippet, choose the appropriate code snippet to print the mark of NSS.

a)

print(marks['Non-academics']['NSS'])

b)

print(marks['NSS'])

c)

print(marks['NSS'])

d)

print(marks['Non-academics'])

e)

print(marks)

63.
a)

Error

b)

Physics

c)

80

d)

Physics : 80

e)

{'Physics': 80, 'Chemistry': 88, 'Mathematics': 92}

64.
a)

Error

b)

( )

c)

{'Physics': 80, 'Chemistry': 88, 'Mathematics': 92}

d)

{'Chemistry': 88, 'Mathematics': 92}

e)

{'Physics': 80, 'Chemistry': 88}

65.

What will be the output of the following Python code?

a)

a) 1

2

3

b)

b) error

c)

c) 1

2

d)

d) none of the mentioned

66.

What are the values of the following Python expressions?

2**(3**2)

(2**3)**2

2**3**2

a)

a) 512, 64, 512

b)

b) 512, 512, 512

c)

c) 64, 512, 64

d)

d) 64, 64, 64

67.

What will be the output of the following Python program?

a)

a) error

b)

b) 0 1 2 0

c)

c) 0 1 2

d)

d) none of the mentioned

68.

What will be the output of the following Python code?

a)

a) 1 2 3 4 5 6

b)

b) 1 2 3 4 5 6 7

c)

c) error

d)

d) none of the mentioned

69.

What will be the output of the following Python code?

a)

a) 1

b)

b) 1 3 5 7.....

c)

c) 1 2 3 4..... .

d)

d) none of the mentioned

70.

What will be the output of the following Python code?

a)

a) a b c d

b)

b) 0 1 2 3

c)

c) error

d)

d) none of the mentioned

71.

What will be the output of the following Python code?

a)

a) a b c d

b)

b) 0 1 2 3

c)

c) error

d)

d) 1 2 3 4

72.

What will be the output of the following Python code?

a)

a) 0 1 2

b)

b) a b c

c)

c) {0: 'a', 1: 'b', 2: 'c'}

{0: 'a', 1: 'b', 2: 'c'}

{0: 'a', 1: 'b', 2: 'c'}

d)

d) none of the mentioned

73.

What will be the output of the following Python code?

for i in range(0):

print(i)

a)

a) 0

b)

b) no output

c)

c) error

d)

d) none of the mentioned

74.

What will be the output of the following Python code snippet?

a)

a) 0 1 2 3 4 …

b)

b) 0 -2

c)

c) 0

d)

d) error

75.

What will be the output of the following Python code?

a)

a) 0 1 2 3 4 Here

b)

b) 0 1 2 3 4 5 Here

c)

c) 0 1 2 3 4

d)

d) 1 2 3 4 5

76.

  #! Is called as

a)

Shebang

b)

Hebang

c)

Hash prompt

d)

    Begin

77.

  Which of the following is not a kind of shell?

a)

bash

b)

ksh

c)

csh

d)

dsh

78.

[ is equivalent to

a)

Test

b)

For

c)

While

d)

Then

79.

   The difference between printf and echo is

a)

  Echo adds fa new line after printing, printf does not

b)

Printing adds a new line after printing, echo does not

c)

    Both are same

d)

  None of the above

80.

   “.” Is used to match

a)

Any one character

b)

Any number of characters

c)

Only "."

d)

Only special characters

81.

Which of the following symbols is used as prefix to access the variables in scripting

a)

#

b)

$

c)

^

d)

&

82.

  The comparison operator " -eq " is used for

a)

Numbers

b)

Charaters

c)

Strings

d)

Any kind of data

83.

  A comment line in a script begins with

a)

#

b)

$

c)

^

d)

&

84.

Every line in a shell script ends with

a)

;

b)

:

c)

>

d)

There is no rule

85.

  Scripts are made executable using the command

a)

Chown

b)

chmod

c)

Exe

d)

Run

86.

Who can change the password of any user?

a)

Everyone

b)

Super user

c)

Supervisor

d)

End-User

87.

All configuration files are stored under which directory

a)

/home/etc

b)

/etc

c)

/bin

d)

/

88.

Which of the following command is file editor command ?

a)

cat

b)

vi

c)

echo

d)

grep

89.

which of the following command is used to change the file permission?  

a)

usermod

b)

umask

c)

chage

d)

chmod

90.

Which of the following is used to append the contents of a file?

a)

=

b)

>>

c)

<

d)

>

91.

Which command displays the contents of a file?

a)

cat

b)

pipe

c)

ls

d)

tee

92.

Which of the command is used to change the password?

a)

password

b)

passwd

c)

changepasswd

d)

gpasswd

93.

User passwords are stored in which file?

a)

/etc/password

b)

/root/password

c)

/etc/passwd

d)

/etc/shadow

94.

How do you delete user along with home directory?

a)

userdel

b)

userdel -r

c)

deleteuser

d)

userdel -d

95.

if normal user wants to run super users command he must be added in the which of the following file?

a)

/etc/login.defs

b)

/etc/sudoers

c)

/etc/passwd

d)

/etc/group

96.

In vi editor a tilde (~) represents ________

a)

used

line

b)

unused line

c)

blocked

d)

header

97.

The vi editor has two modes

a)

command and input

b)

read and write

c)

write

d)

read

98.

The vi always starts in _______ mode

a)

insert

b)

read

c)

command

d)

write

99.

In Vi editor command mode delete character under cursor we use ____

a)

x

b)

d

c)

p

d)

yy

100.

To save and exit the file in vi editor we use

a)

":q"

b)

":sw"

c)

": wq"

d)

":qs"