wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming

Total questions: 75

Worksheet time: 37mins

Name
Class
Date
1.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

2.

What is a input?

a)

To plug in something

b)

A function that allows us to ask the user to enter some data

c)

Data displayed on a screen

d)

A routine

3.

A variable must have been assigned (given) a value before that value is referenced (used).

a)

True

b)

False

4.

The correct way to convert user input is:

a)

birth_year = number(input())

b)

birth_year = int(input())

c)

birth_year = (input(int))

d)

birth_year = int(input)

5.

To display the following on screen Hello World! the following command should be used:

a)

print(Hello World!)

b)

print("Hello World" + !)

c)

print("Hello World!")

d)

print"(Hello World!)"

6.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

7.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

8.

Program statements are executed in sequence, one after the other...

a)

True

b)

False

9.

if you receive a NameError when you run your program it means....

a)

A variable has been assigned before it has been referred to

b)

An incorrect name has been chosen

c)

A variable has been referred to before it has been assigned

d)

A language key word has been used

10.

If the coding steps are in the incorrect order, the computer can still execute the program.

a)

True

b)

False

11.

Who is the father of Computer?

a)

Allen Turing

b)

Charles Babbage

c)

Simur Cray

d)

Augusta Adaming

12.

Which of the following is also known as brain of computer?

a)

Control unit

b)

Central Processing unit

c)

Arithmetic and language unit

d)

Monitor

13.

ASCII stands for

a)

American Stable Code for International Interchange

b)

American Standard Case for Institutional Interchange

c)

American Standard Code for Information Interchange

d)

American Standard Code for Interchange Information

14.

Microprocessors as switching devices are for which generation computers

a)

First Generation

b)

Second Generation

c)

Third Generation

d)

Fourth Generation

15.

Which of the following is a part of the Central Processing Unit?

a)

Printer

b)

Key board

c)

Mouse

d)

Arithmetic & Logic unit

16.

Which device is required for the Internet connection?

a)

Repeater

b)

Modem

c)

CD Drive

d)

NIC Card

17.

Which of the following is incorrect variable name in Python?

a)

variable_1

b)

variable1

c)

1variable

d)

_variable

18.

Which functions are used to accept input from the user.

a)

input()

b)

raw_input()

c)

rawinput()

d)

string()

19.

What is the data type of print(type(10))

a)

float

b)

integer

c)

int

d)

String

20.

What is the output of the following code

x = 6 y = 2

print(x ** y) print(x // y)

a)

66 0

b)

36 0

c)

66 3

d)

36 3

21.

Which of the following statement is False?

a)

They can contain both letters and numbers.

b)

Variable names can be arbitrarily long.

c)

Variable name can begin with underscore.

d)

Variable name can begin with number.

22.

Which of the following is not used as loop in Python?

a)

for loop

b)

while loop

c)

do-while loop

d)

None of the above

23.

What is NIC used for?

a)

To remotely access PC

b)

To connect computer to a network

c)

It is used in junipers routers for gateway card

d)

None

24.

. In a type of computer network, what does MAN stands for?

a)

Metropolis area network

b)

Mini area network

c)

Metropolitan area network

d)

Micro area network

25.

Which of the following is the type of the computer network?

a)

Metropolitan area network (MAN)

b)

Local area network (LAN)

c)

Wide area network (WAN)

d)

All of the above

26.

The _______ provides pictorial representation of given problem.

a)

Algorithm

b)

Flowchart

c)

Pseudocode

d)

All of these

27.

_______ is a procedure or step by step process for solving a problem.

a)

Algorithm

b)

Flowchart

c)

Pseudocode

d)

All of these

28.

The ______ symbol is used at the beginning of a flow chart.

a)

Circle

b)

Rectangle

c)

Diamond

d)

None of these

29.

What will be the output of above Python code?

str1="6/4"

print("str1")

a)

1

b)

6/4

c)

1.5

d)

str1

30.

What will following Python code return?

str1="Stack of books"

print(len(str1))

a)

13

b)

14

c)

15

d)

16

31.

Which one of the following is correct way of declaring and initializing a variable, x with value 5?

int x

a)

Int x=5

b)

int x=5

c)

x=5

d)

declare x=5

32.

All keyword in python are in

a)

Lowercase

b)

Uppercase

c)

Both uppercase & Lowercase

d)

None of the above

33.

How many keywords are there in python 3.7?

a)

32

b)

33

c)

30

d)

31

34.

In Python3, which functions are used to accept input from the user

a)

input()

b)

raw_input()

c)

rawinput()

d)

string()

35.

Who developed the Python language?

a)

Zim Den

b)

Guido van Rossum

c)

Niene Stom

d)

Wick van Rossum

36.

What is the output of the following piece of code when executed in Python shell?


>>> a=("Check")*3

>>> a



a)

(‘Check’,’Check’,’Check’)

b)

* Operator not valid for tuples

c)

(‘CheckCheckCheck’)

d)

Syntax error

37.

Which are arithmetic operators?

a)

+

b)

-

c)

>

d)

<

38.

Which of the following cannot be a variable?

a)

_init_

b)

in

c)

it

d)

on

39.

Which one of these is floor division?

a)

//

b)

/

c)

%

d)

None of the above

40.

Python is a general purpose programming language created by

a)

Dennis M. Ritchie

b)

Guido Van Rossum

c)

James Gosling

d)

Bjarne Stroustrup

41.

Expand IDLE

a)

Internal Development Learning Environment

b)

Integrated Development Learning Enforcement

c)

Interactive Development Learning Environment

d)

Integrated Development Learning Environment

42.

Example of valid identifiers

a)

12Name

b)

name$

c)

total-mark

d)

total_marks

43.

A Relational operator is also called as ___________

a)

Arithmetic operator

b)

Logical operator

c)

Assignment operator

d)

Comparative operator

44.

"and, or and not" are ___________________

a)

Arithmetic operator

b)

Logical operators

c)

Assignment operator

d)

Comparative operator

45.

__________are special words that are used by Python interpreter to recognize the

structure of program.

a)

Tokens

b)

Identifiers

c)

Keywords

d)

Operators

46.

Choose the INVALID identifiers from the following

a)

NUmbEr1

b)

1NUMBer

c)

A_B

d)

A&B

47.

________ are data items that have a fixed value

a)

Tokens

b)

Literals

c)

Keyword

d)

Operators

48.

Examples of String Literals

a)

"ABC1273"

b)

nfjdlsj@@$

c)

12638

d)

'7e920938'

49.

Choose the keyword from the following

a)

IF

b)

Else

c)

iF

d)

else

50.

‘If’ is a decision making statement

a)

TRUE

b)

FALSE

51.

What is the word (command) used to display numbers and text on the screen?

a)

Input

b)

Output

c)

Print

d)

Command

52.

What symbol is used in python to assign values to a variable?

a)

:

b)

*

c)

=

d)

==

53.

Which of these would work as a piece of code?

a)

if string="Dove"

b)

if string=="Dove"

c)

IF string="Dove":

d)

if string=="Dove":

54.

Python is -------language

a)

compiled

b)

interpreted

c)

both compiled and interpreted

d)

none of the above

55.

What extension must you add to the end of a file when saving?

a)

.c

b)

.java

c)

.py

d)

.pyc

56.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

57.

The equivalent of the above for loop using the while syntax would be

a)
b)
c)
d)
58.

The above program prints

a)

Numbers 1 to 10 in reverse order

b)

Numbers 1 to 11 in reverse order

c)

Numbers 1 to 10

d)

Numbers 1 to 11

59.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
60.

The result of this program:

Friday = False

if Friday:

print("Jeans day!")

else:

print("Uniform day")

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

61.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

62.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

63.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

64.

Result of the program above is

a)

('1', '2', '3', '4', '5')

b)

(1, 2, 3, 4, 5)

c)

12345

d)

"12345"

65.

What is the output of the code:

d1 = {"john":40, "peter":45}

d2 = {"john":466, "peter":45}

print d1 > d2

a)

True

b)

False

c)

Not applicable

66.

Predict the output of the following code:

x=3

If x>2 or x<5 and x==6:

Print(“ok”)

else:

print(“no output”)

a)

ok

b)

okok

c)

no output

d)

none of above

67.

Which one of the following if statements will not execute successfully?

1) if (1, 2);

print(‘foo’)

2) if (1, 2):

print(‘foo’)

3) if (1):

print( ‘foo’ )

4) if (1);

print( ‘foo’ )

a)

1,4

b)

2

c)

2,4

d)

4

68.

Find the output of the following program segments:

for i in range(20,30,2):

print(i)

a)

20 22 24 26 28

b)

20

22

24

26

28

c)

20 22 24 26 28 30

d)

20

22

24

26

28

30

69.

Which one of the following is incorrect?

a)

The variables used inside function are called local variables.

b)

The local variables of a particular function can be used inside other functions, but these cannot be used in global space.

c)

The variables used outside function are called global variables

d)

In order to change the value of global variable inside function, keyword global is used.

70.

Suppose a function called add() is defined in a module called adder.py. Which of the following code snippets correctly show how to import and use the add() function? Select all that apply.

a)

from adder import add

result = adder.add(2, 3)

b)

from adder import add

result = add(2, 3)

c)

import add from adder

result = add(2, 3)

d)

import adder

result = adder.add(2, 3)

71.

What is the output of the given below program?

print("Know Program".split())

a)

‘Know’, ‘Program’

b)

(‘Know’, ‘Program’)

c)

[‘Know’, ‘Program’]

d)

{‘Know’, ‘Program’}

72.

Find the output of the given Python program?

print(list("abcd".split('')))

a)

[‘a’, ‘’, ‘b’, ‘’, ‘c’, ‘*’, ‘d’]

b)

[‘a’, ‘b’, ‘c’, ‘d’]

c)

[‘abcd’]

d)

[‘abc*d’]

73.

What will be the output of the following Python code?

a={1:"A",2:"B",3:"C"}

a.items()

a)

items()

b)

dict_items([(1,2,3)])

c)

dict_items([(‘A’), (‘B’), (‘C’)])

d)

dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])

74.

Which of the following is correctly evaluated for this function?

  1. pow(x,y,z)  

a)
  1. (x**y) / z

b)
  1. (x / y) * z

c)
  1. (x**y) % z

d)
  1. (x / y) / z

75.

Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?

a)
  1. Infile = open(''d:\\java.txt'', ''r'')

b)
  1. Infile = open(file=''d:\\\java.txt'', ''r'')

c)
  1. Infile = open(''d:\java.txt'',''r'')

d)
  1. Infile = open.file(''d:\\java.txt'',''r'')