wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SCRIPTING PROGRAMMING WITH PYTHON

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which are the composites values for Python?

I. Tuples

II. Dictionaries

III. Lists

IV. Objects

a)

I, II

b)

I, III

c)

I, II, III

d)

I, II, III, IV

2.

Keyword __________ is used to define function in Python.

a)

_init_

b)

self.

c)

def

d)

construct

3.

What is the output from the following Pythons program segment?


x = 2 ** 3 / 2 ** 2

print x

a)

1.5

b)

2

c)

2.25

d)

3

4.

Give the output when the following codes written in Python are compiled.


str1= "saya anak merdeka"

print str1[:10] + 'malaysia'

a)

saya anak malaysia

b)

saya anak merdeka malaysia

c)

saya anakmalaysia

d)

saya anak memalaysia

5.

Which of the data type is NOT supported by Python?

a)

Numbers

b)

String

c)

List

d)

Enum

6.

What do we use to define a block of code in Python language?

a)

Key

b)

Brackets

c)

Indentation

d)

None of these

7.

Which character is used in Python to make a single line comment?

a)

/

b)

//

c)

!

d)

#

8.

What is the subprogram called in Python language?

a)

Object

b)

Function

c)

Method

d)

Parameter

9.

Which of the following operators is the correct option for A power to the B?

a)

A**B

b)

A ^ B

c)

A ^^ B

d)

A ^* B

10.

What will be the output of this function for Python?


round(4.576)

a)

4

b)

5

c)

0.576

d)

4576

11.

Scripting languages are ________ typing languages.

a)

static

b)

compiled

c)

dynamic

d)

behaviour

12.

The code block within every function in Python will start with a _____ and is indented.

a)

:

b)

(

c)

,

d)

{

13.

Codes given below are an example of _____ in Python.


thisLine = ["Code":"CSC305", "Semester":5]

a)

dictionary

b)

list

c)

string

d)

tuple

14.

Which of the following are NOT programming languages that support the scripting paradigm?

a)

PHP

b)

Java

c)

Python

d)

JavaScript

15.

What will be the output of the following Python code?


num_list = [1, 2, 3, 4, 5]

print(num_list[2])

a)

1

b)

2

c)

3

d)

4