wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

KENNETH'S Quiz 😁

Total questions: 93

Worksheet time: 50mins

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.

Which of the following is an advantage of using local variables?

a)

They allow the variable to be used throughout the whole program

b)

They allow variable identifiers to be reused each time

c)

They are easier to program than global variables

d)

A wider range of data types can be used

19.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

20.

Leo wants to create a subroutine that will roll a dice. Which syntax is correct?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

21.

What would the output be from the program shown here? (assuming that the user enters "John" and "Smith"

a)

John

b)

Smith

c)

John Smith

d)

Error

22.

What would the output be from this program?

a)

Error

b)

Hello

c)

Hello, World

d)

World

23.

What is the difference between a subroutine and a function?

a)

They are the same thing

b)

A subroutine passes values back out to the program, a function does not

c)

A function passes values back out to the program, a subroutine does not

d)

A function can run without being called

24.

What will the output of this program be when it is run?

a)

Nothing

b)

Hello, world

c)

It will generate an error

25.

What will be the output of this program if the user enters "Han" and then "Solo"?

a)

An error

b)

Nothing

c)

first surname

d)

Han Solo

26.

Which of the following statements is not true?

a)

Functions/subroutines are examples of reusable code

b)

Functions and subroutines are always appropriate in programs

c)

Using functions/subroutines make it easier to "deconstruct" a problem into smaller pieces

d)

They can make programs easier to read and understand

27.

What would the output be for the following program if the user enters 4 and 6?

a)

10

b)

14

c)

16

d)

error

28.
Which of the following best describes the order in which these lines are processed in Python?
a)
4, 1, 2
b)
4, 2, 1
c)
1, 2, 3, 4
d)
3, 1, 2
29.
How do you correctly call this function
a)
def(1)
b)
x=square( )
c)
defSquare(4)
d)
x=square(5)
30.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

31.

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

32.

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

a)

True

b)

False

33.

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)

34.

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

35.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

36.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

37.

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

a)

True

b)

False

38.

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

39.

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

a)

True

b)

False

40.

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

41.

Which are arithmetic operators?

a)

+

b)

-

c)

>

d)

<

42.

Which of the following cannot be a variable?

a)

_init_

b)

in

c)

it

d)

on

43.

Which one of these is floor division?

a)

//

b)

/

c)

%

d)

None of the above

44.

Python is a general purpose programming language created by

a)

Dennis M. Ritchie

b)

Guido Van Rossum

c)

James Gosling

d)

Bjarne Stroustrup

45.

Expand IDLE

a)

Internal Development Learning Environment

b)

Integrated Development Learning Enforcement

c)

Interactive Development Learning Environment

d)

Integrated Development Learning Environment

46.

Example of valid identifiers

a)

12Name

b)

name$

c)

total-mark

d)

total_marks

47.

A Relational operator is also called as ___________

a)

Arithmetic operator

b)

Logical operator

c)

Assignment operator

d)

Comparative operator

48.

"and, or and not" are ___________________

a)

Arithmetic operator

b)

Logical operators

c)

Assignment operator

d)

Comparative operator

49.

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

structure of program.

a)

Tokens

b)

Identifiers

c)

Keywords

d)

Operators

50.

Choose the INVALID identifiers from the following

a)

NUmbEr1

b)

1NUMBer

c)

A_B

d)

A&B

51.

________ are data items that have a fixed value

a)

Tokens

b)

Literals

c)

Keyword

d)

Operators

52.

Examples of String Literals

a)

"ABC1273"

b)

nfjdlsj@@$

c)

12638

d)

'7e920938'

53.

Choose the keyword from the following

a)

IF

b)

Else

c)

iF

d)

else

54.

‘If’ is a decision making statement

a)

TRUE

b)

FALSE

55.

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

56.

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

57.

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

58.

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

59.

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

60.

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

61.

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

62.

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’]

63.

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

64.

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

a)

% Modulus

b)

& BitWise AND

c)

**, Exponent

d)

> Comparison

65.

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,

66.

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

67.

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

68.

14. What is the output of the following code?

str = "pynative"

print (str[1:3])

a)

py

b)

yn

c)

pyn

d)

yna

69.

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

70.

Which command will display the text 'Hello world!' on the screen?

a)

print(Hello world!)

b)

print "Hello world!"

c)

print("Hello world!")

d)

print = "Hello world!"

71.

Which command will correctly ask the user for their age?

a)

age = input("How old are you?")

b)

age = input(How old are you?)

c)

input("How old are you?") = age

d)

How old are you = input()

72.

Which decision statement will be triggered if the variable x is less than 20?

a)

if x > 20:

b)

if x <> 20:

c)

if x == 20:

d)

if x < 20:

73.

Which of these tests whether the variable x is the same as 'Hello'?

a)

x = "Hello"

b)

x != "Hello"

c)

x == "Hello"

d)

x <> "Hello"

74.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

75.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

76.

What is the output of the following program?

a)

1 to 10 numbers

b)

1 to 5 numbers

c)

1

d)

5

77.

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

a)

Pass

b)

Fail

c)

Merit

d)

Distinction

78.

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

79.

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

80.

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

81.

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

82.
Which python operator means 'less than or equal to'?
a)
>
b)
<
c)
>=
d)
<=
83.
What is another word for 'iteration'?
a)
Selection
b)
Variable Assignment
c)
Repetition
d)
Sequencing
84.
How many times will this loop run?
a)
10
b)
9
c)
4
d)
5
85.
I want to allow the program to repeatedly ask the user to enter their guess if it does not equal the answer...Which option do I use?
a)
while guess == answer:
    guess=input()
b)
while answer != guess:
guess=input()
c)
while answer =! guess:
guess=input()
d)
while guess != answer:
guess=input()
86.

Which word completes this sentence: "Iteration makes code more ___________"

a)

Complex

b)

Efficient

c)

Simple

d)

Straightforward

87.

A FOR loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

88.

A WHILE loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

89.

What will the output be for the code shown here?

a)

3,2,1,0

b)

0,1,2,3

c)

3,2,1

d)

1,2,3

90.

What would the output be for the code shown here?

a)

0,1,2,3,4,5,6,7,8,9

b)

1,2,3,4,5,6,7,8,9,10

c)

0,2,4,6,8,10

d)

0,2,4,6,8

91.

Anil is writing a "rock, scissors, paper" program. He wants the game to repeat until the user doesn't want to play anymore. What loop should he use?

a)

a FOR loop

b)

a WHILE loop

92.

Clara is writing a program that will print out the first ten numbers of a times table (chosen by the user). Should she use....

a)

a FOR loop

b)

a WHILE loop

93.

Tara has written a "Hide and Seek Simulator" - what will happen when she runs it?

a)

It will print "1,2,3,4,5,6,7,8,9,10 Coming ready or not!"

b)

The program will not run

c)

It will print "1,2,3,4,5,6,7,8,9,11 Coming ready or not!"

d)

It will print ("10 Coming ready or not!")