Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MSTIP-Python-FinalExam

Total questions: 71

Worksheet time: 1hrs 11mins

Name
Class
Date
1.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

2.

What would be the output of this program if the user input was 10?

a)

22.04

b)

220.4

c)

2204

d)

Error wrong data type

3.

What operator is being used in this program?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

4.

What type of list is being used in this example?

a)

Dictionary

b)

List

c)

Tuple

d)

2d Array

5.

Which of the following statements apply to tuples?

a)

They are created using square brackets

b)

They are created using curved brackets

c)

They can be amended when the program is running

d)

They can not be amended when the program is running

6.

What would be the output of this program if the user entered "yes" then "what"?

a)

Enjoy your day

b)

it is too windy for an umbrella

c)

Take an umbrella

d)

Error

7.

What would be the output of this program if the user entered "Alien"

a)

Alienway

b)

wayAlien

c)

lienAay

d)

ayAlien

8.

What data type represents a whole number?

a)

Float

b)

Int

c)

Boolean

d)

String

9.

What data type represents a decimal number?

a)

Float

b)

Int

c)

Boolean

d)

String

10.

What data type represents characters?

a)

Float

b)

Int

c)

Boolean

d)

String

11.

What data type represents only two possible outcomes?

a)

Float

b)

Int

c)

Boolean

d)

String

12.

What you the output of this program be if the user guessed "h"?

a)

Error

b)

It was heads

c)

It was tails

d)

Bad luck

13.

What shape would this code produce?

a)

5 pointed star

b)

Pentagon

c)

Sqaure

d)

Nothing it would give an error

14.

Is the following subprogram a function or procedure?

a)

Function

b)

Procedure

15.

What type of loop is being used in this program?

a)

Count controlled

b)

Condition Controlled

16.

How many errors are there in this code?

a)

1

b)

2

c)

3

d)

4

17.

How many errors are there in this piece of code?

a)

0

b)

1

c)

2

d)

3

18.

Name of your Country

a)

Changes every year

b)

Always the same

c)

I change it when I wish

d)

Changes every month

19.

Something that could change or vary.

a)

Output

b)

Print

c)

Input

d)

Variable

20.

Variable

a)

Something that couldn't change

b)

Something that I don't know

c)

Something that could change

d)

Something that always stays the same

21.

What is a boolean type variable?

a)

A popular song that was written by a Mr. Bull

b)

Things expressed by words

c)

Things expressed by numbers

d)

Things expressed in True or False

22.

If a = 3 and b= 8 and c=b=a. print (b)

a)

11

b)

8

c)

24

d)

3

23.

What would be the value of the variable named count?

count = '46'

count = int(count)

print(count)

a)

'46'

b)

int

c)

count

d)

46

24.

Symbol that you will use to check whether the two values are not the same.

a)

and

b)

or

c)

then

d)

!=

25.

Keyword you will use to convert the user input to a number.

a)

float

b)

int

c)

input

d)

int_float

26.

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

27.

Which are arithmetic operators?

a)

+

b)

-

c)

>

d)

<

28.

Which of the following cannot be a variable?

a)

_init_

b)

in

c)

it

d)

on

29.

Which one of these is floor division?

a)

//

b)

/

c)

%

d)

None of the above

30.

Expand IDLE

a)

Internal Development Learning Environment

b)

Integrated Development Learning Enforcement

c)

Interactive Development Learning Environment

d)

Integrated Development Learning Environment

31.

Example of valid identifiers

a)

12Name

b)

name$

c)

total-mark

d)

total_marks

32.

A Relational operator is also called as ___________

a)

Arithmetic operator

b)

Logical operator

c)

Assignment operator

d)

Comparative operator

33.

"and, or and not" are ___________________

a)

Arithmetic operator

b)

Logical operators

c)

Assignment operator

d)

Comparative operator

34.

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

structure of program.

a)

Tokens

b)

Identifiers

c)

Keywords

d)

Operators

35.

Choose the INVALID identifiers from the following

a)

NUmbEr1

b)

1NUMBer

c)

A_B

d)

A&B

36.

________ are data items that have a fixed value

a)

Tokens

b)

Literals

c)

Keyword

d)

Operators

37.

Examples of String Literals

a)

"ABC1273"

b)

nfjdlsj@@$

c)

12638

d)

'7e920938'

38.

Choose the keyword from the following

a)

IF

b)

Else

c)

iF

d)

else

39.

‘If’ is a decision making statement

a)

TRUE

b)

FALSE

40.

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

41.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

42.

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

43.

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)

44.

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

a)

True

b)

False

45.

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!)"

46.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

47.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

48.

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

a)

True

b)

False

49.

1. What is the output of the following code?


var1 = 1

var2 = 2

var3 = "3"

print(var + var2 + var3)

a)

6

b)

33

c)

123

d)

ERROR

50.

2. What is the output of the following code?


p, q, r = 10, 20 ,30

print(p, q, r)

a)

10 20

b)

10 20 30

c)

Error: invalid syntax

51.

3. What is the Output of the following code?


for x in range(0.5, 5.5, 0.5):

print(x)

a)

[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]

b)

[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]

c)

The Program executed with errors

52.

4. What is the output of the following code?


salary = 8000


def printSalary():

salary = 12000

print("Salary:", salary)


printSalary()

print("Salary:", salary)

a)

Salary: 12000 Salary: 8000

b)

Salary: 8000 Salary: 12000

c)

The program failed with errors

53.

5. What is the output of the following code?


def calculate (num1, num2=4):

res = num1 * num2

print(res)


calculate(5, 6)

a)

20

b)

The program executed with errors

c)

30

54.

6. Can we use the “else” clause for loops?

for example:

for i in range(1, 5):

print(i)

else:

print("this is else block statement" )

a)

YES

b)

NO

55.

7. A string is immutable in Python?

Every time when we modify the string, Python Always creates a new String and assigns a new string to that variable.

a)

TRUE

b)

FALSE

56.

8. What is the output of the following code?

sampleList = ["Jon", "Kelly", "Jessa"]

sampleList.append(2, "Scott")

print(sampleList)

a)

The program executed with errors

b)

[‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’]

c)

[‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’]

57.

9. What is the output of the following?

x = 36 / 4 * (3 + 2) * 4 + 2

print(x)

a)

182.0

b)

37

c)

117

d)

ERROR

58.

10. Which operator has higher precedence in the following list?

a)

% Modulus

b)

& BitWise AND

c)

**, Exponent

d)

> Comparison

59.

11. What is the output of the following code?

for i in range(10, 15, 1):

print( i, end=', ')

a)

10, 11, 12, 13, 14,

b)

10, 11, 12, 13, 14, 15,

60.

12. What is the output of the following code?


listOne = [20, 40, 60, 80]

listTwo = [20, 40, 60, 80]


print(listOne == listTwo)

print(listOne is listTwo)

a)

TRUE

TRUE

b)

TRUE

FALSE

c)

FALSE

TRUE

61.

13. The ‘in’ operator is used to check if a value exists within an iterable object container such as a list. Evaluates to true if it finds a variable in the specified sequence and false otherwise.

a)

TRUE

b)

FALSE

62.

14. What is the output of the following code?

str = "pynative"

print (str[1:3])

a)

py

b)

yn

c)

pyn

d)

yna

63.

15. What is the output of the following code?


valueOne = 5 ** 2

valueTwo = 5 ** 3


print(valueOne)

print(valueTwo)

a)

10

15

b)

25

125

c)

ERROR

64.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

65.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

66.

What is the output of the following program?

a)

1 to 10 numbers

b)

1 to 5 numbers

c)

1

d)

5

67.

What would the output of this code be if the user entered the value 70?

a)

Pass

b)

Fail

c)

Merit

d)

Distinction

68.

What would the outcome of this program be?

a)

22

b)

50

c)

Nothing, it won't run due to errors in the code

d)

38

69.

What would the outcome of this program be?

a)

prints 1 to 10 numbers

b)

prints 10 to 1 numbers

c)

prints 1 to 15 numbers

d)

prints 1 to 14 numbers

70.

What would the outcome of this program be?

a)

prints 5 to 50 numbers

b)

prints 5 to 49 numbers

c)

prints 5 to 55 numbers

d)

prints multiples of 5 upto 50

71.

What is the output of the following program?

for i in range(0, 5):

print(i)

i=i+1

a)

1 to 5 numbers

b)

1 to 4 numbers

c)

0 to 4 numbers

d)

0 to 5 numbers