wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Iedc Coders Club Programming Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is a correct syntax to output "Hello World" in Python?

a)

echo "Hello world"

b)

print("Hello world")

c)

echo("Hello world")

d)

p("Hello world")

2.

How do you insert COMMENTS in Python code

a)

// This is a comment

b)

#this is a comment

c)

/*Thisi s a comment*/

3.

Which is not a legal variable name ?

a)

Myvar

b)

my-var

c)

my_var

d)

_myvar

4.

How do you create a varaiable with numeric value 5 ?

a)

x = 5

b)

Both answers are correct

c)

x = int(5)

5.

What is the correct extension for Python Files ?

a)

.pyt

b)

.py

c)

.pyth

d)

.pt

6.

Create a floating variable 2.8 to x ?

a)

Both of the answers are correct

b)

x = float(2.8)

c)

x = 2.8

7.

What is the correct syntax to output the type of a variable or object in Python

a)

print(typeof x)

b)

print(typeof(x))

c)

print(typeOf(x))

d)

print(type(x))

8.

What is the correct way to decalre a function

a)

func myfunc():

b)

function myfunc():

c)

def myfunc():

d)

create myfunc():

9.

In Python 'Hello' is same as "Hello"

a)

True

b)

False

10.

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

a)

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

b)

x = "Hello"[0]

c)

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

11.

Which method is used for removing whitespaces from both the beginning and the end of the string ?

a)

strip()

b)

trim()

c)

len()

d)

ptrim()

12.

Which method is used to return a string in upper case letters ?

a)

uppercase()

b)

upperCase()

c)

toUpperCase()

d)

upper()

13.

Which method is used for replacing parts of a string ?

a)

switch()

b)

replaceString()

c)

replace()

d)

repl()

14.

Which operator is used for multiplication of numbers ?

a)

#

b)

*

c)

x

d)

%

15.

Which operator is used for compairing two values

a)

=

b)

><

c)

<>

d)

==

16.

Which of the following is defined as a list ?

a)

{"apple", "banana", "cherry"}

b)

{"name":"apple", "color":"red"}

c)

("apple", "banana", "cherry")

d)

["apple", "banana", "cherry"]

17.

Which of the following is defined as a tuple ?

a)

{"apple", "banana", "cherry"}

b)

{"name":"apple", "color":"red"}

c)

("apple", "banana", "cherry")

d)

["apple", "banana", "cherry"]

18.

which of the following collection is ordered, chageable and allows duplicate members

a)

SET

b)

TUPLE

c)

DICTIONARY

d)

LIST

19.

How do you write a if statement in python ?

a)

if (x>y)

b)

if x>y then:

c)

if x>y :

20.

How to write a loop in python ?

a)

while x>y:

b)

x>y while {

c)

while(x>y)

d)

for i in range(x):

21.

Is Python code compiled or intrepreted

a)

Python code is both compiled and interpreted

b)

Python code is neither compiled nor interpreted

c)

Python code is only compiled

d)

Python code is only interpreted

22.

What will be the value of the following Python expression?

4 + 3 % 5

a)

7

b)

2

c)

4

d)

1

23.

What will be the output of the following Python expression?

round(4.576)

a)

4

b)

4.6

c)

5

d)

4.5

24.


Identify the error in this code:
x = [1, 2, 3];

print(x)

a)

Syntax error in variable x

b)

Missing parenthesis in print

c)

Missing bracket in x

d)

No error

25.

In which programming language, Python was written?

a)

Java

b)

Python

c)

JavaScript

d)

C