Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python & SQL

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

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

a)

print("Hello World")

b)

p("Hello World")

c)

print(Hello World")

d)

printf("Hello World")

2.

Which of the following is the correct way to create a list in Python?

a)

my_list = <1, 2, 3>

b)

my_list = {1, 2, 3}

c)

my_list = (1, 2, 3)

d)

my_list = [1, 2, 3]

3.

How do you insert comments in Python code?

a)

# This is a comment

b)

// This is a comment

c)

<!-- This is a comment -->

d)

/* This is a comment */

4.

What is the correct way to declare a variable in Python?

a)

var x = 5

b)

x = 5

c)

int x = 5

d)

declare x = 5

5.

Which of the following is the correct way to define a function in Python?

a)

function myFunction():

b)

def myFunction():

c)

define myFunction():

d)

func myFunction():

6.

Which one is NOT a legal variable name?

a)

my-var

b)

_myvar

c)

myVar

d)

my_var

7.

What is the correct file extension for python files

a)

.pyt

b)

.pyth

c)

.py

d)

.pt

8.

In python, 'Hello', is the same as "Hello"

a)

False

b)

True

9.

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

a)

x = "Hello"[0]

b)

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

c)

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

10.

Which collection is ordered, changeable, and allows duplicate members?

a)

List

b)

Tuple

c)

Set

d)

Dictionary

11.

Which SQL statement is used to retrieve data from a database?

a)

GET

b)

OPEN

c)

SELECT

d)

EXTRACT

12.

Which SQL keyword is used to sort the result-set?

a)

ORDER BY

b)

SORT BY

c)

RRANGE BY

d)

ORGANIZE BY

13.

What does the SQL WHERE clause do?

a)

It filters records

b)

It changes records

c)

It groups records

d)

It sorts records

14.

Which clause is used to combine rows from two or more tables, based on a related column between them?

a)

JOIN

b)

LINK

c)

CONNECT

d)

MERGE

15.

How do you retrieve unique values from a column in SQL?

a)

SELECT DISTINCT column_name FROM table_name;

b)

SELECT UNIQUE column_name FROM table_name;

c)

SELECT DIFFERENT column_name FROM table_name

d)

SELECT SEPARATE column_name FROM table_name;