wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Assessment Quiz 1

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

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()

2.

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"

3.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

4.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

5.

What is the output of the following program?

a)

1 to 10 numbers

b)

1 to 5 numbers

c)

1

d)

5

6.

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

7.

Which of the following cannot be a variable?

a)

_init_

b)

in

c)

it

d)

on

8.

Python is a general purpose programming language created by

a)

Dennis M. Ritchie

b)

Guido Van Rossum

c)

James Gosling

d)

Bjarne Stroustrup

9.

Expand IDLE

a)

Internal Development Learning Environment

b)

Integrated Development Learning Enforcement

c)

Interactive Development Learning Environment

d)

Integrated Development Learning Environment

10.

Example of valid identifiers

a)

12Name

b)

name$

c)

total-mark

d)

total_marks

11.

"and, or and not" are ___________________

a)

Arithmetic operator

b)

Logical operators

c)

Assignment operator

d)

Comparative operator

12.

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

structure of program.

a)

Tokens

b)

Identifiers

c)

Keywords

d)

Operators

13.

Choose the INVALID identifiers from the following

a)

NUmbEr1

b)

1NUMBer

c)

A_B

d)

A&B

14.

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

15.

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

16.

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,

17.

WHICH ONE OF THE FOLLOWING IS THE CORRECT EXTENSION OF THE PYTHON FILE ?

a)

.py

b)

.python

c)

.p

d)

None of these

18.

WHICH ONE OF THESE IS NOT A PYTHON KEYWORD ?

a)

and

b)

or

c)

scanf

d)

is

19.

WHICH ONE OF THESE IS USED TO TAKE INPUT FROM THE USERS ?

a)

input

b)

print

c)

system

20.

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

a)

Input

b)

Output

c)

Print

d)

Command

21.

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

a)

:

b)

*

c)

=

d)

==

22.

Python is -------language

a)

compiled

b)

interpreted

c)

both compiled and interpreted

d)

none of the above

23.

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

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

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

26.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

27.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
28.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
29.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
30.

What is a output?

a)

A piece of data that is shown on the screen.

b)

Data that the user enters

c)

An output

d)

A orange

31.

What syntax would you use to create a name variable?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

32.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
33.
What is syntax?
a)
Syntax is the word used to describe a variable
b)
Syntax is the rules of the programming language
c)
This is used to read information
d)
It is used to output information 
34.

The character that must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

,

35.

The correct way to create a variable in Python?

a)

myVariable = 10

b)

my Variable = 10

c)

myVariable is 10

d)

myVariable: 10

36.
How many times will this loop run?
a)
10
b)
9
c)
4
d)
5
37.

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

38.

Keyword to define functions is

a)

def

b)

deef

c)

no keyword

d)

none of these

39.

When is the finally block executed?

a)

when there is no exception

b)

when there is an exception

c)

only if some condition that has been specified is satisfied

d)

always

40.

What will be the output of the following Python code?

def foo():
    try:
        print(1)
    finally:
        print(2)
foo()
a)

1 2

b)

1

c)

2

d)

none