wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DATATYPES - INPUT/OUTPUT - OPERATORS

Total questions: 24

Worksheet time: 12mins

Name
Class
Date
1.

Which data type can store numbers, letters and symbols?

a)

String

b)

Float

c)

Integer

d)

Boolean

2.

What will the output be from the following code?

print(Hello world!)

a)

Hello World!

b)

Syntax Error

c)

Hello World

d)

print(Hello World!)

3.

What is the answer to print (16//5)?

a)

1

b)

3

c)

21

d)

165

4.

What is the purpose of comment lines in code?

a)

To compliment your work so you feel better about it.

b)

To explain the code that follows it.

c)

To make the code compile.

d)

To make your code longer so you get more points.

5.

Identify python membership operators.

a)

in, not in

b)

is , is not

c)

in, in not

d)

not is, is

6.

Identify valid identifiers (variable or variables)

a)

a@123

b)

_n

c)

1a

d)

n 9

7.

Which is the correct operator for power(x,y)?

a)

X^y

b)

X**y

c)

X^^y

d)

pow(x,y)

8.

Which of the following is not a keyword?

a)

eval

b)

assert

c)

for

d)

elif

9.

All keywords in Python are in _________

a)

lower case

b)

UPPER CASE

c)

Capitalized

d)

None of the mentioned

10.

What data type is the object below?

L = [1, 23, 'hello', 1]

a)

list

b)

dictionary

c)

array

d)

tuple

11.

Select the option that print the following

hello-how-are-you

a)

print(‘hello’, ‘how’, ‘are’, ‘you’)

b)

print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)

c)

print(‘hello-‘ + ‘how-are-you’)

d)

print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

12.

What does 3 ^ 4 evaluate to?

a)

81

b)

12

c)

0.75

d)

7

13.

Which one of the following datatype is not supported in python

a)

string

b)

number

c)

slice

d)

list

14.

If a='cpp', b='buzz' then what is the output of:

c = a-b

print(c)

a)

cpp-buzz

b)

cppbuzz

c)

TypeError: unsupported operand

d)

None of the above

15.

Which of the following symbols are used for single line comments in Python?

a)

//

b)

"

c)

/* */

d)

#

16.

Which of the following operators is used to get accurate result (i.e fraction part also) in case of division ?

a)

//

b)

%

c)

/

d)

None of the Above

17.

What is the correct file extension for Python files?

a)

.pyt

b)

.py

c)

.pt

d)

.pyth

18.

Which operator can be used to compare two values?

==

=

><

<>

a)

==

b)

=

c)

<>

d)

><

19.

A location in memory used to store data that can be changed.

a)

Constant

b)

Variable

c)

Value

d)

Iteration

20.

In python the ' INTEGER data type' can be defined as...?

a)

holds alphanumeric data as text

b)

holds numbers with a decimal point

c)

holds whole numbers

d)

holds either ‘true’ or ‘false’

21.

In python the ' STRING data type' can be defined as...?

a)

holds alphanumeric text

b)

hold whole numbers

c)

holds numbers with a decimal point

d)

holds either a true or false value

22.

In python the ' FLOAT data type' can be defined as...?

a)

holds alphanumerical data

b)

holds whole numbers

c)

holds a decimal point in a number

d)

hold either true or false

23.

Which of the following codes is correct?

a)

("Good Morning. Who are you? " )= name

print("Hi there " + name+ " , nice to meet you")

b)

name = input ("Good Morning. Who are you?" )

print ("Hi there " + name+ " , nice to meet you")

c)

name = input ("Good Morning. Who are you?" )

print ("Hi there " name " , nice to meet you")

d)

("Good Morning. Who are you? " )= name

print ("Hi there " name" , nice to meet you")

24.

Which of the following converts the variable"mynumber" to an integer?

a)

str(mynumber)

b)

float(mynumber)

c)

num(mynumber)

d)

int(mynumber)