wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PYTHON BASIC 1 - 5

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is Python ?

a)

Python is text-based programming

b)

Python is a kind of snake

c)

Python is block-based programming

d)

Python is human language

2.

How do you insert COMMENTS in Python code?

a)

/*This is a comment*/

b)

#This is a comment

c)

//This is a comment

d)

Any of the Above

3.

What is a correct syntax to return the first character in a string?

a)

x = "Hello"[0]

b)

x = "Hello".sub(0, 1)

c)

x = sub("Hello", 0, 1)

d)

x = first("Hello")

4.

What is the output for −

'Hello world' [1:2]

a)

Hello

b)

e

c)

world

d)

Syntax error

5.

How do you define (assign) variables?

a)

var="String"

b)

func==Hello

c)

var : 123

d)

word= Hello

6.

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

a)

Input

b)

Output

c)

Print

d)

Command

7.

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

a)

:

b)

*

c)

=

d)

==

8.

Data type for a whole number (nombor bulat)

a)

Float

b)

Boolean

c)

Integer

d)

String

9.

A Python data type that holds positive and negative whole numbers?

a)

String

b)

int

c)

str

d)

input

10.

In Python, a variable must be declared before it is assigned a value:

a)

False

b)

True

11.

Which of the following statements assigns the value 100 to the variable x in Python:

a)

let x = 100

b)

x = 100

c)

x << 100

d)

x ← 100

e)

x := 100

12.

What is the output of the following code:


x = 5

y = "John"

print(x + y)

a)

5 John

b)

x John

c)

Error because x and y are from two different type of data

d)

Error because 5 does not have quotation mark

13.

Create a variable named carname and assign the value Proton to it.

a)

Proton = carname

b)

Proton = "carname"

c)

carname = "Proton"

d)

carname = 'Proton"

e)

carname = Proton

14.

Create a variable named x and assign the value 50 to it. The value, 50 is in string type.

a)

x = 50

b)

50 = "x"

c)

x = "50"

d)

x (50)

15.

What is the output of the following code?


a = "I am cute

print(a[3)

a)

c

b)

m

c)

space

d)

cute

16.

What is the output of the following code:


b = "Programming is fun!"

print(b[2:7)

a)

ogram

b)

ogramm

c)

gram

d)

gramm

17.

a = "Good Morning!"

print(len(a))

a)

13

b)

12

c)

11

d)

14

18.

a = "Hello, World!"

print(a.lower())

a)

hello, World!

b)

HELLO, WORLD!

c)

hello, world!

d)

Error

19.

a = "Hello, World!"

print(a.replace("H", "J"))

a)

Jello, World!

b)

jello, World!

c)

JELLO, WORLD!

d)

jello, world!

20.

What is the output of the following code:


age = 36

txt = "My name is John, I am " + age

print(txt)

a)

My name is John, I am

b)

My name is John, I am 36

c)

Error