wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Basic Data, Structure, and Concepts

Total questions: 30

Worksheet time: 16mins

Name
Class
Date
1.

Which of these describe Python?

a)

A Complied Programming Language

b)

An Interpreted Coding Language

c)

A useless coding language

d)

A Chinese coding language

2.

A logical plan of our code before we write it is called...?

a)

Pseudo Code

b)

Code Topology

c)

Illogical Code

d)

Code Mapping

3.

An Error in code is typically known as a... ?

a)

bug

b)

road-block

c)

fault

d)

insect

4.

Fixing problems in code is known as...?

a)

Debugging

b)

Error Hunting

c)

Syntax-Sniping

d)

A waste of time

5.

A line of code that begins with '#' will be skipped over by the interpreter and is mainly used to keep notes. This is called a...?

a)

Comment

b)

Annoyance

c)

Marker

d)

Flag

6.

Choose the code that will output an integer

a)

20 / 5

b)

2 * 6

c)

19 < 21

d)

print("123")

7.

Choose the code that will output a float

a)

20 / 5

b)

2 * 6

c)

19 < 21

d)

print("123")

8.

Choose the code that will output a string

a)

20 / 5

b)

2 * 6

c)

19 < 21

d)

print("123")

9.

Choose the code that will output a boolean

a)

20 / 5

b)

2 * 6

c)

19 < 21

d)

print("123")

10.

Which operator will make this statement True?

a = 15

b = 2

a _ b == 30

a)

*

b)

+

c)

-

d)

**

11.

Which lines will break the code? (There's more than one... look at the values AND the varable names and find problems)

text = "Blah"

2_text = "Blah Blah"

text_3 = "Blah Blah Blah

text-4 = "Blah Blah Blah Blah"

a)

Line 1

b)

Line 2

c)

Line 3

d)

Line 4

12.

Create a variable called my_bool and assign it this boolean statement: 19 is greater than or equal to 15

(a)  

13.

how would we most efficiently check for the length of this string?:

text = "How long is this String?"

a)

len(text)

b)

count(text)

c)

Count each character manually

d)

How_long_is_this_string(text)

14.

Which letter will be returned with the last command in this code?:

text = "White Walkers"

text[0]

a)

'W'

b)

'w'

c)

's'

d)

' '

15.

Which letter will be returned with the last command in this code?:

text = "White Walkers"

text[-1]

a)

's'

b)

'W'

c)

'w'

d)

' '

16.

What would be the output of this code?:

11 % 3

a)

2

b)

3.6666

c)

4

d)

1

17.

What would be the output of this expression?

a = "A Lannister always pays his debts."

"ster al" in a

a)

True

b)

False

18.

type( )

print( )

input( )

len( )

These are examples of...?

a)

functions

b)

methods

c)

strings

d)

types

19.

my_string = "Night gathers, and now my watch begins"

my_string[: : 2]

This command will grab...

a)

Every 2nd character

b)

all characters from beginning until index 2

c)

All characters from index 2

d)

All characters

20.

What will be the output of this code?

quote = "And now his watch is ended"

"and" in quote

a)

True

b)

False

21.

Look at these types of Data:

"Hello"

5632

37.11

19 < 20

What is the correct order of their data types from top to bottom?

a)

String

Integer

Float

Boolean

b)

Boolean

Float

Integer

String

c)

String

Float

Integer

Boolean

d)

String

Boolean

Float

Integer

22.

We have a variable called:

my_variable

but we can't remember what type of data it contains.

How would we check what type of data is contained inside?

(Hint: use a function)

(a)  

23.

What will be the output of this expression?

6 == 6 or 10 < 2

a)

True

b)

False

c)

Error

d)

8

24.

What would we call the second line of this code?

my_string = "for altering"

my_string.upper()

a)

A method

b)

An expression

c)

A bug

d)

A trial

25.

Look at this code:

sword_1 = "Ice"

sword_2 = "Oathkeeper"

print(f"{sword_1} is a valerian steel sword that gets melted down and used to make {sword_2}")

This is an example of string...?

a)

Formatting

b)

Concatenation

c)

Indexing

d)

Slicing

26.

What will be the output of this code?

a = "Check me"

type(a)

a)

str

b)

'Check me'

c)

An Error

d)

'check me'

27.

What will be the output of this code?

x = 256

len(x)

a)

int

b)

3

c)

An error

d)

256

28.

What will be the output of this code?

a = "Blardie Blah Blah"

b = 256.2031233331233

c = 23 > 21 and 10 != 10

type(c)

a)

bool

b)

True

c)

False

d)

float

29.

Q. 

What will be the output of this code?

a = "Blardie Blah Blah"

b = 256.2031233331233

c = 23 > 21 and 10 != 10

type(b)

a)

bool

b)

str

c)

float

d)

True

30.

Which Data type is this?: "We do not sow"

a)

String

b)

Integer

c)

Boolean

d)

Float