wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Intro to Python 1

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

Debug the following code: pirnt (Welcome to my program!)

a)

Add quotations

b)

add curly brackets

c)

add quotations and curly brackets

d)

check spelling and add quotations

2.

What kind of file extension must be on your file for Python code to run?

a)

.html

b)

.css

c)

.py

d)

.js

3.

Is Python generally used on the back-end or front-end of web development?

a)

Back-end

b)

Front-end

4.

What is a building block of code that allows you to store data in it like a box?

a)

variable

b)

output

c)

name

d)

attribute

5.

True or False: Creating a variable is the same as declaring a variable.

a)

False

b)

True

6.

What is the best practice when creating variables?

a)

Use more than one word when naming a variable to make it specific.

b)

Use one syllable words when creating variables.

c)

Name your variable something that refers to what it holds.

d)

Use letters like x, y, or n to make code as short as possible.

7.

Debug the following code: class_pet : "snake"

a)

class_pet = “snake”

b)

class_pet & “snake”

c)

class pet = “snake”

d)

class_pet = “snake

8.

Which line of code correctly asks the user for their name and assigns it to a variable?

a)

name = input("What's your name?")

b)

name = input "What's your name?"

c)

name = input("What's your name?)

d)

name = input("What's your name?"

9.

How do you combine text and a variable in a print() statement?

a)

Put the variable before the print() statement

b)

Use the "+" sign

c)

Put the variable outside the print() statement.

d)

Include the variable in the quotation marks.

10.

What key does the user need to press after typing in their input?

a)

+

b)

Enter

c)

-

d)

=

11.

What makes Python syntax different from most other languages?

a)

The order of parentheses matters.

b)

It uses comments in the program.

c)

It uses semicolons at the end of a thought.

d)

It is similar to English syntax.

12.

How do you create a comment in Python?

a)

// Here is my comment

b)

/* Here is my comment */

c)

# Here is my comment

d)

<!-- Here is my comment -->

13.

Which examples are valid strings? Select all that apply.

a)

goats are awesome-

b)

"goats are awesome"

c)

goats are awesome

d)

'goats are awesome'

14.

Which is an example of an integer data type in Python?

a)

"3"

b)

true

c)

32

d)

"three"

15.

What is the benefit of using a float?

a)

It lets us be more accurate by using decmials

b)

There is no benefit.

c)

It's a less accurate number.

d)

It lets us avoid using decimals.

16.

What happens when you change a float to an integer?

a)

It drops the decimal

b)

It moves the decimal to the right one space.

c)

It rounds the decimal up.

d)

It rounds the decimal down.

17.

What data type is this? "7.45"

a)

String

b)

Integer

c)

Float

18.

What will print out with the following code? print("4" * 3)

a)

7

b)

444

c)

12

d)

1

19.

Which symbol is used for multiplication in Python?

a)

^

b)

*

c)

x

d)

+

20.

Which symbol is used for division in Python?

a)

\

b)

|

c)

/

d)

>

21.

What is the output of this code? rocks = 15 print(rocks / 3)

a)

5

b)

15

c)

7

d)

3

22.

What is the following symbol called in Python? %

a)

percentage

b)

modulus

c)

decimal

d)

addition

23.

Which use of quotation marks is correct when creating strings in Python?

a)

"Hello World"

b)

'''Hello World'''

c)

They are all valid ways to create strings.

d)

'Hello World'

24.

How many quotation marks are required at the beginning and end when creating a multi-line string?

a)

2

b)

3

c)

4

d)

1

25.

What is concatenation?

a)

Splitting up strings

b)

Adding strings together

c)

Printing strings.

d)

A kind of string method

26.

Which data grouping is ordered and changeable?

a)

Tupul

b)

List

c)

Dictionary

d)

alpha

27.

What statement will catch everything that is not included in the IF statement?

a)

The ELSE statement

b)

The CATCH statement

c)

The OTHER statement

d)

The THEN statement

28.

What kind of brackets are used for lists in Python?

a)

{ }

b)

( )

c)

[ ]

d)

< >

29.

Debug the following code: distance = (5, 7, 20, 11, 18)

a)

distance = [5, 7, 20, 11, 18]

b)

distance = {5, 7, 20, 11, 18}

c)

distance - [5, 7, 20, 11, 18]

d)

distance + [5, 7, 20, 11, 18]

30.

The results from this code if you enter 2.0 and 5 =

# num1 = input ("Enter a Number")

# num2 = input ("Enter another Number")

# results = int(num1) + int(num2)


# print (results)

a)

2.5

b)

syntax error

c)

5.0

d)

5